From 59b053bc8a9e0b52168b73ca86296e6fe890f522 Mon Sep 17 00:00:00 2001 From: mogguh Date: Mon, 25 Aug 2008 19:46:45 +0000 Subject: Added: Option for background music in sound options (affects UIni too) Added: New language string SING_OPTIONS_SOUND_BACKGROUNDMUSIC Added: CC licensed music loop Improved: Options positions via Deluxe theme (first pass, next will follow) Improved: Code beautified in UScreenMain git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1290 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenOptionsSound.pas | 107 ++++++++++++++++++------------ 1 file changed, 64 insertions(+), 43 deletions(-) (limited to 'Game/Code/Screens/UScreenOptionsSound.pas') diff --git a/Game/Code/Screens/UScreenOptionsSound.pas b/Game/Code/Screens/UScreenOptionsSound.pas index 3a457b7a..9c602788 100644 --- a/Game/Code/Screens/UScreenOptionsSound.pas +++ b/Game/Code/Screens/UScreenOptionsSound.pas @@ -13,90 +13,112 @@ uses type TScreenOptionsSound = class(TMenu) - public - constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: WideChar; PressedDown: Boolean): Boolean; override; - procedure onShow; override; + public + constructor Create; override; + function ParseInput(PressedKey: cardinal; CharCode: widechar; + PressedDown: boolean): boolean; override; + procedure onShow; override; end; implementation uses UGraphic, SysUtils; -function TScreenOptionsSound.ParseInput(PressedKey: Cardinal; CharCode: WideChar; PressedDown: Boolean): Boolean; +function TScreenOptionsSound.ParseInput(PressedKey: cardinal; + CharCode: widechar; PressedDown: boolean): boolean; begin - Result := true; - If (PressedDown) Then + Result := True; + if (PressedDown) then begin // Key Down - // check normal keys + // check normal keys case WideCharUpperCase(CharCode)[1] of 'Q': - begin - Result := false; - Exit; - end; + begin + Result := False; + Exit; + end; end; - + // check special keys case PressedKey of SDLK_ESCAPE, - SDLK_BACKSPACE : + SDLK_BACKSPACE: + begin + // Escape -> save nothing - just leave this screen + AudioPlayback.PlaySound(SoundLib.Back); + FadeTo(@ScreenOptions); + end; + SDLK_RETURN: + begin + if SelInteraction = 8 then begin - // Escape -> save nothing - just leave this screen - + Ini.Save; AudioPlayback.PlaySound(SoundLib.Back); FadeTo(@ScreenOptions); end; - SDLK_RETURN: - begin - if SelInteraction = 7 then begin - Ini.Save; - AudioPlayback.PlaySound(SoundLib.Back); - FadeTo(@ScreenOptions); - end; - end; + end; SDLK_DOWN: InteractNext; - SDLK_UP : + SDLK_UP: InteractPrev; SDLK_RIGHT: + begin + if (SelInteraction >= 0) and (SelInteraction < 8) then begin - if (SelInteraction >= 0) and (SelInteraction <= 7) then begin - AudioPlayback.PlaySound(SoundLib.Option); - InteractInc; - end; + AudioPlayback.PlaySound(SoundLib.Option); + InteractInc; end; + end; SDLK_LEFT: + begin + if (SelInteraction >= 0) and (SelInteraction < 8) then begin - if (SelInteraction >= 0) and (SelInteraction <= 7) then begin - AudioPlayback.PlaySound(SoundLib.Option); - InteractDec; - end; + AudioPlayback.PlaySound(SoundLib.Option); + InteractDec; end; + end; end; end; + +{** + * Actually this one isn't pretty - but it does the trick of + * turning the background music on/off in "real time" + * bgm = background music + * TODO: - Fetching the SelectInteraction via something more descriptive + * - Obtaining the current value of a select is imho ugly + *} + if (SelInteraction = 1) then + begin + if TBackgroundMusicOption(SelectsS[1].SelectedOption) = bmoOn then + SoundLib.StartBgMusic + else + SoundLib.PauseBgMusic; + end; + end; constructor TScreenOptionsSound.Create; -//var -// I: integer; // Auto Removed, Unused Variable begin inherited Create; LoadFromTheme(Theme.OptionsSound); - AddSelectSlide(Theme.OptionsSound.SelectSlideVoicePassthrough, Ini.VoicePassthrough, IVoicePassthrough); - - AddSelectSlide(Theme.OptionsSound.SelectMicBoost, Ini.MicBoost, IMicBoost); // TODO - This need moving to ScreenOptionsRecord + AddSelectSlide(Theme.OptionsSound.SelectSlideVoicePassthrough, + Ini.VoicePassthrough, IVoicePassthrough); + AddSelectSlide(Theme.OptionsSound.SelectBackgroundMusic, + Ini.BackgroundMusicOption, IBackgroundMusic); + AddSelectSlide(Theme.OptionsSound.SelectMicBoost, Ini.MicBoost, IMicBoost); + // TODO: - MicBoost needs to be moved to ScreenOptionsRecord AddSelectSlide(Theme.OptionsSound.SelectClickAssist, Ini.ClickAssist, IClickAssist); AddSelectSlide(Theme.OptionsSound.SelectBeatClick, Ini.BeatClick, IBeatClick); AddSelectSlide(Theme.OptionsSound.SelectThreshold, Ini.ThresholdIndex, IThreshold); - //Song Preview - AddSelectSlide(Theme.OptionsSound.SelectSlidePreviewVolume, Ini.PreviewVolume, IPreviewVolume); - AddSelectSlide(Theme.OptionsSound.SelectSlidePreviewFading, Ini.PreviewFading, IPreviewFading); + AddSelectSlide(Theme.OptionsSound.SelectSlidePreviewVolume, + Ini.PreviewVolume, IPreviewVolume); + AddSelectSlide(Theme.OptionsSound.SelectSlidePreviewFading, + Ini.PreviewFading, IPreviewFading); AddButton(Theme.OptionsSound.ButtonExit); - if (Length(Button[0].Text)=0) then + if (Length(Button[0].Text) = 0) then AddButtonText(14, 20, Theme.Options.Description[7]); Interaction := 0; @@ -105,7 +127,6 @@ end; procedure TScreenOptionsSound.onShow; begin inherited; - Interaction := 0; end; -- cgit v1.2.3