forked from akanyan/mu3-mods
fix(SelectBGM): scoreboard bgm
This commit is contained in:
@ -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<Mod.State>.instance.WithholdPlay) {
|
||||
orig_playBGM(acbData, soundId, selectorID, forcePlay);
|
||||
}
|
||||
}
|
||||
|
8
Extras/SelectBGM/MU3.Mod/State.cs
Normal file
8
Extras/SelectBGM/MU3.Mod/State.cs
Normal 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;
|
||||
}
|
@ -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<Mod.State>.instance.RecentBGM = index;
|
||||
Singleton<GameSound>.instance.gameBGM.playBGM(233, index);
|
||||
}
|
||||
|
||||
private extern void orig_Enter_ChapterSelect();
|
||||
private void Enter_ChapterSelect() {
|
||||
patch_GameBGM.WithholdPlay = true;
|
||||
var state = Singleton<Mod.State>.instance;
|
||||
state.WithholdPlay = true;
|
||||
orig_Enter_ChapterSelect();
|
||||
patch_GameBGM.WithholdPlay = false;
|
||||
state.WithholdPlay = false;
|
||||
|
||||
int selectorID = SingletonStateMachine<DataManager, DataManager.EState>.instance.getMemoryChapterData(
|
||||
_localSessionInfo.chapterSelection.memoryChapterId
|
||||
)?.getMemoryChapterSelectorID() ?? RecentID;
|
||||
)?.getMemoryChapterSelectorID() ?? state.RecentBGM;
|
||||
Singleton<GameSound>.instance.gameBGM.playBGM(233, selectorID);
|
||||
}
|
||||
}
|
||||
|
19
Extras/SelectBGM/MU3.Sequence/patch_PlayMusic.cs
Normal file
19
Extras/SelectBGM/MU3.Sequence/patch_PlayMusic.cs
Normal 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);
|
||||
}
|
||||
}
|
@ -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<Mod.State>.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<GameSound>.instance.gameBGM.playBGM(233, selectorID);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user