mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Merge pull request #944 from AgostonSzepessy/dev/agos/937
Add right click to Quick Recruit Window
This commit is contained in:
commit
2b0f02c832
@ -140,6 +140,7 @@ public:
|
|||||||
//double click
|
//double click
|
||||||
virtual void onDoubleClick(){}
|
virtual void onDoubleClick(){}
|
||||||
|
|
||||||
|
// These are the arguments that can be used to determine what kind of input the CIntObject will receive
|
||||||
enum {LCLICK=1, RCLICK=2, HOVER=4, MOVE=8, KEYBOARD=16, TIME=32, GENERAL=64, WHEEL=128, DOUBLECLICK=256, TEXTINPUT=512, MCLICK=1024, ALL=0xffff};
|
enum {LCLICK=1, RCLICK=2, HOVER=4, MOVE=8, KEYBOARD=16, TIME=32, GENERAL=64, WHEEL=128, DOUBLECLICK=256, TEXTINPUT=512, MCLICK=1024, ALL=0xffff};
|
||||||
const ui16 & active;
|
const ui16 & active;
|
||||||
void addUsedEvents(ui16 newActions);
|
void addUsedEvents(ui16 newActions);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "QuickRecruitmentWindow.h"
|
#include "QuickRecruitmentWindow.h"
|
||||||
#include "../gui/CGuiHandler.h"
|
#include "../gui/CGuiHandler.h"
|
||||||
#include "../../lib/CCreatureHandler.h"
|
#include "../../lib/CCreatureHandler.h"
|
||||||
|
#include "CCreatureWindow.h"
|
||||||
|
|
||||||
void CreaturePurchaseCard::initButtons()
|
void CreaturePurchaseCard::initButtons()
|
||||||
{
|
{
|
||||||
@ -46,6 +47,7 @@ void CreaturePurchaseCard::switchCreatureLevel()
|
|||||||
auto index = vstd::find_pos(upgradesID, creatureOnTheCard->idNumber);
|
auto index = vstd::find_pos(upgradesID, creatureOnTheCard->idNumber);
|
||||||
auto nextCreatureId = vstd::circularAt(upgradesID, ++index);
|
auto nextCreatureId = vstd::circularAt(upgradesID, ++index);
|
||||||
creatureOnTheCard = nextCreatureId.toCreature();
|
creatureOnTheCard = nextCreatureId.toCreature();
|
||||||
|
creatureClickArea = std::make_shared<CCreatureClickArea>(Point(pos.x + CCreatureClickArea::CREATURE_X_POS, pos.y + CCreatureClickArea::CREATURE_Y_POS), picture, creatureOnTheCard);
|
||||||
picture = std::make_shared<CCreaturePic>(parent->pos.x, parent->pos.y, creatureOnTheCard);
|
picture = std::make_shared<CCreaturePic>(parent->pos.x, parent->pos.y, creatureOnTheCard);
|
||||||
parent->updateAllSliders();
|
parent->updateAllSliders();
|
||||||
cost->set(creatureOnTheCard->cost * slider->getValue());
|
cost->set(creatureOnTheCard->cost * slider->getValue());
|
||||||
@ -96,8 +98,27 @@ void CreaturePurchaseCard::initView()
|
|||||||
{
|
{
|
||||||
picture = std::make_shared<CCreaturePic>(pos.x, pos.y, creatureOnTheCard);
|
picture = std::make_shared<CCreaturePic>(pos.x, pos.y, creatureOnTheCard);
|
||||||
background = std::make_shared<CPicture>("QuickRecruitmentWindow/CreaturePurchaseCard.png", pos.x-4, pos.y-50);
|
background = std::make_shared<CPicture>("QuickRecruitmentWindow/CreaturePurchaseCard.png", pos.x-4, pos.y-50);
|
||||||
|
initButtons();
|
||||||
|
|
||||||
|
creatureClickArea = std::make_shared<CCreatureClickArea>(Point(pos.x + CCreatureClickArea::CREATURE_X_POS, pos.y + CCreatureClickArea::CREATURE_Y_POS), picture, creatureOnTheCard);
|
||||||
|
|
||||||
initAmountInfo();
|
initAmountInfo();
|
||||||
initSlider();
|
initSlider();
|
||||||
initButtons();
|
|
||||||
initCostBox();
|
initCostBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreaturePurchaseCard::CCreatureClickArea::CCreatureClickArea(const Point & position, const std::shared_ptr<CCreaturePic> creaturePic, const CCreature * creatureOnTheCard)
|
||||||
|
: CIntObject(RCLICK),
|
||||||
|
creatureOnTheCard(creatureOnTheCard)
|
||||||
|
{
|
||||||
|
pos.x = position.x;
|
||||||
|
pos.y = position.y;
|
||||||
|
pos.w = CREATURE_WIDTH;
|
||||||
|
pos.h = CREATURE_HEIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreaturePurchaseCard::CCreatureClickArea::clickRight(tribool down, bool previousState)
|
||||||
|
{
|
||||||
|
if (down)
|
||||||
|
GH.pushIntT<CStackWindow>(creatureOnTheCard, true);
|
||||||
|
}
|
||||||
|
@ -25,6 +25,7 @@ public:
|
|||||||
QuickRecruitmentWindow * parent;
|
QuickRecruitmentWindow * parent;
|
||||||
int maxAmount;
|
int maxAmount;
|
||||||
void sliderMoved(int to);
|
void sliderMoved(int to);
|
||||||
|
|
||||||
CreaturePurchaseCard(const std::vector<CreatureID> & creaturesID, Point position, int creaturesMaxAmount, QuickRecruitmentWindow * parents);
|
CreaturePurchaseCard(const std::vector<CreatureID> & creaturesID, Point position, int creaturesMaxAmount, QuickRecruitmentWindow * parents);
|
||||||
private:
|
private:
|
||||||
void initView();
|
void initView();
|
||||||
@ -42,10 +43,28 @@ private:
|
|||||||
|
|
||||||
void initCostBox();
|
void initCostBox();
|
||||||
|
|
||||||
|
// This just wraps a clickeable area. There's a weird layout scheme in the file and
|
||||||
|
// it's easier to just add a separate invisble box on top
|
||||||
|
class CCreatureClickArea : public CIntObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CCreatureClickArea(const Point & pos, const std::shared_ptr<CCreaturePic> creaturePic, const CCreature * creatureOnTheCard);
|
||||||
|
void clickRight(tribool down, bool previousState) override;
|
||||||
|
const CCreature * creatureOnTheCard;
|
||||||
|
|
||||||
|
// These are obtained by guessing and checking. I'm not sure how the other numbers
|
||||||
|
// used to set positions were obtained; commit messages don't document it
|
||||||
|
static constexpr int CREATURE_WIDTH = 110;
|
||||||
|
static constexpr int CREATURE_HEIGHT = 132;
|
||||||
|
static constexpr int CREATURE_X_POS = 15;
|
||||||
|
static constexpr int CREATURE_Y_POS = 44;
|
||||||
|
};
|
||||||
|
|
||||||
std::shared_ptr<CButton> maxButton, minButton, creatureSwitcher;
|
std::shared_ptr<CButton> maxButton, minButton, creatureSwitcher;
|
||||||
std::shared_ptr<CLabel> availableAmount, purchaseAmount;
|
std::shared_ptr<CLabel> availableAmount, purchaseAmount;
|
||||||
std::shared_ptr<CCreaturePic> picture;
|
std::shared_ptr<CCreaturePic> picture;
|
||||||
std::shared_ptr<CreatureCostBox> cost;
|
std::shared_ptr<CreatureCostBox> cost;
|
||||||
std::vector<CreatureID> upgradesID;
|
std::vector<CreatureID> upgradesID;
|
||||||
std::shared_ptr<CPicture> background;
|
std::shared_ptr<CPicture> background;
|
||||||
|
std::shared_ptr<CCreatureClickArea> creatureClickArea;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user