From 946402fa82d4547c17bd24549bf4f723ae67d52e Mon Sep 17 00:00:00 2001 From: akanyan Date: Sun, 21 Jul 2024 02:24:09 +0900 Subject: [PATCH] feat: implement PlatinumTiming * Also fix icons in InfiniteGP. --- ...h_UIMoneyExchange.cs => patch_UICredit.cs} | 12 ++-- Mu3Mods.sln | 6 ++ PlatinumTiming/MU3.Battle/patch_Counters.cs | 19 ++++++ PlatinumTiming/MU3.Battle/patch_GameEngine.cs | 13 ++++ .../MU3.Game/patch_SessionResult.cs | 5 ++ PlatinumTiming/MU3/patch_UIResultTechScore.cs | 63 +++++++++++++++++++ PlatinumTiming/PlatinumTiming.csproj | 13 ++++ 7 files changed, 124 insertions(+), 7 deletions(-) rename InfiniteGP/MU3/{patch_UIMoneyExchange.cs => patch_UICredit.cs} (74%) create mode 100644 PlatinumTiming/MU3.Battle/patch_Counters.cs create mode 100644 PlatinumTiming/MU3.Battle/patch_GameEngine.cs create mode 100644 PlatinumTiming/MU3.Game/patch_SessionResult.cs create mode 100644 PlatinumTiming/MU3/patch_UIResultTechScore.cs create mode 100644 PlatinumTiming/PlatinumTiming.csproj diff --git a/InfiniteGP/MU3/patch_UIMoneyExchange.cs b/InfiniteGP/MU3/patch_UICredit.cs similarity index 74% rename from InfiniteGP/MU3/patch_UIMoneyExchange.cs rename to InfiniteGP/MU3/patch_UICredit.cs index fb99561..f656fef 100644 --- a/InfiniteGP/MU3/patch_UIMoneyExchange.cs +++ b/InfiniteGP/MU3/patch_UICredit.cs @@ -13,6 +13,7 @@ class patch_UICredit: UICredit { private MU3UICounter gpPlus_; private MU3UICounter gpMinus_; private MU3UIImageChanger netIcon_; + private MU3UIImageChanger groupIcon_; private void onUpdateGP(int value) { /* nop */ } public extern void orig_initialize(); @@ -30,13 +31,10 @@ class patch_UICredit: UICredit { gpPlus_.transform.localScale = new Vector3(0, 0, 0); gpMinus_.transform.localScale = new Vector3(0, 0, 0); - var tf = (RectTransform)netIcon_.transform; - tf.localPosition = new Vector3(35, netIcon_.transform.localPosition.y, netIcon_.transform.localPosition.z); - for(int i = 0; i < 3; ++i) { - tf.anchorMin = new Vector2(0f, 0.5f); - tf.anchorMax = new Vector2(1f, 0.5f); - tf = (RectTransform)tf.parent; - } + netIcon_.transform.localPosition = new Vector3(-514, netIcon_.transform.localPosition.y, netIcon_.transform.localPosition.z); netIcon_.image.rectTransform.pivot = new Vector2(0f, 0.5f); + + groupIcon_.transform.localPosition = new Vector3(-476, groupIcon_.transform.localPosition.y, groupIcon_.transform.localPosition.z); + groupIcon_.image.rectTransform.pivot = new Vector2(0f, 0.5f); } } \ No newline at end of file diff --git a/Mu3Mods.sln b/Mu3Mods.sln index d2924d7..1e8bb06 100644 --- a/Mu3Mods.sln +++ b/Mu3Mods.sln @@ -37,6 +37,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnlockGameEvents", "UnlockG EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnlockMemoryChapters", "UnlockMemoryChapters\UnlockMemoryChapters.csproj", "{3A217A12-6082-491B-89F6-C1D13AD69A19}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlatinumTiming", "PlatinumTiming\PlatinumTiming.csproj", "{099AD6AF-181A-4745-88C4-1D0466BECCB1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -111,6 +113,10 @@ Global {3A217A12-6082-491B-89F6-C1D13AD69A19}.Debug|x64.Build.0 = Debug|x64 {3A217A12-6082-491B-89F6-C1D13AD69A19}.Release|x64.ActiveCfg = Release|x64 {3A217A12-6082-491B-89F6-C1D13AD69A19}.Release|x64.Build.0 = Release|x64 + {099AD6AF-181A-4745-88C4-1D0466BECCB1}.Debug|x64.ActiveCfg = Debug|x64 + {099AD6AF-181A-4745-88C4-1D0466BECCB1}.Debug|x64.Build.0 = Debug|x64 + {099AD6AF-181A-4745-88C4-1D0466BECCB1}.Release|x64.ActiveCfg = Release|x64 + {099AD6AF-181A-4745-88C4-1D0466BECCB1}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PlatinumTiming/MU3.Battle/patch_Counters.cs b/PlatinumTiming/MU3.Battle/patch_Counters.cs new file mode 100644 index 0000000..d12e743 --- /dev/null +++ b/PlatinumTiming/MU3.Battle/patch_Counters.cs @@ -0,0 +1,19 @@ +using MU3.Notes; + +namespace MU3.Battle; +class patch_Counters: Counters { + public int PlatinumFastCount { get; private set; } + public int PlatinumLateCount { get; private set; } + public extern void orig_addPlatinumScore(Judge judge, Timing timing); + public new void addPlatinumScore(Judge judge, Timing timing) { + orig_addPlatinumScore(judge, timing); + + if(judge == Judge.Perfect) { + if(timing == Timing.Fast) { + PlatinumFastCount += 1; + } else if(timing == Timing.Late) { + PlatinumLateCount += 1; + } + } + } +} diff --git a/PlatinumTiming/MU3.Battle/patch_GameEngine.cs b/PlatinumTiming/MU3.Battle/patch_GameEngine.cs new file mode 100644 index 0000000..688585d --- /dev/null +++ b/PlatinumTiming/MU3.Battle/patch_GameEngine.cs @@ -0,0 +1,13 @@ +using MU3.Game; + +namespace MU3.Battle; +class patch_GameEngine: GameEngine { + private patch_Counters _counters; + public extern void orig_calcCurrentBattleResult(SessionResult sessionResult); + + public void calcCurrentBattleResult(patch_SessionResult sessionResult) { + orig_calcCurrentBattleResult(sessionResult); + sessionResult.PlatinumFastCount = _counters.PlatinumFastCount; + sessionResult.PlatinumLateCount = _counters.PlatinumLateCount; + } +} diff --git a/PlatinumTiming/MU3.Game/patch_SessionResult.cs b/PlatinumTiming/MU3.Game/patch_SessionResult.cs new file mode 100644 index 0000000..13c03ce --- /dev/null +++ b/PlatinumTiming/MU3.Game/patch_SessionResult.cs @@ -0,0 +1,5 @@ +namespace MU3.Game; +class patch_SessionResult: SessionResult { + public int PlatinumFastCount { get; set; } + public int PlatinumLateCount { get; set; } +} diff --git a/PlatinumTiming/MU3/patch_UIResultTechScore.cs b/PlatinumTiming/MU3/patch_UIResultTechScore.cs new file mode 100644 index 0000000..0797458 --- /dev/null +++ b/PlatinumTiming/MU3/patch_UIResultTechScore.cs @@ -0,0 +1,63 @@ +using MU3.CustomUI; +using MU3.Game; +using MU3.Sequence; +using MU3.Util; +using System.Collections; +using UnityEngine; + +namespace MU3; +class patch_UIResultTechScore: UIResultTechScore { + private MU3UICounter counterFast_; + private MU3UICounter counterLate_; + private Animator animator_; + private static readonly int State_TechnicalScore_Loop; + private void cloneCounter(MU3UICounter counter, Color color, int value) { + var otherValue = counter.CounterAsInt; + var offset = 12; + while(otherValue > 9) { + otherValue /= 10; + offset += 8; + } + + var cpy = Instantiate(counter); + cpy.color = color; + cpy.gameObject.transform.SetParent(counter.transform.parent, false); + var pos = counter.gameObject.transform.localPosition; + cpy.gameObject.transform.localPosition = new Vector3(pos.x - offset, pos.y, pos.z); + cpy.gameObject.SetActive(true); + cpy.CounterAsInt = value; + } + + private void drawCounters() { + float posXf = counterFast_.gameObject.transform.localPosition.x + 5.0f; + float posXl = counterLate_.gameObject.transform.localPosition.x + 5.0f; + float posY = counterLate_.gameObject.transform.localPosition.y; + + counterFast_.gameObject.transform.localPosition = new Vector3(posXf, posY, 0.0f); + counterLate_.gameObject.transform.localPosition = new Vector3(posXl, posY, 0.0f); + + var sessionResult = (patch_SessionResult)Singleton.instance.sessionResult; + + cloneCounter( + counterFast_, + new Color(0.630f, 0.766f, 0.829f, 1.000f), + sessionResult.PlatinumFastCount + ); + + cloneCounter( + counterLate_, + new Color(0.809f, 0.396f, 0.365f, 1.000f), + sessionResult.PlatinumLateCount + ); + } + + private extern IEnumerator orig_showPlatinumScore(PlayInfo playInfo); + + private IEnumerator showPlatinumScore(PlayInfo playInfo) { + StartCoroutine(orig_showPlatinumScore(playInfo)); + while(!AnimatorState.stateEquals(animator_, State_TechnicalScore_Loop)) { + yield return null; + } + drawCounters(); + } +} diff --git a/PlatinumTiming/PlatinumTiming.csproj b/PlatinumTiming/PlatinumTiming.csproj new file mode 100644 index 0000000..5710054 --- /dev/null +++ b/PlatinumTiming/PlatinumTiming.csproj @@ -0,0 +1,13 @@ + + + Assembly-CSharp.PlatinumTiming.mm + Platinum early/late + + + + + + + + + \ No newline at end of file