1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Implemented zoom reset shortcut (backspace)

This commit is contained in:
Ivan Savenko 2023-05-17 14:54:19 +03:00
parent 7504ceb256
commit 872b68c59a
4 changed files with 5 additions and 1 deletions

View File

@ -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}); } },

View File

@ -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,

View File

@ -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 },

View File

@ -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();