@@ -9,22 +9,22 @@ namespace kiwi {
99 ******************************************************************************/
1010
1111/* *
12- * @brief Constructor
12+ * @brief Opens a new menu page
1313 *
14- * @param pRootPage Menu root page
14+ * @param rPage Menu page
1515 */
16- DebugMenu::DebugMenu (DebugPage* pRootPage ) {
17- K_ASSERT (pRootPage != nullptr );
18- mPageStack .Push (pRootPage );
16+ void DebugMenu::OpenPage (DebugPage& rPage ) {
17+ rPage. SetParent (* this );
18+ mPageStack .Push (&rPage );
1919}
2020
2121/* *
2222 * @brief Updates the menu state
2323 * @return Result of actions
2424 */
25- DebugMenu::EResult DebugMenu::Calculate () {
25+ EDebugMenuResult DebugMenu::Calculate () {
2626 if (mPageStack .Empty ()) {
27- return EResult_None ;
27+ return EDebugMenuResult_None ;
2828 }
2929
3030 return mPageStack .Top ().Calculate ();
@@ -50,26 +50,24 @@ void DebugMenu::UserDraw() {
5050/* *
5151 * @brief Appends a new option to the page
5252 *
53- * @param pOption Debug option
53+ * @param rOption Debug option
5454 * @return Success
5555 */
56- bool DebugPage::AddOption (DebugOptionBase* pOption) {
57- K_ASSERT (pOption != nullptr );
58-
56+ bool DebugPage::AddOption (DebugOptionBase& rOption) {
5957 if (mOptions .Size () >= mMaxOptions ) {
60- K_LOG_EX (" Can't add option: %s\n " , pOption-> GetName ().CStr ());
58+ K_LOG_EX (" Can't add option: %s\n " , rOption. GetName ().CStr ());
6159 return false ;
6260 }
6361
64- mOptions .PushBack (pOption );
62+ mOptions .PushBack (&rOption );
6563 return true ;
6664}
6765
6866/* *
6967 * @brief Updates the menu state
7068 * @return Result of actions
7169 */
72- DebugMenu::EResult DebugPage::Calculate () {
70+ EDebugMenuResult DebugPage::Calculate () {
7371 for (int i = 0 ; i < EPlayer_Max; i++) {
7472 const WiiCtrl& rCtrl =
7573 CtrlMgr::GetInstance ().GetWiiCtrl (static_cast <EPlayer>(i));
@@ -81,10 +79,11 @@ DebugMenu::EResult DebugPage::Calculate() {
8179 // Highlight option with Up/Down
8280 if (rCtrl.IsTrig (EButton_Up)) {
8381 mCursor = mCursor == 0 ? mOptions .Size () - 1 : mCursor - 1 ;
84- return DebugMenu::EResult_Change;
82+ return EDebugMenuResult_Cursor;
83+
8584 } else if (rCtrl.IsTrig (EButton_Down)) {
8685 mCursor = mCursor == mOptions .Size () - 1 ? 0 : mCursor + 1 ;
87- return DebugMenu::EResult_Change ;
86+ return EDebugMenuResult_Cursor ;
8887 }
8988
9089 K_ASSERT (0 <= mCursor && mCursor < mOptions .Size ());
@@ -95,52 +94,53 @@ DebugMenu::EResult DebugPage::Calculate() {
9594 // Change option with Left/Right
9695 if (rCtrl.IsTrig (EButton_Right)) {
9796 pOption->Increment ();
98- return DebugMenu::EResult_Change;
97+ return EDebugMenuResult_Change;
98+
9999 } else if (rCtrl.IsTrig (EButton_Left)) {
100100 pOption->Decrement ();
101- return DebugMenu::EResult_Change ;
101+ return EDebugMenuResult_Change ;
102102 }
103103
104104 // Select option with A
105105 if (rCtrl.IsTrig (EButton_A)) {
106106 pOption->Select ();
107- return DebugMenu::EResult_Change ;
107+ return EDebugMenuResult_Select ;
108108 }
109109
110110 // Close page with B
111111 if (rCtrl.IsTrig (EButton_B)) {
112- return DebugMenu::EResult_Close ;
112+ return EDebugMenuResult_Close ;
113113 }
114114 }
115115
116- return DebugMenu::EResult_None ;
116+ return EDebugMenuResult_None ;
117117}
118118
119119/* *
120120 * @brief User-level render pass
121121 */
122122void DebugPage::UserDraw () {
123- f32 x = 0 .25f ;
123+ f32 x = 0 .15f ;
124124 f32 y = 0 .20f ;
125+
126+ static const f32 cursor = 0 .015f ;
127+ static const f32 option = 0 .25f ;
125128 static const f32 row = 0 .05f ;
126129
127130 for (u32 i = 0 ; i < mOptions .Size (); i++) {
128131 Text (mOptions [i]->GetName ())
129132 .SetStrokeType (ETextStroke_Outline)
130- .SetPosition (x + 0.00 , y + 0.00 )
131- .SetScale (0.8 );
133+ .SetPosition (x, y);
132134
133135 Text (mOptions [i]->GetValueText ())
134136 .SetStrokeType (ETextStroke_Outline)
135- .SetPosition (x + 0.15 , y + 0.00 )
136- .SetScale (0.8 );
137+ .SetPosition (x + option, y);
137138
138139 // Show cursor at selected option
139140 if (i == mCursor ) {
140141 Text (" *" )
141142 .SetStrokeType (ETextStroke_Outline)
142- .SetPosition (x - 0.015 , y)
143- .SetScale (0.8 );
143+ .SetPosition (x - cursor, y);
144144 }
145145
146146 y += row;
0 commit comments