1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fix: 'Load' and 'Main menu' in-game buttons should work properly

This commit is contained in:
Dmitry Orlov 2021-01-17 19:16:34 +03:00
parent 925857d845
commit c99b8b54e6
5 changed files with 14 additions and 1 deletions

View File

@ -1291,6 +1291,7 @@ static void handleEvent(SDL_Event & ev)
{
CSH->endGameplay();
GH.defActionsDef = 63;
CMM->menu->switchToTab("main");
}
break;
case EUserEvent::RESTART_GAME:

View File

@ -139,6 +139,11 @@ void CMenuScreen::switchToTab(std::string name)
switchToTab(vstd::find_pos(menuNameToEntry, name));
}
size_t CMenuScreen::getActiveTab() const
{
return tabs->getActive();
}
//funciton for std::string -> std::function conversion for main menu
static std::function<void()> genCommand(CMenuScreen * menu, std::vector<std::string> menuType, const std::string & string)
{
@ -301,7 +306,7 @@ void CMainMenu::update()
{
GH.pushInt(CMM);
GH.pushInt(menu);
menu->switchToTab(0);
menu->switchToTab(menu->getActiveTab());
}
// Handles mouse and key input

View File

@ -55,6 +55,7 @@ public:
void switchToTab(size_t index);
void switchToTab(std::string name);
size_t getActiveTab() const;
};
class CMenuEntry : public CIntObject

View File

@ -58,6 +58,11 @@ void CTabbedInt::setActive(size_t which)
}
}
size_t CTabbedInt::getActive() const
{
return activeID;
}
void CTabbedInt::reset()
{
deleteItem(activeTab);

View File

@ -49,6 +49,7 @@ public:
CTabbedInt(CreateFunc create, Point position=Point(), size_t ActiveID=0);
void setActive(size_t which);
size_t getActive() const;
//recreate active tab
void reset();