mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-21 21:17:49 +02:00
use Strg instead mouse pos
This commit is contained in:
parent
dc81426b5e
commit
9a9cc10ee7
@ -305,27 +305,12 @@ void CHeroList::CHeroItem::gesture(bool on, const Point & initialPosition, const
|
|||||||
GH.windows().createAndPushWindow<RadialMenu>(pos.center(), menuElements, true);
|
GH.windows().createAndPushWindow<RadialMenu>(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)
|
void CHeroList::CHeroItem::keyPressed(EShortcut key)
|
||||||
{
|
{
|
||||||
if(!hero)
|
if(!hero)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!pos.isInside(GH.getCursorPosition()))
|
if(parent->selected != this->shared_from_this())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto & heroes = LOCPLINT->localState->getWanderingHeroes();
|
auto & heroes = LOCPLINT->localState->getWanderingHeroes();
|
||||||
@ -512,23 +497,9 @@ void CTownList::CTownItem::gesture(bool on, const Point & initialPosition, const
|
|||||||
GH.windows().createAndPushWindow<RadialMenu>(pos.center(), menuElements, true);
|
GH.windows().createAndPushWindow<RadialMenu>(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)
|
void CTownList::CTownItem::keyPressed(EShortcut key)
|
||||||
{
|
{
|
||||||
if(!pos.isInside(GH.getCursorPosition()))
|
if(parent->selected != this->shared_from_this())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const std::vector<const CGTownInstance *> towns = LOCPLINT->localState->getOwnedTowns();
|
const std::vector<const CGTownInstance *> towns = LOCPLINT->localState->getOwnedTowns();
|
||||||
|
@ -29,9 +29,10 @@ class CList : public Scrollable
|
|||||||
protected:
|
protected:
|
||||||
class CListItem : public CIntObject, public std::enable_shared_from_this<CListItem>
|
class CListItem : public CIntObject, public std::enable_shared_from_this<CListItem>
|
||||||
{
|
{
|
||||||
CList * parent;
|
|
||||||
std::shared_ptr<CIntObject> selection;
|
std::shared_ptr<CIntObject> selection;
|
||||||
public:
|
public:
|
||||||
|
CList * parent;
|
||||||
|
|
||||||
CListItem(CList * parent);
|
CListItem(CList * parent);
|
||||||
~CListItem();
|
~CListItem();
|
||||||
|
|
||||||
@ -55,9 +56,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const size_t size;
|
const size_t size;
|
||||||
|
|
||||||
//for selection\deselection
|
|
||||||
std::shared_ptr<CListItem> selected;
|
|
||||||
void select(std::shared_ptr<CListItem> which);
|
void select(std::shared_ptr<CListItem> which);
|
||||||
friend class CListItem;
|
friend class CListItem;
|
||||||
|
|
||||||
@ -81,6 +79,9 @@ protected:
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//for selection\deselection
|
||||||
|
std::shared_ptr<CListItem> selected;
|
||||||
|
|
||||||
/// functions that will be called when selection changes
|
/// functions that will be called when selection changes
|
||||||
CFunctionList<void()> onSelect;
|
CFunctionList<void()> onSelect;
|
||||||
|
|
||||||
@ -128,7 +129,6 @@ class CHeroList : public CList
|
|||||||
void open() override;
|
void open() override;
|
||||||
void showTooltip() override;
|
void showTooltip() override;
|
||||||
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
||||||
bool captureThisKey(EShortcut key) override;
|
|
||||||
void keyPressed(EShortcut key) override;
|
void keyPressed(EShortcut key) override;
|
||||||
std::string getHoverText() override;
|
std::string getHoverText() override;
|
||||||
};
|
};
|
||||||
@ -164,7 +164,6 @@ class CTownList : public CList
|
|||||||
void open() override;
|
void open() override;
|
||||||
void showTooltip() override;
|
void showTooltip() override;
|
||||||
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
||||||
bool captureThisKey(EShortcut key) override;
|
|
||||||
void keyPressed(EShortcut key) override;
|
void keyPressed(EShortcut key) override;
|
||||||
std::string getHoverText() override;
|
std::string getHoverText() override;
|
||||||
};
|
};
|
||||||
|
@ -242,15 +242,15 @@
|
|||||||
"townOpenThievesGuild": "G",
|
"townOpenThievesGuild": "G",
|
||||||
"townOpenVisitingHero": "Ctrl+H",
|
"townOpenVisitingHero": "Ctrl+H",
|
||||||
"townSwapArmies": "Space",
|
"townSwapArmies": "Space",
|
||||||
"listHeroUp": "PageUp",
|
"listHeroUp": "Ctrl+PageUp",
|
||||||
"listHeroDown": "PageDown",
|
"listHeroDown": "Ctrl+PageDown",
|
||||||
"listHeroTop": "Home",
|
"listHeroTop": "Ctrl+Home",
|
||||||
"listHeroBottom": "End",
|
"listHeroBottom": "Ctrl+End",
|
||||||
"listHeroDelete": "Delete",
|
"listHeroDelete": "Delete",
|
||||||
"listTownUp": "PageUp",
|
"listTownUp": "Ctrl+PageUp",
|
||||||
"listTownDown": "PageDown",
|
"listTownDown": "Ctrl+PageDown",
|
||||||
"listTownTop": "Home",
|
"listTownTop": "Ctrl+Home",
|
||||||
"listTownBottom": "End",
|
"listTownBottom": "Ctrl+End",
|
||||||
|
|
||||||
// Controller-specific
|
// Controller-specific
|
||||||
"mouseCursorX": [],
|
"mouseCursorX": [],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user