mirror of
https://github.com/Theaninova/HitScoreVisualizer.git
synced 2025-12-26 10:26:15 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f15dd367a2 | ||
|
|
45658d5d46 | ||
|
|
a30fd6a772 |
@@ -14,28 +14,6 @@ namespace HitScoreVisualizer
|
||||
{
|
||||
public static Config instance;
|
||||
|
||||
public const string mode_hardcoreCompetetive = "hardcoreCompetetive";
|
||||
public const string mode_format = "format";
|
||||
public const string mode_textOnly = "textOnly";
|
||||
public const string mode_numeric = "numeric";
|
||||
public const string mode_scoreOnTop = "scoreOnTop";
|
||||
|
||||
public const char format_indicator = '%';
|
||||
public const char format_beforeCutScore = 'b';
|
||||
public const char format_accuracyScore = 'c';
|
||||
public const char format_afterCutScore = 'a';
|
||||
public const char FORMAT_BEFORECUTSCORE = 'B';
|
||||
public const char FORMAT_ACCUTRACYSCORE = 'C';
|
||||
public const char FORMAT_AFTERCUTSCORE = 'A';
|
||||
public const char format_score = 's';
|
||||
public const char format_indicatorChar = format_indicator;
|
||||
public const char format_lineBreak = 'n';
|
||||
|
||||
public const bool percentages = true;
|
||||
public const int maxBeforeCutScore = 70;
|
||||
public const int maxAfterCutScore = 30;
|
||||
public const int maxAccuracyScore = 10;
|
||||
|
||||
// If true, this config will not overwrite the existing config file.
|
||||
// (This gets set if a config from a newer version is detected.)
|
||||
[JsonIgnore]
|
||||
@@ -124,7 +102,6 @@ namespace HitScoreVisualizer
|
||||
|
||||
// path to where the config is saved
|
||||
private const string FILE_PATH = "/UserData/HitScoreVisualizerConfig.json";
|
||||
private const string FILE_PATH_RATINGS = "\\Ratings\\Latest.txt";
|
||||
|
||||
private const string DEFAULT_JSON = @"{
|
||||
""majorVersion"": 2,
|
||||
@@ -256,7 +233,6 @@ namespace HitScoreVisualizer
|
||||
};
|
||||
|
||||
public static string fullPath => Environment.CurrentDirectory.Replace('\\', '/') + FILE_PATH;
|
||||
public static string fullPathRatings => Environment.CurrentDirectory + FILE_PATH_RATINGS;
|
||||
|
||||
public static void load()
|
||||
{
|
||||
@@ -363,11 +339,6 @@ namespace HitScoreVisualizer
|
||||
instance = DEFAULT_CONFIG;
|
||||
}
|
||||
|
||||
public static string floatToHexColor(float dec)
|
||||
{
|
||||
return ((int)(255f * dec)).ToString("X2");
|
||||
}
|
||||
|
||||
public static void judge(FlyingScoreTextEffect text, NoteCutInfo noteCutInfo, SaberAfterCutSwingRatingCounter saberAfterCutSwingRatingCounter, ref Color color, int score)
|
||||
{
|
||||
Judgment judgment = DEFAULT_JUDGMENT;
|
||||
@@ -394,77 +365,7 @@ namespace HitScoreVisualizer
|
||||
color = toColor(judgment.color);
|
||||
}
|
||||
|
||||
//Hardcore Competetive Mode by wulkanat
|
||||
if (instance.displayMode == mode_hardcoreCompetetive)
|
||||
{
|
||||
float beforeCut = noteCutInfo.swingRating;
|
||||
float accuracy = 1f - Mathf.Clamp01(noteCutInfo.cutDistanceToCenter / 0.2f);
|
||||
float afterCut = 0f;
|
||||
if (saberAfterCutSwingRatingCounter != null)
|
||||
afterCut = saberAfterCutSwingRatingCounter.rating;
|
||||
|
||||
int beforeCutScore, accuracyScore, afterCutScore;
|
||||
int beforeMax, accuracyMax, afterMax;
|
||||
|
||||
if (percentages)
|
||||
{
|
||||
beforeMax = 100;
|
||||
accuracyMax = 100;
|
||||
afterMax = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
beforeMax = 70;
|
||||
accuracyMax = 10;
|
||||
afterMax = 30;
|
||||
}
|
||||
|
||||
beforeCutScore = Mathf.RoundToInt(beforeMax * beforeCut);
|
||||
accuracyScore = Mathf.RoundToInt(accuracyMax * accuracy);
|
||||
afterCutScore = Mathf.RoundToInt(afterMax * afterCut);
|
||||
|
||||
if (beforeCutScore == beforeMax && accuracyScore == accuracyMax && afterCutScore == afterMax)
|
||||
{
|
||||
text.text = "Perfect";
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder formattedBuilder = new StringBuilder();
|
||||
|
||||
if (percentages)
|
||||
formattedBuilder.Append( "<color=#" + floatToHexColor(1f - score / 110f) + floatToHexColor(score / 110f) + "00>" + (int) ((score / 110f) * 100f) + "%\n");
|
||||
else
|
||||
formattedBuilder.Append("<color=#" + floatToHexColor(1f - score / 110f) + floatToHexColor(score / 110f) + "00>" + score + "\n");
|
||||
|
||||
if (beforeCutScore == beforeMax)
|
||||
formattedBuilder.Append("<color=#FFFFFF>P ");
|
||||
else
|
||||
formattedBuilder.Append("<color=#" + floatToHexColor(1f - beforeCut) + (floatToHexColor(beforeCut) + "00>" + beforeCutScore + " "));
|
||||
|
||||
if (accuracyScore == accuracyMax)
|
||||
formattedBuilder.Append("<color=#FFFFFF>P ");
|
||||
else
|
||||
formattedBuilder.Append("<color=#" + floatToHexColor(1f - accuracy) + floatToHexColor(accuracy) + "00>" + accuracyScore + " ");
|
||||
|
||||
if (afterCutScore == afterMax)
|
||||
formattedBuilder.Append("<color=#FFFFFF>P");
|
||||
else
|
||||
formattedBuilder.Append("<color=#" + floatToHexColor(1f - afterCut) + floatToHexColor(afterCut) + "00>" + afterCutScore);
|
||||
|
||||
text.text = formattedBuilder.ToString();
|
||||
|
||||
//Feature doesn't work
|
||||
/*if (saberAfterCutSwingRatingCounter.didFinish)
|
||||
{
|
||||
using (StreamWriter file = File.AppendText(fullPathRatings))
|
||||
{
|
||||
file.WriteLine(saberAfterCutSwingRatingCounter.RequestId + " <<>> " + beforeCut + " " + accuracy + " " + afterCut + " | " + score);
|
||||
}
|
||||
}*/
|
||||
|
||||
return;
|
||||
}
|
||||
else if (instance.displayMode == mode_format)
|
||||
if (instance.displayMode == "format")
|
||||
{
|
||||
int beforeCutScore, accuracyScore, afterCutScore;
|
||||
|
||||
@@ -479,7 +380,7 @@ namespace HitScoreVisualizer
|
||||
|
||||
StringBuilder formattedBuilder = new StringBuilder();
|
||||
string formatString = judgment.text;
|
||||
int nextPercentIndex = formatString.IndexOf(format_indicator);
|
||||
int nextPercentIndex = formatString.IndexOf('%');
|
||||
while (nextPercentIndex != -1)
|
||||
{
|
||||
formattedBuilder.Append(formatString.Substring(0, nextPercentIndex));
|
||||
@@ -491,54 +392,62 @@ namespace HitScoreVisualizer
|
||||
|
||||
switch (specifier)
|
||||
{
|
||||
case format_beforeCutScore:
|
||||
case 'b':
|
||||
formattedBuilder.Append(beforeCutScore);
|
||||
break;
|
||||
case format_accuracyScore:
|
||||
case 'c':
|
||||
formattedBuilder.Append(accuracyScore);
|
||||
break;
|
||||
case format_afterCutScore:
|
||||
case 'a':
|
||||
formattedBuilder.Append(afterCutScore);
|
||||
break;
|
||||
case FORMAT_BEFORECUTSCORE:
|
||||
case 'B':
|
||||
formattedBuilder.Append(judgeSegment(beforeCutScore, instance.beforeCutAngleJudgments));
|
||||
break;
|
||||
case FORMAT_ACCUTRACYSCORE:
|
||||
case 'C':
|
||||
formattedBuilder.Append(judgeSegment(accuracyScore, instance.accuracyJudgments));
|
||||
break;
|
||||
case FORMAT_AFTERCUTSCORE:
|
||||
case 'A':
|
||||
formattedBuilder.Append(judgeSegment(afterCutScore, instance.afterCutAngleJudgments));
|
||||
break;
|
||||
case format_score:
|
||||
case 's':
|
||||
formattedBuilder.Append(score);
|
||||
break;
|
||||
case format_indicatorChar:
|
||||
formattedBuilder.Append(format_indicatorChar);
|
||||
case '%':
|
||||
formattedBuilder.Append("%");
|
||||
break;
|
||||
case format_lineBreak:
|
||||
case 'n':
|
||||
formattedBuilder.Append("\n");
|
||||
break;
|
||||
default:
|
||||
formattedBuilder.Append(format_indicator + specifier);
|
||||
formattedBuilder.Append("%" + specifier);
|
||||
break;
|
||||
}
|
||||
|
||||
formatString = formatString.Remove(0, nextPercentIndex + 2);
|
||||
nextPercentIndex = formatString.IndexOf(format_indicator);
|
||||
nextPercentIndex = formatString.IndexOf('%');
|
||||
}
|
||||
formattedBuilder.Append(formatString);
|
||||
|
||||
text.text = formattedBuilder.ToString();
|
||||
return;
|
||||
}
|
||||
else if (instance.displayMode == mode_textOnly)
|
||||
|
||||
if (instance.displayMode == "textOnly")
|
||||
{
|
||||
text.text = judgment.text;
|
||||
else if (instance.displayMode == mode_numeric)
|
||||
return;
|
||||
else if (instance.displayMode == mode_scoreOnTop)
|
||||
}
|
||||
if (instance.displayMode == "numeric")
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (instance.displayMode == "scoreOnTop")
|
||||
{
|
||||
text.text = score + "\n" + judgment.text + "\n";
|
||||
else
|
||||
text.text = judgment.text + "\n" + score + "\n";
|
||||
return;
|
||||
}
|
||||
text.text = judgment.text + "\n" + score + "\n";
|
||||
}
|
||||
|
||||
public static Color toColor(float[] rgba)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\..\Steam Games\steamapps\common\Beat Saber\Plugins\</OutputPath>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -31,16 +31,16 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony">
|
||||
<HintPath>..\..\..\..\Steam Games\steamapps\common\Beat Saber\Beat Saber_Data\Managed\0Harmony.dll</HintPath>
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\0Harmony.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\..\..\..\Steam Games\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp-firstpass">
|
||||
<HintPath>..\..\..\..\Steam Games\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IllusionPlugin">
|
||||
<HintPath>..\..\..\..\Steam Games\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll</HintPath>
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
@@ -54,10 +54,10 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>..\..\..\..\Steam Games\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>..\..\..\..\Steam Games\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -17,8 +17,6 @@ namespace HitScoreVisualizer
|
||||
|
||||
public void OnApplicationStart()
|
||||
{
|
||||
System.IO.File.WriteAllText(Config.fullPathRatings, "NO DATA");
|
||||
|
||||
SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged;
|
||||
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
|
||||
try
|
||||
@@ -35,27 +33,8 @@ namespace HitScoreVisualizer
|
||||
Config.load();
|
||||
}
|
||||
|
||||
private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene newScene)
|
||||
private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene arg1)
|
||||
{
|
||||
switch (newScene.buildIndex)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
// Return if we're not playing in a song.
|
||||
return;
|
||||
case 8:
|
||||
case 9:
|
||||
// We're in a song
|
||||
//System.IO.File.WriteAllText(Config.fullPathRatings, newScene.name);
|
||||
return;
|
||||
|
||||
default:
|
||||
// Unknown, fallback to matching the name.
|
||||
if (newScene.name.Contains("Environment"))
|
||||
goto case 8;
|
||||
else
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
|
||||
|
||||
Reference in New Issue
Block a user