Skip to content

Commit db8bad2

Browse files
committed
fixed bug and added hex color support
1 parent f9b4177 commit db8bad2

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

PerfectDisplay.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class PerfectDisplay : MonoBehaviour
1515
ScoreController scoreController;
1616
public static Vector3 displayPosition = new Vector3(0, 2.3f, 7f);
1717
public static int[] scoreRanges = { 100, 90, 50 };
18-
public static string[] colors = { "blue", "green", "yellow", "orange", "red" };
18+
public static string[] colors = { "#2175ff", "green", "yellow", "orange", "red" };
1919
int[] scoreCount;
2020
int misses = 0;
2121
int notes = 0;
@@ -92,19 +92,19 @@ public void UpdateText()
9292
{
9393
for (int i = 0; i < scoreRanges.Length; i++)
9494
{
95-
text += "<color=\"" + colors[i] + "\">" + ">" + scoreRanges[i] + "-" + scoreCount[i] + "<color=\"black\">|";
95+
text += "<color=" + colors[i] + ">" + ">" + scoreRanges[i] + "-" + scoreCount[i] + "<color=\"black\">|";
9696
}
97-
text += "<color=\"" + colors[scoreRanges.Length] + "\">" + "<" + scoreRanges[scoreRanges.Length - 1] + "-" + scoreCount[scoreRanges.Length] + "<color=\"black\">|";
98-
text += "<color=\"" + colors[scoreRanges.Length + 1] + "\">" + "MISS-" + misses +"\n";
97+
text += "<color=" + colors[scoreRanges.Length] + ">" + "<" + scoreRanges[scoreRanges.Length - 1] + "-" + scoreCount[scoreRanges.Length] + "<color=\"black\">|";
98+
text += "<color=" + colors[scoreRanges.Length + 1] + ">" + "MISS-" + misses +"\n";
9999
}
100100
if (showPercent)
101101
{
102102
for (int i = 0; i < scoreRanges.Length; i++)
103103
{
104-
text += "<color=\"" + colors[i] + "\">" + ">" + scoreRanges[i] + "-" + GetPercent(scoreCount[i]) + "%<color=\"black\">|";
104+
text += "<color=" + colors[i] + ">" + ">" + scoreRanges[i] + "-" + GetPercent(scoreCount[i]) + "%<color=\"black\">|";
105105
}
106-
text += "<color=\"" + colors[scoreRanges.Length] + "\">" + "<" + scoreRanges[scoreRanges.Length - 1] + "-" + GetPercent(scoreCount[scoreRanges.Length]) + "%<color=\"black\">|";
107-
text += "<color=\"" + colors[scoreRanges.Length + 1] + "\">" + "MISS-" + GetPercent(misses) + "%";
106+
text += "<color=" + colors[scoreRanges.Length] + ">" + "<" + scoreRanges[scoreRanges.Length - 1] + "-" + GetPercent(scoreCount[scoreRanges.Length]) + "%<color=\"black\">|";
107+
text += "<color=" + colors[scoreRanges.Length + 1] + ">" + "MISS-" + GetPercent(misses) + "%";
108108
}
109109
scoreMesh.text = text;
110110
}

Plugin.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,21 @@ public void OnApplicationStart()
4646
var rangeString = ModPrefs.GetString("PerfectionDisplay", "Colors");
4747
PerfectDisplay.colors = rangeString.Split(',');
4848
}
49-
if (PerfectDisplay.scoreRanges.Length+2 != PerfectDisplay.colors.Length) Console.WriteLine("[PerfectionDisplay] Config error - colors should have 2 more colors than there are score ranges");
49+
if (PerfectDisplay.scoreRanges.Length + 2 > PerfectDisplay.colors.Length)
50+
{
51+
Console.WriteLine("[PerfectionDisplay] Config error - colors should have 2 more colors than there are score ranges, filling the remaining colors with white");
52+
string[] colors = new string[PerfectDisplay.scoreRanges.Length + 2];
53+
for (int i = 0; i < colors.Length; i++)
54+
{
55+
if (i < PerfectDisplay.colors.Length) colors[i] = PerfectDisplay.colors[i];
56+
else colors[i] = "white";
57+
}
58+
PerfectDisplay.colors = colors;
59+
}
60+
for(int i = 0; i < PerfectDisplay.colors.Length; i++)
61+
{
62+
if (!PerfectDisplay.colors[i].StartsWith("#")) PerfectDisplay.colors[i] = "\""+PerfectDisplay.colors[i]+ "\"";
63+
}
5064
PerfectDisplay.showNumbers = ModPrefs.GetBool("PerfectionDisplay", "Show Count", PerfectDisplay.showNumbers, true);
5165
PerfectDisplay.showPercent = ModPrefs.GetBool("PerfectionDisplay", "Show Percent", PerfectDisplay.showPercent, true);
5266
}

0 commit comments

Comments
 (0)