From 9009dffebdda158a424e3dcf1202dadb37fd9291 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:51:33 +0100 Subject: [PATCH] add "other" for bonus display --- Mods/vcmi/config/english.json | 1 + client/windows/CCreatureWindow.cpp | 71 +++++++++++++++--------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Mods/vcmi/config/english.json b/Mods/vcmi/config/english.json index ac22082de..b0288519d 100644 --- a/Mods/vcmi/config/english.json +++ b/Mods/vcmi/config/english.json @@ -33,6 +33,7 @@ "vcmi.bonusSource.spell" : "Spell", "vcmi.bonusSource.hero" : "Hero", "vcmi.bonusSource.commander" : "Commander", + "vcmi.bonusSource.other" : "Other", "vcmi.capitalColors.0" : "Red", "vcmi.capitalColors.1" : "Blue", diff --git a/client/windows/CCreatureWindow.cpp b/client/windows/CCreatureWindow.cpp index e44809e31..f4f6d6f3c 100644 --- a/client/windows/CCreatureWindow.cpp +++ b/client/windows/CCreatureWindow.cpp @@ -250,45 +250,46 @@ CStackWindow::BonusLineSection::BonusLineSection(CStackWindow * owner, size_t li Point(6, 4), Point(214, 4) }; - - std::map bonusColors = { - {BonusSource::ARTIFACT, Colors::GREEN}, - {BonusSource::ARTIFACT_INSTANCE, Colors::GREEN}, - {BonusSource::CREATURE_ABILITY, Colors::YELLOW}, - {BonusSource::SPELL_EFFECT, Colors::ORANGE}, - {BonusSource::SECONDARY_SKILL, Colors::PURPLE}, - {BonusSource::HERO_SPECIAL, Colors::PURPLE}, - {BonusSource::STACK_EXPERIENCE, Colors::CYAN}, - {BonusSource::COMMANDER, Colors::CYAN}, - }; - - std::map bonusNames = { - {BonusSource::ARTIFACT, CGI->generaltexth->translate("vcmi.bonusSource.artifact")}, - {BonusSource::ARTIFACT_INSTANCE, CGI->generaltexth->translate("vcmi.bonusSource.artifact")}, - {BonusSource::CREATURE_ABILITY, CGI->generaltexth->translate("vcmi.bonusSource.creature")}, - {BonusSource::SPELL_EFFECT, CGI->generaltexth->translate("vcmi.bonusSource.spell")}, - {BonusSource::SECONDARY_SKILL, CGI->generaltexth->translate("vcmi.bonusSource.hero")}, - {BonusSource::HERO_SPECIAL, CGI->generaltexth->translate("vcmi.bonusSource.hero")}, - {BonusSource::STACK_EXPERIENCE, CGI->generaltexth->translate("vcmi.bonusSource.commander")}, - {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 drawBonusSource = [this](int leftRight, Point p, BonusInfo & bi) + { + std::map bonusColors = { + {BonusSource::ARTIFACT, Colors::GREEN}, + {BonusSource::ARTIFACT_INSTANCE, Colors::GREEN}, + {BonusSource::CREATURE_ABILITY, Colors::YELLOW}, + {BonusSource::SPELL_EFFECT, Colors::ORANGE}, + {BonusSource::SECONDARY_SKILL, Colors::PURPLE}, + {BonusSource::HERO_SPECIAL, Colors::PURPLE}, + {BonusSource::STACK_EXPERIENCE, Colors::CYAN}, + {BonusSource::COMMANDER, Colors::CYAN}, + }; + + std::map bonusNames = { + {BonusSource::ARTIFACT, CGI->generaltexth->translate("vcmi.bonusSource.artifact")}, + {BonusSource::ARTIFACT_INSTANCE, CGI->generaltexth->translate("vcmi.bonusSource.artifact")}, + {BonusSource::CREATURE_ABILITY, CGI->generaltexth->translate("vcmi.bonusSource.creature")}, + {BonusSource::SPELL_EFFECT, CGI->generaltexth->translate("vcmi.bonusSource.spell")}, + {BonusSource::SECONDARY_SKILL, CGI->generaltexth->translate("vcmi.bonusSource.hero")}, + {BonusSource::HERO_SPECIAL, CGI->generaltexth->translate("vcmi.bonusSource.hero")}, + {BonusSource::STACK_EXPERIENCE, CGI->generaltexth->translate("vcmi.bonusSource.commander")}, + {BonusSource::COMMANDER, CGI->generaltexth->translate("vcmi.bonusSource.commander")}, + }; - auto c = bonusColors[bi.bonusSource]; - std::string t = bonusNames[bi.bonusSource]; + auto c = bonusColors.count(bi.bonusSource) ? bonusColors[bi.bonusSource] : ColorRGBA(192, 192, 192); + std::string t = bonusNames.count(bi.bonusSource) ? bonusNames[bi.bonusSource] : CGI->generaltexth->translate("vcmi.bonusSource.other"); int maxLen = 50; EFonts f = FONT_TINY; + Point pText = p + Point(3, 40); // 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)); + bonusSource[leftRight].push_back(std::make_shared(pText.x - 1, pText.y, f, ETextAlignment::TOPLEFT, Colors::BLACK, t, maxLen)); + bonusSource[leftRight].push_back(std::make_shared(pText.x + 1, pText.y, f, ETextAlignment::TOPLEFT, Colors::BLACK, t, maxLen)); + bonusSource[leftRight].push_back(std::make_shared(pText.x, pText.y - 1, f, ETextAlignment::TOPLEFT, Colors::BLACK, t, maxLen)); + bonusSource[leftRight].push_back(std::make_shared(pText.x, pText.y + 1, f, ETextAlignment::TOPLEFT, Colors::BLACK, t, maxLen)); + bonusSource[leftRight].push_back(std::make_shared(pText.x, pText.y, f, ETextAlignment::TOPLEFT, c, t, maxLen)); + + frame[leftRight] = std::make_shared(Rect(p.x, p.y, 52, 52)); + frame[leftRight]->addRectangle(Point(0, 0), Point(52, 52), c); }; for(size_t leftRight : {0, 1}) @@ -302,9 +303,7 @@ CStackWindow::BonusLineSection::BonusLineSection(CStackWindow * owner, size_t li 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, 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); + drawBonusSource(leftRight, Point(position.x - 1, position.y - 1), bi); } } }