mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Merge pull request #396 from FeniksFire/update
Update graphics for QuickRecruitmentWindow
This commit is contained in:
commit
e90fcea3d3
Binary file not shown.
Before Width: | Height: | Size: 5.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
Binary file not shown.
BIN
Mods/vcmi/Sprites/QuickRecruitmentWindow/costBackground.png
Normal file
BIN
Mods/vcmi/Sprites/QuickRecruitmentWindow/costBackground.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
@ -34,6 +34,13 @@ void CButton::update()
|
||||
}
|
||||
|
||||
int newPos = stateToIndex[int(state)];
|
||||
if(animateLonelyFrame)
|
||||
{
|
||||
if(state == PRESSED)
|
||||
image->moveBy(Point(1,1));
|
||||
else
|
||||
image->moveBy(Point(-1,-1));
|
||||
}
|
||||
if (newPos < 0)
|
||||
newPos = 0;
|
||||
|
||||
@ -85,6 +92,10 @@ void CButton::setImageOrder(int state1, int state2, int state3, int state4)
|
||||
update();
|
||||
}
|
||||
|
||||
void CButton::setAnimateLonelyFrame(bool agreement)
|
||||
{
|
||||
animateLonelyFrame = agreement;
|
||||
}
|
||||
void CButton::setState(ButtonState newState)
|
||||
{
|
||||
if (state == newState)
|
||||
|
@ -51,7 +51,7 @@ private:
|
||||
|
||||
CAnimImage * image; //image for this button
|
||||
CIntObject * overlay;//object-overlay, can be null
|
||||
|
||||
bool animateLonelyFrame = false;
|
||||
protected:
|
||||
void onButtonClicked(); // calls callback
|
||||
void update();//to refresh button after image or text change
|
||||
@ -79,6 +79,7 @@ public:
|
||||
void addHoverText(ButtonState state, std::string text);
|
||||
|
||||
void setImageOrder(int state1, int state2, int state3, int state4);
|
||||
void setAnimateLonelyFrame(bool agreement);
|
||||
void block(bool on);
|
||||
|
||||
/// State modifiers
|
||||
|
@ -887,6 +887,7 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInst
|
||||
CWindowObject(PLAYER_COLORED | BORDERED),
|
||||
hall(nullptr),
|
||||
fort(nullptr),
|
||||
fastArmyPurhase(nullptr),
|
||||
town(Town)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
@ -988,6 +989,7 @@ void CCastleInterface::recreateIcons()
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
delete fort;
|
||||
delete hall;
|
||||
delete fastArmyPurhase;
|
||||
size_t iconIndex = town->town->clientInfo.icons[town->hasFort()][town->builded >= CGI->modh->settings.MAX_BUILDING_PER_TURN];
|
||||
|
||||
icon->setFrame(iconIndex);
|
||||
@ -996,8 +998,10 @@ void CCastleInterface::recreateIcons()
|
||||
|
||||
hall = new CTownInfo( 80, 413, town, true);
|
||||
fort = new CTownInfo(122, 413, town, false);
|
||||
|
||||
fastArmyPurhase = new CButton(Point(122, 413), "itmcl.def", CButton::tooltip(), [&](){builds->enterToTheQuickRecruitmentWindow();});
|
||||
fastArmyPurhase->setImageOrder(town->fortLevel()-1,town->fortLevel()-1,town->fortLevel()-1,town->fortLevel()-1);
|
||||
fastArmyPurhase->setAnimateLonelyFrame(true);
|
||||
for (auto & elem : creainfo)
|
||||
delete elem;
|
||||
creainfo.clear();
|
||||
|
@ -26,12 +26,12 @@ void CreaturePurchaseCard::initButtons()
|
||||
|
||||
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_LSHIFT);
|
||||
maxButton = std::make_shared<CButton>(Point(pos.x + 52, pos.y + 180), "QuickRecruitmentWindow/QuickRecruitmentAllButton.def", CButton::tooltip(), std::bind(&CSlider::moveToMax,slider), SDLK_LSHIFT);
|
||||
}
|
||||
|
||||
void CreaturePurchaseCard::initMinButton()
|
||||
{
|
||||
minButton = std::make_shared<CButton>(Point(pos.x, pos.y + 178), "iam015.def", CButton::tooltip(), std::bind(&CSlider::moveToMin,slider), SDLK_LCTRL);
|
||||
minButton = std::make_shared<CButton>(Point(pos.x, pos.y + 180), "QuickRecruitmentWindow/QuickRecruitmentNoneButton.def", CButton::tooltip(), std::bind(&CSlider::moveToMin,slider), SDLK_LCTRL);
|
||||
}
|
||||
|
||||
void CreaturePurchaseCard::initCreatureSwitcherButton()
|
||||
@ -52,8 +52,8 @@ void CreaturePurchaseCard::switchCreatureLevel()
|
||||
|
||||
void CreaturePurchaseCard::initAmountInfo()
|
||||
{
|
||||
availableAmount = std::make_shared<CLabel>(pos.x + 24, pos.y + 144, FONT_SMALL, CENTER, Colors::YELLOW);
|
||||
purhaseAmount = std::make_shared<CLabel>(pos.x + 77, pos.y + 144, FONT_SMALL, CENTER, Colors::WHITE);
|
||||
availableAmount = std::make_shared<CLabel>(pos.x + 25, pos.y + 146, FONT_SMALL, CENTER, Colors::YELLOW);
|
||||
purhaseAmount = std::make_shared<CLabel>(pos.x + 76, pos.y + 146, FONT_SMALL, CENTER, Colors::WHITE);
|
||||
updateAmountInfo(0);
|
||||
}
|
||||
|
||||
|
@ -28,20 +28,20 @@ void QuickRecruitmentWindow::setButtons()
|
||||
|
||||
void QuickRecruitmentWindow::setCancelButton()
|
||||
{
|
||||
cancelButton = std::make_shared<CButton>(Point((pos.w / 2) + 47, 417), "ICN6432.DEF", CButton::tooltip(), [&](){ close(); }, SDLK_RETURN);
|
||||
cancelButton = std::make_shared<CButton>(Point((pos.w / 2) + 48, 418), "ICN6432.DEF", CButton::tooltip(), [&](){ close(); }, SDLK_RETURN);
|
||||
cancelButton->setImageOrder(0, 1, 2, 3);
|
||||
}
|
||||
|
||||
void QuickRecruitmentWindow::setBuyButton()
|
||||
{
|
||||
buyButton = std::make_shared<CButton>(Point((pos.w/2)-33, 417), "IBY6432.DEF", CButton::tooltip(), [&](){ purhaseUnits(); });
|
||||
buyButton = std::make_shared<CButton>(Point((pos.w/2)-32, 418), "IBY6432.DEF", CButton::tooltip(), [&](){ purhaseUnits(); });
|
||||
cancelButton->assignedKeys.insert(SDLK_ESCAPE);
|
||||
buyButton->setImageOrder(0, 1, 2, 3);
|
||||
}
|
||||
|
||||
void QuickRecruitmentWindow::setMaxButton()
|
||||
{
|
||||
maxButton = std::make_shared<CButton>(Point((pos.w/2)-113, 417), "IRCBTNS.DEF", CButton::tooltip(), [&](){ maxAllCards(cards); });
|
||||
maxButton = std::make_shared<CButton>(Point((pos.w/2)-112, 418), "IRCBTNS.DEF", CButton::tooltip(), [&](){ maxAllCards(cards); });
|
||||
maxButton->setImageOrder(0, 1, 2, 3);
|
||||
}
|
||||
|
||||
@ -73,6 +73,7 @@ void QuickRecruitmentWindow::initWindow(Rect startupPosition)
|
||||
pos.x -= 55 * (creaturesAmount - 3);
|
||||
}
|
||||
backgroundTexture = std::make_shared<CFilledTexture>("DIBOXBCK.pcx", Rect(0, 0, pos.w, pos.h));
|
||||
costBackground = std::make_shared<CPicture>("QuickRecruitmentWindow/costBackground.png", pos.w/2-113, pos.y+290);
|
||||
}
|
||||
|
||||
void QuickRecruitmentWindow::maxAllCards(std::vector<std::shared_ptr<CreaturePurchaseCard> > cards)
|
||||
|
@ -42,4 +42,5 @@ private:
|
||||
std::shared_ptr<CreatureCostBox> totalCost;
|
||||
std::vector<std::shared_ptr<CreaturePurchaseCard>> cards;
|
||||
std::shared_ptr<CFilledTexture> backgroundTexture;
|
||||
std::shared_ptr<CPicture> costBackground;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user