forked from akanyan/mu3-mods
feat: implement SelectBGM
This commit is contained in:
parent
920d2386d5
commit
07ee892b43
@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net35</TargetFramework>
|
||||
<Company>7EVENDAYS⇔HOLIDAYS</Company>
|
||||
<Version>2.1.0</Version>
|
||||
<Version>2.2.0</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Platforms>x64</Platforms>
|
||||
|
@ -41,6 +41,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlatinumTiming", "PlatinumT
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AttractVideoPlayer", "AttractVideoPlayer\AttractVideoPlayer.csproj", "{6889330F-2E7E-4778-ADFF-70AF036F1BD5}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SelectBGM", "SelectBGM\SelectBGM.csproj", "{07C01DA1-7ABF-4759-A1C2-9DCD04298E85}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@ -123,6 +125,10 @@ Global
|
||||
{6889330F-2E7E-4778-ADFF-70AF036F1BD5}.Debug|x64.Build.0 = Debug|x64
|
||||
{6889330F-2E7E-4778-ADFF-70AF036F1BD5}.Release|x64.ActiveCfg = Release|x64
|
||||
{6889330F-2E7E-4778-ADFF-70AF036F1BD5}.Release|x64.Build.0 = Release|x64
|
||||
{07C01DA1-7ABF-4759-A1C2-9DCD04298E85}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{07C01DA1-7ABF-4759-A1C2-9DCD04298E85}.Debug|x64.Build.0 = Debug|x64
|
||||
{07C01DA1-7ABF-4759-A1C2-9DCD04298E85}.Release|x64.ActiveCfg = Release|x64
|
||||
{07C01DA1-7ABF-4759-A1C2-9DCD04298E85}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
14
SelectBGM/MU3.Game/patch_GameBGM.cs
Normal file
14
SelectBGM/MU3.Game/patch_GameBGM.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using MU3.Sound;
|
||||
|
||||
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) {
|
||||
orig_playBGM(acbData, soundId, selectorID, forcePlay);
|
||||
}
|
||||
}
|
||||
}
|
38
SelectBGM/MU3.Sequence/patch_Play.cs
Normal file
38
SelectBGM/MU3.Sequence/patch_Play.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using MU3.Data;
|
||||
using MU3.Game;
|
||||
using MU3.Util;
|
||||
using System;
|
||||
|
||||
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();
|
||||
using IniFile iniFile = new("mu3.ini");
|
||||
var index = iniFile.getIntValue("Extra", "BGM", 6);
|
||||
if(index == 0) {
|
||||
var rnd = new Random();
|
||||
index = rnd.Next(1, 7);
|
||||
}
|
||||
if(index < 0 || index > 6) {
|
||||
index = 6;
|
||||
}
|
||||
RecentID = index;
|
||||
Singleton<GameSound>.instance.gameBGM.playBGM(233, index);
|
||||
}
|
||||
|
||||
private extern void orig_Enter_ChapterSelect();
|
||||
private void Enter_ChapterSelect() {
|
||||
patch_GameBGM.WithholdPlay = true;
|
||||
orig_Enter_ChapterSelect();
|
||||
patch_GameBGM.WithholdPlay = false;
|
||||
|
||||
int selectorID = SingletonStateMachine<DataManager, DataManager.EState>.instance.getMemoryChapterData(
|
||||
_localSessionInfo.chapterSelection.memoryChapterId
|
||||
)?.getMemoryChapterSelectorID() ?? RecentID;
|
||||
Singleton<GameSound>.instance.gameBGM.playBGM(233, selectorID);
|
||||
}
|
||||
}
|
22
SelectBGM/MU3/patch_Scene_32_PrePlayMusic_ChapterSelect.cs
Normal file
22
SelectBGM/MU3/patch_Scene_32_PrePlayMusic_ChapterSelect.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using MU3.Game;
|
||||
using MU3.Sequence;
|
||||
using MU3.Util;
|
||||
using MU3.ViewData;
|
||||
|
||||
namespace MU3;
|
||||
class patch_Scene_32_PrePlayMusic_ChapterSelect: Scene_32_PrePlayMusic_ChapterSelect {
|
||||
private ChapterSelectorItemViewData _selectItemViewData;
|
||||
private extern void orig_onChangeElement(int index, int indexRaw);
|
||||
private void onChangeElement(int index, int indexRaw) {
|
||||
patch_GameBGM.WithholdPlay = true;
|
||||
orig_onChangeElement(index, indexRaw);
|
||||
patch_GameBGM.WithholdPlay = false;
|
||||
|
||||
int selectorID = (
|
||||
(_selectItemViewData.memoryChapterViewData == null)
|
||||
? null
|
||||
: _selectItemViewData.memoryChapterViewData.memoryChapterData
|
||||
)?.getMemoryChapterSelectorID() ?? patch_Play.RecentID;
|
||||
Singleton<GameSound>.instance.gameBGM.playBGM(233, selectorID);
|
||||
}
|
||||
}
|
7
SelectBGM/SelectBGM.csproj
Normal file
7
SelectBGM/SelectBGM.csproj
Normal file
@ -0,0 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Assembly-CSharp.SelectBGM.mm</AssemblyName>
|
||||
<Description>Select main menu BGM</Description>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\Mu3Mods.csproj" />
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user