mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
round_counter
This commit is contained in:
@ -34,6 +34,7 @@
|
||||
#include "../widgets/Buttons.h"
|
||||
#include "../widgets/Images.h"
|
||||
#include "../widgets/TextControls.h"
|
||||
#include "../widgets/MiscWidgets.h"
|
||||
#include "../windows/CMessage.h"
|
||||
#include "../windows/CSpellWindow.h"
|
||||
#include "../render/CAnimation.h"
|
||||
@ -787,11 +788,16 @@ void StackQueue::update()
|
||||
owner.getBattle()->battleGetTurnOrder(queueData, stackBoxes.size(), 0);
|
||||
|
||||
size_t boxIndex = 0;
|
||||
ui32 tmpTurn = -1;
|
||||
|
||||
for(size_t turn = 0; turn < queueData.size() && boxIndex < stackBoxes.size(); turn++)
|
||||
{
|
||||
for(size_t unitIndex = 0; unitIndex < queueData[turn].size() && boxIndex < stackBoxes.size(); boxIndex++, unitIndex++)
|
||||
stackBoxes[boxIndex]->setUnit(queueData[turn][unitIndex], turn);
|
||||
{
|
||||
ui32 currentTurn = owner.round + turn;
|
||||
stackBoxes[boxIndex]->setUnit(queueData[turn][unitIndex], turn, tmpTurn != currentTurn && owner.round != 0 ? (std::optional<ui32>)currentTurn : std::nullopt);
|
||||
tmpTurn = currentTurn;
|
||||
}
|
||||
}
|
||||
|
||||
for(; boxIndex < stackBoxes.size(); boxIndex++)
|
||||
@ -829,11 +835,15 @@ StackQueue::StackBox::StackBox(StackQueue * owner):
|
||||
{
|
||||
icon = std::make_shared<CAnimImage>(owner->icons, 0, 0, 5, 2);
|
||||
amount = std::make_shared<CLabel>(pos.w/2, pos.h - 7, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
|
||||
roundRect = std::make_shared<TransparentFilledRectangle>(Rect(0, 48, 15, 18), ColorRGBA(0, 0, 0, 255), ColorRGBA(241, 216, 120, 255));
|
||||
round = std::make_shared<CLabel>(4, pos.h + 1, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = std::make_shared<CAnimImage>(owner->icons, 0, 0, 9, 1);
|
||||
amount = std::make_shared<CLabel>(pos.w/2, pos.h - 8, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
|
||||
roundRect = std::make_shared<TransparentFilledRectangle>(Rect(0, 0, 15, 18), ColorRGBA(0, 0, 0, 255), ColorRGBA(241, 216, 120, 255));
|
||||
round = std::make_shared<CLabel>(4, 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
||||
|
||||
int icon_x = pos.w - 17;
|
||||
int icon_y = pos.h - 18;
|
||||
@ -843,7 +853,7 @@ StackQueue::StackBox::StackBox(StackQueue * owner):
|
||||
}
|
||||
}
|
||||
|
||||
void StackQueue::StackBox::setUnit(const battle::Unit * unit, size_t turn)
|
||||
void StackQueue::StackBox::setUnit(const battle::Unit * unit, size_t turn, std::optional<ui32> currentTurn)
|
||||
{
|
||||
if(unit)
|
||||
{
|
||||
@ -861,6 +871,15 @@ void StackQueue::StackBox::setUnit(const battle::Unit * unit, size_t turn)
|
||||
icon->setFrame(owner->getSiegeShooterIconID(), 1);
|
||||
|
||||
amount->setText(TextOperations::formatMetric(unit->getCount(), 4));
|
||||
if(currentTurn)
|
||||
{
|
||||
std::string tmp = std::to_string(*currentTurn);
|
||||
int len = graphics->fonts[FONT_SMALL]->getStringWidth(tmp);
|
||||
roundRect->pos.w = len + 6;
|
||||
round->setText(tmp);
|
||||
}
|
||||
roundRect->setEnabled(currentTurn.has_value());
|
||||
round->setEnabled(currentTurn.has_value());
|
||||
|
||||
if(stateIcon)
|
||||
{
|
||||
|
Reference in New Issue
Block a user