[h&s menu] change: don't close after toggling the gravity button

This commit is contained in:
Robin C. Ladiges 2024-05-29 13:28:39 +02:00
parent 6bc98f79ac
commit 94c6e74400
No known key found for this signature in database
GPG key ID: B494D3DF92661B99
5 changed files with 37 additions and 16 deletions

View file

@ -50,6 +50,7 @@ class StageSceneStateServerConfig : public al::HostStateBase<al::Scene>, public
private:
inline void subMenuStart();
inline void subMenuUpdate();
inline void subMenuRefresh();
al::MessageSystem* mMsgSystem = nullptr;
FooterParts* mFooterParts = nullptr;

View file

@ -4,11 +4,17 @@
class GameModeConfigMenu {
public:
enum UpdateAction {
NOOP,
CLOSE,
REFRESH,
};
GameModeConfigMenu() = default;
virtual void initMenu(const al::LayoutInitInfo &initInfo) {return;}
virtual bool updateMenu(int selectIndex) {return false;}
virtual UpdateAction updateMenu(int selectIndex) {return UpdateAction::NOOP;}
virtual const sead::WFixedSafeString<0x200>* getStringData() {return nullptr;}

View file

@ -10,7 +10,7 @@ public:
void initMenu(const al::LayoutInitInfo &initInfo) override;
const sead::WFixedSafeString<0x200>* getStringData() override;
bool updateMenu(int selectIndex) override;
GameModeConfigMenu::UpdateAction updateMenu(int selectIndex) override;
const int getMenuSize() override { return mItemCount; }

View file

@ -24,27 +24,24 @@ const sead::WFixedSafeString<0x200>* HideAndSeekConfigMenu::getStringData() {
return mItems->mBuffer;
}
bool HideAndSeekConfigMenu::updateMenu(int selectIndex) {
HideAndSeekInfo *curMode = GameModeManager::instance()->getInfo<HideAndSeekInfo>();
GameModeConfigMenu::UpdateAction HideAndSeekConfigMenu::updateMenu(int selectIndex) {
Logger::log("Setting Gravity Mode.\n");
if (!curMode) {
Logger::log("Unable to Load Mode info!\n");
return true;
}
switch (selectIndex) {
case 0: {
HideAndSeekInfo *curMode = GameModeManager::instance()->getInfo<HideAndSeekInfo>();
if (!curMode) {
Logger::log("Unable to Load Mode info!\n");
return UpdateAction::NOOP;
}
if (GameModeManager::instance()->isMode(GameMode::HIDEANDSEEK)) {
curMode->mIsUseGravity = !curMode->mIsUseGravity;
return UpdateAction::REFRESH;
}
return true;
return UpdateAction::NOOP;
}
default:
Logger::log("Failed to interpret Index!\n");
return false;
return UpdateAction::NOOP;
}
}

View file

@ -237,8 +237,17 @@ void StageSceneStateServerConfig::exeGamemodeConfig() {
subMenuUpdate();
if (mIsDecideConfig && mCurrentList->isDecideEnd()) {
if (mGamemodeConfigMenu->mMenu->updateMenu(mCurrentList->mCurSelected)) {
endSubMenu();
GameModeConfigMenu::UpdateAction action = mGamemodeConfigMenu->mMenu->updateMenu(mCurrentList->mCurSelected);
switch (action) {
case GameModeConfigMenu::UpdateAction::CLOSE:
endSubMenu();
break;
case GameModeConfigMenu::UpdateAction::REFRESH:
subMenuRefresh();
break;
case GameModeConfigMenu::UpdateAction::NOOP:
activateInput();
break;
}
}
}
@ -316,6 +325,14 @@ void StageSceneStateServerConfig::subMenuUpdate() {
}
}
void StageSceneStateServerConfig::subMenuRefresh() {
mGamemodeConfigMenu = &mGamemodeConfigMenus[GameModeManager::instance()->getGameMode()];
mGamemodeConfigMenu->mList->initDataNoResetSelected(mGamemodeConfigMenu->mMenu->getMenuSize());
mGamemodeConfigMenu->mList->addStringData(mGamemodeConfigMenu->mMenu->getStringData(), "TxtContent");
mGamemodeConfigMenu->mList->updateParts();
activateInput();
}
void StageSceneStateServerConfig::activateInput() {
mInput->reset();
mCurrentList->activate();