diff --git a/Assembly-CSharp/Assembly-CSharp.csproj b/Assembly-CSharp/Assembly-CSharp.csproj index b68fba5df..f81afb4ed 100644 --- a/Assembly-CSharp/Assembly-CSharp.csproj +++ b/Assembly-CSharp/Assembly-CSharp.csproj @@ -728,7 +728,7 @@ - + diff --git a/Assembly-CSharp/Global/AllSoundDispatchPlayer.cs b/Assembly-CSharp/Global/AllSoundDispatchPlayer.cs index a48469209..f850e68e4 100644 --- a/Assembly-CSharp/Global/AllSoundDispatchPlayer.cs +++ b/Assembly-CSharp/Global/AllSoundDispatchPlayer.cs @@ -24,26 +24,14 @@ private static Single NormalizePitch(Int32 original) Single num3 = (Single)original / (Single)num; return num3 * num2 + 1f; } - - public void SetMusicVolume(Int32 volume) - { - this.musicPlayerVolume = volume / 100f; - this.UpdatePlayingMusicVolume(volume > 0); - } - public void SetSoundEffectVolume(Int32 volume) - { - this.soundEffectPlayerVolume = volume / 100f; - this.UpdatePlayingSoundEffectVolume(volume > 0); - } - - private void UpdatePlayingMusicVolume(Boolean isEnable) + public void UpdatePlayingMusicVolume() { this.GetSoundProfileIfExist(this.currentMusicID, SoundProfileType.Music, delegate(SoundProfile soundProfile) { if (soundProfile != null) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.musicPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * SoundLib.MusicPlayer.Volume, 0); } }); AllSoundDispatchPlayer.PlayingSfx[] array = this.sfxResSlot; @@ -54,7 +42,7 @@ private void UpdatePlayingMusicVolume(Boolean isEnable) { if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(playingSfx.SoundID) != 0) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(playingSfx.SndEffectVol) * this.musicPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(playingSfx.SndEffectVol) * SoundLib.MusicPlayer.Volume, 0); } } } @@ -66,14 +54,14 @@ private void UpdatePlayingMusicVolume(Boolean isEnable) { if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(playingSfx2.SoundID) != 0) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx2.SoundID, AllSoundDispatchPlayer.NormalizeVolume(playingSfx2.SndEffectVol) * this.musicPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx2.SoundID, AllSoundDispatchPlayer.NormalizeVolume(playingSfx2.SndEffectVol) * SoundLib.MusicPlayer.Volume, 0); } } } } } - private void UpdatePlayingSoundEffectVolume(Boolean isEnable) + public void UpdatePlayingSoundEffectVolume() { foreach (AllSoundDispatchPlayer.PlayingSfx playingSfx in this.sfxChanels) { @@ -85,7 +73,7 @@ private void UpdatePlayingSoundEffectVolume(Boolean isEnable) { if (playingSfx.ObjNo != 1261 && playingSfx.ObjNo != 3096) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(playingSfx.SndEffectVol) * this.soundEffectPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(playingSfx.SndEffectVol) * SoundLib.SoundEffectPlayer.Volume, 0); } } } @@ -95,7 +83,7 @@ private void UpdatePlayingSoundEffectVolume(Boolean isEnable) { if (soundProfile != null) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.soundEffectPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * SoundLib.SoundEffectPlayer.Volume, 0); } }); } @@ -147,6 +135,7 @@ public void FF9SOUND_SONG_LOAD(Int32 ObjNo) this.CreateSound(soundProfile); soundProfile.SoundVolume = 1f; ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, SoundLib.MusicPlayer.Volume, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPause(soundProfile.SoundID, 1, 0); Int16 fldMapNo = FF9StateSystem.Common.FF9.fldMapNo; if (fldMapNo == 503 && PersistenSingleton.Instance.eBin.getVarManually(EBin.SC_COUNTER_SVR) == 2970 && PersistenSingleton.Instance.eBin.getVarManually(EBin.MAP_INDEX_SVR) == 11 && ObjNo == 35) @@ -213,7 +202,7 @@ public void FF9SOUND_SONG_PLAY(Int32 ObjNo, Int32 vol = 127, int time = 0) this.CreateSound(soundProfile); soundProfile.SoundVolume = AllSoundDispatchPlayer.NormalizeVolume(vol); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, time * 1000); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.musicPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * SoundLib.MusicPlayer.Volume, 0); this.currentMusicID = ObjNo; this.StopAndClearSuspendBGM(ObjNo, true); }); @@ -226,7 +215,7 @@ public void FF9SOUND_SONG_PLAY(Int32 ObjNo, Int32 vol = 127, int time = 0) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPause(soundProfile.SoundID, 0, time * 1000); soundProfile.SoundVolume = AllSoundDispatchPlayer.NormalizeVolume(vol); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.musicPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * SoundLib.MusicPlayer.Volume, 0); this.StopAndClearSuspendBGM(ObjNo, true); } }); @@ -334,7 +323,7 @@ public void FF9SOUND_SONG_VOL(Int32 ObjNo, Int32 vol) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPause(soundProfile.SoundID, 0, 0); soundProfile.SoundVolume = AllSoundDispatchPlayer.NormalizeVolume(vol); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.musicPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * SoundLib.MusicPlayer.Volume, 0); } }); } @@ -347,7 +336,7 @@ public void FF9SOUND_SONG_VOL_INTPL(Int32 ObjNo, Int32 ticks, Int32 to) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPause(soundProfile.SoundID, 0, 0); soundProfile.SoundVolume = AllSoundDispatchPlayer.NormalizeVolume(to); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.musicPlayerVolume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * SoundLib.MusicPlayer.Volume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); } }); } @@ -361,7 +350,7 @@ public void FF9SOUND_SONG_VOL_FADE(Int32 ObjNo, Int32 ticks, Int32 from, Int32 t ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPause(soundProfile.SoundID, 0, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, AllSoundDispatchPlayer.NormalizeVolume(from), 0); soundProfile.SoundVolume = AllSoundDispatchPlayer.NormalizeVolume(to); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.musicPlayerVolume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * SoundLib.MusicPlayer.Volume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); } }); } @@ -380,7 +369,7 @@ public void FF9SOUND_SONG_VOL_INTPLALL(Int32 ticks, Int32 to) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPause(soundProfile.SoundID, 0, 0); soundProfile.SoundVolume = AllSoundDispatchPlayer.NormalizeVolume(to); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.musicPlayerVolume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * SoundLib.MusicPlayer.Volume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); } }); } @@ -472,7 +461,8 @@ public void FF9SOUND_SONG_SKIPPHRASE_MILLISEC(Int32 ObjNo, Int32 offsetTimeMSec) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(soundProfile.SoundID, 0); soundProfile.SoundID = ISdLibAPIProxy.Instance.SdSoundSystem_CreateSound(soundProfile.BankID); - Int32 num = ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, offsetTimeMSec); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, offsetTimeMSec); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, SoundLib.MusicPlayer.Volume, 0); } }); } @@ -488,7 +478,7 @@ public void FF9SOUND_SNDEFFECT_PLAY(Int32 ObjNo, Int32 attr, Int32 pos, Int32 vo if (this.TuneUpSoundEffectByObjNo(ObjNo, soundProfile) == 0) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * this.soundEffectPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * SoundLib.SoundEffectPlayer.Volume, 0); this.ShiftPitchIfFastForward(soundProfile); } AllSoundDispatchPlayer.PlayingSfx playingSfx = new AllSoundDispatchPlayer.PlayingSfx(); @@ -535,7 +525,7 @@ private Int32 TuneUpSoundEffectByObjNo(Int32 ObjNo, SoundProfile soundProfile) if (ObjNo == 1748) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, 0.6f, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, 0.6f * SoundLib.SoundEffectPlayer.Volume, 0); soundProfile.Pitch *= 0.6f; ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPitch(soundProfile.SoundID, soundProfile.Pitch, 0); return 1; @@ -612,7 +602,7 @@ public void FF9SOUND_SNDEFFECT_VOL(Int32 ObjNo, Int32 attr, Int32 vol) if (playingSfx.ObjNo == ObjNo) { playingSfx.SndEffectVol = vol; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * this.soundEffectPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * SoundLib.SoundEffectPlayer.Volume, 0); } } } @@ -624,7 +614,7 @@ public void FF9SOUND_SNDEFFECT_VOL_INTPL(Int32 ObjNo, Int32 attr, Int32 ticks, I if (playingSfx.ObjNo == ObjNo) { playingSfx.SndEffectVol = to; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(to) * this.soundEffectPlayerVolume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(to) * SoundLib.SoundEffectPlayer.Volume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); } } } @@ -636,7 +626,7 @@ public void FF9SOUND_SNDEFFECT_VOL_ALL(Int32 vol) if (!FF9Snd.GetIsExtEnvObjNo(playingSfx.ObjNo)) { playingSfx.SndEffectVol = vol; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * this.soundEffectPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * SoundLib.SoundEffectPlayer.Volume, 0); } } } @@ -648,7 +638,7 @@ public void FF9SOUND_SNDEFFECT_VOL_INTPLALL(Int32 ticks, Int32 to) if (!FF9Snd.GetIsExtEnvObjNo(playingSfx.ObjNo) || playingSfx.ObjNo == 656) { playingSfx.SndEffectVol = to; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(to) * this.soundEffectPlayerVolume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(to) * SoundLib.SoundEffectPlayer.Volume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); } } } @@ -717,7 +707,7 @@ public void FF9SOUND_SNDEFFECTRES_PLAY(Int32 slot, Int32 ObjNo, Int32 attr, Int3 { this.CreateSound(soundProfile); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * this.musicPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * SoundLib.MusicPlayer.Volume, 0); AllSoundDispatchPlayer.PlayingSfx playingSfx = new AllSoundDispatchPlayer.PlayingSfx(); playingSfx.ObjNo = ObjNo; playingSfx.SoundID = soundProfile.SoundID; @@ -816,7 +806,7 @@ public void FF9SOUND_SNDEFFECTRES_VOL(Int32 slot, Int32 ObjNo, Int32 attr, Int32 if (playingSfx.ObjNo == ObjNo) { playingSfx.SndEffectVol = vol; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * this.musicPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * SoundLib.MusicPlayer.Volume, 0); } } } @@ -836,7 +826,7 @@ public void FF9SOUND_SNDEFFECTRES_VOL_INTPL(Int32 slot, Int32 ObjNo, Int32 attr, if (playingSfx.ObjNo == ObjNo) { playingSfx.SndEffectVol = to; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(to) * this.musicPlayerVolume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(to) * SoundLib.MusicPlayer.Volume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); } } } @@ -854,7 +844,7 @@ public void FF9SOUND_SNDEFFECTRES_VOL_ALL(Int32 vol) if (playingSfx != null) { playingSfx.SndEffectVol = vol; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * this.musicPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(vol) * SoundLib.MusicPlayer.Volume, 0); } } } @@ -871,7 +861,7 @@ public void FF9SOUND_SNDEFFECTRES_VOL_INTPLALL(Int32 ticks, Int32 to) if (playingSfx != null) { playingSfx.SndEffectVol = to; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(to) * this.musicPlayerVolume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(playingSfx.SoundID, AllSoundDispatchPlayer.NormalizeVolume(to) * SoundLib.MusicPlayer.Volume, AllSoundDispatchPlayer.ConvertTickToMillisec(ticks)); } } } @@ -892,6 +882,7 @@ public void FF9SOUND_STREAM_PLAY(Int32 streamid, Int32 pos, Int32 reverb) { base.CreateSound(soundProfile); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, SoundLib.SoundEffectPlayer.Volume, 0); this.currentSongID = soundProfile.SoundIndex; }); } @@ -927,7 +918,7 @@ public void FF9SOUND_STREAM_VOL(Int32 vol) this.CreateSoundProfileIfNotExist(this.currentSongID, SoundProfileType.Song, delegate(SoundProfile soundProfile) { soundProfile.SoundVolume = AllSoundDispatchPlayer.NormalizeVolume(vol); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.soundEffectPlayerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * SoundLib.SoundEffectPlayer.Volume, 0); }); } else @@ -1406,13 +1397,11 @@ public void UpdatePlayingSoundEffectPitchFollowingGameSpeed() } } - public const Int32 VOLUME_MAX = 127; - - public const Int32 SNDEFFECTRES_SLOT_MAX = 2; + public override Single Volume => throw new NotImplementedException(); - private Single musicPlayerVolume = 1f; + public const Int32 VOLUME_MAX = 127; - private Single soundEffectPlayerVolume = 1f; + public const Int32 SNDEFFECTRES_SLOT_MAX = 2; private Int32 currentMusicID = -1; diff --git a/Assembly-CSharp/Global/Config/ConfigUI.cs b/Assembly-CSharp/Global/Config/ConfigUI.cs index cdfaf15cc..b25182b1b 100644 --- a/Assembly-CSharp/Global/Config/ConfigUI.cs +++ b/Assembly-CSharp/Global/Config/ConfigUI.cs @@ -37,8 +37,6 @@ public class ConfigUI : UIScene { - private const Int32 VIBRATION_CONFIG_INDEX = 12; - private enum TriggerState { Idle, @@ -64,7 +62,11 @@ public enum Configurator ControlTutorial, CombatTutorial, Title, - QuitGame + QuitGame, + SoundVolume, + MusicVolume, + MovieVolume, + VoiceVolume } public GameObject KeyboardButton; @@ -174,7 +176,11 @@ public enum Configurator private static List ConfigSliderIdList = new List(new[] { Configurator.FieldMessage, - Configurator.BattleSpeed + Configurator.BattleSpeed, + Configurator.SoundVolume, + Configurator.MusicVolume, + Configurator.MovieVolume, + Configurator.VoiceVolume }); private List ConfigFieldList; @@ -699,8 +705,7 @@ public override void Hide(SceneVoidDelegate afterFinished = null) private void RemoveCursorMemorize() { - ConfigField configField = ConfigFieldList.First(field => field.Configurator == Configurator.Sound); - ButtonGroupState.SetCursorStartSelect(configField.ConfigParent, ConfigGroupButton); + ButtonGroupState.SetCursorStartSelect(ConfigFieldList[0].ConfigParent, ConfigGroupButton); ButtonGroupState.RemoveCursorMemorize(ConfigGroupButton); } @@ -722,17 +727,17 @@ public override Boolean OnKeyConfirm(GameObject go) } else { - Int32 siblingIndex = go.transform.GetSiblingIndex(); - if (siblingIndex == 2) + ConfigField config = ConfigFieldList.First(field => field.ConfigParent == go); + if (config?.Configurator == Configurator.Controller) { FF9Sfx.FF9SFX_Play(103); // ReSharper disable once CompareOfFloatsByEqualityOperator - if (ConfigFieldList[2].Value == 1f) + if (config.Value == 1f) { CheckAndDisplayCustomControllerPanel(); } } - else if (siblingIndex == 15) + else if (config?.Configurator == Configurator.Title) { FF9Sfx.FF9SFX_Play(103); hitpointScreenButton.KeyCommand = Control.None; @@ -746,7 +751,7 @@ public override Boolean OnKeyConfirm(GameObject go) ButtonGroupState.HoldActiveStateOnGroup(ConfigGroupButton); }); } - else if (siblingIndex == 13) + else if (config?.Configurator == Configurator.ControlTutorial) { FF9Sfx.FF9SFX_Play(103); hitpointScreenButton.KeyCommand = Control.Confirm; @@ -762,7 +767,7 @@ public override Boolean OnKeyConfirm(GameObject go) ButtonGroupState.HoldActiveStateOnGroup(ConfigGroupButton); }); } - else if (siblingIndex == 14) + else if (config?.Configurator == Configurator.CombatTutorial) { FF9Sfx.FF9SFX_Play(103); NextSceneIsModal = true; @@ -775,7 +780,7 @@ public override Boolean OnKeyConfirm(GameObject go) ButtonGroupState.HoldActiveStateOnGroup(ConfigGroupButton); }); } - else if (siblingIndex == 16) + else if (config?.Configurator == Configurator.QuitGame) { FF9Sfx.FF9SFX_Play(103); UIManager.Input.OnQuitCommandDetected(); @@ -784,23 +789,19 @@ public override Boolean OnKeyConfirm(GameObject go) } else if (ButtonGroupState.ActiveGroup == WarningMenuGroupButton) { - Int32 siblingIndex2 = go.transform.GetSiblingIndex(); - Int32 num = siblingIndex2; - if (num != 2) + Int32 num = go.transform.GetSiblingIndex(); + if (num == 3) { - if (num == 3) + FF9Sfx.FF9SFX_Play(101); + Loading = true; + WarningDialogHitPoint.SetActive(false); + warningTransition.TweenOut(delegate { - FF9Sfx.FF9SFX_Play(101); - Loading = true; - WarningDialogHitPoint.SetActive(false); - warningTransition.TweenOut(delegate - { - Loading = false; - }); - ButtonGroupState.ActiveGroup = ConfigGroupButton; - } + Loading = false; + }); + ButtonGroupState.ActiveGroup = ConfigGroupButton; } - else + else if (num == 2) { FF9Sfx.FF9SFX_Play(103); WarningDialogHitPoint.SetActive(false); @@ -1038,27 +1039,14 @@ public void OnKeyChoice(GameObject go, KeyCode key) ConfigField configField = ConfigFieldList.First(field => field.ConfigParent == go); if (configField.IsSlider) { + var step = configField.ConfigChoice[0].GetComponent().numberOfSteps - 1; if (key == KeyCode.LeftArrow) { - if (configField.Configurator == Configurator.FieldMessage) - { - setConfigValue(configField.ConfigParent, configField.Value - 1f / fieldMessageSliderStep, false); - } - else if (configField.Configurator == Configurator.BattleSpeed) - { - setConfigValue(configField.ConfigParent, configField.Value - 1f / battleSpeedSliderStep, false); - } + setConfigValue(configField.ConfigParent, configField.Value - 1f / step, false); } else if (key == KeyCode.RightArrow) { - if (configField.Configurator == Configurator.FieldMessage) - { - setConfigValue(configField.ConfigParent, configField.Value + 1f / fieldMessageSliderStep, false); - } - else if (configField.Configurator == Configurator.BattleSpeed) - { - setConfigValue(configField.ConfigParent, configField.Value + 1f / battleSpeedSliderStep, false); - } + setConfigValue(configField.ConfigParent, configField.Value + 1f / step, false); } } else if (configField.Configurator != Configurator.CombatTutorial && configField.Configurator != Configurator.ControlTutorial && configField.Configurator != Configurator.Title && configField.Configurator != Configurator.QuitGame && (key == KeyCode.LeftArrow || key == KeyCode.RightArrow)) @@ -1281,6 +1269,18 @@ private void DisplayConfigValue() case Configurator.Vibration: current.Value = FF9StateSystem.Settings.cfg.vibe; break; + case Configurator.SoundVolume: + current.Value = Configuration.Audio.SoundVolume / 100f; + break; + case Configurator.MusicVolume: + current.Value = Configuration.Audio.MusicVolume / 100f; + break; + case Configurator.MovieVolume: + current.Value = Configuration.Audio.MovieVolume / 100f; + break; + case Configurator.VoiceVolume: + current.Value = Configuration.VoiceActing.Volume / 100f; + break; default: current.Value = 0f; break; @@ -1315,7 +1315,7 @@ private void CheckAndDisplayCustomControllerPanel() { ValidateKeyboard(); ValidateController(); - + // TODO Check Native: #147 - Will incombaitble with Android and PC with Controller? O.o // this.currentControllerType = ControllerType.Keyboard; if (PersistenSingleton.Instance.IsControllerConnect || FF9StateSystem.aaaaPlatform || FF9StateSystem.IOSPlatform) // aaaa is Vita @@ -1346,6 +1346,11 @@ private void setConfigValue(GameObject configGameObject, Single value, Boolean i { configField.Value = Mathf.Clamp(value, 0f, 1f); configField.ConfigChoice[0].GetComponent().value = configField.Value; + if(configField.Configurator >= Configurator.SoundVolume) + { + // Update the label with the volume value + configField.ConfigParent.GetChild(1).GetChild(0).GetComponent().text = ((Int32)Math.Round(configField.Value * 20) * 5).ToString(); + } if (configField.Value == value2) { flag = false; @@ -1426,6 +1431,26 @@ private void setConfigValue(GameObject configGameObject, Single value, Boolean i vib.VIB_actuatorSet(1, 0.003921569f, 1f); } break; + case Configurator.SoundVolume: + FF9StateSystem.Settings.cfg.sound_effect = 0; // Useless setting now + Configuration.Audio.SoundVolume = (Int32)Math.Round(configField.Value * 20) * 5; + SoundLib.TryUpdateSoundVolume(); + Configuration.Audio.SaveSoundVolume(); + break; + case Configurator.MusicVolume: + FF9StateSystem.Settings.cfg.sound = 0; // Useless setting now + Configuration.Audio.MusicVolume = (Int32)Math.Round(configField.Value * 20) * 5; + SoundLib.TryUpdateMusicVolume(); + Configuration.Audio.SaveMusicVolume(); + break; + case Configurator.MovieVolume: + Configuration.Audio.MovieVolume = (Int32)Math.Round(configField.Value * 20) * 5; + Configuration.Audio.SaveMovieVolume(); + break; + case Configurator.VoiceVolume: + Configuration.VoiceActing.Volume = (Int32)Math.Round(configField.Value * 20) * 5; + Configuration.VoiceActing.SaveVolume(); + break; default: configField.Value = 0f; break; @@ -1455,37 +1480,103 @@ private void Update() } } + /* + * This was very useful for debugging + * Leaving it as a comment + * + private void ListComponents(GameObject go, int indent = 0) + { + Log.Message($"[DEBUG] {new string(' ', indent * 4)}> {go.name} position: {go.transform.localPosition}"); + var comps = go.GetComponents(); + if (comps != null && comps.Length > 0) + { + foreach (Component c in comps) + { + if (c is Transform) continue; + if (c is UIWidget) + { + var w = c as UIWidget; + Log.Message($"[DEBUG] {new string(' ', indent * 4)}{c} {c.GetType()} w: {w.width} h: {w.height}"); + } + else + { + Log.Message($"[DEBUG] {new string(' ', indent * 4)}{c} {c.GetType()}"); + } + } + foreach (Transform child in go.transform) + { + if (child.gameObject != go) ListComponents(child.gameObject, indent + 1); + } + } + }*/ + + private GameObject CreateVolumeSlider(GameObject template, Configurator id, int siblingIndex) + { + try + { + GameObject go = Instantiate(template); + go.transform.parent = template.transform.parent; + go.transform.localPosition = template.transform.localPosition; + go.transform.localScale = template.transform.localScale; + go.transform.SetSiblingIndex(siblingIndex); + go.name = $"{name} Panel - Slider"; + go.GetComponent().ID = (int)id; + + var locs = go.GetComponentsInChildren(); + locs[0].key = id.ToString(); + DestroyImmediate(locs[1]); + DestroyImmediate(locs[2]); + + var labels = go.GetComponentsInChildren(); + Destroy(labels[2]); + + var slider = go.GetComponentInChildren(); + slider.numberOfSteps = 21; + slider.value = 0f; + + return go; + } + catch (Exception ex) + { + Log.Error($"[ConfigUI] Couldn't create volume silder\n{ex.Message}\n{ex.StackTrace}"); + } + return null; + } + private void Awake() { FadingComponent = ScreenFadeGameObject.GetComponent(); ConfigFieldList = new List(); - // If the cheats of the Configuration menu are disabled, hide them and expand the ConfigList menu - if (!Configuration.Cheats.MasterSkill && !Configuration.Cheats.LvMax && !Configuration.Cheats.GilMax) - ConfigList.GetComponent().bottomAnchor.SetVertical(this.ConfigList.GetComponent().cachedTransform.parent, -940f); - Int32 configCount = ConfigList.GetChild(1).GetChild(0).transform.childCount; + + // Adding the volume sliders + UITable table = ConfigList.GetChild(1).GetChild(0).GetComponent(); + GameObject template = table.gameObject.GetChild((int)Configurator.FieldMessage); + CreateVolumeSlider(template, Configurator.SoundVolume, 0); + CreateVolumeSlider(template, Configurator.MusicVolume, 1); + CreateVolumeSlider(template, Configurator.MovieVolume, 2); + if (Configuration.VoiceActing.Enabled) + CreateVolumeSlider(template, Configurator.VoiceVolume, 3); + foreach (Transform trans in ConfigList.GetChild(1).GetChild(0).transform) { ConfigField configField = new ConfigField(); GameObject configTopObj = trans.gameObject; - Int32 id = configTopObj.GetComponent().ID; - - // Hide vibration settings from menu - if (!FF9StateSystem.IsPlatformVibration) + Configurator id = (Configurator)configTopObj.GetComponent().ID; + + // Remove unused settings from menu + if ((id == Configurator.Vibration && !FF9StateSystem.IsPlatformVibration) + || id == Configurator.Sound + || id == Configurator.SoundEffect) { - if (id == VIBRATION_CONFIG_INDEX) // Configurator.Vibration - { - configCount--; - gameObject.SetActive(false); - } - else if (id > VIBRATION_CONFIG_INDEX) // ControlTutorial, CombatTutorial, Title, QuitGame - { - gameObject.GetComponent().ID = id - 1; - } + configTopObj.SetActive(false); + Destroy(configTopObj); + continue; } - + + configTopObj.GetComponent().ID = ConfigFieldList.Count; configField.ConfigParent = configTopObj; configField.Button = configTopObj.GetComponent(); - configField.Configurator = (Configurator)id; + configField.Configurator = id; if (ConfigSliderIdList.Contains(configField.Configurator)) { configField.ConfigChoice.Add(trans.GetChild(1).GetChild(1).gameObject); @@ -1512,16 +1603,23 @@ private void Awake() UIEventListener.Get(trans.gameObject).onNavigate += OnKeyChoice; ConfigFieldList.Add(configField); } - - if (!FF9StateSystem.IsPlatformVibration) + + // Update onUp and onDown + for (int i = 0; i < ConfigFieldList.Count; i++) { - this.ConfigFieldList[VIBRATION_CONFIG_INDEX - 1].ConfigParent.GetComponent().onDown = this.ConfigFieldList[VIBRATION_CONFIG_INDEX + 1].ConfigParent; - this.ConfigFieldList[VIBRATION_CONFIG_INDEX + 1].ConfigParent.GetComponent().onUp = this.ConfigFieldList[VIBRATION_CONFIG_INDEX - 1].ConfigParent; + var navig = ConfigFieldList[i].ConfigParent.GetComponent(); + navig.onUp = null; + if (i > 1) navig.onUp = ConfigFieldList[i - 1].ConfigParent; + navig.onDown = null; + if (i < ConfigFieldList.Count - 2) navig.onDown = ConfigFieldList[i + 1].ConfigParent; } - + + // Put the cursor on first field + ButtonGroupState.SetCursorStartSelect(ConfigFieldList[0].ConfigParent, ConfigGroupButton); + configScrollButton = ConfigList.GetChild(0).GetComponent(); configScrollView = ConfigList.GetChild(1).GetComponent(); - configScrollView.MaxItem = configCount; + configScrollView.MaxItem = ConfigFieldList.Count; UIEventListener.Get(WarningDialog.GetChild(0).GetChild(2)).onClick += onClick; UIEventListener.Get(WarningDialog.GetChild(0).GetChild(3)).onClick += onClick; warningTransition = TransitionGroup.GetChild(0).GetComponent(); @@ -1543,7 +1641,18 @@ private void Awake() configScrollButton.DisplayScrollButton(false, false); transform.GetChild(3).GetChild(4).gameObject.SetActive(false); backButtonGameObject = ControlPanelGroup.GetChild(1); - if (!Configuration.Cheats.MasterSkill && !Configuration.Cheats.LvMax && !Configuration.Cheats.GilMax) - BoosterPanel.SetActive(false); + + // If the cheats of the Configuration menu are disabled, remove them and expand the ConfigList menu + if (!Configuration.Cheats.MasterSkill && !Configuration.Cheats.LvMax && !Configuration.Cheats.GilMax) + { + ConfigList.GetComponent().bottomAnchor.SetVertical(this.ConfigList.GetComponent().cachedTransform.parent, -940f); + BoosterPanel.SetActive(false); + Destroy(BoosterPanel); + configScrollView.VisibleItem += 2; + } + else + { + ConfigFieldList[ConfigFieldList.Count - 1].ConfigParent.GetComponent().onDown = masterSkillButtonGameObject; + } } } \ No newline at end of file diff --git a/Assembly-CSharp/Global/Movie/MovieAudioPlayer.cs b/Assembly-CSharp/Global/Movie/MovieAudioPlayer.cs index 915c03da4..ff35eef03 100644 --- a/Assembly-CSharp/Global/Movie/MovieAudioPlayer.cs +++ b/Assembly-CSharp/Global/Movie/MovieAudioPlayer.cs @@ -1,19 +1,13 @@ using System; +using Memoria; public class MovieAudioPlayer : MusicPlayer { - public void PlayMusic(String soundName, Int32 fadeIn = 0) - { - Int32 soundIndex = SoundMetaData.GetSoundIndex(soundName, SoundProfileType.MovieAudio); - SoundLib.Log("PlayMuvieAudio movieName: " + soundName); - if (soundIndex != -1) - { - base.PlayMusic(soundIndex, fadeIn, SoundProfileType.MovieAudio); - } - } - public SoundProfile GetActiveSoundProfile() { return this.activeSoundProfile; } + + public override Single Volume => Configuration.Audio.MovieVolume / 100f; + } diff --git a/Assembly-CSharp/Global/SFX/SfxSoundPlayer.cs b/Assembly-CSharp/Global/SFX/SfxSoundPlayer.cs index 4e20c030f..f42c2cd5e 100644 --- a/Assembly-CSharp/Global/SFX/SfxSoundPlayer.cs +++ b/Assembly-CSharp/Global/SFX/SfxSoundPlayer.cs @@ -7,20 +7,14 @@ public class SfxSoundPlayer : SoundPlayer { - public void SetVolume(Int32 volume) - { - this.playerVolume = volume / 100f; - this.UpdatePlayingSoundVolume(); - } - - private void UpdatePlayingSoundVolume() + public void UpdateVolume() { foreach (Int32 key in this.playingDict.Keys) { SoundProfile soundProfile = this.playingDict[key]; if (this.residentSoundDatabase.Read(soundProfile.SoundIndex) != null) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.playerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.Volume, 0); } } } @@ -145,7 +139,7 @@ public SoundProfile PlaySfxSound(Int32 soundIndexInSpecialEffect, Single soundVo ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(soundProfile.SoundID) != 0) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.playerVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.Volume, 0); SoundLib.Log("Panning: " + soundProfile.Panning); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPanning(soundProfile.SoundID, soundProfile.Panning, 0); Int32 fastForwardFactor = HonoBehaviorSystem.Instance.GetFastForwardFactor(); @@ -398,7 +392,7 @@ private Int32 GetSoundIndex(Int32 specialEffectID, Int32 soundIndexInSpecialEffe private Int32 playingAtFrameCount; - private Single playerVolume = 1f; + public override Single Volume => Configuration.Audio.SoundVolume / 100f; private SoundProfile loadingSoundProfile; } diff --git a/Assembly-CSharp/Global/Sound/Effect/SoundEffectPlayer.cs b/Assembly-CSharp/Global/Sound/Effect/SoundEffectPlayer.cs index 6d9f06b88..0d23fa6a9 100644 --- a/Assembly-CSharp/Global/Sound/Effect/SoundEffectPlayer.cs +++ b/Assembly-CSharp/Global/Sound/Effect/SoundEffectPlayer.cs @@ -3,7 +3,7 @@ public class SoundEffectPlayer : SoundPlayer { - public void SetVolume(Single volume) + public void UpdateVolume() { SoundDatabase[] array = new SoundDatabase[] { @@ -21,7 +21,7 @@ public void SetVolume(Single volume) Int32 soundID = value.SoundID; if (this.playedEffectSet.Contains(soundID)) { - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundID, volume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundID, value.SoundVolume * this.Volume, 0); SoundLib.Log("Set volume to soundID: " + soundID + " finished"); } else @@ -30,7 +30,6 @@ public void SetVolume(Single volume) } } } - this.playerVolume = volume; } public void StopAllSoundEffects() @@ -141,7 +140,7 @@ public void PlaySoundEffect(Int32 soundIndex, Single soundVolume = 1f, Single pa } if (soundProfile != null) { - soundProfile.SoundVolume = soundVolume * this.playerVolume; + soundProfile.SoundVolume = soundVolume; soundProfile.Panning = panning; soundProfile.Pitch = pitch; this.activeSoundEffect = soundProfile; @@ -165,7 +164,7 @@ public void PlaySoundEffect(Int32 soundIndex, Single soundVolume = 1f, Single pa { soundProfile = SoundMetaData.GetSoundProfile(soundIndex, type); } - soundProfile.SoundVolume = soundVolume * this.playerVolume; + soundProfile.SoundVolume = soundVolume; soundProfile.Panning = panning; soundProfile.Pitch = pitch; if (soundProfile == null) @@ -201,7 +200,7 @@ private void LoadOnTheFlySoundResourceCallback(SoundDatabase soundDatabase, Bool private void PlaySoundEffect(SoundProfile soundProfile) { base.CreateSound(soundProfile); - base.StartSound(soundProfile, 1f); + base.StartSound(soundProfile, Volume); this.playedEffectSet.Add(soundProfile.SoundID); soundProfile.SoundProfileState = SoundProfileState.Released; this.gameSoundDatabase.Update(soundProfile); @@ -275,5 +274,5 @@ public override void Update() private SoundProfile activeSoundEffect; - private Single playerVolume = 1f; + public override Single Volume => Memoria.Configuration.Audio.SoundVolume / 100f; } diff --git a/Assembly-CSharp/Global/Sound/Lib/SoundLib.cs b/Assembly-CSharp/Global/Sound/Lib/SoundLib.cs index c74c16fd0..3ffb9319e 100644 --- a/Assembly-CSharp/Global/Sound/Lib/SoundLib.cs +++ b/Assembly-CSharp/Global/Sound/Lib/SoundLib.cs @@ -21,7 +21,7 @@ public static void PlayMovieMusic(String movieName, Int32 offsetTimeMSec = 0) Int32 movieSoundIndex = SoundLib.GetMovieSoundIndex(movieName); if (movieSoundIndex != -1) { - SoundLib.movieAudioPlayer.PlayMusic(movieSoundIndex, offsetTimeMSec, SoundProfileType.MovieAudio); + SoundLib.MovieAudioPlayer.PlayMusic(movieSoundIndex, offsetTimeMSec, SoundProfileType.MovieAudio); } else { @@ -31,7 +31,7 @@ public static void PlayMovieMusic(String movieName, Int32 offsetTimeMSec = 0) public static SoundProfile GetActiveMovieAudioSoundProfile() { - return SoundLib.movieAudioPlayer.GetActiveSoundProfile(); + return SoundLib.MovieAudioPlayer.GetActiveSoundProfile(); } public static Int32 GetMovieSoundIndex(String movieName) @@ -124,7 +124,7 @@ public static void PauseMovieMusic(String movieName) { return; } - SoundLib.movieAudioPlayer.PauseMusic(); + SoundLib.MovieAudioPlayer.PauseMusic(); } public static void StopMovieMusic(String movieName, Boolean isForceStop = false) @@ -141,18 +141,18 @@ public static void StopMovieMusic(String movieName, Boolean isForceStop = false) } else { - SoundLib.movieAudioPlayer.StopMusic(); + SoundLib.MovieAudioPlayer.StopMusic(); } } else if (String.Equals(movieName, "FMV000")) { Int32 ticks = 90; Int32 fadeOut = AllSoundDispatchPlayer.ConvertTickToMillisec(ticks); - SoundLib.movieAudioPlayer.StopMusic(fadeOut); + SoundLib.MovieAudioPlayer.StopMusic(fadeOut); } else { - SoundLib.movieAudioPlayer.StopMusic(); + SoundLib.MovieAudioPlayer.StopMusic(); } } @@ -163,12 +163,12 @@ public static void AddNewSound(String fileName, Int32 soundId, AudioSource sourc public static void SeekMovieAudio(String movieName, Single time) { - SoundLib.movieAudioPlayer.SeekActiveSound((Int32)(time * 1000f)); + SoundLib.MovieAudioPlayer.SeekActiveSound((Int32)(time * 1000f)); } public static void SeekMusic(Single time) { - SoundLib.musicPlayer.SeekActiveSound((Int32)(time * 1000f)); + SoundLib.MusicPlayer.SeekActiveSound((Int32)(time * 1000f)); } public static void LoadMovieResources(String basePath, String[] movies) @@ -210,7 +210,7 @@ public static void LoadGameSoundEffect(String jsonMetaData) { try { - SoundLib.soundEffectPlayer.LoadGameSoundEffect(jsonMetaData); + SoundLib.SoundEffectPlayer.LoadGameSoundEffect(jsonMetaData); } catch (Exception message) { @@ -222,7 +222,7 @@ public static void LoadSceneSoundEffect(String jsonMetaData) { try { - SoundLib.soundEffectPlayer.LoadSceneSoundEffect(jsonMetaData); + SoundLib.SoundEffectPlayer.LoadSceneSoundEffect(jsonMetaData); } catch (Exception message) { @@ -234,7 +234,7 @@ public static void UnloadSoundEffect() { try { - SoundLib.soundEffectPlayer.UnloadSoundEffect(); + SoundLib.SoundEffectPlayer.UnloadSoundEffect(); } catch (Exception message) { @@ -246,7 +246,7 @@ public static void UnloadAllSoundEffect() { try { - SoundLib.soundEffectPlayer.UnloadAllSoundEffect(); + SoundLib.SoundEffectPlayer.UnloadAllSoundEffect(); } catch (Exception message) { @@ -258,7 +258,7 @@ public static Boolean IsSoundEffectPlaying(Int32 soundIndex) { try { - return SoundLib.soundEffectPlayer.IsSoundEffectPlaying(soundIndex); + return SoundLib.SoundEffectPlayer.IsSoundEffectPlaying(soundIndex); } catch (Exception message) { @@ -271,7 +271,7 @@ public static void StopSoundEffect(Int32 soundIndex) { try { - SoundLib.soundEffectPlayer.StopSoundEffect(soundIndex); + SoundLib.SoundEffectPlayer.StopSoundEffect(soundIndex); } catch (Exception message) { @@ -283,8 +283,8 @@ public static void StopAllSoundEffects() { try { - SoundLib.soundEffectPlayer.StopAllSoundEffects(); - SoundLib.songPlayer.StopAllSoundEffects(); + SoundLib.SoundEffectPlayer.StopAllSoundEffects(); + SoundLib.SongPlayer.StopAllSoundEffects(); } catch (Exception message) { @@ -301,7 +301,7 @@ public static void PlaySoundEffect(Int32 soundIndex, Single soundVolume = 1f, Si Int32 sndPos = 0; Int32 volume = (Int32)(soundVolume * 127); FF9Snd.ParameterChanger(ref paramType, ref soundIndex, ref attr, ref sndPos, ref volume); - SoundLib.soundEffectPlayer.PlaySoundEffect(soundIndex, soundVolume, panning, pitch); + SoundLib.SoundEffectPlayer.PlaySoundEffect(soundIndex, soundVolume, panning, pitch); } catch (Exception message) { @@ -318,7 +318,7 @@ public static void LoadAllResidentSfxSoundData() { try { - SoundLib.sfxSoundPlayer.LoadAllResidentSoundData(); + SoundLib.SfxSoundPlayer.LoadAllResidentSoundData(); } catch (Exception message) { @@ -330,7 +330,7 @@ public static void UnloadAllResidentSfxSoundData() { try { - SoundLib.sfxSoundPlayer.UnloadAllResidentSoundData(); + SoundLib.SfxSoundPlayer.UnloadAllResidentSoundData(); } catch (Exception message) { @@ -342,7 +342,7 @@ public static void LoadSfxSoundData(Int32 specialEffectID) { try { - SoundLib.sfxSoundPlayer.LoadSoundData(specialEffectID); + SoundLib.SfxSoundPlayer.LoadSoundData(specialEffectID); } catch (Exception message) { @@ -355,7 +355,7 @@ public static SoundProfile PlaySfxSound(Int32 soundIndexInSpecialEffect, Single SoundProfile result; try { - result = SoundLib.sfxSoundPlayer.PlaySfxSound(soundIndexInSpecialEffect, soundVolume, panning, pitch); + result = SoundLib.SfxSoundPlayer.PlaySfxSound(soundIndexInSpecialEffect, soundVolume, panning, pitch); } catch (Exception message) { @@ -370,7 +370,7 @@ public static Boolean IsSfxSoundPlaying(Int32 soundIndexInSpecialEffect) Boolean result; try { - result = SoundLib.sfxSoundPlayer.IsPlaying(soundIndexInSpecialEffect); + result = SoundLib.SfxSoundPlayer.IsPlaying(soundIndexInSpecialEffect); } catch (Exception message) { @@ -384,7 +384,7 @@ public static void StopSfxSound(Int32 soundIndexInSpecialEffect) { try { - SoundLib.sfxSoundPlayer.StopSound(soundIndexInSpecialEffect); + SoundLib.SfxSoundPlayer.StopSound(soundIndexInSpecialEffect); } catch (Exception message) { @@ -396,7 +396,7 @@ public static void StopAllSfxSound() { try { - SoundLib.sfxSoundPlayer.StopAllSounds(); + SoundLib.SfxSoundPlayer.StopAllSounds(); } catch (Exception message) { @@ -408,7 +408,7 @@ public static void PlaySong(Int32 soundIndex) { try { - SoundLib.songPlayer.PlaySong(soundIndex, 1f, 0f, 1f); + SoundLib.SongPlayer.PlaySong(soundIndex, 1f, 0f, 1f); } catch (Exception message) { @@ -420,7 +420,7 @@ public static void StopSong(Int32 soundIndex) { try { - SoundLib.songPlayer.StopSong(soundIndex); + SoundLib.SongPlayer.StopSong(soundIndex); } catch (Exception message) { @@ -432,7 +432,7 @@ public static void StopAllSongs() { try { - SoundLib.songPlayer.StopAllSongs(); + SoundLib.SongPlayer.StopAllSongs(); } catch (Exception message) { @@ -444,7 +444,7 @@ public static void PlaySong(Int32 soundIndex, Single soundVolume, Single panning { try { - SoundLib.songPlayer.PlaySong(soundIndex, soundVolume, panning, pitch); + SoundLib.SongPlayer.PlaySong(soundIndex, soundVolume, panning, pitch); } catch (Exception message) { @@ -474,7 +474,7 @@ public static void LoadMusic(String jsonMetaData) { try { - SoundLib.musicPlayer.LoadMusic(jsonMetaData); + SoundLib.MusicPlayer.LoadMusic(jsonMetaData); } catch (Exception message) { @@ -486,7 +486,7 @@ public static void UnloadMusic() { try { - SoundLib.musicPlayer.UnloadMusic(); + SoundLib.MusicPlayer.UnloadMusic(); } catch (Exception message) { @@ -498,7 +498,7 @@ public static void LoadMovieAudio(String jsonMetaData) { try { - SoundLib.movieAudioPlayer.LoadMusic(jsonMetaData); + SoundLib.MovieAudioPlayer.LoadMusic(jsonMetaData); } catch (Exception message) { @@ -510,7 +510,7 @@ public static void UnloadMovieAudio() { try { - SoundLib.movieAudioPlayer.UnloadMusic(); + SoundLib.MovieAudioPlayer.UnloadMusic(); } catch (Exception message) { @@ -522,7 +522,7 @@ public static void PlayMusic(Int32 soundIndex) { try { - SoundLib.musicPlayer.PlayMusic(soundIndex); + SoundLib.MusicPlayer.PlayMusic(soundIndex); } catch (Exception message) { @@ -534,7 +534,7 @@ public static void SetNextLoopRegion(Int32 soundIndex) { try { - SoundLib.musicPlayer.NextLoopRegion(soundIndex); + SoundLib.MusicPlayer.NextLoopRegion(soundIndex); } catch (Exception message) { @@ -546,7 +546,7 @@ public static void PlayMusic(Int32 soundIndex, Int32 fadeIn) { try { - SoundLib.musicPlayer.PlayMusic(soundIndex, fadeIn, SoundProfileType.Music); + SoundLib.MusicPlayer.PlayMusic(soundIndex, fadeIn, SoundProfileType.Music); } catch (Exception message) { @@ -558,7 +558,7 @@ public static void PauseMusic() { try { - SoundLib.musicPlayer.PauseMusic(); + SoundLib.MusicPlayer.PauseMusic(); } catch (Exception message) { @@ -570,7 +570,7 @@ public static void ResumeMusic() { try { - SoundLib.musicPlayer.ResumeMusic(); + SoundLib.MusicPlayer.ResumeMusic(); } catch (Exception message) { @@ -582,7 +582,7 @@ public static Int32 GetActiveMusicSoundID() { try { - return SoundLib.musicPlayer.GetActiveSoundID(); + return SoundLib.MusicPlayer.GetActiveSoundID(); } catch (Exception message) { @@ -595,7 +595,7 @@ public static void StopMusic() { try { - SoundLib.musicPlayer.StopMusic(); + SoundLib.MusicPlayer.StopMusic(); } catch (Exception message) { @@ -607,7 +607,7 @@ public static void StopMusic(Int32 fadeOut) { try { - SoundLib.musicPlayer.StopMusic(fadeOut); + SoundLib.MusicPlayer.StopMusic(fadeOut); } catch (Exception message) { @@ -619,7 +619,7 @@ public static void SetMusicVolume(Single volume) { try { - SoundLib.musicPlayer.SetMusicVolume(volume); + SoundLib.MusicPlayer.SetMusicVolume(volume); } catch (Exception message) { @@ -631,7 +631,7 @@ public static void SetMusicPanning(Single panning) { try { - SoundLib.musicPlayer.SetMusicPanning(panning); + SoundLib.MusicPlayer.SetMusicPanning(panning); } catch (Exception message) { @@ -643,7 +643,7 @@ public static void SetMusicPitch(Single pitch) { try { - SoundLib.musicPlayer.SetMusicPitch(pitch); + SoundLib.MusicPlayer.SetMusicPitch(pitch); } catch (Exception message) { @@ -661,9 +661,9 @@ public static void EnableMusic() { try { - SoundLib.allSoundDispatchPlayer.SetMusicVolume(Configuration.Audio.MusicVolume); - SoundLib.musicPlayer.SetOptionVolume(Configuration.Audio.MusicVolume); - SoundLib.movieAudioPlayer.SetOptionVolume(Configuration.Audio.MusicVolume); + SoundLib.AllSoundDispatchPlayer.UpdatePlayingMusicVolume(); + SoundLib.MusicPlayer.UpdateVolume(); + SoundLib.MovieAudioPlayer.UpdateVolume(); SoundLib.MusicIsMute = false; } catch (Exception message) @@ -676,10 +676,9 @@ public static void DisableMusic() { try { - SoundLib.allSoundDispatchPlayer.SetMusicVolume(0); - SoundLib.allSoundDispatchPlayer.SetMusicVolume(0); - SoundLib.musicPlayer.SetOptionVolume(0); - SoundLib.movieAudioPlayer.SetOptionVolume(0); + SoundLib.AllSoundDispatchPlayer.UpdatePlayingMusicVolume(); + SoundLib.MusicPlayer.UpdateVolume(); + SoundLib.MovieAudioPlayer.UpdateVolume(); SoundLib.MusicIsMute = true; } catch (Exception message) @@ -699,10 +698,10 @@ public static void EnableSoundEffect() { try { - SoundLib.allSoundDispatchPlayer.SetSoundEffectVolume(Configuration.Audio.SoundVolume); - SoundLib.sfxSoundPlayer.SetVolume(Configuration.Audio.SoundVolume); - SoundLib.soundEffectPlayer.SetVolume(Configuration.Audio.SoundVolume / 100f); - SoundLib.songPlayer.SetVolume(Configuration.Audio.SoundVolume / 100f); + SoundLib.AllSoundDispatchPlayer.UpdatePlayingSoundEffectVolume(); + SoundLib.SfxSoundPlayer.UpdateVolume(); + SoundLib.SoundEffectPlayer.UpdateVolume(); + SoundLib.SongPlayer.UpdateVolume(); SoundLib.SoundEffectIsMute = false; } catch (Exception message) @@ -715,10 +714,10 @@ public static void DisableSoundEffect() { try { - SoundLib.allSoundDispatchPlayer.SetSoundEffectVolume(0); - SoundLib.sfxSoundPlayer.SetVolume(0); - SoundLib.soundEffectPlayer.SetVolume(0f); - SoundLib.songPlayer.SetVolume(0f); + SoundLib.AllSoundDispatchPlayer.UpdatePlayingSoundEffectVolume(); + SoundLib.SfxSoundPlayer.UpdateVolume(); + SoundLib.SoundEffectPlayer.UpdateVolume(); + SoundLib.SongPlayer.UpdateVolume(); SoundLib.SoundEffectIsMute = true; } catch (Exception message) @@ -729,31 +728,31 @@ public static void DisableSoundEffect() public static AllSoundDispatchPlayer GetAllSoundDispatchPlayer() { - return SoundLib.allSoundDispatchPlayer; + return SoundLib.AllSoundDispatchPlayer; } public static void UpdatePlayingSoundEffectPitchByGameSpeed() { - SoundLib.allSoundDispatchPlayer.UpdatePlayingSoundEffectPitchFollowingGameSpeed(); + SoundLib.AllSoundDispatchPlayer.UpdatePlayingSoundEffectPitchFollowingGameSpeed(); } public static void StopAllSounds(Boolean isAll = true) { try { - SoundLib.musicPlayer.StopMusic(); - SoundLib.soundEffectPlayer.StopAllSoundEffects(); - SoundLib.songPlayer.StopAllSoundEffects(); - SoundLib.movieAudioPlayer.StopMusic(); + SoundLib.MusicPlayer.StopMusic(); + SoundLib.SoundEffectPlayer.StopAllSoundEffects(); + SoundLib.SongPlayer.StopAllSoundEffects(); + SoundLib.MovieAudioPlayer.StopMusic(); if (isAll) { - SoundLib.allSoundDispatchPlayer.StopAllSounds(); + SoundLib.AllSoundDispatchPlayer.StopAllSounds(); } else { - SoundLib.allSoundDispatchPlayer.PauseAllSounds(); + SoundLib.AllSoundDispatchPlayer.PauseAllSounds(); } - SoundLib.sfxSoundPlayer.StopAllSounds(); + SoundLib.SfxSoundPlayer.StopAllSounds(); } catch (Exception message) { @@ -763,17 +762,17 @@ public static void StopAllSounds(Boolean isAll = true) public static void ClearSuspendedSounds() { - SoundLib.allSoundDispatchPlayer.ClearSuspendedSounds(); + SoundLib.AllSoundDispatchPlayer.ClearSuspendedSounds(); } public static void SuspendSoundSystem() { if (!SoundLib.isSuspendAllSounds) { - SoundLib.movieAudioPlayer.PauseMusic(); - SoundLib.allSoundDispatchPlayer.PauseAllSounds(); - SoundLib.sfxSoundPlayer.PauseAllSounds(); - SoundLib.voicePlayer.PauseAllSounds(); + SoundLib.MovieAudioPlayer.PauseMusic(); + SoundLib.AllSoundDispatchPlayer.PauseAllSounds(); + SoundLib.SfxSoundPlayer.PauseAllSounds(); + SoundLib.VoicePlayer.PauseAllSounds(); SoundLib.isSuspendAllSounds = true; } } @@ -782,10 +781,10 @@ public static void ResumeSoundSystem() { if (SoundLib.isSuspendAllSounds) { - SoundLib.movieAudioPlayer.ResumeMusic(); - SoundLib.allSoundDispatchPlayer.ResumeAllSounds(); - SoundLib.sfxSoundPlayer.ResumeAllSounds(); - SoundLib.voicePlayer.ResumeAllSounds(); + SoundLib.MovieAudioPlayer.ResumeMusic(); + SoundLib.AllSoundDispatchPlayer.ResumeAllSounds(); + SoundLib.SfxSoundPlayer.ResumeAllSounds(); + SoundLib.VoicePlayer.ResumeAllSounds(); SoundLib.isSuspendAllSounds = false; } } @@ -884,38 +883,38 @@ private void FinalizePlugin() private void InitializeSoundPlayer() { - SoundLib.soundEffectPlayer = new SoundEffectPlayer(); - SoundLib.musicPlayer = new MusicPlayer(); - SoundLib.movieAudioPlayer = new MovieAudioPlayer(); - SoundLib.songPlayer = new SongPlayer(); - SoundLib.allSoundDispatchPlayer = new AllSoundDispatchPlayer(); - SoundLib.sfxSoundPlayer = new SfxSoundPlayer(); - SoundLib.voicePlayer = new VoicePlayer(); + SoundLib.SoundEffectPlayer = new SoundEffectPlayer(); + SoundLib.MusicPlayer = new MusicPlayer(); + SoundLib.MovieAudioPlayer = new MovieAudioPlayer(); + SoundLib.SongPlayer = new SongPlayer(); + SoundLib.AllSoundDispatchPlayer = new AllSoundDispatchPlayer(); + SoundLib.SfxSoundPlayer = new SfxSoundPlayer(); + SoundLib.VoicePlayer = new VoicePlayer(); this.soundPlayerList = new List(); - this.soundPlayerList.Add(SoundLib.soundEffectPlayer); - this.soundPlayerList.Add(SoundLib.musicPlayer); - this.soundPlayerList.Add(SoundLib.movieAudioPlayer); - this.soundPlayerList.Add(SoundLib.songPlayer); - this.soundPlayerList.Add(SoundLib.allSoundDispatchPlayer); - this.soundPlayerList.Add(SoundLib.sfxSoundPlayer); - this.soundPlayerList.Add(SoundLib.voicePlayer); + this.soundPlayerList.Add(SoundLib.SoundEffectPlayer); + this.soundPlayerList.Add(SoundLib.MusicPlayer); + this.soundPlayerList.Add(SoundLib.MovieAudioPlayer); + this.soundPlayerList.Add(SoundLib.SongPlayer); + this.soundPlayerList.Add(SoundLib.AllSoundDispatchPlayer); + this.soundPlayerList.Add(SoundLib.SfxSoundPlayer); + this.soundPlayerList.Add(SoundLib.VoicePlayer); } private Boolean m_isInitialized; - private static SoundEffectPlayer soundEffectPlayer; - - public static VoicePlayer voicePlayer; + public static SoundEffectPlayer SoundEffectPlayer { get; private set; } + + public static VoicePlayer VoicePlayer { get; private set; } - private static MusicPlayer musicPlayer; + public static MusicPlayer MusicPlayer { get; private set; } - public static MovieAudioPlayer movieAudioPlayer; + public static MovieAudioPlayer MovieAudioPlayer { get; private set; } - private static SongPlayer songPlayer; + public static SongPlayer SongPlayer { get; private set; } - private static AllSoundDispatchPlayer allSoundDispatchPlayer; + public static AllSoundDispatchPlayer AllSoundDispatchPlayer { get; private set; } - private static SfxSoundPlayer sfxSoundPlayer; + public static SfxSoundPlayer SfxSoundPlayer { get; private set; } private List soundPlayerList; diff --git a/Assembly-CSharp/Global/MusicPlayer.cs b/Assembly-CSharp/Global/Sound/MusicPlayer.cs similarity index 88% rename from Assembly-CSharp/Global/MusicPlayer.cs rename to Assembly-CSharp/Global/Sound/MusicPlayer.cs index e3272f119..c6e31fcb0 100644 --- a/Assembly-CSharp/Global/MusicPlayer.cs +++ b/Assembly-CSharp/Global/Sound/MusicPlayer.cs @@ -6,7 +6,7 @@ public class MusicPlayer : SoundPlayer { public MusicPlayer() { - this.playerVolume = Configuration.Audio.MusicVolume / 100f; + this.previousPlayerVolume = this.Volume; this.playerPitch = 1f; this.playerPanning = 0f; this.fadeInDuration = 0f; @@ -40,12 +40,7 @@ public void UnloadMusic() base.UnloadResource(this.soundDatabase); } - public void PlayMusic(Int32 soundIndex) - { - this.PlayMusic(soundIndex, 0, SoundProfileType.Music); - } - - public void PlayMusic(Int32 soundIndex, Int32 fadeIn, SoundProfileType type = SoundProfileType.Music) + public void PlayMusic(Int32 soundIndex, Int32 fadeIn = 0, SoundProfileType type = SoundProfileType.Music) { SoundProfile soundProfile = this.soundDatabase.Read(soundIndex); if (soundProfile == null) @@ -111,7 +106,7 @@ public void PlayMusic(SoundProfile soundProfileFromIndex, Int32 fadeIn) if (this.activeSoundProfile.SoundProfileState == SoundProfileState.Paused) { this.stateTransition.Transition(soundProfileFromIndex, new SdLibSoundProfileStateGraph.TransitionDelegate(base.ResumeSound)); - this.SetMusicVolume(this.playerVolume * this.optionVolume, soundProfileFromIndex); + this.SetMusicVolume(this.Volume, soundProfileFromIndex); this.SetMusicPanning(this.playerPanning, soundProfileFromIndex); this.SetMusicPitch(this.playerPitch, soundProfileFromIndex); } @@ -125,8 +120,7 @@ public void PlayMusic(SoundProfile soundProfileFromIndex, Int32 fadeIn) if (this.upcomingSoundProfile != null && (this.upcomingSoundProfile.SoundProfileState == SoundProfileState.CrossfadeIn || this.upcomingSoundProfile.SoundProfileState == SoundProfileState.Paused)) { this.stateTransition.Transition(this.upcomingSoundProfile, new SdLibSoundProfileStateGraph.TransitionDelegate(base.ResumeSound)); - this.upcomingSoundProfile.SoundVolume = this.playerVolume * this.optionVolume; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(this.upcomingSoundProfile.SoundID, this.playerVolume * this.optionVolume, (Int32)(this.fadeInTimeRemain * 1000f)); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(this.upcomingSoundProfile.SoundID, this.upcomingSoundProfile.SoundVolume * this.Volume, (Int32)(this.fadeInTimeRemain * 1000f)); this.SetMusicPanning(this.playerPanning, this.upcomingSoundProfile); this.SetMusicPitch(this.playerPitch, this.upcomingSoundProfile); this.activeSoundProfile = this.upcomingSoundProfile; @@ -177,8 +171,7 @@ private void StartSoundCrossfadeIn(SoundProfile soundProfile) return; } ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, 0f, 0); - soundProfile.SoundVolume = this.playerVolume * this.optionVolume; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, this.playerVolume * this.optionVolume, (Int32)(this.fadeInDuration * 1000f)); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.Volume, (Int32)(this.fadeInDuration * 1000f)); this.SetMusicPanning(this.playerPanning, soundProfile); this.SetMusicPitch(this.playerPitch, soundProfile); this.upcomingSoundProfile = soundProfile; @@ -237,44 +230,39 @@ public void StopMusic(Int32 fadeOut) } } - public void SetOptionVolume(Int32 volume) + public void UpdateVolume() { - this.optionVolume = volume / 100f; - this.SetMusicVolume(this.playerVolume); + this.SetMusicVolume(this.Volume); + this.previousPlayerVolume = this.Volume; } public void SetMusicVolume(Single volume) { - Single oldPlayerVolume = this.playerVolume; - this.playerVolume = volume; if (this.activeSoundProfile != null && this.activeSoundProfile.SoundProfileState == SoundProfileState.Played) { this.SetMusicVolume(volume, this.activeSoundProfile); } if (this.upcomingSoundProfile != null && this.upcomingSoundProfile.SoundProfileState == SoundProfileState.CrossfadeIn) { - this.SetMusicVolumeWhileFade(oldPlayerVolume, volume, this.upcomingSoundProfile); - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(this.upcomingSoundProfile.SoundID, volume, (Int32)(this.fadeInTimeRemain * 1000f)); + this.SetMusicVolumeWhileFade(this.previousPlayerVolume, volume, this.upcomingSoundProfile); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(this.upcomingSoundProfile.SoundID, this.upcomingSoundProfile.SoundVolume * volume, (Int32)(this.fadeInTimeRemain * 1000f)); } } private void SetMusicVolume(Single volume, SoundProfile soundProfile) { - soundProfile.SoundVolume = this.optionVolume * volume; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * volume, 0); } private void SetMusicVolumeWhileFade(Single oldPlayerVolume, Single newPlayerVolume, SoundProfile soundProfile) { - Single num = ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_GetVolume(soundProfile.SoundID); Single volume = 0f; if (oldPlayerVolume != 0f) { - Single num2 = num / oldPlayerVolume; - Single num3 = newPlayerVolume - oldPlayerVolume; - volume = num + num3 * num2; + Single factor = newPlayerVolume / oldPlayerVolume; + volume = factor * ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_GetVolume(soundProfile.SoundID); } - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, volume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * volume, 0); } public void SetMusicPanning(Single panning) @@ -327,7 +315,6 @@ public override void Update() { if (this.upcomingSoundProfile != null) { - Single num = ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_GetVolume(this.upcomingSoundProfile.SoundID); this.fadeInTimeRemain -= Time.deltaTime; if (this.fadeInTimeRemain <= 0f) { @@ -342,6 +329,8 @@ public override void Update() } } + public override Single Volume => Configuration.Audio.MusicVolume / 100f; + public SoundDatabase soundDatabase = new SoundDatabase(); private SoundDatabase onTheFlySoundDatabase = new SoundDatabase(); @@ -352,8 +341,7 @@ public override void Update() private SoundProfile upcomingSoundProfile; - private Single playerVolume; - + private Single previousPlayerVolume; private Single playerPitch; private Single playerPanning; @@ -367,6 +355,4 @@ public override void Update() private SoundProfile onTheFlyLoadedSoundProfile; private Int32 onTheFlyLoadedFadeIn; - - private Single optionVolume = 1f; } diff --git a/Assembly-CSharp/Global/Sound/SoundPlayer.cs b/Assembly-CSharp/Global/Sound/SoundPlayer.cs index 0fee94e64..1fbb54ab5 100644 --- a/Assembly-CSharp/Global/Sound/SoundPlayer.cs +++ b/Assembly-CSharp/Global/Sound/SoundPlayer.cs @@ -215,6 +215,8 @@ public static void StaticUnregisterBank(SoundProfile soundProfile) } } + public abstract Single Volume { get; } + private Boolean m_isInitialized; private Int32 resourceLoadingCounter; diff --git a/Assembly-CSharp/Memoria/Assets/Text/LanguageMap.cs b/Assembly-CSharp/Memoria/Assets/Text/LanguageMap.cs index fb363bb12..22b23bb0d 100644 --- a/Assembly-CSharp/Memoria/Assets/Text/LanguageMap.cs +++ b/Assembly-CSharp/Memoria/Assets/Text/LanguageMap.cs @@ -164,7 +164,7 @@ private void ReadText(ByteReader reader, Dictionary cellLanguages private void LoadModText(Dictionary cellLanguages) { String inputPath = DataResources.Text.PureDirectory + DataResources.Text.LocalizationPatchFile; - foreach(AssetManager.AssetFolder folder in AssetManager.FolderLowToHigh) + foreach (AssetManager.AssetFolder folder in AssetManager.FolderLowToHigh) { if (folder.TryFindAssetInModOnDisc(inputPath, out String fullPath, AssetManagerUtil.GetStreamingAssetsPath() + "/")) { diff --git a/Assembly-CSharp/Memoria/Battle/SFX/UnifiedBattleSequencer.cs b/Assembly-CSharp/Memoria/Battle/SFX/UnifiedBattleSequencer.cs index 124710f37..f20df2ee8 100644 --- a/Assembly-CSharp/Memoria/Battle/SFX/UnifiedBattleSequencer.cs +++ b/Assembly-CSharp/Memoria/Battle/SFX/UnifiedBattleSequencer.cs @@ -816,7 +816,7 @@ public void ExecuteSingleCode(Int32 runningThreadId) if (pr == null) throw new NullReferenceException(); SoundPlayer.StaticCreateSound(pr); - SoundPlayer.StaticStartSound(pr); + SoundPlayer.StaticStartSound(pr, SoundLib.SoundEffectPlayer.Volume); }, null); } catch (Exception err) diff --git a/Assembly-CSharp/Memoria/Configuration/Access/Audio.cs b/Assembly-CSharp/Memoria/Configuration/Access/Audio.cs index 5aa9e3521..1a2324bab 100644 --- a/Assembly-CSharp/Memoria/Configuration/Access/Audio.cs +++ b/Assembly-CSharp/Memoria/Configuration/Access/Audio.cs @@ -19,6 +19,12 @@ public static Int32 MusicVolume set => Instance._audio.MusicVolume.Value = value; } + public static Int32 MovieVolume + { + get => Instance._audio.MovieVolume; + set => Instance._audio.MovieVolume.Value = value; + } + public static Boolean PriorityToOGG => Instance._audio.PriorityToOGG; public static void SaveSoundVolume() @@ -30,6 +36,11 @@ public static void SaveMusicVolume() { SaveValue(Instance._audio.Name, Instance._audio.MusicVolume); } + + public static void SaveMovieVolume() + { + SaveValue(Instance._audio.Name, Instance._audio.MovieVolume); + } } } } \ No newline at end of file diff --git a/Assembly-CSharp/Memoria/Configuration/Access/VoiceActing.cs b/Assembly-CSharp/Memoria/Configuration/Access/VoiceActing.cs index bd01d5b11..31ba6e61b 100644 --- a/Assembly-CSharp/Memoria/Configuration/Access/VoiceActing.cs +++ b/Assembly-CSharp/Memoria/Configuration/Access/VoiceActing.cs @@ -12,7 +12,19 @@ public static class VoiceActing public static Boolean LogVoiceActing => Instance._voiceActing.LogVoiceActing; public static Boolean StopVoiceWhenDialogDismissed = Instance._voiceActing.StopVoiceWhenDialogDismissed; public static Boolean AutoDismissDialogAfterCompletion = Instance._voiceActing.AutoDismissDialogAfterCompletion; - public static Int32 Volume = Instance._voiceActing.Volume; + public static Int32 Volume + { + get => Instance._voiceActing.Volume; + set => Instance._voiceActing.Volume.Value = value; + } + + public static void SaveVolume() + { + // We need to make sure VoiceActing is enabled otherwise the volume won't apply + // This can happen if a mod enable the VoiceActing + SaveValue(Instance._voiceActing.Name, Instance._voiceActing.Enabled); + SaveValue(Instance._voiceActing.Name, Instance._voiceActing.Volume); + } } } } \ No newline at end of file diff --git a/Assembly-CSharp/Memoria/Configuration/Memoria.ini b/Assembly-CSharp/Memoria/Configuration/Memoria.ini index 7b5eb635f..f71dbc5ea 100644 --- a/Assembly-CSharp/Memoria/Configuration/Memoria.ini +++ b/Assembly-CSharp/Memoria/Configuration/Memoria.ini @@ -15,6 +15,7 @@ Size = 24 ; PriorityToOGG (default 0) When enabled, ".ogg" audio files are used instead of the ".akb.bytes" counterpart when both exist; the AKB header is then generated again at each usage MusicVolume = 100 SoundVolume = 100 +MovieVolume = 100 PriorityToOGG = 0 [Graphics] diff --git a/Assembly-CSharp/Memoria/Configuration/Structure/AudioSection.cs b/Assembly-CSharp/Memoria/Configuration/Structure/AudioSection.cs index 75aa78708..adc718f8e 100644 --- a/Assembly-CSharp/Memoria/Configuration/Structure/AudioSection.cs +++ b/Assembly-CSharp/Memoria/Configuration/Structure/AudioSection.cs @@ -9,12 +9,14 @@ private sealed class AudioSection : IniSection { public readonly IniValue SoundVolume; public readonly IniValue MusicVolume; + public readonly IniValue MovieVolume; public readonly IniValue PriorityToOGG; public AudioSection() : base(nameof(AudioSection), true) { SoundVolume = BindInt32(nameof(SoundVolume), 100); MusicVolume = BindInt32(nameof(MusicVolume), 100); + MovieVolume = BindInt32(nameof(MovieVolume), 100); PriorityToOGG = BindBoolean(nameof(PriorityToOGG), false); } } diff --git a/Assembly-CSharp/Memoria/Configuration/Structure/VoiceActingSection.cs b/Assembly-CSharp/Memoria/Configuration/Structure/VoiceActingSection.cs index eaf5894f3..c0ba96cb8 100644 --- a/Assembly-CSharp/Memoria/Configuration/Structure/VoiceActingSection.cs +++ b/Assembly-CSharp/Memoria/Configuration/Structure/VoiceActingSection.cs @@ -17,7 +17,7 @@ public VoiceActingSection() : base(nameof(VoiceActingSection), false) LogVoiceActing = BindBoolean(nameof(LogVoiceActing), false); StopVoiceWhenDialogDismissed = BindBoolean(nameof(StopVoiceWhenDialogDismissed), false); AutoDismissDialogAfterCompletion = BindBoolean(nameof(AutoDismissDialogAfterCompletion), false); - Volume = BindInt32(nameof(Volume), 80); + Volume = BindInt32(nameof(Volume), 100); } } } diff --git a/Assembly-CSharp/Memoria/VoiceActing/BattleVoice.cs b/Assembly-CSharp/Memoria/VoiceActing/BattleVoice.cs index e3017ab20..c28cb8501 100644 --- a/Assembly-CSharp/Memoria/VoiceActing/BattleVoice.cs +++ b/Assembly-CSharp/Memoria/VoiceActing/BattleVoice.cs @@ -205,7 +205,7 @@ private static void PlayVoiceEffect(GenericVoiceEffect voiceEffect) foreach (BTL_DATA btl in speakerBtlList) { if (_currentVoicePlay.TryGetValue(btl, out playingVoice)) - SoundLib.voicePlayer.StopSound(playingVoice.Value); + SoundLib.VoicePlayer.StopSound(playingVoice.Value); _currentVoicePlay[btl] = new KeyValuePair(voiceEffect.Priority, audioProfile); } } @@ -462,7 +462,7 @@ private static void ParseEffect(String effectCode) if (pathsValue.IndexOf(',') > 0) { Int32 p = pathsValue.LastIndexOf('/'); - String folder = (p < 0) ? "" : folder = pathsValue.Substring(0, p + 1); + String folder = (p < 0) ? "" : pathsValue.Substring(0, p + 1); String[] files = (p < 0) ? pathsValue.Split(',') : pathsValue.Substring(p + 1).Split(','); paths = new String[files.Length]; for (Int32 j = 0; j < files.Length; j++) diff --git a/Assembly-CSharp/Memoria/VoiceActing/VoicePlayer.cs b/Assembly-CSharp/Memoria/VoiceActing/VoicePlayer.cs index f19f937a7..4bf11a2b5 100644 --- a/Assembly-CSharp/Memoria/VoiceActing/VoicePlayer.cs +++ b/Assembly-CSharp/Memoria/VoiceActing/VoicePlayer.cs @@ -11,11 +11,9 @@ public class VoicePlayer : SoundPlayer { public VoicePlayer() { - this.playerVolume = Configuration.VoiceActing.Volume / 10f; this.playerPitch = 1f; this.playerPanning = 0f; this.fadeInDuration = 0f; - this.fadeOutDuration = 0f; this.fadeInTimeRemain = 0f; this.stateTransition = new SdLibSoundProfileStateGraph(); this.stateTransition.Add(new SdLibSoundProfileStateGraph.TransitionDelegate(base.CreateSound), SoundProfileState.Idle, SoundProfileState.Created); @@ -41,10 +39,7 @@ public static Boolean HasDialogVoice(Dialog dialog) return false; } - public new void StartSound(SoundProfile soundProfile, Single playerVolume = 1f) => StaticStartSound(soundProfile, playerVolume); - public void StartSound(SoundProfile soundProfile, Single playerVolume = 1f, Action onFinished = null) => StaticStartSound(soundProfile, playerVolume, onFinished); - - public static void StaticStartSound(SoundProfile soundProfile, Single playerVolume = 1f, Action onFinished = null) + public void StartSound(SoundProfile soundProfile, Action onFinished = null) { if (onFinished != null) { @@ -81,7 +76,7 @@ public static void StaticStartSound(SoundProfile soundProfile, Single playerVolu soundProfile.SoundID = 0; return; } - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, Configuration.VoiceActing.Volume / 10f * soundProfile.SoundVolume, 0); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.Volume, 0); SoundLib.Log("Panning: " + soundProfile.Panning); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPanning(soundProfile.SoundID, soundProfile.Panning, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPitch(soundProfile.SoundID, soundProfile.Pitch, 0); @@ -203,7 +198,7 @@ private static void FieldZoneReleaseVoice(Dialog dialog, Boolean stopSound) if (soundOfDialog.TryGetValue(dialog, out attachedVoice)) { if (stopSound && ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(attachedVoice.SoundID) == 1) - SoundLib.voicePlayer.StopSound(attachedVoice); + SoundLib.VoicePlayer.StopSound(attachedVoice); Thread soundWatcher; if (watcherOfSound.TryGetValue(attachedVoice, out soundWatcher)) { @@ -233,8 +228,8 @@ public static SoundProfile CreateLoadThenPlayVoice(Int32 soundIndex, String vaPa { if (soundProfile != null) { - SoundLib.voicePlayer.CreateSound(soundProfile); - SoundLib.voicePlayer.StartSound(soundProfile, 1, onFinished); + SoundLib.VoicePlayer.CreateSound(soundProfile); + SoundLib.VoicePlayer.StartSound(soundProfile, onFinished); if (db.ReadAll().ContainsKey(soundProfile.SoundIndex)) db.Update(soundProfile); else @@ -296,8 +291,7 @@ private void StartSoundCrossfadeIn(SoundProfile soundProfile) return; } ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, 0f, 0); - soundProfile.SoundVolume = this.playerVolume * this.optionVolume; - ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, this.playerVolume * this.optionVolume, (Int32)(this.fadeInDuration * 1000f)); + ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * this.Volume, (Int32)(this.fadeInDuration * 1000f)); this.SetMusicPanning(this.playerPanning, soundProfile); this.SetMusicPitch(this.playerPitch, soundProfile); this.upcomingSoundProfile = soundProfile; @@ -351,15 +345,13 @@ public override void Update() public SoundDatabase soundDatabase = new SoundDatabase(); - private SoundDatabase onTheFlySoundDatabase = new SoundDatabase(); - private SdLibSoundProfileStateGraph stateTransition; protected SoundProfile activeSoundProfile; private SoundProfile upcomingSoundProfile; - private Single playerVolume; + public override Single Volume => Configuration.VoiceActing.Volume / 100f; private Single playerPitch; @@ -370,10 +362,4 @@ public override void Update() private Single fadeOutDuration; private Single fadeInTimeRemain; - - private SoundProfile onTheFlyLoadedSoundProfile; - - private Int32 onTheFlyLoadedFadeIn; - - private Single optionVolume = 1f; } diff --git a/Assembly-CSharp/SoundDebugRoom/SoundViewController.cs b/Assembly-CSharp/SoundDebugRoom/SoundViewController.cs index 519971f70..94e381639 100644 --- a/Assembly-CSharp/SoundDebugRoom/SoundViewController.cs +++ b/Assembly-CSharp/SoundDebugRoom/SoundViewController.cs @@ -133,7 +133,7 @@ public void SetMusicPitch(Single pitch) } else if (this.activeSound.SoundProfileType == SoundProfileType.MovieAudio) { - SoundLib.movieAudioPlayer.SetMusicPitch(pitch); + SoundLib.MovieAudioPlayer.SetMusicPitch(pitch); } } diff --git a/Memoria.Launcher/Ini/Memoria.ini b/Memoria.Launcher/Ini/Memoria.ini index 7b5eb635f..f71dbc5ea 100644 --- a/Memoria.Launcher/Ini/Memoria.ini +++ b/Memoria.Launcher/Ini/Memoria.ini @@ -15,6 +15,7 @@ Size = 24 ; PriorityToOGG (default 0) When enabled, ".ogg" audio files are used instead of the ".akb.bytes" counterpart when both exist; the AKB header is then generated again at each usage MusicVolume = 100 SoundVolume = 100 +MovieVolume = 100 PriorityToOGG = 0 [Graphics] diff --git a/Memoria.Launcher/Languages/Lang.cs b/Memoria.Launcher/Languages/Lang.cs index 542138db3..a0976103c 100644 --- a/Memoria.Launcher/Languages/Lang.cs +++ b/Memoria.Launcher/Languages/Lang.cs @@ -180,8 +180,10 @@ private static String GetSettings(string name) public static readonly string TripleTriadType0 = GetSettings(nameof(TripleTriadType0)); public static readonly string TripleTriadType1 = GetSettings(nameof(TripleTriadType1)); public static readonly string TripleTriadType2 = GetSettings(nameof(TripleTriadType2)); + public static readonly string Volume = GetSettings(nameof(Volume)); public static readonly string SoundVolume = GetSettings(nameof(SoundVolume)); public static readonly string MusicVolume = GetSettings(nameof(MusicVolume)); + public static readonly string MovieVolume = GetSettings(nameof(MovieVolume)); public static readonly string IniCheats = GetSettings(nameof(IniCheats)); public static readonly string MaxStealRate = GetSettings(nameof(MaxStealRate)); public static readonly string DisableCantConcentrate = GetSettings(nameof(DisableCantConcentrate)); diff --git a/Memoria.Launcher/Languages/en.xml b/Memoria.Launcher/Languages/en.xml index 0ec073a55..056d202ff 100644 --- a/Memoria.Launcher/Languages/en.xml +++ b/Memoria.Launcher/Languages/en.xml @@ -67,8 +67,10 @@ TripleTriadType0 = "Tetra Master" TripleTriadType1 = "Tetra Triad" TripleTriadType2 = "Triple Triad" - SoundVolume = "Sound volume" - MusicVolume = "Music volume" + Volume = "Volume:" + SoundVolume = "Sound" + MusicVolume = "Music" + MovieVolume = "Movie" IniCheats = "Cheats" MaxStealRate = " 100% steal rate" DisableCantConcentrate = " Disable 'can't concentrate'" diff --git a/Memoria.Launcher/Languages/fr.xml b/Memoria.Launcher/Languages/fr.xml index 515fa5da3..2f0edc3ce 100644 --- a/Memoria.Launcher/Languages/fr.xml +++ b/Memoria.Launcher/Languages/fr.xml @@ -67,8 +67,10 @@ TripleTriadType0 = "Tetra Master" TripleTriadType1 = "Tetra Triad" TripleTriadType2 = "Triple Triad" - SoundVolume = "Volume des sons" - MusicVolume = "Volume de la musique" + Volume = "Volume :" + SoundVolume = "Sons" + MusicVolume = "Musique" + MovieVolume = "Films" IniCheats = "Triche" MaxStealRate = " Voler ne rate jamais" DisableCantConcentrate = " Désactiver 'déconcentration'" diff --git a/Memoria.Launcher/Languages/ru.xml b/Memoria.Launcher/Languages/ru.xml index e663130dc..14240edf5 100644 --- a/Memoria.Launcher/Languages/ru.xml +++ b/Memoria.Launcher/Languages/ru.xml @@ -66,8 +66,10 @@ TripleTriadType0 = "Tetra Master" TripleTriadType1 = "Tetra Triad" TripleTriadType2 = "Triple Triad" - SoundVolume = "Громкость звука" - MusicVolume = "Громкость музыки" + Volume = "Громкость:" + SoundVolume = "Звука" + MusicVolume = "Музыки" + MovieVolume = "Фильма" IniCheats = "Читы" MaxStealRate = " 100% кража" DisableCantConcentrate = " Гарнет не теряет концентрацию" diff --git a/Memoria.Launcher/Memoria/MemoriaIniControl.cs b/Memoria.Launcher/Memoria/MemoriaIniControl.cs index 5b6b86c75..70da45492 100644 --- a/Memoria.Launcher/Memoria/MemoriaIniControl.cs +++ b/Memoria.Launcher/Memoria/MemoriaIniControl.cs @@ -139,15 +139,19 @@ public MemoriaIniControl() tripleTriadBox.FontSize = 10; tripleTriadBox.Margin = rowMargin; - UiTextBlock soundVolumeText = AddUiElement(UiTextBlockFactory.Create(Lang.Settings.SoundVolume), row++, 0, 1, 8); + UiTextBlock volumeText = AddUiElement(UiTextBlockFactory.Create(Lang.Settings.Volume), row++, 0, 1, 8); + volumeText.Foreground = Brushes.White; + volumeText.Margin = rowMargin; + + UiTextBlock soundVolumeText = AddUiElement(UiTextBlockFactory.Create(Lang.Settings.SoundVolume), row, 0, 1, 3); soundVolumeText.Foreground = Brushes.White; soundVolumeText.Margin = rowMargin; - UiTextBlock soundVolumeTextIndex = AddUiElement(UiTextBlockFactory.Create(""), row, 0, 1, 2); + UiTextBlock soundVolumeTextIndex = AddUiElement(UiTextBlockFactory.Create(""), row, 1, 1, 2); soundVolumeTextIndex.SetBinding(TextBlock.TextProperty, new Binding(nameof(SoundVolume)) { Mode = BindingMode.TwoWay }); soundVolumeTextIndex.Foreground = Brushes.White; soundVolumeTextIndex.Margin = rowMargin; - //soundVolumeTextIndex.TextAlignment = TextAlignment.Right; - Slider soundVolumeSlider = AddUiElement(UiSliderFactory.Create(0), row++, 2, 1, 6); + soundVolumeTextIndex.TextAlignment = TextAlignment.Right; + Slider soundVolumeSlider = AddUiElement(UiSliderFactory.Create(0), row++, 3, 1, 6); soundVolumeSlider.SetBinding(Slider.ValueProperty, new Binding(nameof(SoundVolume)) { Mode = BindingMode.TwoWay }); soundVolumeSlider.TickFrequency = 5; soundVolumeSlider.IsSnapToTickEnabled = true; @@ -155,14 +159,15 @@ public MemoriaIniControl() soundVolumeSlider.Maximum = 100; soundVolumeSlider.Margin = rowMargin; - UiTextBlock musicVolumeText = AddUiElement(UiTextBlockFactory.Create(Lang.Settings.MusicVolume), row++, 0, 1, 8); + UiTextBlock musicVolumeText = AddUiElement(UiTextBlockFactory.Create(Lang.Settings.MusicVolume), row, 0, 1, 3); musicVolumeText.Foreground = Brushes.White; musicVolumeText.Margin = rowMargin; - UiTextBlock musicVolumeTextIndex = AddUiElement(UiTextBlockFactory.Create(""), row, 0, 1, 2); + UiTextBlock musicVolumeTextIndex = AddUiElement(UiTextBlockFactory.Create(""), row, 1, 1, 2); musicVolumeTextIndex.SetBinding(TextBlock.TextProperty, new Binding(nameof(MusicVolume)) { Mode = BindingMode.TwoWay }); musicVolumeTextIndex.Foreground = Brushes.White; musicVolumeTextIndex.Margin = rowMargin; - Slider musicVolumeSlider = AddUiElement(UiSliderFactory.Create(0), row++, 2, 1, 6); + musicVolumeTextIndex.TextAlignment = TextAlignment.Right; + Slider musicVolumeSlider = AddUiElement(UiSliderFactory.Create(0), row++, 3, 1, 6); musicVolumeSlider.SetBinding(Slider.ValueProperty, new Binding(nameof(MusicVolume)) { Mode = BindingMode.TwoWay }); musicVolumeSlider.TickFrequency = 5; musicVolumeSlider.IsSnapToTickEnabled = true; @@ -170,6 +175,22 @@ public MemoriaIniControl() musicVolumeSlider.Maximum = 100; musicVolumeSlider.Margin = rowMargin; + UiTextBlock movieVolumeText = AddUiElement(UiTextBlockFactory.Create(Lang.Settings.MovieVolume), row, 0, 1, 6); + movieVolumeText.Foreground = Brushes.White; + movieVolumeText.Margin = rowMargin; + UiTextBlock movieVolumeTextIndex = AddUiElement(UiTextBlockFactory.Create(""), row, 1, 1, 2); + movieVolumeTextIndex.SetBinding(TextBlock.TextProperty, new Binding(nameof(MovieVolume)) { Mode = BindingMode.TwoWay }); + movieVolumeTextIndex.Foreground = Brushes.White; + movieVolumeTextIndex.Margin = rowMargin; + movieVolumeTextIndex.TextAlignment = TextAlignment.Right; + Slider movieVolumeSlider = AddUiElement(UiSliderFactory.Create(0), row++, 3, 1, 6); + movieVolumeSlider.SetBinding(Slider.ValueProperty, new Binding(nameof(MovieVolume)) { Mode = BindingMode.TwoWay }); + movieVolumeSlider.TickFrequency = 5; + movieVolumeSlider.IsSnapToTickEnabled = true; + movieVolumeSlider.Minimum = 0; + movieVolumeSlider.Maximum = 100; + movieVolumeSlider.Margin = rowMargin; + if (PsxFontInstalled) { UiTextBlock fontChoiceText = AddUiElement(UiTextBlockFactory.Create(Lang.Settings.FontChoice), row, 0, 1, 2); @@ -360,6 +381,18 @@ public Int16 MusicVolume } } } + public Int16 MovieVolume + { + get { return _movievolume; } + set + { + if (_movievolume != value) + { + _movievolume = value; + OnPropertyChanged(); + } + } + } public Int16 UseGarnetFont { get { return _usegarnetfont; } @@ -421,7 +454,7 @@ public bool IsOptionPresentInIni(String category, String option) } return false; } - private Int16 _iswidescreensupport, _battleInterface, _isskipintros, _ishidecards, _speed, _tripleTriad, _battleswirlframes, _soundvolume, _musicvolume, _usegarnetfont, _scaledbattleui; + private Int16 _iswidescreensupport, _battleInterface, _isskipintros, _ishidecards, _speed, _tripleTriad, _battleswirlframes, _soundvolume, _musicvolume, _movievolume, _usegarnetfont, _scaledbattleui; private double _scaledbattleuiscale; private String _fontChoice; private UiComboBox _fontChoiceBox; @@ -533,6 +566,15 @@ private void LoadSettings() if (!Int16.TryParse(value, out _musicvolume)) _musicvolume = 100; + value = iniFile.ReadValue("Audio", nameof(MovieVolume)); + if (String.IsNullOrEmpty(value)) + { + value = "100"; + OnPropertyChanged(nameof(MovieVolume)); + } + if (!Int16.TryParse(value, out _movievolume)) + _movievolume = 100; + Refresh(nameof(WidescreenSupport)); Refresh(nameof(BattleInterface)); Refresh(nameof(SkipIntros)); @@ -542,6 +584,7 @@ private void LoadSettings() Refresh(nameof(BattleSwirlFrames)); Refresh(nameof(SoundVolume)); Refresh(nameof(MusicVolume)); + Refresh(nameof(MovieVolume)); if (PsxFontInstalled) { value = iniFile.ReadValue("Font", "Enabled"); @@ -671,6 +714,9 @@ private async void OnPropertyChanged([CallerMemberName] String propertyName = nu case nameof(MusicVolume): iniFile.WriteValue("Audio", propertyName, " " + MusicVolume); break; + case nameof(MovieVolume): + iniFile.WriteValue("Audio", propertyName, " " + MovieVolume); + break; case nameof(UseGarnetFont): iniFile.WriteValue("Graphics", propertyName, " " + UseGarnetFont); if (UseGarnetFont == 1) diff --git a/Memoria.Patcher/Memoria.Patcher.csproj b/Memoria.Patcher/Memoria.Patcher.csproj index 7f339bb6a..5ffab1d24 100644 --- a/Memoria.Patcher/Memoria.Patcher.csproj +++ b/Memoria.Patcher/Memoria.Patcher.csproj @@ -3071,6 +3071,9 @@ + + PreserveNewest + PreserveNewest diff --git a/Memoria.Patcher/StreamingAssets/Data/Text/LocalizationPatch.txt b/Memoria.Patcher/StreamingAssets/Data/Text/LocalizationPatch.txt new file mode 100644 index 000000000..136e41316 --- /dev/null +++ b/Memoria.Patcher/StreamingAssets/Data/Text/LocalizationPatch.txt @@ -0,0 +1,8 @@ +SoundVolume,Sound Volume,Sound Volume,サウンド音量,Volumen de sonidos,Volume des sons,Lautstärke der Geräusche,Volume dei suoni +MusicVolume,Music Volume,Music Volume,音楽の音量,Volumen de la música,Volume de la musique,Musiklautstärke,Volume della musica +MovieVolume,Movie Volume,Movie Volume,動画の音量,Volumen de la película,Volume des films,Filmlautstärke,Volume di film +VoiceVolume,Voice Volume,Voice Volume,音声音量,Volumen de voz,Volume des voix,Stimmen Lautstärke,Volume della voce +ATBModeNormal,Mode: Normal,Mode: Normal,ATBモード: 通常,Modo: Normal,Mode : Normal,Modus: Normaler,Modalità: Normale +ATBModeFast,Mode: Fast,Mode: Fast,ATBモード: 高速,Modo: Rápido,Mode : Rapide,Modus: Schneller,Modalità: Veloce +ATBModeTurnBased,Mode: Turn-Based,Mode: Turn-Based,ATBモード: ターン制,Modo: Por Turnos,Mode : Par Tour,Modus: Turn,Modalità: A Turni +ATBModeDynamic,Mode: Dynamic,Mode: Dynamic,ATBモード: 動的,Modo: Dinámico,Mode: Dynamique,Modus: Dynamischer,Modalità: Dinamica \ No newline at end of file