From 17ee363d8d4b1eef1d5d193d1ccc8f208a9c38fa Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:37:21 +0100 Subject: [PATCH] changed bonus source text pos --- Mods/vcmi/config/english.json | 6 +++--- client/windows/CCreatureWindow.cpp | 24 +++++++++++++++++++++--- client/windows/CCreatureWindow.h | 2 +- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Mods/vcmi/config/english.json b/Mods/vcmi/config/english.json index 7afc0f8ec..ac22082de 100644 --- a/Mods/vcmi/config/english.json +++ b/Mods/vcmi/config/english.json @@ -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", diff --git a/client/windows/CCreatureWindow.cpp b/client/windows/CCreatureWindow.cpp index 4613e9e63..e44809e31 100644 --- a/client/windows/CCreatureWindow.cpp +++ b/client/windows/CCreatureWindow.cpp @@ -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(p.x - 1, p.y, f, ETextAlignment::TOPLEFT, Colors::BLACK, t, maxLen)); + bonusSource[leftRight].push_back(std::make_shared(p.x + 1, p.y, f, ETextAlignment::TOPLEFT, Colors::BLACK, t, maxLen)); + bonusSource[leftRight].push_back(std::make_shared(p.x, p.y - 1, f, ETextAlignment::TOPLEFT, Colors::BLACK, t, maxLen)); + bonusSource[leftRight].push_back(std::make_shared(p.x, p.y + 1, f, ETextAlignment::TOPLEFT, Colors::BLACK, t, maxLen)); + bonusSource[leftRight].push_back(std::make_shared(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(bi.imagePath, position.x, position.y); - name[leftRight] = std::make_shared(position.x + 60, position.y + 2, FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, bi.name, 110); - description[leftRight] = std::make_shared(Rect(position.x + 60, position.y + 17, 137, 30), FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, bi.description); - bonusSource[leftRight] = std::make_shared(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(position.x + 60, position.y + 2, FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, bi.name, 137); + description[leftRight] = std::make_shared(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(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); } diff --git a/client/windows/CCreatureWindow.h b/client/windows/CCreatureWindow.h index 3f69f711d..a94196a26 100644 --- a/client/windows/CCreatureWindow.h +++ b/client/windows/CCreatureWindow.h @@ -87,7 +87,7 @@ class CStackWindow : public CWindowObject std::array, 2> name; std::array, 2> description; std::array, 2> frame; - std::array, 2> bonusSource; + std::array>, 2> bonusSource; public: BonusLineSection(CStackWindow * owner, size_t lineIndex, bool noScroll); };