ソースを参照

Quick backpack window on shift+click

SoundSSGood 1 年間 前
コミット
f0a5bcfebb

+ 4 - 0
client/gui/EventDispatcher.cpp

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

+ 1 - 0
client/gui/EventsReceiver.h

@@ -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) {}

+ 6 - 0
client/windows/CHeroBackpackWindow.cpp

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

+ 1 - 0
client/windows/CHeroBackpackWindow.h

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

+ 5 - 0
client/windows/CWindowWithArtifacts.cpp

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