8 Commits

Author SHA1 Message Date
Wieland Schöbl
7b8f210e65 First Release 2018-10-06 14:41:19 +02:00
Wieland Schöbl
337c3b3f3b Bugfixing 2018-08-27 05:17:46 +02:00
Wieland Schöbl
232264ea1b Plugin works now as intended 2018-08-27 05:10:02 +02:00
Wieland Schöbl
0ebc4fe99f Different colors are now fading for how good the cut was 2018-08-27 05:00:29 +02:00
Wieland Schöbl
5232e704f6 Plugin should work in theory 2018-08-27 04:28:39 +02:00
Wieland Schöbl
4cc7cb0856 Basic functionality obtained 2018-08-27 03:59:58 +02:00
Wieland Schöbl
f8a54ee407 Started working on competetive mode 2018-08-27 03:41:01 +02:00
Wieland Schöbl
ca796ed1c1 Cleaning up 2018-08-27 03:30:05 +02:00
3 changed files with 146 additions and 35 deletions

View File

@@ -14,6 +14,28 @@ 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]
@@ -102,6 +124,7 @@ 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,
@@ -233,6 +256,7 @@ namespace HitScoreVisualizer
};
public static string fullPath => Environment.CurrentDirectory.Replace('\\', '/') + FILE_PATH;
public static string fullPathRatings => Environment.CurrentDirectory + FILE_PATH_RATINGS;
public static void load()
{
@@ -339,6 +363,11 @@ 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;
@@ -365,7 +394,76 @@ namespace HitScoreVisualizer
color = toColor(judgment.color);
}
if (instance.displayMode == "format")
//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();
if (saberAfterCutSwingRatingCounter.didFinish)
{
using (StreamWriter file = File.AppendText(fullPathRatings))
{
file.WriteLine(saberAfterCutSwingRatingCounter.RequestId + " <<>> " + beforeCut + " " + accuracy + " " + afterCut + " | " + score);
}
}
return;
}
else if (instance.displayMode == mode_format)
{
int beforeCutScore, accuracyScore, afterCutScore;
@@ -380,7 +478,7 @@ namespace HitScoreVisualizer
StringBuilder formattedBuilder = new StringBuilder();
string formatString = judgment.text;
int nextPercentIndex = formatString.IndexOf('%');
int nextPercentIndex = formatString.IndexOf(format_indicator);
while (nextPercentIndex != -1)
{
formattedBuilder.Append(formatString.Substring(0, nextPercentIndex));
@@ -392,62 +490,54 @@ namespace HitScoreVisualizer
switch (specifier)
{
case 'b':
case format_beforeCutScore:
formattedBuilder.Append(beforeCutScore);
break;
case 'c':
case format_accuracyScore:
formattedBuilder.Append(accuracyScore);
break;
case 'a':
case format_afterCutScore:
formattedBuilder.Append(afterCutScore);
break;
case 'B':
case FORMAT_BEFORECUTSCORE:
formattedBuilder.Append(judgeSegment(beforeCutScore, instance.beforeCutAngleJudgments));
break;
case 'C':
case FORMAT_ACCUTRACYSCORE:
formattedBuilder.Append(judgeSegment(accuracyScore, instance.accuracyJudgments));
break;
case 'A':
case FORMAT_AFTERCUTSCORE:
formattedBuilder.Append(judgeSegment(afterCutScore, instance.afterCutAngleJudgments));
break;
case 's':
case format_score:
formattedBuilder.Append(score);
break;
case '%':
formattedBuilder.Append("%");
case format_indicatorChar:
formattedBuilder.Append(format_indicatorChar);
break;
case 'n':
case format_lineBreak:
formattedBuilder.Append("\n");
break;
default:
formattedBuilder.Append("%" + specifier);
formattedBuilder.Append(format_indicator + specifier);
break;
}
formatString = formatString.Remove(0, nextPercentIndex + 2);
nextPercentIndex = formatString.IndexOf('%');
nextPercentIndex = formatString.IndexOf(format_indicator);
}
formattedBuilder.Append(formatString);
text.text = formattedBuilder.ToString();
return;
}
if (instance.displayMode == "textOnly")
{
else if (instance.displayMode == mode_textOnly)
text.text = judgment.text;
else if (instance.displayMode == mode_numeric)
return;
}
if (instance.displayMode == "numeric")
{
return;
}
if (instance.displayMode == "scoreOnTop")
{
else if (instance.displayMode == mode_scoreOnTop)
text.text = score + "\n" + judgment.text + "\n";
return;
}
text.text = judgment.text + "\n" + score + "\n";
else
text.text = judgment.text + "\n" + score + "\n";
}
public static Color toColor(float[] rgba)

View File

@@ -16,7 +16,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\..\..\..\Steam Games\steamapps\common\Beat Saber\Plugins\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -31,16 +31,16 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\0Harmony.dll</HintPath>
<HintPath>..\..\..\..\Steam Games\steamapps\common\Beat Saber\Beat Saber_Data\Managed\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\..\Steam Games\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>..\..\..\..\Steam Games\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="IllusionPlugin">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll</HintPath>
<HintPath>..\..\..\..\Steam Games\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>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\..\..\Steam Games\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\..\..\..\Steam Games\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>

View File

@@ -17,6 +17,8 @@ namespace HitScoreVisualizer
public void OnApplicationStart()
{
System.IO.File.WriteAllText(Config.fullPathRatings, "NO DATA");
SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged;
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
try
@@ -33,8 +35,27 @@ namespace HitScoreVisualizer
Config.load();
}
private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene arg1)
private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene newScene)
{
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)