11using System ;
2- using System . Collections . Generic ;
32using System . Linq ;
4- using System . Text ;
5- using System . Threading . Tasks ;
63using UnityEngine ;
7- using TMPro ;
84using System . Collections ;
95
106namespace PerfectionDisplay
117{
128 class PerfectDisplay : MonoBehaviour
139 {
14- TextMeshPro scoreMesh ;
1510 ScoreController scoreController ;
1611 public static Vector3 displayPosition = new Vector3 ( 0 , 2.3f , 7f ) ;
1712 public static int [ ] scoreRanges = { 100 , 90 , 50 } ;
13+ public static string [ ] hitScoreNames ;
14+ public static bool shouldHitscore = true ;
1815 public static string [ ] colors = { "#2175ff" , "green" , "yellow" , "orange" , "red" } ;
1916 int [ ] scoreCount ;
17+ DisplaySection [ ] sections ;
2018 int misses = 0 ;
2119 int notes = 0 ;
2220 public static bool showNumbers = true ;
@@ -42,13 +40,21 @@ void Awake()
4240 }
4341 private void Init ( )
4442 {
45- scoreMesh = this . gameObject . AddComponent < TextMeshPro > ( ) ;
46- scoreMesh . text = "" ;
47- scoreMesh . fontSize = 3 ;
48- scoreMesh . color = Color . white ;
49- scoreMesh . font = Resources . Load < TMP_FontAsset > ( "Teko-Medium SDF No Glow" ) ;
50- scoreMesh . alignment = TextAlignmentOptions . Center ;
51- scoreMesh . rectTransform . position = displayPosition ;
43+ sections = new DisplaySection [ colors . Length ] ;
44+ sections [ scoreRanges . Length ] = new GameObject ( ) . AddComponent < DisplaySection > ( ) ;
45+ sections [ scoreRanges . Length ] . color = colors [ scoreRanges . Length ] ;
46+ sections [ scoreRanges . Length ] . title = "<" + scoreRanges [ scoreRanges . Length - 1 ] ;
47+ if ( shouldHitscore ) sections [ scoreRanges . Length ] . title = hitScoreNames [ hitScoreNames . Length - 1 ] ;
48+ sections [ scoreRanges . Length + 1 ] = new GameObject ( ) . AddComponent < DisplaySection > ( ) ;
49+ sections [ scoreRanges . Length + 1 ] . color = colors [ scoreRanges . Length + 1 ] ;
50+ sections [ scoreRanges . Length + 1 ] . title = "MISS" ;
51+ for ( int i = 0 ; i < scoreRanges . Length ; i ++ )
52+ {
53+ sections [ i ] = new GameObject ( ) . AddComponent < DisplaySection > ( ) ;
54+ sections [ i ] . color = colors [ i ] ;
55+ sections [ i ] . title = ">" + scoreRanges [ i ] ;
56+ if ( shouldHitscore ) sections [ i ] . title = hitScoreNames [ i ] ;
57+ }
5258 if ( scoreController != null )
5359 {
5460 scoreController . noteWasMissedEvent += Miss ;
@@ -93,47 +99,46 @@ public void Cut(NoteData data, NoteCutInfo info, int combo)
9399
94100 public void UpdateText ( )
95101 {
96- String text = "" ;
97- if ( showNumbers )
102+ float width = 0 ;
103+ for ( int i = 0 ; i < scoreCount . Length ; i ++ )
98104 {
99- for ( int i = 0 ; i < scoreRanges . Length ; i ++ )
100- {
101- text += "<color=" + colors [ i ] + ">" + ">" + scoreRanges [ i ] + "-" + scoreCount [ i ] + "<color=\" black\" >|" ;
102- }
103- text += "<color=" + colors [ scoreRanges . Length ] + ">" + "<" + scoreRanges [ scoreRanges . Length - 1 ] + "-" + scoreCount [ scoreRanges . Length ] + "<color=\" black\" >|" ;
104- text += "<color=" + colors [ scoreRanges . Length + 1 ] + ">" + "MISS-" + misses + "\n " ;
105+ sections [ i ] . UpdateText ( scoreCount [ i ] , GetPercent ( scoreCount [ i ] ) ) ;
106+ width += sections [ i ] . GetWidth ( ) ;
105107 }
106- if ( showPercent )
108+ sections [ scoreRanges . Length + 1 ] . UpdateText ( misses , GetPercent ( misses ) ) ;
109+ width += sections [ scoreRanges . Length + 1 ] . GetWidth ( ) ;
110+
111+ float curX = sections [ 0 ] . GetWidth ( ) / 2 ; ;
112+ for ( int i = 0 ; i < scoreCount . Length ; i ++ )
107113 {
108- for ( int i = 0 ; i < scoreRanges . Length ; i ++ )
109- {
110- text += "<color=" + colors [ i ] + ">" + ">" + scoreRanges [ i ] + "-" + GetPercent ( scoreCount [ i ] ) + "%<color=\" black\" >|" ;
111- }
112- text += "<color=" + colors [ scoreRanges . Length ] + ">" + "<" + scoreRanges [ scoreRanges . Length - 1 ] + "-" + GetPercent ( scoreCount [ scoreRanges . Length ] ) + "%<color=\" black\" >|" ;
113- text += "<color=" + colors [ scoreRanges . Length + 1 ] + ">" + "MISS-" + GetPercent ( misses ) + "%" ;
114+ sections [ i ] . UpdatePosition ( - ( width / 2 ) + curX ) ;
115+ curX += sections [ i ] . GetWidth ( ) / 2 ;
116+ curX += sections [ i + 1 ] . GetWidth ( ) / 2 ;
114117 }
118+ sections [ scoreRanges . Length + 1 ] . UpdatePosition ( - ( width / 2 ) + curX ) ;
119+
120+
115121 Plugin . lastText = "Range\n " ;
116122 for ( int i = 0 ; i < scoreRanges . Length ; i ++ )
117123 {
118- Plugin . lastText += "<color=" + colors [ i ] + ">" + ">" + scoreRanges [ i ] + "\n " ;
124+ Plugin . lastText += "<color=" + colors [ i ] + ">" + ( shouldHitscore ? hitScoreNames [ i ] : ( ">" + scoreRanges [ i ] ) ) + "\n " ;
119125 }
120- Plugin . lastText += "<color=" + colors [ scoreRanges . Length ] + ">" + "<" + scoreRanges [ scoreRanges . Length - 1 ] + "\n " ;
126+ Plugin . lastText += "<color=" + colors [ scoreRanges . Length ] + ">" + ( shouldHitscore ? hitScoreNames [ scoreRanges . Length - 1 ] : ( "<" + scoreRanges [ scoreRanges . Length - 1 ] ) ) + "\n " ;
121127 Plugin . lastText += "<color=" + colors [ scoreRanges . Length + 1 ] + ">" + "MISS" ;
122128 Plugin . lastCount = "Count\n " ;
123129 for ( int i = 0 ; i < scoreRanges . Length ; i ++ )
124130 {
125131 Plugin . lastCount += "<color=" + colors [ i ] + ">" + scoreCount [ i ] + "\n " ;
126132 }
127- Plugin . lastCount += "<color=" + colors [ scoreRanges . Length ] + ">" + scoreCount [ scoreRanges . Length - 1 ] + "\n " ;
133+ Plugin . lastCount += "<color=" + colors [ scoreRanges . Length ] + ">" + scoreCount [ scoreRanges . Length ] + "\n " ;
128134 Plugin . lastCount += "<color=" + colors [ scoreRanges . Length + 1 ] + ">" + misses ;
129135 Plugin . lastPercent = "Percent\n " ;
130136 for ( int i = 0 ; i < scoreRanges . Length ; i ++ )
131137 {
132138 Plugin . lastPercent += "<color=" + colors [ i ] + ">" + GetPercent ( scoreCount [ i ] ) + "%\n " ;
133139 }
134- Plugin . lastPercent += "<color=" + colors [ scoreRanges . Length ] + ">" + GetPercent ( scoreCount [ scoreRanges . Length - 1 ] ) + "%\n " ;
135- Plugin . lastPercent += "<color=" + colors [ scoreRanges . Length + 1 ] + ">" + GetPercent ( misses ) ;
136- scoreMesh . text = text ;
140+ Plugin . lastPercent += "<color=" + colors [ scoreRanges . Length ] + ">" + GetPercent ( scoreCount [ scoreRanges . Length ] ) + "%\n " ;
141+ Plugin . lastPercent += "<color=" + colors [ scoreRanges . Length + 1 ] + ">" + GetPercent ( misses ) + "%" ;
137142 }
138143 private String GetPercent ( int hits )
139144 {
0 commit comments