Cleaning up

This commit is contained in:
2018-08-27 03:30:05 +02:00
parent f4546fecd6
commit 4ffe8423e8

View File

@@ -14,6 +14,27 @@ namespace HitScoreVisualizer
{ {
public static Config instance; public static Config instance;
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. // If true, this config will not overwrite the existing config file.
// (This gets set if a config from a newer version is detected.) // (This gets set if a config from a newer version is detected.)
[JsonIgnore] [JsonIgnore]
@@ -365,7 +386,7 @@ namespace HitScoreVisualizer
color = toColor(judgment.color); color = toColor(judgment.color);
} }
if (instance.displayMode == "format") if (instance.displayMode == mode_format)
{ {
int beforeCutScore, accuracyScore, afterCutScore; int beforeCutScore, accuracyScore, afterCutScore;
@@ -380,7 +401,7 @@ namespace HitScoreVisualizer
StringBuilder formattedBuilder = new StringBuilder(); StringBuilder formattedBuilder = new StringBuilder();
string formatString = judgment.text; string formatString = judgment.text;
int nextPercentIndex = formatString.IndexOf('%'); int nextPercentIndex = formatString.IndexOf(format_indicator);
while (nextPercentIndex != -1) while (nextPercentIndex != -1)
{ {
formattedBuilder.Append(formatString.Substring(0, nextPercentIndex)); formattedBuilder.Append(formatString.Substring(0, nextPercentIndex));
@@ -392,62 +413,54 @@ namespace HitScoreVisualizer
switch (specifier) switch (specifier)
{ {
case 'b': case format_beforeCutScore:
formattedBuilder.Append(beforeCutScore); formattedBuilder.Append(beforeCutScore);
break; break;
case 'c': case format_accuracyScore:
formattedBuilder.Append(accuracyScore); formattedBuilder.Append(accuracyScore);
break; break;
case 'a': case format_afterCutScore:
formattedBuilder.Append(afterCutScore); formattedBuilder.Append(afterCutScore);
break; break;
case 'B': case FORMAT_BEFORECUTSCORE:
formattedBuilder.Append(judgeSegment(beforeCutScore, instance.beforeCutAngleJudgments)); formattedBuilder.Append(judgeSegment(beforeCutScore, instance.beforeCutAngleJudgments));
break; break;
case 'C': case FORMAT_ACCUTRACYSCORE:
formattedBuilder.Append(judgeSegment(accuracyScore, instance.accuracyJudgments)); formattedBuilder.Append(judgeSegment(accuracyScore, instance.accuracyJudgments));
break; break;
case 'A': case FORMAT_AFTERCUTSCORE:
formattedBuilder.Append(judgeSegment(afterCutScore, instance.afterCutAngleJudgments)); formattedBuilder.Append(judgeSegment(afterCutScore, instance.afterCutAngleJudgments));
break; break;
case 's': case format_score:
formattedBuilder.Append(score); formattedBuilder.Append(score);
break; break;
case '%': case format_indicatorChar:
formattedBuilder.Append("%"); formattedBuilder.Append(format_indicatorChar);
break; break;
case 'n': case format_lineBreak:
formattedBuilder.Append("\n"); formattedBuilder.Append("\n");
break; break;
default: default:
formattedBuilder.Append("%" + specifier); formattedBuilder.Append(format_indicator + specifier);
break; break;
} }
formatString = formatString.Remove(0, nextPercentIndex + 2); formatString = formatString.Remove(0, nextPercentIndex + 2);
nextPercentIndex = formatString.IndexOf('%'); nextPercentIndex = formatString.IndexOf(format_indicator);
} }
formattedBuilder.Append(formatString); formattedBuilder.Append(formatString);
text.text = formattedBuilder.ToString(); text.text = formattedBuilder.ToString();
return; return;
} }
else if (instance.displayMode == mode_textOnly)
if (instance.displayMode == "textOnly")
{
text.text = judgment.text; text.text = judgment.text;
else if (instance.displayMode == mode_numeric)
return; return;
} else if (instance.displayMode == mode_scoreOnTop)
if (instance.displayMode == "numeric")
{
return;
}
if (instance.displayMode == "scoreOnTop")
{
text.text = score + "\n" + judgment.text + "\n"; text.text = score + "\n" + judgment.text + "\n";
return; else
} text.text = judgment.text + "\n" + score + "\n";
text.text = judgment.text + "\n" + score + "\n";
} }
public static Color toColor(float[] rgba) public static Color toColor(float[] rgba)