1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-18 03:21:27 +02:00

changed bonus source text pos

This commit is contained in:
Laserlicht 2024-11-02 14:37:21 +01:00
parent 5a72a65b31
commit 17ee363d8d
3 changed files with 25 additions and 7 deletions

View File

@ -28,11 +28,11 @@
"vcmi.adventureMap.movementPointsHeroInfo" : "(Movement points: %REMAINING / %POINTS)",
"vcmi.adventureMap.replayOpponentTurnNotImplemented" : "Sorry, replay opponent turn is not implemented yet!",
"vcmi.bonusSource.artifact" : "Art.",
"vcmi.bonusSource.creature" : "Crea.",
"vcmi.bonusSource.artifact" : "Artifact",
"vcmi.bonusSource.creature" : "Creature",
"vcmi.bonusSource.spell" : "Spell",
"vcmi.bonusSource.hero" : "Hero",
"vcmi.bonusSource.commander" : "Comm.",
"vcmi.bonusSource.commander" : "Commander",
"vcmi.capitalColors.0" : "Red",
"vcmi.capitalColors.1" : "Blue",

View File

@ -273,6 +273,24 @@ CStackWindow::BonusLineSection::BonusLineSection(CStackWindow * owner, size_t li
{BonusSource::COMMANDER, CGI->generaltexth->translate("vcmi.bonusSource.commander")},
};
auto drawBonusSourceText = [this, &bonusColors, &bonusNames](int leftRight, Point p, BonusInfo & bi)
{
if(!bonusColors.count(bi.bonusSource) || !bonusNames.count(bi.bonusSource))
return;
auto c = bonusColors[bi.bonusSource];
std::string t = bonusNames[bi.bonusSource];
int maxLen = 50;
EFonts f = FONT_TINY;
// 1px Black border
bonusSource[leftRight].push_back(std::make_shared<CLabel>(p.x - 1, p.y, f, ETextAlignment::TOPLEFT, Colors::BLACK, t, maxLen));
bonusSource[leftRight].push_back(std::make_shared<CLabel>(p.x + 1, p.y, f, ETextAlignment::TOPLEFT, Colors::BLACK, t, maxLen));
bonusSource[leftRight].push_back(std::make_shared<CLabel>(p.x, p.y - 1, f, ETextAlignment::TOPLEFT, Colors::BLACK, t, maxLen));
bonusSource[leftRight].push_back(std::make_shared<CLabel>(p.x, p.y + 1, f, ETextAlignment::TOPLEFT, Colors::BLACK, t, maxLen));
bonusSource[leftRight].push_back(std::make_shared<CLabel>(p.x, p.y, f, ETextAlignment::TOPLEFT, c, t, maxLen));
};
for(size_t leftRight : {0, 1})
{
auto position = offset[leftRight];
@ -282,9 +300,9 @@ CStackWindow::BonusLineSection::BonusLineSection(CStackWindow * owner, size_t li
{
BonusInfo & bi = parent->activeBonuses[bonusIndex];
icon[leftRight] = std::make_shared<CPicture>(bi.imagePath, position.x, position.y);
name[leftRight] = std::make_shared<CLabel>(position.x + 60, position.y + 2, FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, bi.name, 110);
description[leftRight] = std::make_shared<CMultiLineLabel>(Rect(position.x + 60, position.y + 17, 137, 30), FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, bi.description);
bonusSource[leftRight] = std::make_shared<CLabel>(position.x + 60 + 137, position.y + 2, FONT_TINY, ETextAlignment::TOPRIGHT, bonusColors.count(bi.bonusSource) ? bonusColors[bi.bonusSource] : Colors::BLACK, bonusNames.count(bi.bonusSource) ? bonusNames[bi.bonusSource] : "", 27);
name[leftRight] = std::make_shared<CLabel>(position.x + 60, position.y + 2, FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, bi.name, 137);
description[leftRight] = std::make_shared<CMultiLineLabel>(Rect(position.x + 60, position.y + 20, 137, 30), FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, bi.description);
drawBonusSourceText(leftRight, Point(position.x + 2, position.y + 39), bi);
frame[leftRight] = std::make_shared<GraphicalPrimitiveCanvas>(Rect(position.x - 1, position.y - 1, 52, 52));
frame[leftRight]->addRectangle(Point(0, 0), Point(52, 52), bonusColors.count(bi.bonusSource) ? bonusColors[bi.bonusSource] : Colors::BLACK);
}

View File

@ -87,7 +87,7 @@ class CStackWindow : public CWindowObject
std::array<std::shared_ptr<CLabel>, 2> name;
std::array<std::shared_ptr<CMultiLineLabel>, 2> description;
std::array<std::shared_ptr<GraphicalPrimitiveCanvas>, 2> frame;
std::array<std::shared_ptr<CLabel>, 2> bonusSource;
std::array<std::vector<std::shared_ptr<CLabel>>, 2> bonusSource;
public:
BonusLineSection(CStackWindow * owner, size_t lineIndex, bool noScroll);
};