mirror of
https://github.com/vcmi/vcmi.git
synced 2025-10-08 23:22:25 +02:00
Merge pull request #6105 from GeorgeK1ng/garrison
Use buildin Garrison background
This commit is contained in:
@@ -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)
|
||||
{
|
||||
@@ -298,14 +287,49 @@ void CArmyTooltip::init(const InfoAboutArmy &army)
|
||||
}
|
||||
else
|
||||
{
|
||||
subtitle = LIBRARY->generaltexth->arraytxt[171 + 3*(slot.second.getCount())];
|
||||
subtitle = LIBRARY->generaltexth->arraytxt[171 + 3 * (slot.second.getCount())];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@@ -62,7 +62,7 @@ public:
|
||||
void showPopupWindow(const Point & cursorPosition) override;
|
||||
};
|
||||
|
||||
/// base class for hero/town/garrison tooltips
|
||||
/// base class for hero/town tooltips
|
||||
class CArmyTooltip : public CIntObject
|
||||
{
|
||||
std::shared_ptr<CLabel> title;
|
||||
@@ -74,6 +74,17 @@ public:
|
||||
CArmyTooltip(Point pos, const CArmedInstance * army);
|
||||
};
|
||||
|
||||
/// base class garrison tooltips
|
||||
class CGarrisonTooltip : public CIntObject
|
||||
{
|
||||
std::shared_ptr<CLabel> title;
|
||||
std::vector<std::shared_ptr<CAnimImage>> icons;
|
||||
std::vector<std::shared_ptr<CLabel>> subtitles;
|
||||
void init(const InfoAboutArmy& army);
|
||||
public:
|
||||
CGarrisonTooltip(Point pos, const InfoAboutArmy& army);
|
||||
};
|
||||
|
||||
/// Class for hero tooltip. Does not have any background!
|
||||
/// background for infoBox: ADSTATHR
|
||||
/// background for tooltip: HEROQVBK
|
||||
|
@@ -316,14 +316,22 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGHeroInstance * hero)
|
||||
}
|
||||
|
||||
CInfoBoxPopup::CInfoBoxPopup(Point position, const CGGarrison * garr)
|
||||
: AdventureMapPopup(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("TOWNQVBK"), position)
|
||||
: AdventureMapPopup(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin(settings["general"]["enableUiEnhancements"].Bool() ? "GARRIPOP" : "TOWNQVBK"), position)
|
||||
{
|
||||
InfoAboutTown iah;
|
||||
GAME->interface()->cb->getTownInfo(garr, iah);
|
||||
|
||||
OBJECT_CONSTRUCTION;
|
||||
tooltip = std::make_shared<CArmyTooltip>(Point(9, 10), iah);
|
||||
|
||||
|
||||
if(settings["general"]["enableUiEnhancements"].Bool())
|
||||
{
|
||||
tooltip = std::make_shared<CGarrisonTooltip>(Point(9, 10), iah);
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltip = std::make_shared<CArmyTooltip>(Point(9, 10), iah);
|
||||
}
|
||||
|
||||
addUsedEvents(DRAG_POPUP);
|
||||
|
||||
fitToScreen(10);
|
||||
|
Reference in New Issue
Block a user