diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/base/UMain.pas | 9 | ||||
-rw-r--r-- | src/base/URecord.pas | 31 | ||||
-rw-r--r-- | src/screens/UScreenOptionsRecord.pas | 24 | ||||
-rw-r--r-- | src/screens/UScreenSing.pas | 3 |
4 files changed, 51 insertions, 16 deletions
diff --git a/src/base/UMain.pas b/src/base/UMain.pas index 0d479420..1d924d56 100644 --- a/src/base/UMain.pas +++ b/src/base/UMain.pas @@ -98,6 +98,7 @@ uses procedure Main; var WindowTitle: string; + BadPlayer: integer; begin {$IFNDEF Debug} try @@ -304,8 +305,14 @@ begin SoundLib.StartBgMusic; // check microphone settings, goto record options if they are corrupt - if (not AudioInputProcessor.ValidateSettings) then + BadPlayer := AudioInputProcessor.ValidateSettings; + if (BadPlayer <> 0) then + begin + ScreenPopupError.ShowPopup( + Format(Language.Translate('ERROR_PLAYER_DEVICE_ASSIGNMENT'), + [BadPlayer])); Display.CurrentScreen^.FadeTo( @ScreenOptionsRecord ); + end; //------------------------------ // Start Mainloop diff --git a/src/base/URecord.pas b/src/base/URecord.pas index 5d2b4666..6b8ba8cf 100644 --- a/src/base/URecord.pas +++ b/src/base/URecord.pas @@ -139,9 +139,11 @@ type {** * Validates the mic settings. * If a player was assigned to multiple mics a popup will be displayed - * with the ID of the player and the return value will be false. + * with the ID of the player. + * The return value is the player number of the first player that is not + * configured correctly or 0 if all players are correct. *} - function ValidateSettings: boolean; + function ValidateSettings: integer; {** * Checks if players 1 to PlayerCount are configured correctly. @@ -153,7 +155,12 @@ type * The PlayerState array is zero based (index 0 for player 1). *} function CheckPlayersConfig(PlayerCount: cardinal; - var PlayerState: TBooleanDynArray): integer; + var PlayerState: TBooleanDynArray): integer; overload; + + {** + * Same as the array version but it does not output a state for each player. + *} + function CheckPlayersConfig(PlayerCount: cardinal): integer; overload; {** * Handle microphone input @@ -185,8 +192,6 @@ implementation uses ULog, - UGraphic, - ULanguage, UNote; var @@ -619,7 +624,7 @@ begin end; end; -function TAudioInputProcessor.ValidateSettings: boolean; +function TAudioInputProcessor.ValidateSettings: integer; const MAX_PLAYER_COUNT = 6; // FIXME: there should be a global variable for this var @@ -648,10 +653,7 @@ begin // check if player is already assigned to another device/channel if (PlayerMap[PlayerID - 1]) then begin - ScreenPopupError.ShowPopup( - Format(Language.Translate('ERROR_PLAYER_DEVICE_ASSIGNMENT'), - [PlayerID])); - Result := false; + Result := PlayerID; Exit; end; @@ -660,7 +662,7 @@ begin end; end; end; - Result := true; + Result := 0; end; function TAudioInputProcessor.CheckPlayersConfig(PlayerCount: cardinal; @@ -708,6 +710,13 @@ begin end; end; +function TAudioInputProcessor.CheckPlayersConfig(PlayerCount: cardinal): integer; +var + PlayerState: TBooleanDynArray; +begin + CheckPlayersConfig(PlayerCount, PlayerState); +end; + {* * Handles captured microphone input data. * Params: diff --git a/src/screens/UScreenOptionsRecord.pas b/src/screens/UScreenOptionsRecord.pas index f1cfe628..dc4a355f 100644 --- a/src/screens/UScreenOptionsRecord.pas +++ b/src/screens/UScreenOptionsRecord.pas @@ -88,6 +88,7 @@ type procedure StartPreview; procedure StopPreview; procedure UpdateInputDevice; + function ValidateSettings: boolean; procedure ChangeVolume(VolumeChange: single); procedure DrawVolume(x, y, Width, Height: single); procedure DrawVUMeter(const State: TDrawState; x, y, Width, Height: single); @@ -120,6 +121,7 @@ uses TextGL, UGraphic, UDraw, + ULanguage, UMain, UMenuSelectSlide, UMenuText, @@ -168,7 +170,7 @@ begin SDLK_BACKSPACE: begin // TODO: Show Save/Abort screen - if (AudioInputProcessor.ValidateSettings()) then + if (ValidateSettings()) then begin Ini.Save; AudioPlayback.PlaySound(SoundLib.Back); @@ -179,7 +181,7 @@ begin begin if (SelInteraction = ExitButtonIID) then begin - if (AudioInputProcessor.ValidateSettings()) then + if (ValidateSettings()) then begin Ini.Save; AudioPlayback.PlaySound(SoundLib.Back); @@ -213,6 +215,24 @@ begin end; end; +function TScreenOptionsRecord.ValidateSettings: boolean; +var + BadPlayer: integer; +begin + BadPlayer := AudioInputProcessor.ValidateSettings(); + if (BadPlayer <> 0) then + begin + ScreenPopupError.ShowPopup( + Format(Language.Translate('ERROR_PLAYER_DEVICE_ASSIGNMENT'), + [BadPlayer])); + Result := false; + end + else + begin + Result := true; + end; +end; + constructor TScreenOptionsRecord.Create; var DeviceIndex: integer; diff --git a/src/screens/UScreenSing.pas b/src/screens/UScreenSing.pas index aa32dd4a..fe8ea8e8 100644 --- a/src/screens/UScreenSing.pas +++ b/src/screens/UScreenSing.pas @@ -370,7 +370,6 @@ var Color: TRGB; VideoFile, BgFile: IPath; success: boolean; - PlayerState: TBooleanDynArray; BadPlayer: integer; begin inherited; @@ -587,7 +586,7 @@ begin LyricsState.TotalTime := AudioPlayback.Length; LyricsState.UpdateBeats(); - BadPlayer := AudioInputProcessor.CheckPlayersConfig(PlayersPlay, PlayerState); + BadPlayer := AudioInputProcessor.CheckPlayersConfig(PlayersPlay); if (BadPlayer <> 0) then begin ScreenPopupError.ShowPopup( |