mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Merge pull request #674 from ShubusCorporation/do/fix/game_interface/load_and_main_menu_buttons
Fix: 'Load' and 'Main Menu' in-game buttons should work properly
This commit is contained in:
		| @@ -1291,6 +1291,7 @@ static void handleEvent(SDL_Event & ev) | ||||
| 			{ | ||||
| 				CSH->endGameplay(); | ||||
| 				GH.defActionsDef = 63; | ||||
| 				CMM->menu->switchToTab("main"); | ||||
| 			} | ||||
| 			break; | ||||
| 		case EUserEvent::RESTART_GAME: | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -55,6 +55,7 @@ public: | ||||
|  | ||||
| 	void switchToTab(size_t index); | ||||
| 	void switchToTab(std::string name); | ||||
| 	size_t getActiveTab() const; | ||||
| }; | ||||
|  | ||||
| class CMenuEntry : public CIntObject | ||||
|   | ||||
| @@ -58,6 +58,11 @@ void CTabbedInt::setActive(size_t which) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| size_t CTabbedInt::getActive() const | ||||
| { | ||||
| 	return activeID; | ||||
| } | ||||
|  | ||||
| void CTabbedInt::reset() | ||||
| { | ||||
| 	deleteItem(activeTab); | ||||
|   | ||||
| @@ -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(); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user