瀏覽代碼

Implemented zoom reset shortcut (backspace)

Ivan Savenko 2 年之前
父節點
當前提交
872b68c59a

+ 1 - 0
client/adventureMap/AdventureMapShortcuts.cpp

@@ -82,6 +82,7 @@ std::vector<AdventureMapShortcutState> AdventureMapShortcuts::getShortcuts()
 		{ EShortcut::GAME_OPEN_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); } },
 		{ EShortcut::ADVENTURE_NEXT_TOWN,        optionInMapView(),      [this]() { this->nextTown(); } },
 		{ EShortcut::ADVENTURE_NEXT_OBJECT,      optionInMapView(),      [this]() { this->nextObject(); } },
 		{ EShortcut::ADVENTURE_MOVE_HERO_SW,     optionHeroSelected(),   [this]() { this->moveHeroDirectional({-1, +1}); } },

+ 1 - 0
client/gui/Shortcut.h

@@ -107,6 +107,7 @@ enum class EShortcut
 	ADVENTURE_EXIT_WORLD_VIEW,
 	ADVENTURE_ZOOM_IN,
 	ADVENTURE_ZOOM_OUT,
+	ADVENTURE_ZOOM_RESET,
 
 	// Move hero one tile in specified direction. Bound to cursors & numpad buttons
 	ADVENTURE_MOVE_HERO_SW,

+ 2 - 0
client/gui/ShortcutHandler.cpp

@@ -118,6 +118,7 @@ std::vector<EShortcut> ShortcutHandler::translateKeycode(SDL_Keycode key) const
 		{SDLK_g,         EShortcut::ADVENTURE_THIEVES_GUILD   },
 		{SDLK_KP_PLUS,   EShortcut::ADVENTURE_ZOOM_IN         },
 		{SDLK_KP_MINUS,  EShortcut::ADVENTURE_ZOOM_OUT        },
+		{SDLK_BACKSPACE, EShortcut::ADVENTURE_ZOOM_RESET      },
 		{SDLK_q,         EShortcut::BATTLE_TOGGLE_QUEUE       },
 		{SDLK_c,         EShortcut::BATTLE_USE_CREATURE_SPELL },
 		{SDLK_s,         EShortcut::BATTLE_SURRENDER          },
@@ -257,6 +258,7 @@ EShortcut ShortcutHandler::findShortcut(const std::string & identifier ) const
 		{"adventureExitWorldView",   EShortcut::ADVENTURE_EXIT_WORLD_VIEW },
 		{"adventureZoomIn",          EShortcut::ADVENTURE_ZOOM_IN         },
 		{"adventureZoomOut",         EShortcut::ADVENTURE_ZOOM_OUT        },
+		{"adventureZoomReset",       EShortcut::ADVENTURE_ZOOM_RESET      },
 		{"battleToggleQueue",        EShortcut::BATTLE_TOGGLE_QUEUE       },
 		{"battleUseCreatureSpell",   EShortcut::BATTLE_USE_CREATURE_SPELL },
 		{"battleSurrender",          EShortcut::BATTLE_SURRENDER          },

+ 1 - 1
client/mapView/MapViewController.cpp

@@ -91,7 +91,7 @@ void MapViewController::modifyTileSize(int stepsChange)
 	// try to determine current zooming level and change it by requested number of steps
 	double currentZoomFactor = model->getSingleTileSize().x / 32.0;
 	double currentZoomSteps = std::round(std::log(currentZoomFactor) / std::log(1.1));
-	double newZoomSteps = currentZoomSteps + stepsChange;
+	double newZoomSteps = stepsChange != 0 ? currentZoomSteps + stepsChange : stepsChange;
 	double newZoomFactor = std::pow(1.1, newZoomSteps);
 
 	Point currentZoom = model->getSingleTileSize();