diff --git a/HitScoreVisualizer/Config.cs b/HitScoreVisualizer/Config.cs index 7353b46..578de74 100644 --- a/HitScoreVisualizer/Config.cs +++ b/HitScoreVisualizer/Config.cs @@ -74,7 +74,7 @@ namespace HitScoreVisualizer private const string DEFAULT_JSON = @"{ ""majorVersion"": 2, ""minorVersion"": 0, - ""patchVersion"": 0, + ""patchVersion"": 2, ""isDefaultConfig"": true, ""displayMode"": ""textOnTop"", ""judgments"": [ @@ -227,7 +227,6 @@ namespace HitScoreVisualizer { if (config.majorVersion < Plugin.majorVersion) return true; if (config.minorVersion < Plugin.minorVersion) return true; - if (config.patchVersion < Plugin.patchVersion) return true; return false; } @@ -246,24 +245,28 @@ namespace HitScoreVisualizer public static void judge(FlyingScoreTextEffect text, ref Color color, int score) { Judgment judgment = DEFAULT_JUDGMENT; - Judgment fadeJudgment = DEFAULT_JUDGMENT; - for (int i = 0; i < instance.judgments.Length; i++) + int index; // save in case we need to fade + for (index = 0; index < instance.judgments.Length; index++) { - Judgment j = instance.judgments[i]; + Judgment j = instance.judgments[index]; if (score >= j.threshold) { - if (j.fade) fadeJudgment = instance.judgments[i-1]; - else fadeJudgment = j; - judgment = j; break; } } - - Color baseColor = toColor(judgment.color); - Color fadeColor = toColor(fadeJudgment.color); - float lerpDistance = Mathf.InverseLerp(judgment.threshold, fadeJudgment.threshold, score); - color = Color.Lerp(baseColor, fadeColor, lerpDistance); + if (judgment.fade) + { + Judgment fadeJudgment = instance.judgments[index - 1]; + Color baseColor = toColor(judgment.color); + Color fadeColor = toColor(fadeJudgment.color); + float lerpDistance = Mathf.InverseLerp(judgment.threshold, fadeJudgment.threshold, score); + color = Color.Lerp(baseColor, fadeColor, lerpDistance); + } + else + { + color = toColor(judgment.color); + } if (instance.displayMode == "textOnly") { diff --git a/HitScoreVisualizer/Harmony Patches/FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent.cs b/HitScoreVisualizer/Harmony Patches/FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent.cs index 07e10f7..4a45ec0 100644 --- a/HitScoreVisualizer/Harmony Patches/FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent.cs +++ b/HitScoreVisualizer/Harmony Patches/FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent.cs @@ -12,12 +12,12 @@ namespace HitScoreVisualizer.Harmony_Patches new Type[] { typeof(SaberAfterCutSwingRatingCounter), typeof(float) })] class FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent { - static void Postfix(SaberAfterCutSwingRatingCounter afterCutRating, FlyingScoreTextEffect __instance, - ref Color ____color, NoteCutInfo ____noteCutInfo, int ____multiplier) + static bool Prefix(SaberAfterCutSwingRatingCounter afterCutRating, FlyingScoreTextEffect __instance, ref Color ____color, NoteCutInfo ____noteCutInfo, int ____multiplier) { ScoreController.ScoreWithoutMultiplier(____noteCutInfo, afterCutRating, out int before, out int after); int total = before + after; Config.judge(__instance, ref ____color, total); + return false; } } } diff --git a/HitScoreVisualizer/Harmony Patches/FlyingScoreTextEffectInitAndPresent.cs b/HitScoreVisualizer/Harmony Patches/FlyingScoreTextEffectInitAndPresent.cs new file mode 100644 index 0000000..92184f0 --- /dev/null +++ b/HitScoreVisualizer/Harmony Patches/FlyingScoreTextEffectInitAndPresent.cs @@ -0,0 +1,29 @@ +using Harmony; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace HitScoreVisualizer.Harmony_Patches +{ + /* + [HarmonyPatch(typeof(FlyingScoreTextEffect), "InitAndPresent", + new Type[] { + typeof(NoteCutInfo), + typeof(int), + typeof(Vector3), + typeof(Color), + typeof(SaberAfterCutSwingRatingCounter)})] + */ + class FlyingScoreTextEffectInitAndPresent + { + static void Postfix(SaberAfterCutSwingRatingCounter saberAfterCutSwingRatingCounter, FlyingScoreTextEffect __instance, ref Color ____color, NoteCutInfo noteCutInfo) + { + ScoreController.ScoreWithoutMultiplier(noteCutInfo, saberAfterCutSwingRatingCounter, out int before, out int after); + int total = before + after; + Config.judge(__instance, ref ____color, total); + } + } +} diff --git a/HitScoreVisualizer/HitScoreVisualizer.csproj b/HitScoreVisualizer/HitScoreVisualizer.csproj index 2bedc75..5316364 100644 --- a/HitScoreVisualizer/HitScoreVisualizer.csproj +++ b/HitScoreVisualizer/HitScoreVisualizer.csproj @@ -63,6 +63,7 @@ + diff --git a/HitScoreVisualizer/Plugin.cs b/HitScoreVisualizer/Plugin.cs index 9a8b845..650b301 100644 --- a/HitScoreVisualizer/Plugin.cs +++ b/HitScoreVisualizer/Plugin.cs @@ -9,11 +9,11 @@ namespace HitScoreVisualizer public class Plugin : IPlugin { public string Name => "HitScoreVisualizer"; - public string Version => "2.0.0"; + public string Version => "2.0.2"; internal const int majorVersion = 2; internal const int minorVersion = 0; - internal const int patchVersion = 0; + internal const int patchVersion = 2; public void OnApplicationStart() {