1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Add SHIFT + hover shortcut to show movement highlight while pressed.

This commit is contained in:
krs
2023-04-07 00:29:58 +03:00
parent 709a8a6eb3
commit 3194999809
3 changed files with 22 additions and 1 deletions

View File

@@ -198,6 +198,23 @@ void BattleWindow::keyPressed(const SDL_Keycode & key)
{
owner.actionsController->endCastingSpell();
}
else if(key == SDLK_LSHIFT)
{
// save and activate setting
Settings movementHighlightOnHover = settings.write["battle"]["movementHighlightOnHover"];
movementHighlightOnHoverCache = movementHighlightOnHover->Bool();
movementHighlightOnHover->Bool() = true;
}
}
void BattleWindow::keyReleased(const SDL_Keycode & key)
{
if(key == SDLK_LSHIFT)
{
// set back to initial state
Settings movementHighlightOnHover = settings.write["battle"]["movementHighlightOnHover"];
movementHighlightOnHover->Bool() = movementHighlightOnHoverCache;
}
}
void BattleWindow::clickRight(tribool down, bool previousState)

View File

@@ -85,6 +85,7 @@ public:
void activate() override;
void deactivate() override;
void keyPressed(const SDL_Keycode & key) override;
void keyReleased(const SDL_Keycode& key) override;
void clickRight(tribool down, bool previousState) override;
void show(SDL_Surface *to) override;
void showAll(SDL_Surface *to) override;
@@ -98,5 +99,8 @@ public:
/// Set possible alternative options. If more than 1 - the last will be considered as default option
void setAlternativeActions(const std::list<PossiblePlayerBattleAction> &);
private:
/// used to save the state of this setting on toggle.
bool movementHighlightOnHoverCache;
};

View File

@@ -418,7 +418,7 @@ void CGuiHandler::handleCurrentEvent( SDL_Event & current )
for(auto i = miCopy.begin(); i != miCopy.end() && continueEventHandling; i++)
if(vstd::contains(keyinterested,*i) && (!keysCaptured || (*i)->captureThisKey(key.keysym.sym)))
{
if (key.state == SDL_PRESSED)
if (key.state == SDL_PRESSED && key.repeat == 0) // function like key_DOWN, and not like a periodic key_Pressed check
(**i).keyPressed(key.keysym.sym);
if (key.state == SDL_RELEASED)
(**i).keyReleased(key.keysym.sym);