Skip to content

Commit 0951101

Browse files
committed
Cool menu
1 parent 6834984 commit 0951101

26 files changed

+643
-291
lines changed

base/symbols_resort.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3649,7 +3649,13 @@ spInstance__17RPSysSystemWinMgr=0x806f4cd0
36493649
updatePauseClosed__17RPSysSystemWinMgrFv=0x80234d58
36503650
sActiveScreen__13RPGrpRenderer=0x807cef2c
36513651

3652-
setStaticVar__Q33Sp23Cmn9StaticMemFiib=0x80269f08
3652+
setVariable__Q33Sp23Cmn9StaticMemFUlUlb=0x80269f08
3653+
setSceneGroup__Q33Sp23Cmn9StaticMemFUl=0x8026a334
3654+
setSceneSeq__Q33Sp23Cmn9StaticMemFUl=0x8026a32c
3655+
spInstance__Q33Sp23Cmn7GameMgr=0x806f4cd8
3656+
writeDebugPlayerData__Q33Sp23Cmn7GameMgrFv=0x8023568c
3657+
setPlayerNum__Q33Sp23Cmn7GameMgrFi=0x80235684
3658+
setControllerNum__Q33Sp23Cmn7GameMgrFi=0x8023562c
36533659

36543660
setTimer__Q43Sp23Bsk3Lyt4MainFUlUl=0x80533a78
36553661
setType__Q33Sp23Bsk4BallFQ43Sp23Bsk4Ball5EType=0x804ffa44
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef SPORTS2_CMN_GAME_MGR_H
2+
#define SPORTS2_CMN_GAME_MGR_H
3+
#include <Pack/RPSystem.h>
4+
#include <Sports2/Sp2Types.h>
5+
6+
namespace Sp2 {
7+
namespace Cmn {
8+
9+
class GameMgr {
10+
RP_SINGLETON_DECL(GameMgr);
11+
12+
public:
13+
void setPlayerNum(int num);
14+
void setControllerNum(int num);
15+
16+
void writeDebugPlayerData();
17+
18+
private:
19+
;
20+
};
21+
22+
} // namespace Cmn
23+
} // namespace Sp2
24+
25+
#endif

include/Sports2/Cmn/Sp2CmnStaticMem.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ class StaticMem {
1010
RP_SINGLETON_DECL(StaticMem);
1111

1212
public:
13-
int getStaticVar(int var, bool absolute);
14-
void setStaticVar(int var, int value, bool absolute);
13+
u32 getVariable(u32 index, bool local = false);
14+
void setVariable(u32 index, u32 value, bool local = false);
1515

16-
u32 getSequence() const {
17-
return mSequence;
16+
u32 getSceneSeq() const {
17+
return mSequenceNo;
1818
}
19+
void setSceneSeq(u32 seq);
20+
21+
u32 getSceneGroup() const {
22+
return mGroupNo;
23+
}
24+
void setSceneGroup(u32 group);
1925

2026
RPSysScene::ETime getIslandTime() const {
2127
return mIslandTime;
@@ -25,8 +31,9 @@ class StaticMem {
2531
}
2632

2733
private:
28-
char _04[0x14];
29-
u32 mSequence; // at 0x18
34+
char _04[0x14 - 0x4];
35+
u32 mGroupNo; // at 0x14
36+
u32 mSequenceNo; // at 0x18
3037
char _1C[0x380 - 0x1C];
3138
RPSysScene::ETime mIslandTime; // at 0x380
3239
};

include/Sports2/Sp2Cmn.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <Sports2/Cmn/Sp2CmnConst.h>
55
#include <Sports2/Cmn/Sp2CmnController.h>
6+
#include <Sports2/Cmn/Sp2CmnGameMgr.h>
67
#include <Sports2/Cmn/Sp2CmnModel.h>
78
#include <Sports2/Cmn/Sp2CmnSeqModel.h>
89
#include <Sports2/Cmn/Sp2CmnStaticMem.h>

lib/libkiwi/core/kiwiSceneCreator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const SceneCreator::Info SceneCreator::scPackScenes[] = {
5454
{nullptr, "Fld(Frisbee)", "FldScene/", kiwi::ESceneID_Sp2FldScene, true, kiwi::EGroupID_Fld, kiwi::EPackID_SportsPack, kiwi::ECreateType_Standard, kiwi::EExitType_Standard, true},
5555
{nullptr, "Bsk(Basket)", "BskScene/", kiwi::ESceneID_Sp2BskScene, true, kiwi::EGroupID_Bsk, kiwi::EPackID_SportsPack, kiwi::ECreateType_Standard, kiwi::EExitType_Standard, true},
5656
{nullptr, "Bwl(Bowling)", "BwlScene/", kiwi::ESceneID_Sp2BwlScene, true, kiwi::EGroupID_Bwl, kiwi::EPackID_SportsPack, kiwi::ECreateType_Standard, kiwi::EExitType_Standard, true},
57-
{nullptr, "Can(Kata)", "CanScene/", kiwi::ESceneID_Sp2CanScene, true, kiwi::EGroupID_Can, kiwi::EPackID_SportsPack, kiwi::ECreateType_Standard, kiwi::EExitType_Standard, true},
57+
{nullptr, "Can(Canoe)", "CanScene/", kiwi::ESceneID_Sp2CanScene, true, kiwi::EGroupID_Can, kiwi::EPackID_SportsPack, kiwi::ECreateType_Standard, kiwi::EExitType_Standard, true},
5858
{nullptr, "Png(PingPong)", "PngScene/", kiwi::ESceneID_Sp2PngScene, true, kiwi::EGroupID_Png, kiwi::EPackID_SportsPack, kiwi::ECreateType_Standard, kiwi::EExitType_Standard, true},
5959
{nullptr, "Wkb(Wakeboard)", "JskScene/", kiwi::ESceneID_Sp2WkbScene, true, kiwi::EGroupID_Wkb, kiwi::EPackID_SportsPack, kiwi::ECreateType_Standard, kiwi::EExitType_Standard, true},
6060
{nullptr, "Pln(Plane)", "PlnScene/", kiwi::ESceneID_Sp2PlnScene, true, kiwi::EGroupID_Pln, kiwi::EPackID_SportsPack, kiwi::ECreateType_Standard, kiwi::EExitType_Standard, true},

lib/libkiwi/debug/kiwiDebugMenu.cpp

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
8355
EDebugMenuResult 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
*/
129106
void 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

lib/libkiwi/debug/kiwiDebugMenu.h

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ enum EDebugMenuResult {
2222
EDebugMenuResult_Cursor, //!< Cursor changed
2323
EDebugMenuResult_Change, //!< State changed
2424
EDebugMenuResult_Select, //!< Button selected
25-
EDebugMenuResult_Close, //!< Request to close page/menu
25+
EDebugMenuResult_Back, //!< Request to close page
26+
EDebugMenuResult_Exit, //!< Request to exit menu
2627
};
2728

2829
/**
@@ -49,7 +50,9 @@ class DebugMenu : public IRPGrpDrawObject {
4950
*
5051
* @param rPage Menu page
5152
*/
52-
void OpenPage(DebugPage& rPage);
53+
void OpenPage(DebugPage& rPage) {
54+
mPageStack.Push(&rPage);
55+
}
5356

5457
/**
5558
* @brief Updates the menu state
@@ -73,43 +76,27 @@ class DebugMenu : public IRPGrpDrawObject {
7376
class DebugPage {
7477
public:
7578
//! Default options limit
76-
static const u32 DEFAULT_MAX_OPTIONS = 16;
79+
static const u32 DEFAULT_MAX_OPTIONS = 20;
7780

7881
public:
7982
/**
8083
* @brief Constructor
8184
*
85+
* @param rMenu Parent menu
8286
* @param maxOptions Maximum number of options on the page
8387
*/
84-
DebugPage(u32 maxOptions = DEFAULT_MAX_OPTIONS)
85-
: mCursor(0), mMaxOptions(maxOptions) {}
88+
DebugPage(DebugMenu& rMenu, u32 maxOptions = DEFAULT_MAX_OPTIONS)
89+
: mrMenu(rMenu), mCursor(0), mMaxOptions(maxOptions) {}
8690

8791
/**
8892
* @brief Gets the page's parent menu
8993
*/
90-
DebugMenu& GetParent() const {
91-
K_ASSERT(mpParent != nullptr);
92-
return *mpParent;
93-
}
94-
/**
95-
* @brief Sets the page's parent menu
96-
*
97-
* @param rMenu Parent menu
98-
*/
99-
void SetParent(DebugMenu& rMenu) {
100-
mpParent = &rMenu;
94+
DebugMenu& GetMenu() const {
95+
return mrMenu;
10196
}
10297

10398
/**
104-
* @brief Appends a new option to the page
105-
*
106-
* @param rOption Debug option
107-
* @return Success
108-
*/
109-
bool AddOption(DebugOptionBase& rOption);
110-
111-
/**
112-
* @brief Updates the menu state
99+
* @brief Updates the page state
113100
* @return Result of actions
114101
*/
115102
virtual EDebugMenuResult Calculate();
@@ -121,7 +108,7 @@ class DebugPage {
121108

122109
protected:
123110
//! Parent menu
124-
DebugMenu* mpParent;
111+
DebugMenu& mrMenu;
125112

126113
//! Cursor position
127114
u32 mCursor;

lib/libkiwi/debug/kiwiDebugOption.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ void DebugOptionBase::SetEnabled(bool enable) {
2727
/**
2828
* @brief Constructor
2929
*
30+
* @param rPage Parent page
3031
* @param rName Option name
3132
* @param min Minimum value (inclusive)
3233
* @param max Maximum value (inclusive)
3334
* @param initial Initial value (optional)
3435
*/
35-
DebugIntOption::DebugIntOption(const String& rName, int min, int max,
36-
Optional<int> initial)
37-
: DebugOptionBase(rName), mMin(min), mMax(max) {
36+
DebugIntOption::DebugIntOption(DebugPage& rPage, const String& rName, int min,
37+
int max, Optional<int> initial)
38+
: DebugOptionBase(rPage, rName), mMin(min), mMax(max) {
3839

3940
K_ASSERT(max >= min);
4041

@@ -51,6 +52,10 @@ EDebugMenuResult DebugIntOption::Increment() {
5152
return EDebugMenuResult_Invalid;
5253
}
5354

55+
if (mMin == mMax) {
56+
return EDebugMenuResult_Invalid;
57+
}
58+
5459
// Value wraps around
5560
SetValue(mValue == mMax ? mMin : mValue + 1);
5661
return EDebugMenuResult_Change;
@@ -65,6 +70,10 @@ EDebugMenuResult DebugIntOption::Decrement() {
6570
return EDebugMenuResult_Invalid;
6671
}
6772

73+
if (mMin == mMax) {
74+
return EDebugMenuResult_Invalid;
75+
}
76+
6877
// Value wraps around
6978
SetValue(mValue == mMin ? mMax : mValue - 1);
7079
return EDebugMenuResult_Change;
@@ -172,7 +181,7 @@ void DebugBoolOption::UpdateString() {
172181
* @param ppValues Enum value strings
173182
*/
174183
void DebugEnumOption::SetEnumValues(const char** ppValues) {
175-
K_ASSERT(ppValues != nullptr);
184+
K_ASSERT_PTR(ppValues);
176185

177186
mppValues = ppValues;
178187
UpdateString();
@@ -182,7 +191,7 @@ void DebugEnumOption::SetEnumValues(const char** ppValues) {
182191
* @brief Updates the option value string
183192
*/
184193
void DebugEnumOption::UpdateString() {
185-
K_ASSERT(mppValues != nullptr);
194+
K_ASSERT_PTR(mppValues);
186195

187196
if (IsEnabled()) {
188197
mValueText = mppValues[GetValue()];
@@ -225,10 +234,10 @@ EDebugMenuResult DebugProcOption::Select() {
225234
* @param pArg Callback user argument
226235
*/
227236
EDebugMenuResult DebugOpenPageOption::OpenPageProc(void* pArg) {
228-
K_ASSERT(pArg != nullptr);
237+
K_ASSERT_PTR(pArg);
229238

230239
DebugOpenPageOption* p = static_cast<DebugOpenPageOption*>(pArg);
231-
p->GetParent().GetParent().OpenPage(*p->mpPage);
240+
p->GetPage().GetMenu().OpenPage(*p->mpOpenPage);
232241

233242
return EDebugMenuResult_Select;
234243
}

0 commit comments

Comments
 (0)