diff --git a/AquaMai.Mods/GameSettings/JudgeAdjust.cs b/AquaMai.Mods/GameSettings/JudgeAdjust.cs index c69c6760..4d425977 100644 --- a/AquaMai.Mods/GameSettings/JudgeAdjust.cs +++ b/AquaMai.Mods/GameSettings/JudgeAdjust.cs @@ -2,7 +2,6 @@ using AquaMai.Config.Attributes; using HarmonyLib; using Manager.UserDatas; -using MelonLoader; namespace AquaMai.Mods.GameSettings; diff --git a/AquaMai.Mods/UX/DontRuinMyAccount.cs b/AquaMai.Mods/UX/DontRuinMyAccount.cs index e5004b92..d1497e96 100644 --- a/AquaMai.Mods/UX/DontRuinMyAccount.cs +++ b/AquaMai.Mods/UX/DontRuinMyAccount.cs @@ -1,11 +1,15 @@ using System; using System.Reflection; using AquaMai.Config.Attributes; +using AquaMai.Core.Attributes; +using AquaMai.Core.Helpers; +using DB; using HarmonyLib; using MAI2.Util; using Manager; using Manager.UserDatas; using MelonLoader; +using Monitor; using Process; using UnityEngine; @@ -18,8 +22,10 @@ namespace AquaMai.Mods.UX; // 收编自 https://github.com/Starrah/DontRuinMyAccount/blob/master/Core.cs public class DontRuinMyAccount { + [ConfigEntry(zh: "AutoPlay 激活后显示提示", en: "Show notice when AutoPlay is activated")] + public static readonly bool showNotice = true; private static uint currentTrackNumber => GameManager.MusicTrackNumber; - private static bool ignoreScore; + public static bool ignoreScore; private static UserScore oldScore; [HarmonyPatch(typeof(GameProcess), "OnUpdate")] @@ -33,6 +39,14 @@ public class DontRuinMyAccount } } + [HarmonyPatch(typeof(GameProcess), "OnStart")] + [HarmonyPostfix] + [EnableIf(nameof(showNotice))] + public static void OnStart(GameMonitor[] ____monitors) + { + ____monitors[0].gameObject.AddComponent(); + } + [HarmonyPrefix] [HarmonyPatch(typeof(UserData), "UpdateScore")] public static bool BeforeUpdateScore(int musicid, int difficulty, uint achive, uint romVersion) @@ -78,10 +92,10 @@ public class DontRuinMyAccount // current music playlog var score = Singleton.Instance.GetGameScore(0, (int)currentTrackNumber - 1); // score.Achivement = 0; // Private setter, so reflection is essential - typeof(GameScoreList).GetProperty("Achivement", BindingFlags.Public | BindingFlags.Instance)?.GetSetMethod(true)?.Invoke(score, new object[] - { - new Decimal(0) - }); + typeof(GameScoreList).GetProperty("Achivement", BindingFlags.Public | BindingFlags.Instance)?.GetSetMethod(true)?.Invoke(score, [0m]); + typeof(GameScoreList).GetProperty("ComboType", BindingFlags.Public | BindingFlags.Instance)?.GetSetMethod(true)?.Invoke(score, [PlayComboflagID.None]); + typeof(GameScoreList).GetProperty("NowComboType", BindingFlags.Public | BindingFlags.Instance)?.GetSetMethod(true)?.Invoke(score, [PlayComboflagID.None]); + score.SyncType = PlaySyncflagID.None; // user's all scores var userData = Singleton.Instance.GetUserData(0); var userScoreDict = userData.ScoreDic[difficulty]; @@ -96,4 +110,23 @@ public class DontRuinMyAccount MelonLogger.Msg("[DontRuinMyAccount] Reset scores: trackNo {0}, music {1}:{2}, set current music playlog to 0.0000%, and userScoreDict[{1}:{2}] to {3}", currentTrackNumber, musicid, difficulty, oldScore?.achivement); } + + private class NoticeUI : MonoBehaviour + { + public void OnGUI() + { + if (!ignoreScore) return; + var y = Screen.height * .075f; + var width = GuiSizes.FontSize * 20f; + var x = GuiSizes.PlayerCenter + GuiSizes.PlayerWidth / 2f - width; + var rect = new Rect(x, y, width, GuiSizes.LabelHeight * 2.5f); + + var labelStyle = GUI.skin.GetStyle("label"); + labelStyle.fontSize = (int)(GuiSizes.FontSize * 1.2); + labelStyle.alignment = TextAnchor.MiddleCenter; + + GUI.Box(rect, ""); + GUI.Label(rect, "AutoPlay"); + } + } } \ No newline at end of file