1 Commits

Author SHA1 Message Date
Arti Kearney
d1d7070548 Bug fixes and performance improvements 2018-08-23 14:38:26 -07:00
5 changed files with 50 additions and 17 deletions

View File

@@ -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")
{

View File

@@ -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;
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -63,6 +63,7 @@
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="Harmony Patches\FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent.cs" />
<Compile Include="Harmony Patches\FlyingScoreTextEffectInitAndPresent.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@@ -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()
{