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/Classes/UIni.pas | 26 +++++++++++++++++++------- Game/Code/Classes/UMusic.pas | 31 +++++++++++++++++++++++-------- Game/Code/Classes/UThemes.pas | 2 ++ 3 files changed, 44 insertions(+), 15 deletions(-) (limited to 'Game/Code/Classes') diff --git a/Game/Code/Classes/UIni.pas b/Game/Code/Classes/UIni.pas index c66a10c7..b286c917 100644 --- a/Game/Code/Classes/UIni.pas +++ b/Game/Code/Classes/UIni.pas @@ -41,8 +41,8 @@ type //Options - TVisualizerOption = (voOff, voWhenNoVideo, voOn); - + TVisualizerOption = (voOff, voWhenNoVideo, voOn); + TBackgroundMusicOption = (bmoOff, bmoOn); TIni = class private function RemoveFileExt(FullName: string): string; @@ -113,7 +113,8 @@ type Theme: integer; SkinNo: integer; Color: integer; - + BackgroundMusicOption:integer; + // Record InputDeviceConfig: array of TInputDeviceConfig; @@ -168,6 +169,9 @@ const IDepth: array[0..1] of string = ('16 bit', '32 bit'); IVisualizer: array[0..2] of string = ('Off', 'WhenNoVideo','On'); + IBackgroundMusic: array[0..1] of string = ('Off', 'On'); + + ITextureSize: array[0..2] of string = ('128', '256', '512'); ITextureSizeVals: array[0..2] of integer = ( 128, 256, 512); @@ -716,6 +720,11 @@ begin // || VisualizerOption := TVisualizerOption(GetArrayIndex(IVisualizer, IniFile.ReadString('Graphics', 'Visualization', 'Off'))); VisualizerOption := GetArrayIndex(IVisualizer, IniFile.ReadString('Graphics', 'Visualization', 'Off')); +{** + * Background music + *} + BackgroundMusicOption := GetArrayIndex(IBackgroundMusic, IniFile.ReadString('Sound', 'BackgroundMusic', 'Off')); + // EffectSing EffectSing := GetArrayIndex(IEffectSing, IniFile.ReadString('Advanced', 'EffectSing', 'On')); @@ -811,6 +820,9 @@ begin // AudioOutputBufferSize IniFile.WriteString('Sound', 'AudioOutputBufferSize', IAudioOutputBufferSize[AudioOutputBufferSizeIndex]); + // Background music + IniFile.WriteString('Sound', 'BackgroundMusic', IBackgroundMusic[BackgroundMusicOption]); + // Song Preview IniFile.WriteString('Sound', 'PreviewVolume', IPreviewVolume[PreviewVolume]); @@ -820,11 +832,11 @@ begin // SavePlayback IniFile.WriteString('Sound', 'SavePlayback', ISavePlayback[SavePlayback]); - // VoicePasstrough - IniFile.WriteString('Sound', 'VoicePassthrough', IVoicePassthrough[VoicePassthrough]); + // VoicePasstrough + IniFile.WriteString('Sound', 'VoicePassthrough', IVoicePassthrough[VoicePassthrough]); - // Lyrics Font - IniFile.WriteString('Lyrics', 'LyricsFont', ILyricsFont[LyricsFont]); + // Lyrics Font + IniFile.WriteString('Lyrics', 'LyricsFont', ILyricsFont[LyricsFont]); // Lyrics Effect IniFile.WriteString('Lyrics', 'LyricsEffect', ILyricsEffect[LyricsEffect]); diff --git a/Game/Code/Classes/UMusic.pas b/Game/Code/Classes/UMusic.pas index f3474e30..4090bd2f 100644 --- a/Game/Code/Classes/UMusic.pas +++ b/Game/Code/Classes/UMusic.pas @@ -503,6 +503,8 @@ type procedure LoadSounds(); procedure UnloadSounds(); + procedure StartBgMusic(); + procedure PauseBgMusic(); // TODO //function AddSound(Filename: string): integer; //procedure RemoveSound(ID: integer); @@ -536,6 +538,7 @@ implementation uses sysutils, math, + UIni, UMain, UCommandLine, URecord, @@ -709,7 +712,6 @@ begin // Load in-game sounds SoundLib := TSoundLibrary.Create; - AudioPlayback.PlaySound(SoundLib.BGMusic); end; procedure InitializeVideo(); @@ -860,9 +862,6 @@ end; procedure TSoundLibrary.LoadSounds(); begin - //Log.LogStatus('Loading Sounds', 'Music Initialize'); - //Log.BenchmarkStart(4); - UnloadSounds(); Start := AudioPlayback.OpenSound(SoundPath + 'Common start.mp3'); @@ -872,11 +871,10 @@ begin Option := AudioPlayback.OpenSound(SoundPath + 'option change col.mp3'); Click := AudioPlayback.OpenSound(SoundPath + 'rimshot022b.mp3'); - //BGMusic := AudioPlayback.OpenSound(SoundPath + '18982__bebeto__Loop010_ambient.mp3'); - //BGMusic.SetLoop(true); + BGMusic := AudioPlayback.OpenSound(SoundPath + 'Bebeto_-_Loop010.mp3'); - //Log.BenchmarkEnd(4); - //Log.LogBenchmark('--> Loading Sounds', 4); + if (BGMusic <> nil) then + BGMusic.Loop := True; end; procedure TSoundLibrary.UnloadSounds(); @@ -900,6 +898,23 @@ begin end; *) +procedure TSoundLibrary.StartBgMusic(); +begin + if (TBackgroundMusicOption(Ini.BackgroundMusicOption) = bmoOn) and + (Soundlib.BGMusic <> nil) and not (Soundlib.BGMusic.Status = ssPlaying) then + begin + AudioPlayback.PlaySound(Soundlib.BGMusic); + end; +end; + +procedure TSoundLibrary.PauseBgMusic(); +begin + If (Soundlib.BGMusic <> nil) then + begin + Soundlib.BGMusic.Pause; + end; +end; + { TVoiceRemoval } procedure TVoiceRemoval.Callback(Buffer: PChar; BufSize: integer); diff --git a/Game/Code/Classes/UThemes.pas b/Game/Code/Classes/UThemes.pas index 46327b7c..8a31b21a 100644 --- a/Game/Code/Classes/UThemes.pas +++ b/Game/Code/Classes/UThemes.pas @@ -408,6 +408,7 @@ type TThemeOptionsSound = class(TThemeBasic) SelectMicBoost: TThemeSelectSlide; + SelectBackgroundMusic: TThemeSelectSlide; SelectClickAssist: TThemeSelectSlide; SelectBeatClick: TThemeSelectSlide; SelectThreshold: TThemeSelectSlide; @@ -1159,6 +1160,7 @@ begin // Options Sound ThemeLoadBasic(OptionsSound, 'OptionsSound'); + ThemeLoadSelectSlide(OptionsSound.SelectBackgroundMusic, 'OptionsSoundSelectBackgroundMusic'); ThemeLoadSelectSlide(OptionsSound.SelectMicBoost, 'OptionsSoundSelectMicBoost'); ThemeLoadSelectSlide(OptionsSound.SelectClickAssist, 'OptionsSoundSelectClickAssist'); ThemeLoadSelectSlide(OptionsSound.SelectBeatClick, 'OptionsSoundSelectBeatClick'); -- cgit v1.2.3