1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Update MiscWidgets.cpp

This commit is contained in:
George King
2025-09-03 13:52:49 +02:00
committed by GitHub
parent 1114afb479
commit 04d30cbc5e

View File

@@ -257,22 +257,9 @@ CMinorResDataBar::CMinorResDataBar()
CMinorResDataBar::~CMinorResDataBar() = default;
void CArmyTooltip::init(const InfoAboutArmy &army)
void BuildArmyStacksUI(const InfoAboutArmy& army, const std::vector<Point>& slotsPos, std::vector<std::shared_ptr<CAnimImage>>& icons, std::vector<std::shared_ptr<CLabel>>& subtitles)
{
OBJECT_CONSTRUCTION;
title = std::make_shared<CLabel>(66, 3, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, army.name);
std::vector<Point> slotsPos;
slotsPos.push_back(Point(36, 73));
slotsPos.push_back(Point(72, 73));
slotsPos.push_back(Point(108, 73));
slotsPos.push_back(Point(18, 122));
slotsPos.push_back(Point(54, 122));
slotsPos.push_back(Point(90, 122));
slotsPos.push_back(Point(126, 122));
for(auto & slot : army.army)
for(const auto& slot : army.army)
{
if(slot.first.getNum() >= GameConstants::ARMY_SIZE)
{
@@ -280,8 +267,10 @@ void CArmyTooltip::init(const InfoAboutArmy &army)
continue;
}
// Creature icon
icons.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("CPRSMALL"), slot.second.getType()->getIconIndex(), 0, slotsPos[slot.first.getNum()].x, slotsPos[slot.first.getNum()].y));
// Subtitle
std::string subtitle;
if(army.army.isDetailed)
{
@@ -305,7 +294,42 @@ void CArmyTooltip::init(const InfoAboutArmy &army)
subtitles.push_back(std::make_shared<CLabel>(slotsPos[slot.first.getNum()].x + 17, slotsPos[slot.first.getNum()].y + 39, FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, subtitle));
}
}
void CArmyTooltip::init(const InfoAboutArmy &army)
{
OBJECT_CONSTRUCTION;
title = std::make_shared<CLabel>(66, 3, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, army.name);
std::vector<Point> slotsPos;
slotsPos.push_back(Point(36, 73));
slotsPos.push_back(Point(72, 73));
slotsPos.push_back(Point(108, 73));
slotsPos.push_back(Point(18, 122));
slotsPos.push_back(Point(54, 122));
slotsPos.push_back(Point(90, 122));
slotsPos.push_back(Point(126, 122));
BuildArmyStacksUI(army, slotsPos, icons, subtitles);
}
void CGarrisonTooltip::init(const InfoAboutArmy& army)
{
OBJECT_CONSTRUCTION;
title = std::make_shared<CLabel>(142, 26, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, army.name);
std::vector<Point> slotsPos;
slotsPos.push_back(Point(14, 48));
slotsPos.push_back(Point(50, 48));
slotsPos.push_back(Point(86, 48));
slotsPos.push_back(Point(122, 48));
slotsPos.push_back(Point(158, 48));
slotsPos.push_back(Point(194, 48));
slotsPos.push_back(Point(230, 48));
BuildArmyStacksUI(army, slotsPos, icons, subtitles);
}
CArmyTooltip::CArmyTooltip(Point pos, const InfoAboutArmy & army):
@@ -314,6 +338,12 @@ CArmyTooltip::CArmyTooltip(Point pos, const InfoAboutArmy & army):
init(army);
}
CGarrisonTooltip::CGarrisonTooltip(Point pos, const InfoAboutArmy & army)
: CIntObject(0, pos)
{
init(army);
}
CArmyTooltip::CArmyTooltip(Point pos, const CArmedInstance * army):
CIntObject(0, pos)
{