Skip to content

Commit 825f2f9

Browse files
committed
updated
1 parent f13b929 commit 825f2f9

File tree

3 files changed

+74
-47
lines changed

3 files changed

+74
-47
lines changed

DisplaySection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void UpdateText(int score, string percent)
3232
if (!PerfectDisplay.showNumbers && !PerfectDisplay.showPercent) return;
3333
string text = "<color=" + color + ">" + title+"\n";
3434
if (PerfectDisplay.showNumbers) text += score + "\n";
35-
if (PerfectDisplay.showPercent) text += percent + "%\n";
35+
if (PerfectDisplay.showPercent) text += percent + "%";
3636
scoreMesh.text = text;
3737
scoreMesh.ForceMeshUpdate();
3838
}

PerfectDisplay.cs

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class PerfectDisplay : MonoBehaviour
1717
DisplaySection[] sections;
1818
int misses = 0;
1919
int notes = 0;
20-
public static bool showNumbers = true;
21-
public static bool showPercent = true;
20+
public static bool showNumbers = false;
21+
public static bool showPercent = false;
2222
IEnumerator WaitForLoad()
2323
{
2424
bool loaded = false;
@@ -35,7 +35,7 @@ IEnumerator WaitForLoad()
3535
}
3636
void Awake()
3737
{
38-
scoreCount = new int[scoreRanges.Length+1];
38+
scoreCount = new int[scoreRanges.Length + 1];
3939
StartCoroutine(WaitForLoad());
4040
}
4141
private void Init()
@@ -44,13 +44,13 @@ private void Init()
4444
sections[scoreRanges.Length] = new GameObject().AddComponent<DisplaySection>();
4545
sections[scoreRanges.Length].color = colors[scoreRanges.Length];
4646
sections[scoreRanges.Length].title = "<" + scoreRanges[scoreRanges.Length - 1];
47-
if(shouldHitscore) sections[scoreRanges.Length].title = hitScoreNames[hitScoreNames.Length-1];
47+
if (shouldHitscore) sections[scoreRanges.Length].title = hitScoreNames[hitScoreNames.Length - 1];
4848
sections[scoreRanges.Length + 1] = new GameObject().AddComponent<DisplaySection>();
4949
sections[scoreRanges.Length + 1].color = colors[scoreRanges.Length + 1];
5050
sections[scoreRanges.Length + 1].title = "MISS";
5151
for (int i = 0; i < scoreRanges.Length; i++)
5252
{
53-
sections[i] = new GameObject().AddComponent<DisplaySection>();
53+
sections[i] = new GameObject("PerfectionDisplaySection").AddComponent<DisplaySection>();
5454
sections[i].color = colors[i];
5555
sections[i].title = ">" + scoreRanges[i];
5656
if (shouldHitscore) sections[i].title = hitScoreNames[i];
@@ -79,14 +79,15 @@ public void Cut(NoteData data, NoteCutInfo info, int combo)
7979
return;
8080
}
8181
bool didDone = false;
82-
info.afterCutSwingRatingCounter.didFinishEvent += e => {
82+
info.afterCutSwingRatingCounter.didFinishEvent += e =>
83+
{
8384
if (didDone) return;
8485
didDone = true;
8586
ScoreController.ScoreWithoutMultiplier(info, info.afterCutSwingRatingCounter, out int before, out int after);
8687
int total = before + after;
8788
for (int i = 0; i < scoreRanges.Length; i++)
8889
{
89-
if (scoreRanges[i] <total)
90+
if (scoreRanges[i] < total)
9091
{
9192
scoreCount[i]++;
9293
UpdateText();
@@ -100,29 +101,32 @@ public void Cut(NoteData data, NoteCutInfo info, int combo)
100101

101102
public void UpdateText()
102103
{
103-
float width = 0;
104-
for(int i = 0; i < scoreCount.Length; i++)
104+
if (PerfectDisplay.showNumbers || PerfectDisplay.showPercent)
105105
{
106-
sections[i].UpdateText(scoreCount[i], GetPercent(scoreCount[i]));
107-
width += sections[i].GetWidth();
108-
}
109-
sections[scoreRanges.Length+1].UpdateText(misses, GetPercent(misses));
110-
width += sections[scoreRanges.Length + 1].GetWidth();
106+
float width = 0;
107+
for (int i = 0; i < scoreCount.Length; i++)
108+
{
109+
sections[i].UpdateText(scoreCount[i], GetPercent(scoreCount[i]));
110+
width += sections[i].GetWidth();
111+
}
112+
sections[scoreRanges.Length + 1].UpdateText(misses, GetPercent(misses));
113+
width += sections[scoreRanges.Length + 1].GetWidth();
111114

112-
float curX = sections[0].GetWidth() / 2; ;
113-
for (int i = 0; i < scoreCount.Length; i++)
114-
{
115-
sections[i].UpdatePosition(-(width/2)+curX);
116-
curX += sections[i].GetWidth() / 2;
117-
curX += sections[i + 1].GetWidth() / 2;
115+
float curX = sections[0].GetWidth() / 2; ;
116+
for (int i = 0; i < scoreCount.Length; i++)
117+
{
118+
sections[i].UpdatePosition(-(width / 2) + curX);
119+
curX += sections[i].GetWidth() / 2;
120+
curX += sections[i + 1].GetWidth() / 2;
121+
}
122+
sections[scoreRanges.Length + 1].UpdatePosition(-(width / 2) + curX);
118123
}
119-
sections[scoreRanges.Length+1].UpdatePosition(-(width / 2) + curX);
120124

121125

122126
Plugin.lastText = "Range\n";
123127
for (int i = 0; i < scoreRanges.Length; i++)
124128
{
125-
Plugin.lastText += "<color=" + colors[i] + ">" + (shouldHitscore?hitScoreNames[i]:(">" + scoreRanges[i])) + "\n";
129+
Plugin.lastText += "<color=" + colors[i] + ">" + (shouldHitscore ? hitScoreNames[i] : (">" + scoreRanges[i])) + "\n";
126130
}
127131
Plugin.lastText += "<color=" + colors[scoreRanges.Length] + ">" + (shouldHitscore ? hitScoreNames[scoreRanges.Length] : ("<" + scoreRanges[scoreRanges.Length - 1])) + "\n";
128132
Plugin.lastText += "<color=" + colors[scoreRanges.Length + 1] + ">" + "MISS";
@@ -139,7 +143,7 @@ public void UpdateText()
139143
Plugin.lastPercent += "<color=" + colors[i] + ">" + GetPercent(scoreCount[i]) + "%\n";
140144
}
141145
Plugin.lastPercent += "<color=" + colors[scoreRanges.Length] + ">" + GetPercent(scoreCount[scoreRanges.Length]) + "%\n";
142-
Plugin.lastPercent += "<color=" + colors[scoreRanges.Length + 1] + ">" + GetPercent(misses)+"%";
146+
Plugin.lastPercent += "<color=" + colors[scoreRanges.Length + 1] + ">" + GetPercent(misses) + "%";
143147
}
144148
private String GetPercent(int hits)
145149
{

Plugin.cs

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ namespace PerfectionDisplay
1313
public class Plugin : IPlugin
1414
{
1515
public string Name => "Perfection Display";
16-
public string Version => "1.3.1";
16+
public string Version => "1.4.0";
1717

1818
public static string lastText = "";
1919
public static string lastPercent = "";
2020
public static string lastCount = "";
2121

22-
private readonly string[] env = { "DefaultEnvironment", "BigMirrorEnvironment", "TriangleEnvironment", "NiceEnvironment" };
22+
TextMeshProUGUI text;
23+
TextMeshProUGUI percent;
24+
TextMeshProUGUI count;
2325

2426
bool init = true;
27+
GameScenesManager gameScenesManager = null;
2528

2629
public void OnApplicationStart()
2730
{
@@ -91,10 +94,18 @@ private void LoadHitScore()
9194
PerfectDisplay.hitScoreNames[i] = judgments[i].text.Replace("%n", "").Replace("%s", "").Replace("%B", "").Replace("%C", "").Replace("%A", "").Trim();
9295
PerfectDisplay.colors[i] = "#" + ((int)(judgments[i].color[0] * 255)).ToString("X2") + ((int)(judgments[i].color[1] * 255)).ToString("X2") + ((int)(judgments[i].color[2] * 255)).ToString("X2") + ((int)(judgments[i].color[3] * 255)).ToString("X2");
9396
}
94-
PerfectDisplay.colors[PerfectDisplay.colors.Length - 1] = "#FF0000";
97+
PerfectDisplay.colors[PerfectDisplay.colors.Length - 1] = "#afa5a3";
9598
}
9699
private void OnSceneChanged(Scene _, Scene scene)
97100
{
101+
if (gameScenesManager == null)
102+
{
103+
gameScenesManager = Resources.FindObjectsOfTypeAll<GameScenesManager>().FirstOrDefault();
104+
if (gameScenesManager != null)
105+
{
106+
gameScenesManager.transitionDidFinishEvent += OnTransition;
107+
}
108+
}
98109
if (init)
99110
{
100111
init = false;
@@ -107,34 +118,44 @@ private void OnSceneChanged(Scene _, Scene scene)
107118
{
108119
if (rootGameObject.name.Equals("ViewControllers"))
109120
{
110-
TextMeshProUGUI text = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll<TextMeshProUGUI>().Last(x => (x.name == "Title")), rootGameObject.transform.Find("Results").Find("Cleared"), false);
111-
text.fontSize = 4;
121+
int extraOffset = 25;
122+
Console.WriteLine(rootGameObject.transform.childCount);
123+
text = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll<TextMeshProUGUI>().Last(x => (x.name == "Title")), rootGameObject.transform.Find("LevelSelection").Find("StandardLevelResultsViewController"), false);
124+
text.fontSize = 5;
112125
text.color = Color.white;
113126
text.paragraphSpacing = -15f;
114127
text.text = lastText;
115128
text.alignment = TextAlignmentOptions.TopLeft;
116-
text.rectTransform.localPosition = new Vector3(-25, 40, 0);
117-
text = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll<TextMeshProUGUI>().Last(x => (x.name == "Title")), rootGameObject.transform.Find("Results").Find("Cleared"), false);
118-
text.fontSize = 4;
119-
text.color = Color.white;
120-
text.paragraphSpacing = -15f;
121-
text.text = lastCount;
122-
text.alignment = TextAlignmentOptions.TopLeft;
123-
text.rectTransform.localPosition = new Vector3(0-5, 40, 0);
124-
text = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll<TextMeshProUGUI>().Last(x => (x.name == "Title")), rootGameObject.transform.Find("Results").Find("Cleared"), false);
125-
text.fontSize = 4;
126-
text.color = Color.white;
127-
text.paragraphSpacing = -15f;
128-
text.text = lastPercent;
129-
text.alignment = TextAlignmentOptions.TopLeft;
130-
text.rectTransform.localPosition = new Vector3(10-5, 40, 0);
129+
text.rectTransform.localPosition = new Vector3(-20+extraOffset, 40, 0);
130+
percent = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll<TextMeshProUGUI>().Last(x => (x.name == "Title")), rootGameObject.transform.Find("LevelSelection").Find("StandardLevelResultsViewController"), false);
131+
percent.fontSize = 5;
132+
percent.color = Color.white;
133+
percent.paragraphSpacing = -15f;
134+
percent.text = lastCount;
135+
percent.alignment = TextAlignmentOptions.TopLeft;
136+
percent.rectTransform.localPosition = new Vector3(0 + extraOffset, 40, 0);
137+
count = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll<TextMeshProUGUI>().Last(x => (x.name == "Title")), rootGameObject.transform.Find("LevelSelection").Find("StandardLevelResultsViewController"), false);
138+
count.fontSize = 5;
139+
count.color = Color.white;
140+
count.paragraphSpacing = -15f;
141+
count.text = lastPercent;
142+
count.alignment = TextAlignmentOptions.TopLeft;
143+
count.rectTransform.localPosition = new Vector3(15 + extraOffset, 40, 0);
131144
return;
132145
}
133146
}
134147
}
135-
if (!env.Contains(scene.name)) return;
136-
137-
new GameObject("PerfectDisplay").AddComponent<PerfectDisplay>();
148+
if (scene.name.Equals("GameCore")) new GameObject("PerfectDisplay").AddComponent<PerfectDisplay>();
149+
}
150+
private void OnSceneLoad(Scene _, LoadSceneMode mode)
151+
{
152+
Console.WriteLine(_.name);
153+
}
154+
public void OnTransition()
155+
{
156+
if (text != null) text.text = lastText;
157+
if (percent!= null) percent.text = lastPercent;
158+
if (count != null) count.text = lastCount;
138159
}
139160

140161
private bool HasType(string typeName)
@@ -153,10 +174,12 @@ private bool HasType(string typeName)
153174

154175
public void OnLevelWasLoaded(int level)
155176
{
177+
156178
}
157179

158180
public void OnLevelWasInitialized(int level)
159181
{
182+
160183
}
161184

162185
public void OnUpdate()

0 commit comments

Comments
 (0)