forked from akanyan/mu3-mods
feat(NaiveRating): make it togglable
This commit is contained in:
parent
af15a4410a
commit
b54b8676c1
@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net35</TargetFramework>
|
||||
<Company>7EVENDAYS⇔HOLIDAYS</Company>
|
||||
<Version>1.8.1</Version>
|
||||
<Version>1.9.0</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Platforms>x64</Platforms>
|
||||
|
@ -5,6 +5,10 @@ namespace MU3.Data;
|
||||
class patch_GameData: GameData {
|
||||
public extern static RatingColorID orig_getRatingColorIDFromRating100(int rating100);
|
||||
public static new RatingColorID getRatingColorIDFromRating100(int rating100) {
|
||||
return orig_getRatingColorIDFromRating100(NaiveRating.Get());
|
||||
if(NaiveRating.IsEnabled()) {
|
||||
return orig_getRatingColorIDFromRating100(NaiveRating.Get());
|
||||
} else {
|
||||
return orig_getRatingColorIDFromRating100(rating100);
|
||||
}
|
||||
}
|
||||
}
|
10
NaiveRating/MU3.User/patch_Scene_32_PrePlayMusic_Confirm.cs
Normal file
10
NaiveRating/MU3.User/patch_Scene_32_PrePlayMusic_Confirm.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace MU3;
|
||||
|
||||
// It doesn't have to be PrePlayMusic_Confirm, but it prev rating has to be stored at some point
|
||||
class patch_Scene_32_PrePlayMusic_Confirm: Scene_32_PrePlayMusic_Confirm {
|
||||
private extern void orig_Enter_Select();
|
||||
private void Enter_Select() {
|
||||
NaiveRating.SavePrev();
|
||||
orig_Enter_Select();
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
using MU3.Game;
|
||||
|
||||
namespace MU3.User;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -4,7 +4,12 @@ namespace MU3.User;
|
||||
|
||||
[MonoModPatch("global::MU3.User.UserUtil")]
|
||||
public static class patch_UserUtil {
|
||||
public extern static float orig_toRatingFloat(int rating);
|
||||
public static float toRatingFloat(int rating) {
|
||||
return NaiveRating.Get() * 0.01f + 1E-05f;
|
||||
if(NaiveRating.IsEnabled()) {
|
||||
return orig_toRatingFloat(NaiveRating.Get());
|
||||
} else {
|
||||
return orig_toRatingFloat(rating);
|
||||
}
|
||||
}
|
||||
}
|
11
NaiveRating/MU3/patch_ANM_CMN_User.cs
Normal file
11
NaiveRating/MU3/patch_ANM_CMN_User.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using MU3.CustomUI;
|
||||
|
||||
namespace MU3.SceneObject;
|
||||
class patch_ANM_CMN_UserDeta_01: ANM_CMN_UserDeta_01 {
|
||||
private MU3UICounter rating;
|
||||
public extern void orig_setUserDetail();
|
||||
public new void setUserDetail() {
|
||||
((patch_MU3UICounter)rating).isDispSuffix = NaiveRating.IsEnabled();
|
||||
orig_setUserDetail();
|
||||
}
|
||||
}
|
@ -9,11 +9,15 @@ class patch_ANM_SWH_Profile: ANM_SWH_Profile {
|
||||
// Fixes login display
|
||||
public new void setUpLogin() {
|
||||
UserManager instance = Singleton<UserManager>.instance;
|
||||
var prev = instance.userPreview;
|
||||
var temp = prev;
|
||||
temp.dispRating = 0;
|
||||
instance.userPreview = temp;
|
||||
orig_setUpLogin();
|
||||
instance.userPreview = prev;
|
||||
var up = instance.userPreview;
|
||||
if(NaiveRating.IsEnabled()) {
|
||||
up.dispRating = 0;
|
||||
instance.userPreview = up;
|
||||
orig_setUpLogin();
|
||||
up.dispRating = 2;
|
||||
instance.userPreview = up;
|
||||
} else {
|
||||
orig_setUpLogin();
|
||||
}
|
||||
}
|
||||
}
|
18
NaiveRating/MU3/patch_MU3UICounter.cs
Normal file
18
NaiveRating/MU3/patch_MU3UICounter.cs
Normal file
@ -0,0 +1,18 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
public bool isDispSuffix { get; set; }
|
||||
protected void pushFigureFront(byte c) {
|
||||
for(int i = numFigures_; i > 0; --i) {
|
||||
figures_[i] = figures_[i - 1];
|
||||
}
|
||||
figures_[0] = c;
|
||||
numFigures_ += 1;
|
||||
}
|
||||
}
|
23
NaiveRating/MU3/patch_OptionSelecterController.cs
Normal file
23
NaiveRating/MU3/patch_OptionSelecterController.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using MU3.CustomUI;
|
||||
using MU3.User;
|
||||
using MU3.Util;
|
||||
|
||||
namespace MU3;
|
||||
class patch_OptionSelecterController: OptionSelecterController {
|
||||
private chengeParamFuncArray[] cpFuncArray = new chengeParamFuncArray[35];
|
||||
public extern void orig_init(UserOption.OptionName id);
|
||||
private extern void orig_chengeParamOther(int currentParam);
|
||||
public new void init(UserOption.OptionName id) {
|
||||
orig_init(id);
|
||||
cpFuncArray[33].max = 2;
|
||||
}
|
||||
private void chengeParamOther(int currentParam) {
|
||||
if(myOptionId == UserOption.OptionName.Rating) {
|
||||
transform.Find("NUL_SWH_Option_00/NUL_Select/PAT_OnOff").GetComponent<MU3UIImageChanger>().patternNumber = currentParam != 0 ? 0f : 1f;
|
||||
Singleton<UserManager>.instance.userOption.customSet.Rating = (UserOption.eRating)currentParam;
|
||||
SingletonMonoBehaviour<SystemUI>.instance.userData.setUserDetail();
|
||||
} else {
|
||||
orig_chengeParamOther(currentParam);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using MU3.Sequence;
|
||||
|
||||
namespace MU3;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
47
NaiveRating/MU3/patch_UIResultBattlePoint.cs
Normal file
47
NaiveRating/MU3/patch_UIResultBattlePoint.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using MU3.CustomUI;
|
||||
using MU3.Sequence;
|
||||
using MU3.User;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MU3;
|
||||
class patch_UIResultBattlePoint: UIResultBattlePoint {
|
||||
private Animator animator_;
|
||||
private MU3UICounter counterScore_;
|
||||
private MU3UIImageChanger imageHeader_;
|
||||
private MU3UICounter counterScorePlus_;
|
||||
private MU3UICounter counterScoreMinus_;
|
||||
private GameObject hideScore_;
|
||||
|
||||
private extern void orig_disable(MU3UICounter counter);
|
||||
private void disable(MU3UICounter counter) => orig_disable(counter);
|
||||
public extern void orig_initTechRating(PlayInfo playInfo);
|
||||
public new void initTechRating(PlayInfo playInfo) {
|
||||
((patch_MU3UICounter)counterScore_).isDispSuffix = NaiveRating.IsEnabled();
|
||||
if(!NaiveRating.IsEnabled()) {
|
||||
orig_initTechRating(playInfo);
|
||||
return;
|
||||
}
|
||||
int prevRating = NaiveRating.PrevRating;
|
||||
int rating1 = NaiveRating.Get();
|
||||
if((bool)hideScore_) {
|
||||
hideScore_.SetActive(false);
|
||||
}
|
||||
counterScore_.Counter = (double)UserUtil.toRatingFloat(rating1);
|
||||
int ratingPatternNo = UserUtil.toRatingPatternNo(rating1);
|
||||
counterScore_.SpriteIndex = ratingPatternNo;
|
||||
imageHeader_.patternNumber = (float)ratingPatternNo;
|
||||
int rating2 = rating1 - prevRating;
|
||||
if(rating2 == 0) {
|
||||
disable(counterScorePlus_);
|
||||
disable(counterScoreMinus_);
|
||||
animator_.SetInteger(MU3.Sys.Const.AnimatorID_State, 2);
|
||||
} else if(0 < rating2) {
|
||||
disable(counterScoreMinus_);
|
||||
if((bool)counterScorePlus_) {
|
||||
counterScorePlus_.Counter = rating2 * 0.01f + 1E-05f;
|
||||
}
|
||||
animator_.SetInteger(MU3.Sys.Const.AnimatorID_State, 0);
|
||||
}
|
||||
animator_.SetTrigger(MU3.Sys.Const.AnimatorID_In);
|
||||
}
|
||||
}
|
36
NaiveRating/MU3/patch_UserOption.cs
Normal file
36
NaiveRating/MU3/patch_UserOption.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using MonoMod;
|
||||
|
||||
namespace MU3.User;
|
||||
|
||||
class patch_UserOption: UserOption {
|
||||
[MonoModEnumReplace]
|
||||
public enum patch_eRating {
|
||||
OFF = 0,
|
||||
Default = 1,
|
||||
ON = 1,
|
||||
Naive = 2,
|
||||
MAX = 2
|
||||
}
|
||||
class patch_DataSet: DataSet {
|
||||
private patch_eRating rating = patch_eRating.ON;
|
||||
public extern bool orig_isMax(OptionName id);
|
||||
public new bool isMax(OptionName id) {
|
||||
if(id == OptionName.Rating) {
|
||||
return rating == patch_eRating.MAX;
|
||||
}
|
||||
return orig_isMax(id);
|
||||
}
|
||||
public new patch_eRating Rating {
|
||||
get => rating;
|
||||
set {
|
||||
if(patch_eRating.MAX < value) {
|
||||
rating = patch_eRating.MAX;
|
||||
} else if(value < patch_eRating.OFF) {
|
||||
rating = patch_eRating.OFF;
|
||||
} else {
|
||||
rating = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,10 +5,8 @@ using MU3.Util;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MU3;
|
||||
|
||||
public static class NaiveRating {
|
||||
public static int PrevRating { get; set; }
|
||||
public static int PrevRating { get; private set; }
|
||||
|
||||
// Adapted from MU3.User.UserRating.calcBest()
|
||||
private static RatingList calcSane() {
|
||||
@ -48,4 +46,10 @@ public static class NaiveRating {
|
||||
}
|
||||
return res / 45;
|
||||
}
|
||||
public static bool IsEnabled() {
|
||||
return Singleton<UserManager>.instance.userOption.customSet.Rating == (UserOption.eRating)patch_UserOption.patch_eRating.Naive;
|
||||
}
|
||||
public static void SavePrev() {
|
||||
PrevRating = Get();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user