forked from akanyan/mu3-mods
feat: reachable rating
This commit is contained in:
@ -21,7 +21,7 @@ class patch_OperationManager: OperationManager {
|
||||
try {
|
||||
File.WriteAllText(_fileName, MovieIndex.ToString());
|
||||
} catch(Exception ex) {
|
||||
Debug.Log(ex);
|
||||
Debug.Log("Unable to write attract selection: " + ex);
|
||||
}
|
||||
}
|
||||
get {
|
||||
|
@ -1,11 +1,13 @@
|
||||
namespace MU3.CustomUI;
|
||||
using MU3.Mod;
|
||||
|
||||
namespace MU3.CustomUI;
|
||||
|
||||
class patch_MU3UICounter: MU3UICounter {
|
||||
protected extern void orig_calcNumFiguresFloat(double value);
|
||||
protected new void calcNumFiguresFloat(double value) {
|
||||
orig_calcNumFiguresFloat(value);
|
||||
if(isDispSuffix) {
|
||||
pushFigureFront(10);
|
||||
pushFigureFront(CustomRating.GetSuffix());
|
||||
}
|
||||
}
|
||||
public bool isDispSuffix { get; set; }
|
||||
|
@ -6,8 +6,8 @@ namespace MU3.Data;
|
||||
class patch_GameData: GameData {
|
||||
public extern static RatingColorID orig_getRatingColorIDFromRating100(int rating100);
|
||||
public static new RatingColorID getRatingColorIDFromRating100(int rating100) {
|
||||
if(NaiveRating.IsEnabled()) {
|
||||
return orig_getRatingColorIDFromRating100(NaiveRating.Get());
|
||||
if(CustomRating.IsEnabled()) {
|
||||
return orig_getRatingColorIDFromRating100(CustomRating.Get());
|
||||
} else {
|
||||
return orig_getRatingColorIDFromRating100(rating100);
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
using MU3.Battle;
|
||||
using MU3.Mod;
|
||||
using MU3.Mod;
|
||||
|
||||
namespace MU3.Game;
|
||||
|
||||
class patch_SessionResult: SessionResult {
|
||||
public int prevNaiveRating;
|
||||
public int prevCustomRating;
|
||||
|
||||
public extern void orig_calcTotalRewards();
|
||||
public new void calcTotalRewards() {
|
||||
orig_calcTotalRewards();
|
||||
prevNaiveRating = NaiveRating.Get();
|
||||
prevCustomRating = CustomRating.Get();
|
||||
}
|
||||
}
|
||||
|
105
Extras/MoreProfileOptions/MU3.Mod/CustomRating.cs
Normal file
105
Extras/MoreProfileOptions/MU3.Mod/CustomRating.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using MU3.Data;
|
||||
using MU3.DataStudio;
|
||||
using MU3.User;
|
||||
using MU3.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace MU3.Mod;
|
||||
|
||||
public static class CustomRating {
|
||||
// Adapted from MU3.User.UserRating.calcBest()
|
||||
private static RatingList calcNaive() {
|
||||
RatingList ratingList = [];
|
||||
|
||||
var usMgr = Singleton<UserManager>.instance;
|
||||
var musicDict = usMgr.userMusic;
|
||||
|
||||
foreach(KeyValuePair<int, UserMusic> item in musicDict) {
|
||||
var musicData = SingletonStateMachine<DataManager, DataManager.EState>
|
||||
.instance.getMusicData(item.Key);
|
||||
|
||||
if(musicData == null || item.Key == 1 || musicData.isBonusTrack) {
|
||||
continue;
|
||||
}
|
||||
for(int i = 0; i < 5; i++) {
|
||||
var fumenDifficulty = (FumenDifficulty)i;
|
||||
var userFumen = usMgr.getUserFumen(item.Key, fumenDifficulty, create: false);
|
||||
if(userFumen == null) {
|
||||
continue;
|
||||
}
|
||||
Rating rating = new(musicData.id, fumenDifficulty, userFumen.TechScoreMax);
|
||||
if(rating.level100 == 0) {
|
||||
continue;
|
||||
}
|
||||
ratingList.Add(rating);
|
||||
}
|
||||
}
|
||||
|
||||
ratingList.Sort();
|
||||
return ratingList;
|
||||
}
|
||||
public static int GetNaive() {
|
||||
int res = 0;
|
||||
foreach(Rating best in calcNaive().Take(45)) {
|
||||
res += best.rate100;
|
||||
}
|
||||
return res / 45;
|
||||
}
|
||||
|
||||
public static int GetReachable() {
|
||||
FieldInfo piOld = typeof(UserRating).GetField("_bestOldList", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
FieldInfo piNew = typeof(UserRating).GetField("_bestNewList", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
var ur = Singleton<UserManager>.instance.userRating;
|
||||
|
||||
int res = 0;
|
||||
int top = 0;
|
||||
foreach(Rating best in ((RatingList)piOld.GetValue(ur))) {
|
||||
res += best.rate100;
|
||||
if(best.musicID < 7000) {
|
||||
top = Math.Max(top, best.rate100);
|
||||
}
|
||||
}
|
||||
foreach(Rating best in ((RatingList)piNew.GetValue(ur))) {
|
||||
res += best.rate100;
|
||||
if(best.musicID < 7000) {
|
||||
top = Math.Max(top, best.rate100);
|
||||
}
|
||||
}
|
||||
|
||||
res += top * 10;
|
||||
|
||||
return res / 55;
|
||||
}
|
||||
|
||||
public static bool IsNaiveEnabled() {
|
||||
return Singleton<UserManager>.instance.userOption.customSet.Rating == (UserOption.eRating)patch_UserOption.eRating.Naive;
|
||||
}
|
||||
public static bool IsReachableEnabled() {
|
||||
return Singleton<UserManager>.instance.userOption.customSet.Rating == (UserOption.eRating)patch_UserOption.eRating.Reachable;
|
||||
}
|
||||
public static bool IsEnabled() {
|
||||
return IsNaiveEnabled() || IsReachableEnabled();
|
||||
}
|
||||
|
||||
public static int Get() {
|
||||
if(IsNaiveEnabled()) {
|
||||
return GetNaive();
|
||||
} else if(IsReachableEnabled()) {
|
||||
return GetReachable();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte GetSuffix() {
|
||||
if(IsNaiveEnabled()) {
|
||||
return MU3CounterBase.FigurePlus;
|
||||
} else {
|
||||
return MU3CounterBase.FigureMinus;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
using MU3.Data;
|
||||
using MU3.DataStudio;
|
||||
using MU3.User;
|
||||
using MU3.Util;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MU3.Mod;
|
||||
|
||||
public static class NaiveRating {
|
||||
// Adapted from MU3.User.UserRating.calcBest()
|
||||
private static RatingList calcSane() {
|
||||
RatingList ratingList = [];
|
||||
|
||||
var usMgr = Singleton<UserManager>.instance;
|
||||
var musicDict = usMgr.userMusic;
|
||||
|
||||
foreach(KeyValuePair<int, UserMusic> item in musicDict) {
|
||||
var musicData = SingletonStateMachine<DataManager, DataManager.EState>
|
||||
.instance.getMusicData(item.Key);
|
||||
|
||||
if(musicData == null || item.Key == 1 || musicData.isBonusTrack) {
|
||||
continue;
|
||||
}
|
||||
for(int i = 0; i < 5; i++) {
|
||||
var fumenDifficulty = (FumenDifficulty)i;
|
||||
var userFumen = usMgr.getUserFumen(item.Key, fumenDifficulty, create: false);
|
||||
if(userFumen == null) {
|
||||
continue;
|
||||
}
|
||||
Rating rating = new(musicData.id, fumenDifficulty, userFumen.TechScoreMax);
|
||||
if(rating.level100 == 0) {
|
||||
continue;
|
||||
}
|
||||
ratingList.Add(rating);
|
||||
}
|
||||
}
|
||||
|
||||
ratingList.Sort();
|
||||
return ratingList;
|
||||
}
|
||||
public static int Get() {
|
||||
int res = 0;
|
||||
foreach(Rating best in calcSane().Take(45)) {
|
||||
res += best.rate100;
|
||||
}
|
||||
return res / 45;
|
||||
}
|
||||
public static bool IsEnabled() {
|
||||
return Singleton<UserManager>.instance.userOption.customSet.Rating == (UserOption.eRating)patch_UserOption.eRating.Naive;
|
||||
}
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
using MU3.Battle;
|
||||
using MU3.DataStudio;
|
||||
using MU3.DB;
|
||||
using MU3.User;
|
||||
using MU3.Util;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MU3.Notes;
|
||||
|
||||
@ -30,7 +27,6 @@ class patch_NotesManager: NotesManager {
|
||||
UserManager userManager = Singleton<UserManager>.instance;
|
||||
_userFumen = userManager.getUserFumen(_sessionInfo.musicData.id, _sessionInfo.musicLevel, create: false);
|
||||
_previousPb = _userFumen?.TechScoreMax ?? 0;
|
||||
UnityEngine.Debug.Log(_previousPb + "HELLO THIS ONLY EXECUTES ONCE");
|
||||
}
|
||||
threshold = _previousPb;
|
||||
break;
|
||||
|
@ -7,7 +7,7 @@ class patch_ANM_CMN_UserDeta_01: ANM_CMN_UserDeta_01 {
|
||||
private patch_MU3UICounter rating;
|
||||
public extern void orig_setUserDetail();
|
||||
public new void setUserDetail() {
|
||||
rating.isDispSuffix = NaiveRating.IsEnabled();
|
||||
rating.isDispSuffix = CustomRating.IsEnabled();
|
||||
orig_setUserDetail();
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ class patch_UserOption: UserOption {
|
||||
Default = 1,
|
||||
ON = 1,
|
||||
Naive = 2,
|
||||
MAX = 2
|
||||
Reachable = 3,
|
||||
MAX = 3
|
||||
}
|
||||
|
||||
[MonoModEnumReplace]
|
||||
@ -22,7 +23,7 @@ class patch_UserOption: UserOption {
|
||||
PB = 5,
|
||||
FB = 6,
|
||||
ZERO = 7,
|
||||
MAX = 8,
|
||||
MAX = 7,
|
||||
Default = 0
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,8 @@ namespace MU3.User;
|
||||
public static class patch_UserUtil {
|
||||
public extern static float orig_toRatingFloat(int rating);
|
||||
public static float toRatingFloat(int rating) {
|
||||
if(NaiveRating.IsEnabled()) {
|
||||
return orig_toRatingFloat(NaiveRating.Get());
|
||||
if(CustomRating.IsEnabled()) {
|
||||
return orig_toRatingFloat(CustomRating.Get());
|
||||
} else {
|
||||
return orig_toRatingFloat(rating);
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
using MU3.User;
|
||||
using MU3.Util;
|
||||
using MU3.Mod;
|
||||
|
||||
namespace MU3;
|
||||
|
||||
class patch_ANM_SWH_Profile: ANM_SWH_Profile {
|
||||
public extern void orig_setUpLogin();
|
||||
|
||||
// Fixes login display
|
||||
public new void setUpLogin() {
|
||||
UserManager instance = Singleton<UserManager>.instance;
|
||||
var up = instance.userPreview;
|
||||
if(NaiveRating.IsEnabled()) {
|
||||
up.dispRating = 0;
|
||||
instance.userPreview = up;
|
||||
orig_setUpLogin();
|
||||
up.dispRating = 2;
|
||||
instance.userPreview = up;
|
||||
} else {
|
||||
orig_setUpLogin();
|
||||
}
|
||||
}
|
||||
}
|
@ -20,6 +20,9 @@ class patch_OptionMiniSummaryController: OptionMiniSummaryController {
|
||||
case 2:
|
||||
comp.text = "TYPE-B";
|
||||
break;
|
||||
case 3:
|
||||
comp.text = "TYPE-C";
|
||||
break;
|
||||
}
|
||||
} else if(id == UserOption.OptionName.Abort) {
|
||||
switch(value) {
|
||||
|
@ -16,7 +16,7 @@ class patch_OptionSelecterController: OptionSelecterController {
|
||||
public extern void orig_init(UserOption.OptionName id);
|
||||
public new void init(UserOption.OptionName id) {
|
||||
orig_init(id);
|
||||
cpFuncArray[33].max = 2;
|
||||
cpFuncArray[33].max = 3;
|
||||
cpFuncArray[4].max = 7;
|
||||
|
||||
if(id == UserOption.OptionName.Rating) {
|
||||
@ -28,12 +28,15 @@ class patch_OptionSelecterController: OptionSelecterController {
|
||||
|
||||
var spritesFi = typeof(MU3UIImageChanger).GetField("_sprites", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
var tex = ((Sprite[])spritesFi.GetValue(changer))[0].texture;
|
||||
var newSprites = new Sprite[3];
|
||||
spritesFi.SetValue(changer, newSprites);
|
||||
spritesFi.SetValue(changer, new Sprite[4]);
|
||||
|
||||
changer.setSprite(0, Sprite.Create(tex, new Rect(1552.0f, 366.0f, 160.0f, 65.0f), new Vector2(80.0f, 0.0f)));
|
||||
changer.setSprite(1, Sprite.Create(tex, new Rect(1221.0f, 1488.0f, 160.0f, 70.0f), new Vector2(80.0f, 35.0f)));
|
||||
changer.setSprite(2, Sprite.Create(tex, new Rect(1221.0f, 1410.0f, 160.0f, 70.0f), new Vector2(80.0f, 35.0f)));
|
||||
changer.setSprite(2, Sprite.Create(tex, new Rect(1223.0f, 1410.0f, 160.0f, 70.0f), new Vector2(80.0f, 35.0f)));
|
||||
changer.setSprite(3, Sprite.Create(tex, new Rect(1508.0f, 1346.0f, 160.0f, 70.0f), new Vector2(80.0f, 35.0f)));
|
||||
//changer.setSprite(4, Sprite.Create(tex, new Rect(1389.0f, 1424.0f, 160.0f, 70.0f), new Vector2(80.0f, 35.0f)));
|
||||
//changer.setSprite(5, Sprite.Create(tex, new Rect(941.0f, 1502.0f, 160.0f, 70.0f), new Vector2(80.0f, 35.0f)));
|
||||
//changer.setSprite(6, Sprite.Create(tex, new Rect(797.0f, 1604.0f, 160.0f, 70.0f), new Vector2(80.0f, 35.0f)));
|
||||
|
||||
setInputCursor((int)Singleton<UserManager>.instance.userOption.customSet.Rating);
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
using MonoMod;
|
||||
using MU3.CustomUI;
|
||||
using MU3.Game;
|
||||
using MU3.Mod;
|
||||
using MU3.Sequence;
|
||||
using MU3.User;
|
||||
using MU3.Mod;
|
||||
using MU3.Game;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MU3;
|
||||
@ -21,22 +21,21 @@ class patch_UIResultBattlePoint: UIResultBattlePoint {
|
||||
|
||||
public extern void orig_initTechRating(PlayInfo playInfo);
|
||||
public new void initTechRating(PlayInfo playInfo) {
|
||||
counterScore_.isDispSuffix = NaiveRating.IsEnabled();
|
||||
if(!NaiveRating.IsEnabled()) {
|
||||
counterScore_.isDispSuffix = CustomRating.IsEnabled();
|
||||
if(!CustomRating.IsEnabled()) {
|
||||
orig_initTechRating(playInfo);
|
||||
return;
|
||||
}
|
||||
int prevRating = ((patch_SessionResult)playInfo.sessionResult).prevNaiveRating;
|
||||
int rating1 = NaiveRating.Get();
|
||||
int prevRating = ((patch_SessionResult)playInfo.sessionResult).prevCustomRating;
|
||||
int rating1 = CustomRating.Get();
|
||||
|
||||
UnityEngine.Debug.Log(prevRating + " " + rating1);
|
||||
if((bool)hideScore_) {
|
||||
hideScore_.SetActive(false);
|
||||
}
|
||||
counterScore_.Counter = (double)UserUtil.toRatingFloat(rating1);
|
||||
int ratingPatternNo = UserUtil.toRatingPatternNo(rating1);
|
||||
counterScore_.SpriteIndex = ratingPatternNo;
|
||||
imageHeader_.patternNumber = (float)ratingPatternNo;
|
||||
imageHeader_.patternNumber = ratingPatternNo;
|
||||
int rating2 = rating1 - prevRating;
|
||||
if(rating2 == 0) {
|
||||
disable(counterScorePlus_);
|
||||
|
@ -1,6 +1,4 @@
|
||||
using MonoMod;
|
||||
|
||||
namespace MU3.Game;
|
||||
namespace MU3.Game;
|
||||
|
||||
// This is in SessionResult because BattleResult is a struct
|
||||
class patch_SessionResult: SessionResult {
|
||||
|
Reference in New Issue
Block a user