|
@@ -8,69 +8,88 @@
|
|
|
*
|
|
|
*/
|
|
|
#include "StdInc.h"
|
|
|
-#include "CreaturePurhaseCard.h"
|
|
|
+#include "CreaturePurchaseCard.h"
|
|
|
#include "CAdvmapInterface.h"
|
|
|
#include "CHeroWindow.h"
|
|
|
#include "../widgets/Buttons.h"
|
|
|
#include "../../CCallback.h"
|
|
|
#include "../CreatureCostBox.h"
|
|
|
#include "QuickRecruitmentWindow.h"
|
|
|
+#include "../gui/CGuiHandler.h"
|
|
|
|
|
|
-void CreaturePurhaseCard::initButtons()
|
|
|
+void CreaturePurchaseCard::initButtons()
|
|
|
{
|
|
|
initMaxButton();
|
|
|
initMinButton();
|
|
|
+ initCreatureSwitcherButton();
|
|
|
}
|
|
|
|
|
|
-void CreaturePurhaseCard::initMaxButton()
|
|
|
+void CreaturePurchaseCard::initMaxButton()
|
|
|
{
|
|
|
- maxButton = std::make_shared<CButton>(Point(pos.x + 52, pos.y + 178), "iam014.def", CButton::tooltip(), std::bind(&CSlider::moveToMax,slider), SDLK_m);
|
|
|
+ maxButton = std::make_shared<CButton>(Point(pos.x + 52, pos.y + 178), "iam014.def", CButton::tooltip(), std::bind(&CSlider::moveToMax,slider), SDLK_LSHIFT);
|
|
|
}
|
|
|
|
|
|
-void CreaturePurhaseCard::initMinButton()
|
|
|
+void CreaturePurchaseCard::initMinButton()
|
|
|
{
|
|
|
- minButton = std::make_shared<CButton>(Point(pos.x, pos.y + 178), "iam015.def", CButton::tooltip(), std::bind(&CSlider::moveToMin,slider), SDLK_m);
|
|
|
+ minButton = std::make_shared<CButton>(Point(pos.x, pos.y + 178), "iam015.def", CButton::tooltip(), std::bind(&CSlider::moveToMin,slider), SDLK_LCTRL);
|
|
|
}
|
|
|
|
|
|
-void CreaturePurhaseCard::initAmountInfo()
|
|
|
+void CreaturePurchaseCard::initCreatureSwitcherButton()
|
|
|
+{
|
|
|
+ creatureSwitcher = std::make_shared<CButton>(Point(pos.x + 20, pos.y-33), "iDv6432.def", CButton::tooltip(), [&](){ switchCreatureLevel(); });
|
|
|
+}
|
|
|
+
|
|
|
+void CreaturePurchaseCard::switchCreatureLevel()
|
|
|
+{
|
|
|
+ OBJECT_CONSTRUCTION_CAPTURING(ACTIVATE + DEACTIVATE + UPDATE + SHOWALL + SHARE_POS);
|
|
|
+ auto index = vstd::find_pos(upgradesID, creatureOnTheCard->idNumber);
|
|
|
+ auto nextCreatureId = vstd::circularAt(upgradesID, ++index);
|
|
|
+ creatureOnTheCard = nextCreatureId.toCreature();
|
|
|
+ picture = std::make_shared<CCreaturePic>(parent->pos.x, parent->pos.y, creatureOnTheCard);
|
|
|
+ parent->updateAllSliders();
|
|
|
+ cost->set(creatureOnTheCard->cost * slider->getValue());
|
|
|
+}
|
|
|
+
|
|
|
+void CreaturePurchaseCard::initAmountInfo()
|
|
|
{
|
|
|
availableAmount = std::make_shared<CLabel>(pos.x + 27, pos.y + 146, FONT_SMALL, CENTER, Colors::YELLOW);
|
|
|
purhaseAmount = std::make_shared<CLabel>(pos.x + 77, pos.y + 146, FONT_SMALL, CENTER, Colors::WHITE);
|
|
|
updateAmountInfo(0);
|
|
|
}
|
|
|
|
|
|
-void CreaturePurhaseCard::updateAmountInfo(int value)
|
|
|
+void CreaturePurchaseCard::updateAmountInfo(int value)
|
|
|
{
|
|
|
availableAmount->setText(boost::lexical_cast<std::string>(maxAmount-value));
|
|
|
purhaseAmount->setText(boost::lexical_cast<std::string>(value));
|
|
|
}
|
|
|
|
|
|
-void CreaturePurhaseCard::initSlider()
|
|
|
+void CreaturePurchaseCard::initSlider()
|
|
|
{
|
|
|
- slider = std::make_shared<CSlider>(Point(pos.x, pos.y + 158), 102, std::bind(&CreaturePurhaseCard::sliderMoved, this , _1), 0, maxAmount, 0);
|
|
|
+ slider = std::make_shared<CSlider>(Point(pos.x, pos.y + 158), 102, std::bind(&CreaturePurchaseCard::sliderMoved, this , _1), 0, maxAmount, 0);
|
|
|
}
|
|
|
|
|
|
-void CreaturePurhaseCard::initCostBox()
|
|
|
+void CreaturePurchaseCard::initCostBox()
|
|
|
{
|
|
|
cost = std::make_shared<CreatureCostBox>(Rect(pos.x, pos.y + 194, 97, 74), "");
|
|
|
cost->createItems(creatureOnTheCard->cost);
|
|
|
}
|
|
|
|
|
|
|
|
|
-void CreaturePurhaseCard::sliderMoved(int to)
|
|
|
+void CreaturePurchaseCard::sliderMoved(int to)
|
|
|
{
|
|
|
updateAmountInfo(to);
|
|
|
cost->set(creatureOnTheCard->cost * to);
|
|
|
parent->updateAllSliders();
|
|
|
}
|
|
|
|
|
|
-CreaturePurhaseCard::CreaturePurhaseCard(const CCreature * creature, Point position, int creaturesMaxAmount, QuickRecruitmentWindow * parents) : creatureOnTheCard(creature), parent(parents), maxAmount(creaturesMaxAmount)
|
|
|
+CreaturePurchaseCard::CreaturePurchaseCard(const std::vector<CreatureID> & creaturesID, Point position, int creaturesMaxAmount, QuickRecruitmentWindow * parents) : upgradesID(creaturesID), parent(parents), maxAmount(creaturesMaxAmount)
|
|
|
{
|
|
|
+ creatureOnTheCard = upgradesID.back().toCreature();
|
|
|
moveTo(Point(position.x, position.y));
|
|
|
initView();
|
|
|
}
|
|
|
|
|
|
-void CreaturePurhaseCard::initView()
|
|
|
+void CreaturePurchaseCard::initView()
|
|
|
{
|
|
|
picture = std::make_shared<CCreaturePic>(pos.x, pos.y, creatureOnTheCard);
|
|
|
initAmountInfo();
|