Skip to content

Commit d1d7070

Browse files
Bug fixes and performance improvements
1 parent 8fd8bf2 commit d1d7070

File tree

5 files changed

+50
-17
lines changed

5 files changed

+50
-17
lines changed

HitScoreVisualizer/Config.cs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public struct Judgment
7474
private const string DEFAULT_JSON = @"{
7575
""majorVersion"": 2,
7676
""minorVersion"": 0,
77-
""patchVersion"": 0,
77+
""patchVersion"": 2,
7878
""isDefaultConfig"": true,
7979
""displayMode"": ""textOnTop"",
8080
""judgments"": [
@@ -227,7 +227,6 @@ public static bool outdated(Config config)
227227
{
228228
if (config.majorVersion < Plugin.majorVersion) return true;
229229
if (config.minorVersion < Plugin.minorVersion) return true;
230-
if (config.patchVersion < Plugin.patchVersion) return true;
231230
return false;
232231
}
233232

@@ -246,24 +245,28 @@ public static void resetToDefault()
246245
public static void judge(FlyingScoreTextEffect text, ref Color color, int score)
247246
{
248247
Judgment judgment = DEFAULT_JUDGMENT;
249-
Judgment fadeJudgment = DEFAULT_JUDGMENT;
250-
for (int i = 0; i < instance.judgments.Length; i++)
248+
int index; // save in case we need to fade
249+
for (index = 0; index < instance.judgments.Length; index++)
251250
{
252-
Judgment j = instance.judgments[i];
251+
Judgment j = instance.judgments[index];
253252
if (score >= j.threshold)
254253
{
255-
if (j.fade) fadeJudgment = instance.judgments[i-1];
256-
else fadeJudgment = j;
257-
258254
judgment = j;
259255
break;
260256
}
261257
}
262-
263-
Color baseColor = toColor(judgment.color);
264-
Color fadeColor = toColor(fadeJudgment.color);
265-
float lerpDistance = Mathf.InverseLerp(judgment.threshold, fadeJudgment.threshold, score);
266-
color = Color.Lerp(baseColor, fadeColor, lerpDistance);
258+
if (judgment.fade)
259+
{
260+
Judgment fadeJudgment = instance.judgments[index - 1];
261+
Color baseColor = toColor(judgment.color);
262+
Color fadeColor = toColor(fadeJudgment.color);
263+
float lerpDistance = Mathf.InverseLerp(judgment.threshold, fadeJudgment.threshold, score);
264+
color = Color.Lerp(baseColor, fadeColor, lerpDistance);
265+
}
266+
else
267+
{
268+
color = toColor(judgment.color);
269+
}
267270

268271
if (instance.displayMode == "textOnly")
269272
{

HitScoreVisualizer/Harmony Patches/FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ namespace HitScoreVisualizer.Harmony_Patches
1212
new Type[] { typeof(SaberAfterCutSwingRatingCounter), typeof(float) })]
1313
class FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent
1414
{
15-
static void Postfix(SaberAfterCutSwingRatingCounter afterCutRating, FlyingScoreTextEffect __instance,
16-
ref Color ____color, NoteCutInfo ____noteCutInfo, int ____multiplier)
15+
static bool Prefix(SaberAfterCutSwingRatingCounter afterCutRating, FlyingScoreTextEffect __instance, ref Color ____color, NoteCutInfo ____noteCutInfo, int ____multiplier)
1716
{
1817
ScoreController.ScoreWithoutMultiplier(____noteCutInfo, afterCutRating, out int before, out int after);
1918
int total = before + after;
2019
Config.judge(__instance, ref ____color, total);
20+
return false;
2121
}
2222
}
2323
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Harmony;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using UnityEngine;
8+
9+
namespace HitScoreVisualizer.Harmony_Patches
10+
{
11+
/*
12+
[HarmonyPatch(typeof(FlyingScoreTextEffect), "InitAndPresent",
13+
new Type[] {
14+
typeof(NoteCutInfo),
15+
typeof(int),
16+
typeof(Vector3),
17+
typeof(Color),
18+
typeof(SaberAfterCutSwingRatingCounter)})]
19+
*/
20+
class FlyingScoreTextEffectInitAndPresent
21+
{
22+
static void Postfix(SaberAfterCutSwingRatingCounter saberAfterCutSwingRatingCounter, FlyingScoreTextEffect __instance, ref Color ____color, NoteCutInfo noteCutInfo)
23+
{
24+
ScoreController.ScoreWithoutMultiplier(noteCutInfo, saberAfterCutSwingRatingCounter, out int before, out int after);
25+
int total = before + after;
26+
Config.judge(__instance, ref ____color, total);
27+
}
28+
}
29+
}

HitScoreVisualizer/HitScoreVisualizer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<ItemGroup>
6464
<Compile Include="Config.cs" />
6565
<Compile Include="Harmony Patches\FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent.cs" />
66+
<Compile Include="Harmony Patches\FlyingScoreTextEffectInitAndPresent.cs" />
6667
<Compile Include="Plugin.cs" />
6768
<Compile Include="Properties\AssemblyInfo.cs" />
6869
</ItemGroup>

HitScoreVisualizer/Plugin.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ namespace HitScoreVisualizer
99
public class Plugin : IPlugin
1010
{
1111
public string Name => "HitScoreVisualizer";
12-
public string Version => "2.0.0";
12+
public string Version => "2.0.2";
1313

1414
internal const int majorVersion = 2;
1515
internal const int minorVersion = 0;
16-
internal const int patchVersion = 0;
16+
internal const int patchVersion = 2;
1717

1818
public void OnApplicationStart()
1919
{

0 commit comments

Comments
 (0)