From 3b75874ef3d80ff77d1e47283981dcdfae7756a3 Mon Sep 17 00:00:00 2001 From: akanyan Date: Sat, 4 Jan 2025 02:36:33 +0000 Subject: [PATCH] fix(SelectBGM): scoreboard bgm --- Extras/SelectBGM/MU3.Game/patch_GameBGM.cs | 4 ++-- Extras/SelectBGM/MU3.Mod/State.cs | 8 ++++++++ Extras/SelectBGM/MU3.Sequence/patch_Play.cs | 11 +++++------ .../SelectBGM/MU3.Sequence/patch_PlayMusic.cs | 19 +++++++++++++++++++ ...tch_Scene_32_PrePlayMusic_ChapterSelect.cs | 10 ++++++---- 5 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 Extras/SelectBGM/MU3.Mod/State.cs create mode 100644 Extras/SelectBGM/MU3.Sequence/patch_PlayMusic.cs diff --git a/Extras/SelectBGM/MU3.Game/patch_GameBGM.cs b/Extras/SelectBGM/MU3.Game/patch_GameBGM.cs index 708d771..45d523f 100644 --- a/Extras/SelectBGM/MU3.Game/patch_GameBGM.cs +++ b/Extras/SelectBGM/MU3.Game/patch_GameBGM.cs @@ -1,13 +1,13 @@ using MU3.Sound; +using MU3.Util; namespace MU3.Game; class patch_GameBGM: GameBGM { - public static bool WithholdPlay = false; public extern void orig_playBGM(SoundManager.ACBData acbData, int soundId, int selectorID, bool forcePlay = false); public new void playBGM(SoundManager.ACBData acbData, int soundId, int selectorID, bool forcePlay = false) { // Prevents theme music from being restarted - if(!WithholdPlay) { + if(!Singleton.instance.WithholdPlay) { orig_playBGM(acbData, soundId, selectorID, forcePlay); } } diff --git a/Extras/SelectBGM/MU3.Mod/State.cs b/Extras/SelectBGM/MU3.Mod/State.cs new file mode 100644 index 0000000..3fffb62 --- /dev/null +++ b/Extras/SelectBGM/MU3.Mod/State.cs @@ -0,0 +1,8 @@ +using MU3.Util; + +namespace MU3.Mod; + +class State: Singleton { + public int RecentBGM { get; set; } = 6; + public bool WithholdPlay { get; set; } = false; +} diff --git a/Extras/SelectBGM/MU3.Sequence/patch_Play.cs b/Extras/SelectBGM/MU3.Sequence/patch_Play.cs index 4dfa167..2c6b17e 100644 --- a/Extras/SelectBGM/MU3.Sequence/patch_Play.cs +++ b/Extras/SelectBGM/MU3.Sequence/patch_Play.cs @@ -7,8 +7,6 @@ namespace MU3.Sequence; class patch_Play: Play { private LocalSessionInfo _localSessionInfo; - - public static int RecentID = 6; private extern void orig_Enter_Login(); private void Enter_Login() { orig_Enter_Login(); @@ -21,19 +19,20 @@ class patch_Play: Play { if(index < 0 || index > 6) { index = 6; } - RecentID = index; + Singleton.instance.RecentBGM = index; Singleton.instance.gameBGM.playBGM(233, index); } private extern void orig_Enter_ChapterSelect(); private void Enter_ChapterSelect() { - patch_GameBGM.WithholdPlay = true; + var state = Singleton.instance; + state.WithholdPlay = true; orig_Enter_ChapterSelect(); - patch_GameBGM.WithholdPlay = false; + state.WithholdPlay = false; int selectorID = SingletonStateMachine.instance.getMemoryChapterData( _localSessionInfo.chapterSelection.memoryChapterId - )?.getMemoryChapterSelectorID() ?? RecentID; + )?.getMemoryChapterSelectorID() ?? state.RecentBGM; Singleton.instance.gameBGM.playBGM(233, selectorID); } } diff --git a/Extras/SelectBGM/MU3.Sequence/patch_PlayMusic.cs b/Extras/SelectBGM/MU3.Sequence/patch_PlayMusic.cs new file mode 100644 index 0000000..1d618b1 --- /dev/null +++ b/Extras/SelectBGM/MU3.Sequence/patch_PlayMusic.cs @@ -0,0 +1,19 @@ +using MU3.Data; +using MU3.Game; +using MU3.Util; + +namespace MU3.Sequence; + +class patch_PlayMusic: PlayMusic { + private SessionInfo _sessionInfo; + + private extern void orig_Enter_ShowBonusStart(); + private void Enter_ShowBonusStart() { + orig_Enter_ShowBonusStart(); + + int selectorID = SingletonStateMachine.instance.getMemoryChapterData( + _sessionInfo.chapterSelection.memoryChapterId + )?.getMemoryChapterSelectorID() ?? Singleton.instance.RecentBGM; + Singleton.instance.gameBGM.playBGM(236, selectorID); + } +} diff --git a/Extras/SelectBGM/MU3/patch_Scene_32_PrePlayMusic_ChapterSelect.cs b/Extras/SelectBGM/MU3/patch_Scene_32_PrePlayMusic_ChapterSelect.cs index d35c8bb..5360224 100644 --- a/Extras/SelectBGM/MU3/patch_Scene_32_PrePlayMusic_ChapterSelect.cs +++ b/Extras/SelectBGM/MU3/patch_Scene_32_PrePlayMusic_ChapterSelect.cs @@ -1,5 +1,4 @@ using MU3.Game; -using MU3.Sequence; using MU3.Util; using MU3.ViewData; @@ -9,13 +8,16 @@ class patch_Scene_32_PrePlayMusic_ChapterSelect: Scene_32_PrePlayMusic_ChapterSe private ChapterSelectorItemViewData _selectItemViewData; private extern void orig_onChangeElement(int index, int indexRaw); private void onChangeElement(int index, int indexRaw) { - patch_GameBGM.WithholdPlay = true; + var state = Singleton.instance; + + // Dumb hack + state.WithholdPlay = true; orig_onChangeElement(index, indexRaw); - patch_GameBGM.WithholdPlay = false; + state.WithholdPlay = false; int selectorID = ( _selectItemViewData.memoryChapterViewData?.memoryChapterData - )?.getMemoryChapterSelectorID() ?? patch_Play.RecentID; + )?.getMemoryChapterSelectorID() ?? state.RecentBGM; Singleton.instance.gameBGM.playBGM(233, selectorID); } }