Browse Source

Set position for CreaturePurchaseCard

This will make it pick up on right clicks. It was 0 before, so it wasn't
doing it.
Agoston Szepessy 3 years ago
parent
commit
dfdaf57803
2 changed files with 16 additions and 1 deletions
  1. 14 1
      client/windows/CreaturePurchaseCard.cpp
  2. 2 0
      client/windows/CreaturePurchaseCard.h

+ 14 - 1
client/windows/CreaturePurchaseCard.cpp

@@ -17,6 +17,7 @@
 #include "QuickRecruitmentWindow.h"
 #include "../gui/CGuiHandler.h"
 #include "../../lib/CCreatureHandler.h"
+#include "CCreatureWindow.h"
 
 void CreaturePurchaseCard::initButtons()
 {
@@ -82,14 +83,26 @@ void CreaturePurchaseCard::sliderMoved(int to)
 	parent->updateAllSliders();
 }
 
+void CreaturePurchaseCard::clickRight(tribool down, bool previousState)
+{
+	if (down)
+		GH.pushIntT<CStackWindow>(creatureOnTheCard, true);
+}
+
 CreaturePurchaseCard::CreaturePurchaseCard(const std::vector<CreatureID> & creaturesID, Point position, int creaturesMaxAmount, QuickRecruitmentWindow * parents)
-	: upgradesID(creaturesID),
+	: CIntObject(RCLICK),
+	upgradesID(creaturesID),
 	parent(parents),
 	maxAmount(creaturesMaxAmount)
 {
 	creatureOnTheCard = upgradesID.back().toCreature();
 	moveTo(Point(position.x, position.y));
 	initView();
+
+	// Card's position needs to be set to the animation's width/height
+	// otherwise the clicks won't register
+	pos.w = picture->pos.w;
+	pos.h = picture->pos.h;
 }
 
 void CreaturePurchaseCard::initView()

+ 2 - 0
client/windows/CreaturePurchaseCard.h

@@ -25,6 +25,8 @@ public:
 	QuickRecruitmentWindow * parent;
 	int maxAmount;
 	void sliderMoved(int to);
+	void clickRight(tribool down, bool previousState) override;
+
 	CreaturePurchaseCard(const std::vector<CreatureID> & creaturesID, Point position, int creaturesMaxAmount, QuickRecruitmentWindow * parents);
 private:
 	void initView();