diff --git a/PerfectDisplay.cs b/PerfectDisplay.cs index d4f629f..3f9ec7f 100644 --- a/PerfectDisplay.cs +++ b/PerfectDisplay.cs @@ -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); @@ -106,6 +112,27 @@ public void UpdateText() text += "" + "<" + scoreRanges[scoreRanges.Length - 1] + "-" + GetPercent(scoreCount[scoreRanges.Length]) + "%|"; text += "" + "MISS-" + GetPercent(misses) + "%"; } + Plugin.lastText = "Range\n"; + for (int i = 0; i < scoreRanges.Length; i++) + { + Plugin.lastText += "" + ">" + scoreRanges[i] + "\n"; + } + Plugin.lastText += "" + "<" + scoreRanges[scoreRanges.Length - 1] + "\n"; + Plugin.lastText += "" + "MISS"; + Plugin.lastCount = "Count\n"; + for (int i = 0; i < scoreRanges.Length; i++) + { + Plugin.lastCount += "" + scoreCount[i] + "\n"; + } + Plugin.lastCount += "" + scoreCount[scoreRanges.Length - 1] + "\n"; + Plugin.lastCount += "" + misses; + Plugin.lastPercent = "Percent\n"; + for (int i = 0; i < scoreRanges.Length; i++) + { + Plugin.lastPercent += "" + GetPercent(scoreCount[i]) + "%\n"; + } + Plugin.lastPercent += "" + GetPercent(scoreCount[scoreRanges.Length - 1]) + "%\n"; + Plugin.lastPercent += "" + GetPercent(misses); scoreMesh.text = text; } private String GetPercent(int hits) diff --git a/Plugin.cs b/Plugin.cs index e4200aa..f7360c9 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -2,6 +2,7 @@ using System; using System.Globalization; using System.Linq; +using TMPro; using UnityEngine; using UnityEngine.SceneManagement; @@ -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" }; @@ -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().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().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().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(); } public void OnLevelWasLoaded(int level) { - } public void OnLevelWasInitialized(int level) @@ -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(); - } } }