From 9a9cc10ee7c98eda520ec09c4750bb6fe83189f5 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Fri, 9 Aug 2024 22:49:05 +0200 Subject: [PATCH] use Strg instead mouse pos --- client/adventureMap/CList.cpp | 33 ++------------------------------- client/adventureMap/CList.h | 11 +++++------ config/shortcutsConfig.json | 16 ++++++++-------- 3 files changed, 15 insertions(+), 45 deletions(-) diff --git a/client/adventureMap/CList.cpp b/client/adventureMap/CList.cpp index 48387bc31..17bacee15 100644 --- a/client/adventureMap/CList.cpp +++ b/client/adventureMap/CList.cpp @@ -305,27 +305,12 @@ void CHeroList::CHeroItem::gesture(bool on, const Point & initialPosition, const GH.windows().createAndPushWindow(pos.center(), menuElements, true); } -bool CHeroList::CHeroItem::captureThisKey(EShortcut key) -{ - - switch(key) - { - case EShortcut::LIST_HERO_UP: - case EShortcut::LIST_HERO_DOWN: - case EShortcut::LIST_HERO_TOP: - case EShortcut::LIST_HERO_BOTTOM: - case EShortcut::LIST_HERO_DELETE: - return hero && pos.isInside(GH.getCursorPosition()); - } - return false; -} - void CHeroList::CHeroItem::keyPressed(EShortcut key) { if(!hero) return; - if(!pos.isInside(GH.getCursorPosition())) + if(parent->selected != this->shared_from_this()) return; auto & heroes = LOCPLINT->localState->getWanderingHeroes(); @@ -512,23 +497,9 @@ void CTownList::CTownItem::gesture(bool on, const Point & initialPosition, const GH.windows().createAndPushWindow(pos.center(), menuElements, true); } -bool CTownList::CTownItem::captureThisKey(EShortcut key) -{ - - switch(key) - { - case EShortcut::LIST_TOWN_UP: - case EShortcut::LIST_TOWN_DOWN: - case EShortcut::LIST_TOWN_TOP: - case EShortcut::LIST_TOWN_BOTTOM: - return town && pos.isInside(GH.getCursorPosition()); - } - return false; -} - void CTownList::CTownItem::keyPressed(EShortcut key) { - if(!pos.isInside(GH.getCursorPosition())) + if(parent->selected != this->shared_from_this()) return; const std::vector towns = LOCPLINT->localState->getOwnedTowns(); diff --git a/client/adventureMap/CList.h b/client/adventureMap/CList.h index 157a4866e..bccd4fecf 100644 --- a/client/adventureMap/CList.h +++ b/client/adventureMap/CList.h @@ -29,9 +29,10 @@ class CList : public Scrollable protected: class CListItem : public CIntObject, public std::enable_shared_from_this { - CList * parent; std::shared_ptr selection; public: + CList * parent; + CListItem(CList * parent); ~CListItem(); @@ -55,9 +56,6 @@ protected: private: const size_t size; - - //for selection\deselection - std::shared_ptr selected; void select(std::shared_ptr which); friend class CListItem; @@ -81,6 +79,9 @@ protected: void update(); public: + //for selection\deselection + std::shared_ptr selected; + /// functions that will be called when selection changes CFunctionList onSelect; @@ -128,7 +129,6 @@ class CHeroList : public CList void open() override; void showTooltip() override; void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override; - bool captureThisKey(EShortcut key) override; void keyPressed(EShortcut key) override; std::string getHoverText() override; }; @@ -164,7 +164,6 @@ class CTownList : public CList void open() override; void showTooltip() override; void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override; - bool captureThisKey(EShortcut key) override; void keyPressed(EShortcut key) override; std::string getHoverText() override; }; diff --git a/config/shortcutsConfig.json b/config/shortcutsConfig.json index 668184dc0..ad1b25a36 100644 --- a/config/shortcutsConfig.json +++ b/config/shortcutsConfig.json @@ -242,15 +242,15 @@ "townOpenThievesGuild": "G", "townOpenVisitingHero": "Ctrl+H", "townSwapArmies": "Space", - "listHeroUp": "PageUp", - "listHeroDown": "PageDown", - "listHeroTop": "Home", - "listHeroBottom": "End", + "listHeroUp": "Ctrl+PageUp", + "listHeroDown": "Ctrl+PageDown", + "listHeroTop": "Ctrl+Home", + "listHeroBottom": "Ctrl+End", "listHeroDelete": "Delete", - "listTownUp": "PageUp", - "listTownDown": "PageDown", - "listTownTop": "Home", - "listTownBottom": "End", + "listTownUp": "Ctrl+PageUp", + "listTownDown": "Ctrl+PageDown", + "listTownTop": "Ctrl+Home", + "listTownBottom": "Ctrl+End", // Controller-specific "mouseCursorX": [],