refactor: clean up Execute_Select

This commit is contained in:
あかニャン 2024-08-24 11:41:13 +00:00
parent 80efe4d918
commit 50e4b53ed9
4 changed files with 28 additions and 206 deletions

View File

@ -1,7 +1,7 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<AssemblyName>Assembly-CSharp.InfiniteStory.mm</AssemblyName> <AssemblyName>Assembly-CSharp.InfiniteStory.mm</AssemblyName>
<Description>Allows to watch infinite story per session</Description> <Description>Allows watching the story endlessly</Description>
</PropertyGroup> </PropertyGroup>
<Import Project="..\Mu3Mods.csproj" /> <Import Project="..\Mu3Mods.csproj" />
</Project> </Project>

View File

@ -5,8 +5,7 @@ namespace MU3.Sequence;
class patch_Play: Play { class patch_Play: Play {
private extern void orig_Enter_PlayScenario(); private extern void orig_Enter_PlayScenario();
private void Enter_PlayScenario() private void Enter_PlayScenario() {
{
orig_Enter_PlayScenario(); orig_Enter_PlayScenario();
Singleton<UserManager>.instance.userLocal.isStoryWatched = false; Singleton<UserManager>.instance.userLocal.isStoryWatched = false;
} }

View File

@ -1,215 +1,33 @@
using MU3.Data; using MonoMod;
using MU3.DataStudio;
using MU3.DB;
using MU3.Game;
using MU3.Sequence;
using MU3.Util;
using MU3.ViewData; using MU3.ViewData;
using UnityEngine;
namespace MU3; namespace MU3;
class patch_Scene_32_PrePlayMusic_MusicSelect: Scene_32_PrePlayMusic_MusicSelect { class patch_Scene_32_PrePlayMusic_MusicSelect: Scene_32_PrePlayMusic_MusicSelect {
private bool _playVoice;
private UIDialogBase _dialogBase;
private ChapterSelectionViewData _chapterSelectionViewData;
private Scene_32_PrePlayMusic _sceneCommonObject;
private bool _isCanceled;
private MusicSelectViewDataList _selectList; private MusicSelectViewDataList _selectList;
private FumenDifficulty _selectorDifficulty;
private SystemUI.Request _deactivateTimer = SystemUI.Request.Default;
private float timeCountLogOutButtonPressed;
private float _timer;
[SerializeField]
private UIMusicSelector _selector; private UIMusicSelector _selector;
private extern void orig_executeDifficulty(); private UIDialogBase _dialogBase;
private void executeDifficulty()
{
orig_executeDifficulty();
}
private extern bool orig_updateMatchingTag();
private bool updateMatchingTag()
{
return orig_updateMatchingTag();
}
private extern void orig_updateSecretMusic();
private void updateSecretMusic()
{
orig_updateSecretMusic();
}
private extern void orig_disableInput();
private void disableInput()
{
orig_disableInput();
}
private extern void orig_onFinishPurchaseItem(ChapterItemViewData itemViewData, int status);
private void onFinishPurchaseItem(ChapterItemViewData itemViewData, int status)
{
orig_onFinishPurchaseItem(itemViewData, status);
}
private extern void orig_onFinishPlayScenario(int status, bool flag);
private void onFinishPlayScenario(int status, bool flag)
{
orig_onFinishPlayScenario(status, flag);
}
private extern void orig_onFinishUnlockMusic(MusicViewData musicViewData, int status);
private void onFinishUnlockMusic(MusicViewData musicViewData, int status)
{
orig_onFinishUnlockMusic(musicViewData, status);
}
private extern void orig_updateSystemUIPanel();
private void updateSystemUIPanel()
{
orig_updateSystemUIPanel();
}
[MonoModIgnore]
private extern void enableInput();
[MonoModIgnore]
private extern void onFinishPlayScenario(int status, bool flag);
[MonoModIgnore]
private extern void updateSystemUIPanel();
private extern void orig_Execute_Select();
private void Execute_Select() { private void Execute_Select() {
// Walk around the warning dialog
if (_dialogBase != null) if(_dialogBase == null && !_selector.isDecided && !_selector.isCanceled && (_selector.isPressed || _selector.isPressedDisabledElement)) {
{
if (_selector.isTimeOut)
{
_dialogBase.forceCancel();
}
return;
}
executeDifficulty();
if (_chapterSelectionViewData.category != ChapterMajorCategoryID.MedalShop)
{
_sceneCommonObject.localMatchingCtrl.addNewRecruitNotice();
}
updateMatchingTag();
updateSecretMusic();
memoryQRReader.update();
UIInput.UILayeredInput input = _selector.getInput();
bool flag = false;
if (_selector.isDecided)
{
flag = true;
_isCanceled = false;
}
else if (_selector.isCanceled)
{
flag = true;
_isCanceled = true;
}
else if (_selector.isPressed || _selector.isPressedDisabledElement)
{
MusicSelectViewData musicViewData = _selectList.getMusicViewData(_selector.selectIndex); MusicSelectViewData musicViewData = _selectList.getMusicViewData(_selector.selectIndex);
if (musicViewData != null) if(musicViewData != null && musicViewData.kind == MusicSelectViewData.Kind.Scenario) {
{ if(musicViewData.scenarioViewData.ngReason == ScenarioViewData.PlayNGReason.None) {
if (musicViewData.kind == MusicSelectViewData.Kind.Music) onFinishPlayScenario(0, false);
{
if (musicViewData.musicViewData.isForMatchingMusic)
{
if (_sceneCommonObject.localMatchingCtrl.startJoin(musicViewData.initOrder, _selectorDifficulty))
{
if (SingletonMonoBehaviour<SystemUI>.instance.systemTimer != null)
{
SingletonMonoBehaviour<SystemUI>.instance.systemTimer.deactivate(ref _deactivateTimer);
} }
setNextState(EState.MatchingEntryWait);
disableInput();
}
}
else if (musicViewData.musicViewData.isSphereLock)
{
if (!musicViewData.musicViewData.isShortOfSphere)
{
Singleton<GameSound>.instance.avatarVoice.play(107);
_dialogBase = UIUnlockMusicDialog.create(musicViewData.musicViewData, _selectorDifficulty, _chapterSelectionViewData, onFinishUnlockMusic);
disableInput();
}
else
{
Singleton<GameSound>.instance.avatarVoice.play(109);
}
}
}
else if (musicViewData.kind == MusicSelectViewData.Kind.Item)
{
ChapterItemViewData itemViewData = musicViewData.itemViewData;
switch (itemViewData.ngReason)
{
case ChapterItemViewData.PurchaseNgReason.ShortOfJewel:
if (itemViewData.jewelWallet != null && itemViewData.jewelWallet.CurrencyType == CurrencyType.Medal)
{
Singleton<GameSound>.instance.avatarVoice.play(1405);
}
else
{
Singleton<GameSound>.instance.avatarVoice.play(109);
}
break;
case ChapterItemViewData.PurchaseNgReason.None:
{
ItemType itemType = itemViewData.itemType;
if (itemType == ItemType.Card)
{
Singleton<GameSound>.instance.avatarVoice.play(108);
}
else
{
Singleton<GameSound>.instance.avatarVoice.play(965);
}
_dialogBase = UIPurchaseItemDialog.create(itemViewData, _chapterSelectionViewData, onFinishPurchaseItem);
disableInput();
break;
}
}
}
else if (musicViewData.kind == MusicSelectViewData.Kind.Scenario)
{
ScenarioViewData scenarioViewData = musicViewData.scenarioViewData;
ScenarioViewData.PlayNGReason ngReason = scenarioViewData.ngReason;
if (ngReason == ScenarioViewData.PlayNGReason.None)
{
Singleton<GameSound>.instance.avatarVoice.play(1396);
onFinishPlayScenario(0, flag: false);
}
}
}
}
else if (input != null && _selector.isInputActive && !_selector.isDecidedOrWait && !_selector.isCanceledOrWait)
{
if (input.getStateOn(UIInput.Key.MenuLeft))
{
timeCountLogOutButtonPressed += UnityEngine.Time.deltaTime;
if ((double)timeCountLogOutButtonPressed > 1.5)
{
timeCountLogOutButtonPressed = 0f;
disableInput();
setNextState(EState.Logout);
}
}
else if (input.getTriggerOn(UIInput.Key.SkipRight, enableRepeat: true))
{
_selector.moveGenre(1);
}
else if (input.getTriggerOn(UIInput.Key.SkipLeft, enableRepeat: true))
{
_selector.moveGenre(-1);
}
else if (input.getTriggerOn(UIInput.Key.MenuRight))
{
MusicSelectViewData selectedMusicSelectViewData = _selector.selectedMusicSelectViewData;
if (selectedMusicSelectViewData != null && selectedMusicSelectViewData.majorCategory == MusicMajorCategoryID.MyList && !selectedMusicSelectViewData.isRandom)
{
disableInput();
setNextState(EState.Sort);
}
}
if (!input.getStateOn(UIInput.Key.MenuLeft) && timeCountLogOutButtonPressed != 0f)
{
timeCountLogOutButtonPressed = 0f;
}
}
if (flag)
{
_timer = 0f;
setNextState(EState.WaitFinish);
} }
updateSystemUIPanel(); updateSystemUIPanel();
} else {
orig_Execute_Select();
}
} }
} }

View File

@ -1,5 +1,4 @@
 Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123 VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
@ -43,6 +42,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AttractVideoPlayer", "Attra
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SelectBGM", "SelectBGM\SelectBGM.csproj", "{07C01DA1-7ABF-4759-A1C2-9DCD04298E85}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SelectBGM", "SelectBGM\SelectBGM.csproj", "{07C01DA1-7ABF-4759-A1C2-9DCD04298E85}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InfiniteStory", "InfiniteStory\InfiniteStory.csproj", "{939914E5-8D9A-4696-9957-AA6C6480FE94}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
@ -129,6 +130,10 @@ Global
{07C01DA1-7ABF-4759-A1C2-9DCD04298E85}.Debug|x64.Build.0 = 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.ActiveCfg = Release|x64
{07C01DA1-7ABF-4759-A1C2-9DCD04298E85}.Release|x64.Build.0 = Release|x64 {07C01DA1-7ABF-4759-A1C2-9DCD04298E85}.Release|x64.Build.0 = Release|x64
{939914E5-8D9A-4696-9957-AA6C6480FE94}.Debug|x64.ActiveCfg = Debug|x64
{939914E5-8D9A-4696-9957-AA6C6480FE94}.Debug|x64.Build.0 = Debug|x64
{939914E5-8D9A-4696-9957-AA6C6480FE94}.Release|x64.ActiveCfg = Release|x64
{939914E5-8D9A-4696-9957-AA6C6480FE94}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE