Skip to content

Commit b1bb4af

Browse files
committed
[O] DontRuinMyAccount
1 parent eef8a67 commit b1bb4af

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

AquaMai.Mods/GameSettings/JudgeAdjust.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using AquaMai.Config.Attributes;
33
using HarmonyLib;
44
using Manager.UserDatas;
5-
using MelonLoader;
65

76
namespace AquaMai.Mods.GameSettings;
87

AquaMai.Mods/UX/DontRuinMyAccount.cs

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
using System;
22
using System.Reflection;
33
using AquaMai.Config.Attributes;
4+
using AquaMai.Core.Attributes;
5+
using AquaMai.Core.Helpers;
6+
using DB;
47
using HarmonyLib;
58
using MAI2.Util;
69
using Manager;
710
using Manager.UserDatas;
811
using MelonLoader;
12+
using Monitor;
913
using Process;
1014
using UnityEngine;
1115

@@ -18,8 +22,10 @@ namespace AquaMai.Mods.UX;
1822
// 收编自 https://github.com/Starrah/DontRuinMyAccount/blob/master/Core.cs
1923
public class DontRuinMyAccount
2024
{
25+
[ConfigEntry(zh: "AutoPlay 激活后显示提示", en: "Show notice when AutoPlay is activated")]
26+
public static readonly bool showNotice = true;
2127
private static uint currentTrackNumber => GameManager.MusicTrackNumber;
22-
private static bool ignoreScore;
28+
public static bool ignoreScore;
2329
private static UserScore oldScore;
2430

2531
[HarmonyPatch(typeof(GameProcess), "OnUpdate")]
@@ -33,6 +39,14 @@ public static void OnUpdate()
3339
}
3440
}
3541

42+
[HarmonyPatch(typeof(GameProcess), "OnStart")]
43+
[HarmonyPostfix]
44+
[EnableIf(nameof(showNotice))]
45+
public static void OnStart(GameMonitor[] ____monitors)
46+
{
47+
____monitors[0].gameObject.AddComponent<NoticeUI>();
48+
}
49+
3650
[HarmonyPrefix]
3751
[HarmonyPatch(typeof(UserData), "UpdateScore")]
3852
public static bool BeforeUpdateScore(int musicid, int difficulty, uint achive, uint romVersion)
@@ -78,10 +92,10 @@ public static void AfterResultProcessStart()
7892
// current music playlog
7993
var score = Singleton<GamePlayManager>.Instance.GetGameScore(0, (int)currentTrackNumber - 1);
8094
// score.Achivement = 0; // Private setter, so reflection is essential
81-
typeof(GameScoreList).GetProperty("Achivement", BindingFlags.Public | BindingFlags.Instance)?.GetSetMethod(true)?.Invoke(score, new object[]
82-
{
83-
new Decimal(0)
84-
});
95+
typeof(GameScoreList).GetProperty("Achivement", BindingFlags.Public | BindingFlags.Instance)?.GetSetMethod(true)?.Invoke(score, [0m]);
96+
typeof(GameScoreList).GetProperty("ComboType", BindingFlags.Public | BindingFlags.Instance)?.GetSetMethod(true)?.Invoke(score, [PlayComboflagID.None]);
97+
typeof(GameScoreList).GetProperty("NowComboType", BindingFlags.Public | BindingFlags.Instance)?.GetSetMethod(true)?.Invoke(score, [PlayComboflagID.None]);
98+
score.SyncType = PlaySyncflagID.None;
8599
// user's all scores
86100
var userData = Singleton<UserDataManager>.Instance.GetUserData(0);
87101
var userScoreDict = userData.ScoreDic[difficulty];
@@ -96,4 +110,23 @@ public static void AfterResultProcessStart()
96110
MelonLogger.Msg("[DontRuinMyAccount] Reset scores: trackNo {0}, music {1}:{2}, set current music playlog to 0.0000%, and userScoreDict[{1}:{2}] to {3}", currentTrackNumber,
97111
musicid, difficulty, oldScore?.achivement);
98112
}
113+
114+
private class NoticeUI : MonoBehaviour
115+
{
116+
public void OnGUI()
117+
{
118+
if (!ignoreScore) return;
119+
var y = Screen.height * .075f;
120+
var width = GuiSizes.FontSize * 20f;
121+
var x = GuiSizes.PlayerCenter + GuiSizes.PlayerWidth / 2f - width;
122+
var rect = new Rect(x, y, width, GuiSizes.LabelHeight * 2.5f);
123+
124+
var labelStyle = GUI.skin.GetStyle("label");
125+
labelStyle.fontSize = (int)(GuiSizes.FontSize * 1.2);
126+
labelStyle.alignment = TextAnchor.MiddleCenter;
127+
128+
GUI.Box(rect, "");
129+
GUI.Label(rect, "AutoPlay");
130+
}
131+
}
99132
}

0 commit comments

Comments
 (0)