1
0
forked from akanyan/mu3-mods

fix(SelectBGM): scoreboard bgm

This commit is contained in:
2025-01-04 02:36:33 +00:00
parent 1f01b460ba
commit 3b75874ef3
5 changed files with 40 additions and 12 deletions

View File

@ -1,13 +1,13 @@
using MU3.Sound; using MU3.Sound;
using MU3.Util;
namespace MU3.Game; namespace MU3.Game;
class patch_GameBGM: GameBGM { 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 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) { public new void playBGM(SoundManager.ACBData acbData, int soundId, int selectorID, bool forcePlay = false) {
// Prevents theme music from being restarted // Prevents theme music from being restarted
if(!WithholdPlay) { if(!Singleton<Mod.State>.instance.WithholdPlay) {
orig_playBGM(acbData, soundId, selectorID, forcePlay); orig_playBGM(acbData, soundId, selectorID, forcePlay);
} }
} }

View File

@ -0,0 +1,8 @@
using MU3.Util;
namespace MU3.Mod;
class State: Singleton<State> {
public int RecentBGM { get; set; } = 6;
public bool WithholdPlay { get; set; } = false;
}

View File

@ -7,8 +7,6 @@ namespace MU3.Sequence;
class patch_Play: Play { class patch_Play: Play {
private LocalSessionInfo _localSessionInfo; private LocalSessionInfo _localSessionInfo;
public static int RecentID = 6;
private extern void orig_Enter_Login(); private extern void orig_Enter_Login();
private void Enter_Login() { private void Enter_Login() {
orig_Enter_Login(); orig_Enter_Login();
@ -21,19 +19,20 @@ class patch_Play: Play {
if(index < 0 || index > 6) { if(index < 0 || index > 6) {
index = 6; index = 6;
} }
RecentID = index; Singleton<Mod.State>.instance.RecentBGM = index;
Singleton<GameSound>.instance.gameBGM.playBGM(233, index); Singleton<GameSound>.instance.gameBGM.playBGM(233, index);
} }
private extern void orig_Enter_ChapterSelect(); private extern void orig_Enter_ChapterSelect();
private void Enter_ChapterSelect() { private void Enter_ChapterSelect() {
patch_GameBGM.WithholdPlay = true; var state = Singleton<Mod.State>.instance;
state.WithholdPlay = true;
orig_Enter_ChapterSelect(); orig_Enter_ChapterSelect();
patch_GameBGM.WithholdPlay = false; state.WithholdPlay = false;
int selectorID = SingletonStateMachine<DataManager, DataManager.EState>.instance.getMemoryChapterData( int selectorID = SingletonStateMachine<DataManager, DataManager.EState>.instance.getMemoryChapterData(
_localSessionInfo.chapterSelection.memoryChapterId _localSessionInfo.chapterSelection.memoryChapterId
)?.getMemoryChapterSelectorID() ?? RecentID; )?.getMemoryChapterSelectorID() ?? state.RecentBGM;
Singleton<GameSound>.instance.gameBGM.playBGM(233, selectorID); Singleton<GameSound>.instance.gameBGM.playBGM(233, selectorID);
} }
} }

View File

@ -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<DataManager, DataManager.EState>.instance.getMemoryChapterData(
_sessionInfo.chapterSelection.memoryChapterId
)?.getMemoryChapterSelectorID() ?? Singleton<Mod.State>.instance.RecentBGM;
Singleton<GameSound>.instance.gameBGM.playBGM(236, selectorID);
}
}

View File

@ -1,5 +1,4 @@
using MU3.Game; using MU3.Game;
using MU3.Sequence;
using MU3.Util; using MU3.Util;
using MU3.ViewData; using MU3.ViewData;
@ -9,13 +8,16 @@ class patch_Scene_32_PrePlayMusic_ChapterSelect: Scene_32_PrePlayMusic_ChapterSe
private ChapterSelectorItemViewData _selectItemViewData; private ChapterSelectorItemViewData _selectItemViewData;
private extern void orig_onChangeElement(int index, int indexRaw); private extern void orig_onChangeElement(int index, int indexRaw);
private void onChangeElement(int index, int indexRaw) { private void onChangeElement(int index, int indexRaw) {
patch_GameBGM.WithholdPlay = true; var state = Singleton<Mod.State>.instance;
// Dumb hack
state.WithholdPlay = true;
orig_onChangeElement(index, indexRaw); orig_onChangeElement(index, indexRaw);
patch_GameBGM.WithholdPlay = false; state.WithholdPlay = false;
int selectorID = ( int selectorID = (
_selectItemViewData.memoryChapterViewData?.memoryChapterData _selectItemViewData.memoryChapterViewData?.memoryChapterData
)?.getMemoryChapterSelectorID() ?? patch_Play.RecentID; )?.getMemoryChapterSelectorID() ?? state.RecentBGM;
Singleton<GameSound>.instance.gameBGM.playBGM(233, selectorID); Singleton<GameSound>.instance.gameBGM.playBGM(233, selectorID);
} }
} }