浏览代码

Add separate shortcuts for adventure map and settings window

Ivan Savenko 1 年之前
父节点
当前提交
6ba36cf6c0

+ 52 - 5
client/adventureMap/AdventureMapShortcuts.cpp

@@ -12,6 +12,7 @@
 #include "AdventureMapShortcuts.h"
 
 #include "../CGameInfo.h"
+#include "../CMT.h"
 #include "../CPlayerInterface.h"
 #include "../CServerHandler.h"
 #include "../PlayerLocalState.h"
@@ -79,17 +80,20 @@ std::vector<AdventureMapShortcutState> AdventureMapShortcuts::getShortcuts()
 		{ EShortcut::GLOBAL_OPTIONS,             optionInMapView(),      [this]() { this->systemOptions(); } },
 		{ EShortcut::ADVENTURE_FIRST_HERO,       optionInMapView(),      [this]() { this->firstHero(); } },
 		{ EShortcut::ADVENTURE_NEXT_HERO,        optionHasNextHero(),    [this]() { this->nextHero(); } },
-		{ EShortcut::GAME_END_TURN,              optionCanEndTurn(),     [this]() { this->endTurn(); } },
+		{ EShortcut::ADVENTURE_END_TURN,         optionCanEndTurn(),     [this]() { this->endTurn(); } },
 		{ EShortcut::ADVENTURE_THIEVES_GUILD,    optionInMapView(),      [this]() { this->showThievesGuild(); } },
 		{ EShortcut::ADVENTURE_VIEW_SCENARIO,    optionInMapView(),      [this]() { this->showScenarioInfo(); } },
-		{ EShortcut::GAME_SAVE_GAME,             optionInMapView(),      [this]() { this->saveGame(); } },
-		{ EShortcut::GAME_LOAD_GAME,             optionInMapView(),      [this]() { this->loadGame(); } },
+		{ EShortcut::ADVENTURE_QUIT_GAME,        optionInMapView(),      [this]() { this->quitGame(); } },
+		{ EShortcut::ADVENTURE_TO_MAIN_MENU,     optionInMapView(),      [this]() { this->toMainMenu(); } },
+		{ EShortcut::ADVENTURE_SAVE_GAME,        optionInMapView(),      [this]() { this->saveGame(); } },
+		{ EShortcut::ADVENTURE_NEW_GAME,         optionInMapView(),      [this]() { this->newGame(); } },
+		{ EShortcut::ADVENTURE_LOAD_GAME,        optionInMapView(),      [this]() { this->loadGame(); } },
+		{ EShortcut::ADVENTURE_RESTART_GAME,     optionInMapView(),      [this]() { this->restartGame(); } },
 		{ EShortcut::ADVENTURE_DIG_GRAIL,        optionHeroSelected(),   [this]() { this->digGrail(); } },
 		{ EShortcut::ADVENTURE_VIEW_PUZZLE,      optionSidePanelActive(),[this]() { this->viewPuzzleMap(); } },
-		{ EShortcut::GAME_RESTART_GAME,          optionInMapView(),      [this]() { this->restartGame(); } },
 		{ EShortcut::ADVENTURE_VISIT_OBJECT,     optionCanVisitObject(), [this]() { this->visitObject(); } },
 		{ EShortcut::ADVENTURE_VIEW_SELECTED,    optionInMapView(),      [this]() { this->openObject(); } },
-		{ EShortcut::GAME_OPEN_MARKETPLACE,      optionInMapView(),      [this]() { this->showMarketplace(); } },
+		{ EShortcut::ADVENTURE_MARKETPLACE,      optionInMapView(),      [this]() { this->showMarketplace(); } },
 		{ EShortcut::ADVENTURE_ZOOM_IN,          optionSidePanelActive(),[this]() { this->zoom(+1); } },
 		{ EShortcut::ADVENTURE_ZOOM_OUT,         optionSidePanelActive(),[this]() { this->zoom(-1); } },
 		{ EShortcut::ADVENTURE_ZOOM_RESET,       optionSidePanelActive(),[this]() { this->zoom( 0); } },
@@ -300,6 +304,49 @@ void AdventureMapShortcuts::showScenarioInfo()
 	AdventureOptions::showScenarioInfo();
 }
 
+void AdventureMapShortcuts::toMainMenu()
+{
+	LOCPLINT->showYesNoDialog(
+		CGI->generaltexth->allTexts[578],
+		[]()
+		{
+			CSH->endGameplay();
+			GH.defActionsDef = 63;
+			CMM->menu->switchToTab("main");
+		},
+		0
+		);
+}
+
+void AdventureMapShortcuts::newGame()
+{
+	LOCPLINT->showYesNoDialog(
+		CGI->generaltexth->allTexts[578],
+		[]()
+		{
+			CSH->endGameplay();
+			GH.defActionsDef = 63;
+			CMM->menu->switchToTab("new");
+		},
+		nullptr
+		);
+}
+
+void AdventureMapShortcuts::quitGame()
+{
+	LOCPLINT->showYesNoDialog(
+		CGI->generaltexth->allTexts[578],
+		[]()
+		{
+			GH.dispatchMainThread( []()
+			{
+				handleQuit(false);
+			});
+		},
+		0
+		);
+}
+
 void AdventureMapShortcuts::saveGame()
 {
 	GH.windows().createAndPushWindow<CSavingScreen>();

+ 3 - 0
client/adventureMap/AdventureMapShortcuts.h

@@ -54,6 +54,9 @@ class AdventureMapShortcuts
 	void endTurn();
 	void showThievesGuild();
 	void showScenarioInfo();
+	void toMainMenu();
+	void newGame();
+	void quitGame();
 	void saveGame();
 	void loadGame();
 	void digGrail();

+ 22 - 15
client/gui/Shortcut.h

@@ -107,15 +107,14 @@ enum class EShortcut
 	MAPS_SORT_MAPS,
 	MAPS_SORT_CHANGEDATE,
 
+	SETTINGS_LOAD_GAME,
+	SETTINGS_SAVE_GAME,
+	SETTINGS_NEW_GAME,
+	SETTINGS_RESTART_GAME,
+	SETTINGS_TO_MAIN_MENU,
+	SETTINGS_QUIT_GAME,
+
 	// In-game hotkeys, require game state but may be available in windows other than adventure map
-	GAME_END_TURN,
-	GAME_LOAD_GAME,
-	GAME_SAVE_GAME,
-	GAME_RESTART_GAME,
-	GAME_TO_MAIN_MENU,
-	GAME_QUIT_GAME,
-	GAME_OPEN_MARKETPLACE,
-	GAME_OPEN_THIEVES_GUILD,
 	GAME_ACTIVATE_CONSOLE, // Tab, activates in-game console
 
 	// Adventure map screen
@@ -145,11 +144,19 @@ enum class EShortcut
 	ADVENTURE_KINGDOM_OVERVIEW,
 	ADVENTURE_QUEST_LOG,
 	ADVENTURE_CAST_SPELL,
+	ADVENTURE_MARKETPLACE,
 	ADVENTURE_THIEVES_GUILD,
 	ADVENTURE_EXIT_WORLD_VIEW,
 	ADVENTURE_ZOOM_IN,
 	ADVENTURE_ZOOM_OUT,
 	ADVENTURE_ZOOM_RESET,
+	ADVENTURE_END_TURN,
+	ADVENTURE_LOAD_GAME,
+	ADVENTURE_SAVE_GAME,
+	ADVENTURE_NEW_GAME,
+	ADVENTURE_RESTART_GAME,
+	ADVENTURE_TO_MAIN_MENU,
+	ADVENTURE_QUIT_GAME,
 
 	// Move hero one tile in specified direction. Bound to cursors & numpad buttons
 	ADVENTURE_MOVE_HERO_SW,
@@ -184,13 +191,13 @@ enum class EShortcut
 	MARKET_MAX_AMOUNT,
 	MARKET_SACRIFICE_ALL,
 	MARKET_SACRIFICE_BACKPACK,
-	MARKET_MODE_RESOURCE_PLAYER,
-	MARKET_MODE_ARTIFACT_RESOURCE,
-	MARKET_MODE_RESOURCE_ARTIFACT,
-	MARKET_MODE_CREATURE_RESOURCE,
-	MARKET_MODE_RESOURCE_RESOURCE,
-	MARKET_MODE_CREATURE_EXPERIENCE,
-	MARKET_MODE_ARTIFACT_EXPERIENCE,
+	MARKET_RESOURCE_PLAYER,
+	MARKET_ARTIFACT_RESOURCE,
+	MARKET_RESOURCE_ARTIFACT,
+	MARKET_CREATURE_RESOURCE,
+	MARKET_RESOURCE_RESOURCE,
+	MARKET_CREATURE_EXPERIENCE,
+	MARKET_ARTIFACT_EXPERIENCE,
 
 	SPECTATE_TRACK_HERO,
 	SPECTATE_SKIP_BATTLE,

+ 7 - 7
client/windows/CMarketWindow.cpp

@@ -147,28 +147,28 @@ void CMarketWindow::createChangeModeButtons(EMarketMode currentMode, const IMark
 	};
 
 	if(isButtonVisible(EMarketMode::RESOURCE_PLAYER))
-		addButton(AnimationPath::builtin("TPMRKBU1.DEF"), CGI->generaltexth->zelp[612], std::bind(&CMarketWindow::createTransferResources, this, market, hero), EShortcut::MARKET_MODE_RESOURCE_PLAYER);
+		addButton(AnimationPath::builtin("TPMRKBU1.DEF"), CGI->generaltexth->zelp[612], std::bind(&CMarketWindow::createTransferResources, this, market, hero), EShortcut::MARKET_RESOURCE_PLAYER);
 	if(isButtonVisible(EMarketMode::ARTIFACT_RESOURCE))
-		addButton(AnimationPath::builtin("TPMRKBU3.DEF"), CGI->generaltexth->zelp[613], std::bind(&CMarketWindow::createArtifactsSelling, this, market, hero), EShortcut::MARKET_MODE_ARTIFACT_RESOURCE);
+		addButton(AnimationPath::builtin("TPMRKBU3.DEF"), CGI->generaltexth->zelp[613], std::bind(&CMarketWindow::createArtifactsSelling, this, market, hero), EShortcut::MARKET_ARTIFACT_RESOURCE);
 	if(isButtonVisible(EMarketMode::RESOURCE_ARTIFACT))
-		addButton(AnimationPath::builtin("TPMRKBU2.DEF"), CGI->generaltexth->zelp[598], std::bind(&CMarketWindow::createArtifactsBuying, this, market, hero), EShortcut::MARKET_MODE_RESOURCE_ARTIFACT);
+		addButton(AnimationPath::builtin("TPMRKBU2.DEF"), CGI->generaltexth->zelp[598], std::bind(&CMarketWindow::createArtifactsBuying, this, market, hero), EShortcut::MARKET_RESOURCE_ARTIFACT);
 
 	buttonPos = Point(516, 520 - buttonHeightWithMargin);
 	if(isButtonVisible(EMarketMode::CREATURE_RESOURCE))
-		addButton(AnimationPath::builtin("TPMRKBU4.DEF"), CGI->generaltexth->zelp[599], std::bind(&CMarketWindow::createFreelancersGuild, this, market, hero), EShortcut::MARKET_MODE_CREATURE_RESOURCE);
+		addButton(AnimationPath::builtin("TPMRKBU4.DEF"), CGI->generaltexth->zelp[599], std::bind(&CMarketWindow::createFreelancersGuild, this, market, hero), EShortcut::MARKET_CREATURE_RESOURCE);
 	if(isButtonVisible(EMarketMode::RESOURCE_RESOURCE))
-		addButton(AnimationPath::builtin("TPMRKBU5.DEF"), CGI->generaltexth->zelp[605], std::bind(&CMarketWindow::createMarketResources, this, market, hero), EShortcut::MARKET_MODE_RESOURCE_RESOURCE);
+		addButton(AnimationPath::builtin("TPMRKBU5.DEF"), CGI->generaltexth->zelp[605], std::bind(&CMarketWindow::createMarketResources, this, market, hero), EShortcut::MARKET_RESOURCE_RESOURCE);
 	
 	buttonPos = Point(516, 421);
 	if(isButtonVisible(EMarketMode::CREATURE_EXP))
 	{
-		addButton(AnimationPath::builtin("ALTSACC.DEF"), CGI->generaltexth->zelp[572], std::bind(&CMarketWindow::createAltarCreatures, this, market, hero), EShortcut::MARKET_MODE_CREATURE_EXPERIENCE);
+		addButton(AnimationPath::builtin("ALTSACC.DEF"), CGI->generaltexth->zelp[572], std::bind(&CMarketWindow::createAltarCreatures, this, market, hero), EShortcut::MARKET_CREATURE_EXPERIENCE);
 		if(marketWidget->hero->getAlignment() == EAlignment::GOOD)
 			changeModeButtons.back()->block(true);
 	}
 	if(isButtonVisible(EMarketMode::ARTIFACT_EXP))
 	{
-		addButton(AnimationPath::builtin("ALTART.DEF"), CGI->generaltexth->zelp[580], std::bind(&CMarketWindow::createAltarArtifacts, this, market, hero), EShortcut::MARKET_MODE_ARTIFACT_EXPERIENCE);
+		addButton(AnimationPath::builtin("ALTART.DEF"), CGI->generaltexth->zelp[580], std::bind(&CMarketWindow::createAltarArtifacts, this, market, hero), EShortcut::MARKET_ARTIFACT_EXPERIENCE);
 		if(marketWidget->hero->getAlignment() == EAlignment::EVIL)
 			changeModeButtons.back()->block(true);
 	}