From 5bd9b5ae70f46b34ac8fca7ec996ac3916e33512 Mon Sep 17 00:00:00 2001 From: akanyan Date: Thu, 27 Jun 2024 08:15:42 +0900 Subject: [PATCH] feat: rework NaiveRating, improve InfiniteGP --- InfiniteGP/MU3.User/patch_Scene_25_Login.cs | 16 +++++++ NaiveRating/MU3.Data/patch_GameData.cs | 15 +++++++ NaiveRating/MU3.User/patch_UserManager.cs | 16 +++++++ NaiveRating/MU3.User/patch_UserUtil.cs | 15 +++++++ .../NaiveRating.cs} | 44 ++++++++++--------- NaiveRating/MU3/patch_ANM_SWH_Profile.cs | 21 +++++++++ .../MU3/patch_Scene_37_Result_Score.cs | 27 ++++++++++++ README.md | 8 ++-- 8 files changed, 136 insertions(+), 26 deletions(-) create mode 100644 InfiniteGP/MU3.User/patch_Scene_25_Login.cs create mode 100644 NaiveRating/MU3.Data/patch_GameData.cs create mode 100644 NaiveRating/MU3.User/patch_UserManager.cs create mode 100644 NaiveRating/MU3.User/patch_UserUtil.cs rename NaiveRating/{MU3.User/patch_UserRating.cs => MU3/NaiveRating.cs} (50%) create mode 100644 NaiveRating/MU3/patch_ANM_SWH_Profile.cs create mode 100644 NaiveRating/MU3/patch_Scene_37_Result_Score.cs diff --git a/InfiniteGP/MU3.User/patch_Scene_25_Login.cs b/InfiniteGP/MU3.User/patch_Scene_25_Login.cs new file mode 100644 index 0000000..9b66b8e --- /dev/null +++ b/InfiniteGP/MU3.User/patch_Scene_25_Login.cs @@ -0,0 +1,16 @@ + +#pragma warning disable CS0649 + +using MU3.Util; + +namespace MU3; + +public class patch_Scene_25_Login : Scene_25_Login { + private enum State { + Login = 2 + } + private Mode mode_; + private void PurchaseGP_Init() { + mode_.set(State.Login); + } +} \ No newline at end of file diff --git a/NaiveRating/MU3.Data/patch_GameData.cs b/NaiveRating/MU3.Data/patch_GameData.cs new file mode 100644 index 0000000..7bad8b0 --- /dev/null +++ b/NaiveRating/MU3.Data/patch_GameData.cs @@ -0,0 +1,15 @@ +#pragma warning disable CS0626 +#pragma warning disable CS0649 +#pragma warning disable IDE0051 +#pragma warning disable IDE1006 + +using MU3.DB; + +namespace MU3.Data; + +public class patch_GameData: GameData { + public extern static RatingColorID orig_getRatingColorIDFromRating100(int rating100); + public static new RatingColorID getRatingColorIDFromRating100(int rating100) { + return orig_getRatingColorIDFromRating100(NaiveRating.Get()); + } +} \ No newline at end of file diff --git a/NaiveRating/MU3.User/patch_UserManager.cs b/NaiveRating/MU3.User/patch_UserManager.cs new file mode 100644 index 0000000..43fa544 --- /dev/null +++ b/NaiveRating/MU3.User/patch_UserManager.cs @@ -0,0 +1,16 @@ +#pragma warning disable CS0626 +#pragma warning disable CS0649 +#pragma warning disable IDE0051 +#pragma warning disable IDE1006 + +using MU3.Game; + +namespace MU3.User; + +public class patch_UserManager: UserManager { + public extern void orig_updateUserRating(SessionInfo sessionInfo, SessionResult result); + public new void updateUserRating(SessionInfo sessionInfo, SessionResult result) { + NaiveRating.PrevRating = NaiveRating.Get(); + orig_updateUserRating(sessionInfo, result); + } +} \ No newline at end of file diff --git a/NaiveRating/MU3.User/patch_UserUtil.cs b/NaiveRating/MU3.User/patch_UserUtil.cs new file mode 100644 index 0000000..4b08ab5 --- /dev/null +++ b/NaiveRating/MU3.User/patch_UserUtil.cs @@ -0,0 +1,15 @@ +#pragma warning disable CS0626 +#pragma warning disable CS0649 +#pragma warning disable IDE0051 +#pragma warning disable IDE1006 + +using MonoMod; + +namespace MU3.User; + +[MonoModPatch("global::MU3.User.UserUtil")] +public static class patch_UserUtil { + public static float toRatingFloat(int rating) { + return NaiveRating.Get() * 0.01f + 1E-05f; + } +} \ No newline at end of file diff --git a/NaiveRating/MU3.User/patch_UserRating.cs b/NaiveRating/MU3/NaiveRating.cs similarity index 50% rename from NaiveRating/MU3.User/patch_UserRating.cs rename to NaiveRating/MU3/NaiveRating.cs index f5914b2..94afeaf 100644 --- a/NaiveRating/MU3.User/patch_UserRating.cs +++ b/NaiveRating/MU3/NaiveRating.cs @@ -1,39 +1,41 @@ -#pragma warning disable CS0626 +#pragma warning disable CS0626 #pragma warning disable CS0649 #pragma warning disable IDE0051 #pragma warning disable IDE1006 -using MU3.Data; -using MU3.DataStudio; -using MU3.Util; using System.Collections.Generic; using System.Linq; +using MU3.Data; +using MU3.DataStudio; +using MU3.User; +using MU3.Util; -namespace MU3.User; +namespace MU3; -public class patch_UserRating: UserRating { - private int _rating100; - private UserManager usMgr => Singleton.instance; +public static class NaiveRating { + public static int PrevRating { get; set; } - // Adaptation of calcBest() without bullshit - // The original lists stay intact because the game expects them to be filled - private RatingList calcSane() { + // Adapted from MU3.User.UserRating.calcBest() + private static RatingList calcSane() { RatingList ratingList = new(); + var usMgr = Singleton.instance; var musicDict = usMgr.userMusic; foreach(KeyValuePair item in musicDict) { - MU3.Data.MusicData musicData = SingletonStateMachine.instance.getMusicData(item.Key); + var musicData = SingletonStateMachine + .instance.getMusicData(item.Key); + if(musicData == null || item.Key == 1 || musicData.isBonusTrack) { continue; } for(int i = 0; i < 5; i++) { - FumenDifficulty fumenDifficulty = (FumenDifficulty)i; - UserFumen userFumen = usMgr.getUserFumen(item.Key, fumenDifficulty, create: false); + var fumenDifficulty = (FumenDifficulty)i; + var userFumen = usMgr.getUserFumen(item.Key, fumenDifficulty, create: false); if(userFumen == null) { continue; } - Rating rating = new Rating(musicData.id, fumenDifficulty, userFumen.TechScoreMax); + Rating rating = new(musicData.id, fumenDifficulty, userFumen.TechScoreMax); if(rating.level100 == 0) { continue; } @@ -42,15 +44,15 @@ public class patch_UserRating: UserRating { } ratingList.Sort(); - return ratingList; } - - private void calcRate() { - _rating100 = 0; + public static int Get() { + int res = 0; foreach(Rating best in calcSane().Take(45)) { - _rating100 += best.rate100; + res += best.rate100; } - _rating100 /= 45; + return res > 0 + ? res / 45 + : Singleton.instance.Rating; } } \ No newline at end of file diff --git a/NaiveRating/MU3/patch_ANM_SWH_Profile.cs b/NaiveRating/MU3/patch_ANM_SWH_Profile.cs new file mode 100644 index 0000000..e69327f --- /dev/null +++ b/NaiveRating/MU3/patch_ANM_SWH_Profile.cs @@ -0,0 +1,21 @@ +#pragma warning disable CS0626 + +using MU3.User; +using MU3.Util; + +namespace MU3; + +public class patch_ANM_SWH_Profile : ANM_SWH_Profile { + public extern void orig_setUpLogin(); + + // Fixes login display + public new void setUpLogin() { + UserManager instance = Singleton.instance; + var prev = instance.userPreview; + var temp = prev; + temp.dispRating = 0; + instance.userPreview = temp; + orig_setUpLogin(); + instance.userPreview = prev; + } +} \ No newline at end of file diff --git a/NaiveRating/MU3/patch_Scene_37_Result_Score.cs b/NaiveRating/MU3/patch_Scene_37_Result_Score.cs new file mode 100644 index 0000000..9dd2286 --- /dev/null +++ b/NaiveRating/MU3/patch_Scene_37_Result_Score.cs @@ -0,0 +1,27 @@ +#pragma warning disable CS0626 +#pragma warning disable CS0649 +#pragma warning disable IDE0051 +#pragma warning disable IDE1006 + +using MU3.Sequence; + +namespace MU3; + +public class patch_Scene_37_Result_Score: Scene_37_Result_Score { + private PlayInfo playInfo_; + private extern void orig_TechRating_Init(); + + // Fixes rating+/rating- display + private void TechRating_Init() { + var origRating = playInfo_.sessionResult.rating_; + var origPrevRating = playInfo_.sessionResult.prevRating_; + + playInfo_.sessionResult.rating_ = NaiveRating.Get(); + playInfo_.sessionResult.prevRating_ = NaiveRating.PrevRating; + + orig_TechRating_Init(); + + playInfo_.sessionResult.rating_ = origRating; + playInfo_.sessionResult.prevRating_ = origPrevRating; + } +} \ No newline at end of file diff --git a/README.md b/README.md index 614830b..dd2ea2d 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,11 @@ Self-explanatory. Saves you time. ### NaiveRating -Replaces the in-game rating algorithm (OldBest30+NewBest15+Recent10) with Best45. This change is client-side and immediate. +Replaces the in-game rating algorithm (OldBest30+NewBest15+Recent10) with Best45. Client-side and purely cosmetic. -⚠️ ACHTUNG ⚠️ I said it's client-side, but the server acknowledges it once you upload a result. If you're on a remote network, check whether it cares too much about stupid ephemeral numbers. Cozynet and Missless do, and may ban you for using this mod. +### SkipNotice ⚠️ -### SkipNotice - -Skips the safety warning screen, notices, login bonuses, etc. +Skips the safety warning screen, event notices, ⚠️login bonuses, event rewards⚠️. ### SkipPreMusicRitual