1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-04 00:15:53 +02:00

Merge pull request #4665 from SoundSSGood/quickbackpack-shift+click

QuickBackpack window is now accessible by shift-clicking
This commit is contained in:
Ivan Savenko 2024-09-27 18:49:23 +03:00 committed by GitHub
commit dc45d82558
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 17 additions and 0 deletions

View File

@ -254,6 +254,10 @@ void EventDispatcher::handleLeftButtonClick(const Point & position, int toleranc
i->mouseClickedState = isPressed;
i->clickCancel(position);
}
else if(isPressed)
{
i->notFocusedClick();
}
}
}
}

View File

@ -51,6 +51,7 @@ public:
virtual void clickCancel(const Point & cursorPosition) {}
virtual void showPopupWindow(const Point & cursorPosition) {}
virtual void clickDouble(const Point & cursorPosition) {}
virtual void notFocusedClick() {};
/// Called when user pans screen by specified distance
virtual void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) {}

View File

@ -77,6 +77,7 @@ CHeroQuickBackpackWindow::CHeroQuickBackpackWindow(const CGHeroInstance * hero,
addSet(arts);
arts->setHero(hero);
addUsedEvents(GESTURE);
addUsedEvents(LCLICK);
pos.w = stretchedBackground->pos.w = arts->pos.w + 2 * windowMargin;
pos.h = stretchedBackground->pos.h = arts->pos.h + windowMargin;
}
@ -96,6 +97,11 @@ void CHeroQuickBackpackWindow::gesturePanning(const Point & initialPosition, con
redraw();
}
void CHeroQuickBackpackWindow::notFocusedClick()
{
close();
}
void CHeroQuickBackpackWindow::showAll(Canvas & to)
{
if(arts->getSlotsNum() == 0)

View File

@ -33,6 +33,7 @@ public:
CHeroQuickBackpackWindow(const CGHeroInstance * hero, ArtifactPosition targetSlot);
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
void notFocusedClick() override;
private:
std::shared_ptr<CArtifactsOfHeroQuickBackpack> arts;

View File

@ -86,6 +86,11 @@ void CWindowWithArtifacts::clickPressedOnArtPlace(const CGHeroInstance * hero, c
if(allowExchange || hero->id == heroArtOwner->id)
putPickedArtifact(*hero, slot);
}
else if(GH.isKeyboardShiftDown())
{
if(ArtifactUtils::isSlotEquipment(slot))
GH.windows().createAndPushWindow<CHeroQuickBackpackWindow>(hero, slot);
}
else if(auto art = hero->getArt(slot))
{
if(hero->getOwner() == LOCPLINT->playerID)