@@ -8,16 +8,6 @@ namespace kiwi {
88 *
99 ******************************************************************************/
1010
11- /* *
12- * @brief Opens a new menu page
13- *
14- * @param rPage Menu page
15- */
16- void DebugMenu::OpenPage (DebugPage& rPage) {
17- rPage.SetParent (*this );
18- mPageStack .Push (&rPage);
19- }
20-
2111/* *
2212 * @brief Updates the menu state
2313 * @return Result of actions
@@ -29,12 +19,12 @@ EDebugMenuResult DebugMenu::Calculate() {
2919
3020 EDebugMenuResult result = mPageStack .Top ().Calculate ();
3121
32- if (result == EDebugMenuResult_Close) {
33- // Can't close the root page
22+ if (result == EDebugMenuResult_Back) {
3423 if (mPageStack .Size () > 1 ) {
3524 mPageStack .Pop ();
3625 } else {
37- result = EDebugMenuResult_Invalid;
26+ // Can't close the root page
27+ result = EDebugMenuResult_Exit;
3828 }
3929 }
4030
@@ -58,30 +48,18 @@ void DebugMenu::UserDraw() {
5848 *
5949 ******************************************************************************/
6050
61- /* *
62- * @brief Appends a new option to the page
63- *
64- * @param rOption Debug option
65- * @return Success
66- */
67- bool DebugPage::AddOption (DebugOptionBase& rOption) {
68- if (mOptions .Size () >= mMaxOptions ) {
69- K_LOG_EX (" Can't add option: %s\n " , rOption.GetName ().CStr ());
70- return false ;
71- }
72-
73- rOption.SetParent (*this );
74- mOptions .PushBack (&rOption);
75-
76- return true ;
77- }
78-
7951/* *
8052 * @brief Updates the menu state
8153 * @return Result of actions
8254 */
8355EDebugMenuResult DebugPage::Calculate () {
56+ EDebugMenuResult result = EDebugMenuResult_None;
57+
8458 for (int i = 0 ; i < EPlayer_Max; i++) {
59+ if (mOptions .Size () == 0 ) {
60+ break ;
61+ }
62+
8563 const WiiCtrl& rCtrl = CtrlMgr::GetInstance ().GetWiiCtrl (i);
8664 if (!rCtrl.IsConnected ()) {
8765 continue ;
@@ -105,6 +83,7 @@ EDebugMenuResult DebugPage::Calculate() {
10583 // Change option with Left/Right
10684 if (rCtrl.IsTrig (EButton_Right)) {
10785 return pOption->Increment ();
86+
10887 } else if (rCtrl.IsTrig (EButton_Left)) {
10988 return pOption->Decrement ();
11089 }
@@ -116,30 +95,38 @@ EDebugMenuResult DebugPage::Calculate() {
11695
11796 // Close page with B
11897 if (rCtrl.IsTrig (EButton_B)) {
119- return EDebugMenuResult_Close ;
98+ return EDebugMenuResult_Back ;
12099 }
121100 }
122-
123- return EDebugMenuResult_None;
124101}
125102
126103/* *
127104 * @brief User-level render pass
128105 */
129106void DebugPage::UserDraw () {
130- f32 x = 0 .15f ;
131- f32 y = 0 .20f ;
107+ static const f32 ox = 0 .15f ;
108+ static const f32 oy = 0 .20f ;
132109
133110 static const f32 cursor = 0 .015f ;
134111 static const f32 option = 0 .25f ;
112+
135113 static const f32 row = 0 .05f ;
114+ static const f32 column = 0 .30f ;
115+
116+ f32 x = ox;
117+ f32 y = oy;
136118
137119 for (u32 i = 0 ; i < mOptions .Size (); i++) {
120+ // Options marked as disabled are displayed in darker colors
121+ Color fill = mOptions [i]->IsEnabled () ? Color::WHITE : Color::GREY;
122+
138123 Text (mOptions [i]->GetName ())
124+ .SetTextColor (fill)
139125 .SetStrokeType (ETextStroke_Outline)
140126 .SetPosition (x, y);
141127
142128 Text (mOptions [i]->GetValueText ())
129+ .SetTextColor (fill)
143130 .SetStrokeType (ETextStroke_Outline)
144131 .SetPosition (x + option, y);
145132
@@ -151,6 +138,12 @@ void DebugPage::UserDraw() {
151138 }
152139
153140 y += row;
141+
142+ // Half of them are in the other column
143+ if (i > 0 && (i % (DEFAULT_MAX_OPTIONS / 2 )) == 0 ) {
144+ x += column;
145+ y = oy;
146+ }
154147 }
155148}
156149
0 commit comments