diff --git a/client/adventureMap/TurnTimerWidget.cpp b/client/adventureMap/TurnTimerWidget.cpp index 2aaa0be9f..b39b78305 100644 --- a/client/adventureMap/TurnTimerWidget.cpp +++ b/client/adventureMap/TurnTimerWidget.cpp @@ -17,6 +17,8 @@ #include "../GameInstance.h" #include "../media/ISoundPlayer.h" #include "../render/Graphics.h" +#include "../render/IFont.h" +#include "../render/IRenderHandler.h" #include "../widgets/Images.h" #include "../widgets/GraphicalPrimitiveCanvas.h" #include "../widgets/TextControls.h" @@ -45,29 +47,28 @@ TurnTimerWidget::TurnTimerWidget(const Point & position, PlayerColor player) const auto & timers = GAME->interface()->cb->getStartInfo()->turnTimerInfo; backgroundTexture = std::make_shared(ImagePath::builtin("DiBoxBck"), pos); // 1 px smaller on all sides + backgroundBorder = std::make_shared(pos, ColorRGBA(0, 0, 0, 128), Colors::BRIGHT_YELLOW); - if (isBattleMode) - backgroundBorder = std::make_shared(pos, ColorRGBA(0, 0, 0, 128), Colors::BRIGHT_YELLOW); - else - backgroundBorder = std::make_shared(pos, ColorRGBA(0, 0, 0, 128), Colors::BLACK); + int bigFontHeight = ENGINE->renderHandler().loadFont(FONT_BIG)->getLineHeight(); + pos.h += 6; if (isBattleMode) { - pos.w = 76; + pos.w = 77; - pos.h += 20; - playerLabelsMain[player] = std::make_shared(pos.w / 2, pos.h - 10, FONT_BIG, ETextAlignment::CENTER, graphics->playerColors[player.getNum()], ""); + pos.h += bigFontHeight - 4; + playerLabelsMain[player] = std::make_shared(pos.w / 2, pos.h - 2, FONT_BIG, ETextAlignment::BOTTOMCENTER, graphics->playerColors[player.getNum()], ""); if (timers.battleTimer != 0) { - pos.h += 20; - playerLabelsBattle[player] = std::make_shared(pos.w / 2, pos.h - 10, FONT_BIG, ETextAlignment::CENTER, graphics->playerColors[player.getNum()], ""); + pos.h += bigFontHeight; + playerLabelsBattle[player] = std::make_shared(pos.w / 2, pos.h - 2, FONT_BIG, ETextAlignment::BOTTOMCENTER, graphics->playerColors[player.getNum()], ""); } if (!timers.accumulatingUnitTimer && timers.unitTimer != 0) { - pos.h += 20; - playerLabelsUnit[player] = std::make_shared(pos.w / 2, pos.h - 10, FONT_BIG, ETextAlignment::CENTER, graphics->playerColors[player.getNum()], ""); + pos.h += bigFontHeight; + playerLabelsUnit[player] = std::make_shared(pos.w / 2, pos.h - 2, FONT_BIG, ETextAlignment::BOTTOMCENTER, graphics->playerColors[player.getNum()], ""); } updateTextLabel(player, GAME->interface()->cb->getPlayerTurnTime(player)); @@ -75,10 +76,10 @@ TurnTimerWidget::TurnTimerWidget(const Point & position, PlayerColor player) else { if (!timers.accumulatingTurnTimer && timers.baseTimer != 0) - pos.w = 120; + pos.w = 130; else - pos.w = 60; - + pos.w = 70; + for(PlayerColor player(0); player < PlayerColor::PLAYER_LIMIT; ++player) { if (GAME->interface()->cb->getStartInfo()->playerInfos.count(player) == 0) @@ -87,8 +88,8 @@ TurnTimerWidget::TurnTimerWidget(const Point & position, PlayerColor player) if (!GAME->interface()->cb->getStartInfo()->playerInfos.at(player).isControlledByHuman()) continue; - pos.h += 20; - playerLabelsMain[player] = std::make_shared(pos.w / 2, pos.h - 10, FONT_BIG, ETextAlignment::CENTER, graphics->playerColors[player.getNum()], ""); + pos.h += bigFontHeight - 4; + playerLabelsMain[player] = std::make_shared(pos.w / 2, pos.h - 2, FONT_BIG, ETextAlignment::BOTTOMCENTER, graphics->playerColors[player.getNum()], ""); updateTextLabel(player, GAME->interface()->cb->getPlayerTurnTime(player)); } diff --git a/client/battle/BattleWindow.cpp b/client/battle/BattleWindow.cpp index ace7348cb..0d55f4437 100644 --- a/client/battle/BattleWindow.cpp +++ b/client/battle/BattleWindow.cpp @@ -191,10 +191,10 @@ void BattleWindow::createQuickSpellWindow() OBJECT_CONSTRUCTION; quickSpellWindow = std::make_shared(owner); - quickSpellWindow->moveTo(Point(pos.x - 67, pos.y)); + quickSpellWindow->moveTo(Point(pos.x - 52, pos.y)); unitActionWindow = std::make_shared(owner); - unitActionWindow->moveTo(Point(pos.x + pos.w + 15, pos.y)); + unitActionWindow->moveTo(Point(pos.x + pos.w, pos.y)); if(settings["battle"]["enableQuickSpellPanel"].Bool()) showStickyQuickSpellWindow(); @@ -218,8 +218,8 @@ void BattleWindow::hideStickyQuickSpellWindow() quickSpellWindow->disable(); unitActionWindow->disable(); - setPositionInfoWindow(); createTimerInfoWindows(); + setPositionInfoWindow(); ENGINE->windows().totalRedraw(); } @@ -236,8 +236,8 @@ void BattleWindow::showStickyQuickSpellWindow() quickSpellWindow->setEnabled(quickSpellWindowVisible); unitActionWindow->setEnabled(unitActionWindowVisible); - setPositionInfoWindow(); createTimerInfoWindows(); + setPositionInfoWindow(); ENGINE->windows().totalRedraw(); } @@ -245,8 +245,8 @@ void BattleWindow::createTimerInfoWindows() { OBJECT_CONSTRUCTION; - int xOffsetAttacker = quickSpellWindow->isDisabled() ? 0 : -53; - int xOffsetDefender = unitActionWindow->isDisabled() ? 0 : 53; + int xOffsetAttacker = quickSpellWindow->isDisabled() ? 0 : -51; + int xOffsetDefender = unitActionWindow->isDisabled() ? 0 : 51; if(GAME->interface()->cb->getStartInfo()->turnTimerInfo.battleTimer != 0 || GAME->interface()->cb->getStartInfo()->turnTimerInfo.unitTimer != 0) { @@ -255,16 +255,16 @@ void BattleWindow::createTimerInfoWindows() if (attacker.isValidPlayer()) { - if (ENGINE->screenDimensions().x >= 1000) - attackerTimerWidget = std::make_shared(Point(-92 + xOffsetAttacker, 1), attacker); + if (ENGINE->screenDimensions().x >= 960) + attackerTimerWidget = std::make_shared(Point(-76 + xOffsetAttacker, 0), attacker); else attackerTimerWidget = std::make_shared(Point(1, 135), attacker); } if (defender.isValidPlayer()) { - if (ENGINE->screenDimensions().x >= 1000) - defenderTimerWidget = std::make_shared(Point(pos.w + 16 + xOffsetDefender, 1), defender); + if (ENGINE->screenDimensions().x >= 960) + defenderTimerWidget = std::make_shared(Point(pos.w + xOffsetDefender, 0), defender); else defenderTimerWidget = std::make_shared(Point(pos.w - 78, 135), defender); } @@ -383,34 +383,37 @@ void BattleWindow::updateQueue() void BattleWindow::setPositionInfoWindow() { - int xOffsetAttacker = quickSpellWindow->isDisabled() ? 0 : -53; - int xOffsetDefender = unitActionWindow->isDisabled() ? 0 : 53; + int xOffsetAttacker = quickSpellWindow->isDisabled() ? 0 : -51; + int xOffsetDefender = unitActionWindow->isDisabled() ? 0 : 51; + + int yOffsetAttacker = attackerTimerWidget ? attackerTimerWidget->pos.h + 9 : 0; + int yOffsetDefender = defenderTimerWidget ? defenderTimerWidget->pos.h + 9 : 0; if(defenderHeroWindow) { - Point position = (ENGINE->screenDimensions().x >= 1000) - ? Point(pos.x + pos.w + 15 + xOffsetDefender, pos.y + 60) + Point position = (ENGINE->screenDimensions().x >= 960) + ? Point(pos.x + pos.w - 1 + xOffsetDefender, pos.y - 1 + yOffsetDefender) : Point(pos.x + pos.w -79, pos.y + 195); defenderHeroWindow->moveTo(position); } if(attackerHeroWindow) { - Point position = (ENGINE->screenDimensions().x >= 1000) - ? Point(pos.x - 93 + xOffsetAttacker, pos.y + 60) + Point position = (ENGINE->screenDimensions().x >= 960) + ? Point(pos.x - 77 + xOffsetAttacker, pos.y - 1 + yOffsetAttacker) : Point(pos.x + 1, pos.y + 195); attackerHeroWindow->moveTo(position); } if(defenderStackWindow) { - Point position = (ENGINE->screenDimensions().x >= 1000) - ? Point(pos.x + pos.w + 15 + xOffsetDefender, defenderHeroWindow ? defenderHeroWindow->pos.y + 210 : pos.y + 60) + Point position = (ENGINE->screenDimensions().x >= 960) + ? Point(pos.x + pos.w - 1 + xOffsetDefender, defenderHeroWindow ? defenderHeroWindow->pos.y + 210 : pos.y - 1 + yOffsetDefender) : Point(pos.x + pos.w -79, defenderHeroWindow ? defenderHeroWindow->pos.y : pos.y + 195); defenderStackWindow->moveTo(position); } if(attackerStackWindow) { - Point position = (ENGINE->screenDimensions().x >= 1000) - ? Point(pos.x - 93 + xOffsetAttacker, attackerHeroWindow ? attackerHeroWindow->pos.y + 210 : pos.y + 60) + Point position = (ENGINE->screenDimensions().x >= 960) + ? Point(pos.x - 77 + xOffsetAttacker, attackerHeroWindow ? attackerHeroWindow->pos.y + 210 : pos.y - 1 + yOffsetAttacker) : Point(pos.x + 1, attackerHeroWindow ? attackerHeroWindow->pos.y : pos.y + 195); attackerStackWindow->moveTo(position); } @@ -444,8 +447,8 @@ void BattleWindow::updateStackInfoWindow(const CStack * stack) else attackerStackWindow = nullptr; - setPositionInfoWindow(); createTimerInfoWindows(); + setPositionInfoWindow(); } void BattleWindow::heroManaPointsChanged(const CGHeroInstance * hero) @@ -847,7 +850,7 @@ void BattleWindow::showAll(Canvas & to) CIntObject::showAll(to); if (ENGINE->screenDimensions().x != 800 || ENGINE->screenDimensions().y !=600) - CMessage::drawBorder(owner.curInt->playerID, to, pos.w+28, pos.h+29, pos.x-14, pos.y-15); + to.drawBorder(Rect(pos.x-1, pos.y, pos.w+2, pos.h+1), Colors::BRIGHT_YELLOW); } void BattleWindow::show(Canvas & to) diff --git a/client/battle/HeroInfoWindow.cpp b/client/battle/HeroInfoWindow.cpp index 7d15a07ef..c5e10ea60 100644 --- a/client/battle/HeroInfoWindow.cpp +++ b/client/battle/HeroInfoWindow.cpp @@ -26,7 +26,7 @@ HeroInfoBasicPanel::HeroInfoBasicPanel(const InfoAboutHero & hero, const Point * if(initializeBackground) { - background = std::make_shared(ImagePath::builtin("CHRPOP")); + background = std::make_shared(ImagePath::builtin("CHRPOP"), Rect(1, 1, 76, 200), 1, 1); background->setPlayerColor(hero.owner); } diff --git a/client/battle/StackInfoBasicPanel.cpp b/client/battle/StackInfoBasicPanel.cpp index 8165cf861..15e67e8ce 100644 --- a/client/battle/StackInfoBasicPanel.cpp +++ b/client/battle/StackInfoBasicPanel.cpp @@ -27,10 +27,10 @@ StackInfoBasicPanel::StackInfoBasicPanel(const CStack * stack, bool initializeBa if(initializeBackground) { - background = std::make_shared(ImagePath::builtin("CCRPOP")); + background = std::make_shared(ImagePath::builtin("CCRPOP"), Rect(1, 1, 76, 286), 1, 1); background->pos.y += 37; background->setPlayerColor(stack->getOwner()); - background2 = std::make_shared(ImagePath::builtin("CHRPOP")); + background2 = std::make_shared(ImagePath::builtin("CHRPOP"), Rect(1, 1, 76, 200), 1, 1); background2->setPlayerColor(stack->getOwner()); } diff --git a/config/widgets/battleWindow2.json b/config/widgets/battleWindow2.json index 7548caba1..873d20fde 100644 --- a/config/widgets/battleWindow2.json +++ b/config/widgets/battleWindow2.json @@ -8,6 +8,12 @@ "position": {"x": 0, "y": 556}, "image": "COPLACBR.bmp" }, + { + // fix transparent gap between content and border + "type": "transparentFilledRectangle", + "rect": {"x": 0, "y": 555, "w": 801, "h": 46}, + "color": [0, 0, 0, 255] + }, { "type": "picture", "name": "menuBattle",