Skip to content

Commit

Permalink
Fixed another bug and added the stats to the results screen
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeymanboy committed Aug 30, 2018
1 parent db8bad2 commit cbe9961
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 16 deletions.
29 changes: 28 additions & 1 deletion PerfectDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ public void Miss(NoteData data, int c)
public void Cut(NoteData data, NoteCutInfo info, int combo)
{
notes++;
if (!info.allIsOK)
{
misses++;
UpdateText();
return;
}
bool didDone = false;
info.afterCutSwingRatingCounter.didFinishEvent += c => {
info.afterCutSwingRatingCounter.didFinishEvent += e => {
if (didDone) return;
didDone = true;
ScoreController.ScoreWithoutMultiplier(info, info.afterCutSwingRatingCounter, out int before, out int after);
Expand Down Expand Up @@ -106,6 +112,27 @@ public void UpdateText()
text += "<color=" + colors[scoreRanges.Length] + ">" + "<" + scoreRanges[scoreRanges.Length - 1] + "-" + GetPercent(scoreCount[scoreRanges.Length]) + "%<color=\"black\">|";
text += "<color=" + colors[scoreRanges.Length + 1] + ">" + "MISS-" + GetPercent(misses) + "%";
}
Plugin.lastText = "Range\n";
for (int i = 0; i < scoreRanges.Length; i++)
{
Plugin.lastText += "<color=" + colors[i] + ">" + ">" + scoreRanges[i] + "\n";
}
Plugin.lastText += "<color=" + colors[scoreRanges.Length] + ">" + "<" + scoreRanges[scoreRanges.Length - 1] + "\n";
Plugin.lastText += "<color=" + colors[scoreRanges.Length + 1] + ">" + "MISS";
Plugin.lastCount = "Count\n";
for (int i = 0; i < scoreRanges.Length; i++)
{
Plugin.lastCount += "<color=" + colors[i] + ">" + scoreCount[i] + "\n";
}
Plugin.lastCount += "<color=" + colors[scoreRanges.Length] + ">" + scoreCount[scoreRanges.Length - 1] + "\n";
Plugin.lastCount += "<color=" + colors[scoreRanges.Length + 1] + ">" + misses;
Plugin.lastPercent = "Percent\n";
for (int i = 0; i < scoreRanges.Length; i++)
{
Plugin.lastPercent += "<color=" + colors[i] + ">" + GetPercent(scoreCount[i]) + "%\n";
}
Plugin.lastPercent += "<color=" + colors[scoreRanges.Length] + ">" + GetPercent(scoreCount[scoreRanges.Length - 1]) + "%\n";
Plugin.lastPercent += "<color=" + colors[scoreRanges.Length + 1] + ">" + GetPercent(misses);
scoreMesh.text = text;
}
private String GetPercent(int hits)
Expand Down
54 changes: 39 additions & 15 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Globalization;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

Expand All @@ -10,7 +11,11 @@ namespace PerfectionDisplay
public class Plugin : IPlugin
{
public string Name => "Perfection Display";
public string Version => "1.1";
public string Version => "1.2.0";

public static string lastText = "";
public static string lastPercent = "";
public static string lastCount = "";

private readonly string[] env = { "DefaultEnvironment", "BigMirrorEnvironment", "TriangleEnvironment", "NiceEnvironment" };

Expand Down Expand Up @@ -65,22 +70,48 @@ public void OnApplicationStart()
PerfectDisplay.showPercent = ModPrefs.GetBool("PerfectionDisplay", "Show Percent", PerfectDisplay.showPercent, true);
}

private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene arg1)
public void OnApplicationQuit()
{
SceneManager.activeSceneChanged -= OnSceneChanged;
}

private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
private void OnSceneChanged(Scene _, Scene scene)
{
}
if(scene.name.Equals("Menu"))
{
foreach (var rootGameObject in scene.GetRootGameObjects())
{
if (rootGameObject.name.Equals("ViewControllers"))
{
TextMeshProUGUI text = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll<TextMeshProUGUI>().Last(x => (x.name == "Title")), rootGameObject.transform.Find("Results").Find("Cleared"), false);
text.fontSize = 4;
text.color = Color.white;
text.text = lastText;
text.alignment = TextAlignmentOptions.Left;
text.rectTransform.localPosition = new Vector3(-20, 28, 0);
text = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll<TextMeshProUGUI>().Last(x => (x.name == "Title")), rootGameObject.transform.Find("Results").Find("Cleared"), false);
text.fontSize = 4;
text.color = Color.white;
text.text = lastCount;
text.alignment = TextAlignmentOptions.Left;
text.rectTransform.localPosition = new Vector3(3, 28, 0);
text = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll<TextMeshProUGUI>().Last(x => (x.name == "Title")), rootGameObject.transform.Find("Results").Find("Cleared"), false);
text.fontSize = 4;
text.color = Color.white;
text.text = lastPercent;
text.alignment = TextAlignmentOptions.Left;
text.rectTransform.localPosition = new Vector3(-10, 28, 0);
return;
}
}
}
if (!env.Contains(scene.name)) return;

public void OnApplicationQuit()
{
SceneManager.activeSceneChanged -= OnSceneChanged;
new GameObject("PerfectDisplay").AddComponent<PerfectDisplay>();
}

public void OnLevelWasLoaded(int level)
{

}

public void OnLevelWasInitialized(int level)
Expand All @@ -94,12 +125,5 @@ public void OnUpdate()
public void OnFixedUpdate()
{
}

private void OnSceneChanged(Scene _, Scene scene)
{
if (!env.Contains(scene.name)) return;

new GameObject("PerfectDisplay").AddComponent<PerfectDisplay>();
}
}
}

0 comments on commit cbe9961

Please sign in to comment.