diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 0a547ac97af..ce5328fdad9 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -873,8 +873,8 @@ namespace fheroes2 break; } - const int32_t textWidth = 108; - createNormalButton( _icnVsSprite[id][0], _icnVsSprite[id][1], textWidth, gettext_noop( "ACCEPT" ), isEvilInterface ); + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "ACCEPT" ), + isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK ); break; } @@ -894,8 +894,8 @@ namespace fheroes2 break; } - const int32_t textWidth = 108; - createNormalButton( _icnVsSprite[id][0], _icnVsSprite[id][1], textWidth, gettext_noop( "DECLINE" ), isEvilInterface ); + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "DECLINE" ), + isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK ); break; } @@ -934,35 +934,8 @@ namespace fheroes2 break; } - const int baseIcnID = isEvilInterface ? ICN::SYSTEME : ICN::SYSTEM; - - for ( int32_t i = 0; i < static_cast( _icnVsSprite[id].size() ); ++i ) { - Sprite & out = _icnVsSprite[id][i]; - const Sprite & originalButton = GetICN( baseIcnID, 11 + i ); - const int extendedAmount = 14; - out.resize( originalButton.width() + extendedAmount, originalButton.height() ); - out.reset(); - - const int widthEndPart = 4 + 2 * i; - const int widthFirstPart = originalButton.width() - widthEndPart; - const int widthMiddlePart = extendedAmount + i; - const int offsetXEndPart = widthFirstPart + widthMiddlePart; - const int startOffsetXMiddlePart = 36; - - // Copy left main body of button. - fheroes2::Copy( originalButton, 0, 0, out, 0, 0, widthFirstPart, originalButton.height() ); - - // Copy middle body of button. - fheroes2::Copy( originalButton, originalButton.width() - startOffsetXMiddlePart, 0, out, widthFirstPart, 0, widthMiddlePart, - originalButton.height() ); - - // Copy terminating right margin of the button. - fheroes2::Copy( originalButton, originalButton.width() - widthEndPart, 0, out, offsetXEndPart, 0, widthEndPart, originalButton.height() ); - } - - const fheroes2::FontColor buttonFontColor = isEvilInterface ? fheroes2::FontColor::GRAY : fheroes2::FontColor::WHITE; - renderTextOnButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "TRADE" ), { 6, 5 }, { 4, 6 }, { 100, 16 }, buttonFontColor ); - + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "TRADE" ), + isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::UNIFORMBAK_EVIL : ICN::UNIFORMBAK_GOOD ); break; } case ICN::BUTTON_SMALL_YES_GOOD: @@ -1023,8 +996,8 @@ namespace fheroes2 break; } - const int32_t textWidth = 85; - createNormalButton( _icnVsSprite[id][0], _icnVsSprite[id][1], textWidth, gettext_noop( "EXIT" ), isEvilInterface ); + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "EXIT" ), isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, + isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK ); break; } @@ -1115,8 +1088,8 @@ namespace fheroes2 break; } - const int32_t textWidth = 110; - createNormalButton( _icnVsSprite[id][0], _icnVsSprite[id][1], textWidth, gettext_noop( "DISMISS" ), isEvilInterface ); + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "DISMISS" ), + isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK ); break; } @@ -1132,8 +1105,8 @@ namespace fheroes2 break; } - const int32_t textWidth = 110; - createNormalButton( _icnVsSprite[id][0], _icnVsSprite[id][1], textWidth, gettext_noop( "UPGRADE" ), isEvilInterface ); + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "UPGRADE" ), + isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK ); break; } @@ -1149,8 +1122,8 @@ namespace fheroes2 break; } - const int32_t textWidth = 102; - createNormalButton( _icnVsSprite[id][0], _icnVsSprite[id][1], textWidth, gettext_noop( "RESTART" ), isEvilInterface ); + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "RESTART" ), + isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK ); break; } @@ -1799,14 +1772,14 @@ namespace fheroes2 case ICN::BUTTON_RESET_GOOD: { _icnVsSprite[id].resize( 2 ); - createNormalButton( _icnVsSprite[id][0], _icnVsSprite[id][1], 80, gettext_noop( "RESET" ), false ); + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "RESET" ), ICN::EMPTY_GOOD_BUTTON, ICN::STONEBAK ); break; } case ICN::BUTTON_START_GOOD: { _icnVsSprite[id].resize( 2 ); - createNormalButton( _icnVsSprite[id][0], _icnVsSprite[id][1], 80, gettext_noop( "START" ), false ); + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "START" ), ICN::EMPTY_GOOD_BUTTON, ICN::STONEBAK ); break; } @@ -1912,13 +1885,8 @@ namespace fheroes2 break; } - for ( int32_t i = 0; i < static_cast( _icnVsSprite[id].size() ); ++i ) { - Sprite & out = _icnVsSprite[id][i]; - out = GetICN( isEvilInterface ? ICN::SYSTEME : ICN::SYSTEM, 11 + i ); - } - - const fheroes2::FontColor buttonFontColor = isEvilInterface ? fheroes2::FontColor::GRAY : fheroes2::FontColor::WHITE; - renderTextOnButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "EXIT" ), { 7, 5 }, { 6, 6 }, { 86, 16 }, buttonFontColor ); + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "EXIT" ), isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, + isEvilInterface ? ICN::UNIFORMBAK_EVIL : ICN::UNIFORMBAK_GOOD ); break; } diff --git a/src/fheroes2/dialog/dialog_armyinfo.cpp b/src/fheroes2/dialog/dialog_armyinfo.cpp index 7f9b372277e..63b9d264369 100644 --- a/src/fheroes2/dialog/dialog_armyinfo.cpp +++ b/src/fheroes2/dialog/dialog_armyinfo.cpp @@ -524,7 +524,9 @@ int Dialog::ArmyInfo( const Troop & troop, int flags, bool isReflected, const in fheroes2::Button buttonDismiss( dst_pt.x, dst_pt.y, dismissButtonIcnID, 0, 1 ); const int exitButtonIcnID = isEvilInterface ? ICN::BUTTON_SMALL_EXIT_EVIL : ICN::BUTTON_SMALL_EXIT_GOOD; - dst_pt.x = pos_rt.x + 415; + const int32_t exitWidth = fheroes2::AGG::GetICN( exitButtonIcnID, 0 ).width(); + const int32_t interfaceAdjustment = isEvilInterface ? 0 : 18; + dst_pt.x = pos_rt.x + sprite_dialog.width() - 58 - exitWidth + interfaceAdjustment; dst_pt.y = pos_rt.y + 221; fheroes2::Button buttonExit( dst_pt.x, dst_pt.y, exitButtonIcnID, 0, 1 ); diff --git a/src/fheroes2/dialog/dialog_system_options.cpp b/src/fheroes2/dialog/dialog_system_options.cpp index 062b98fc115..22a5048cfb9 100644 --- a/src/fheroes2/dialog/dialog_system_options.cpp +++ b/src/fheroes2/dialog/dialog_system_options.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * fheroes2: https://github.com/ihhub/fheroes2 * - * Copyright (C) 2021 - 2023 * + * Copyright (C) 2021 - 2024 * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -241,16 +241,17 @@ namespace drawOptions(); - const auto refreshWindow = [&drawOptions, &emptyDialogRestorer, &display]() { + const fheroes2::Point buttonOffset( 112 + windowRoi.x, 362 + windowRoi.y ); + fheroes2::Button okayButton( buttonOffset.x, buttonOffset.y, isEvilInterface ? ICN::BUTTON_SMALL_OKAY_EVIL : ICN::BUTTON_SMALL_OKAY_GOOD, 0, 1 ); + okayButton.draw(); + + const auto refreshWindow = [&drawOptions, &emptyDialogRestorer, &okayButton, &display]() { emptyDialogRestorer.restore(); drawOptions(); + okayButton.draw(); display.render( emptyDialogRestorer.rect() ); }; - const fheroes2::Point buttonOffset( 112 + windowRoi.x, 362 + windowRoi.y ); - fheroes2::Button okayButton( buttonOffset.x, buttonOffset.y, isEvilInterface ? ICN::BUTTON_SMALL_OKAY_EVIL : ICN::BUTTON_SMALL_OKAY_GOOD, 0, 1 ); - okayButton.draw(); - display.render(); bool isTextSupportModeEnabled = conf.isTextSupportModeEnabled(); @@ -397,10 +398,7 @@ namespace if ( isTextSupportModeEnabled != conf.isTextSupportModeEnabled() ) { isTextSupportModeEnabled = conf.isTextSupportModeEnabled(); - emptyDialogRestorer.restore(); - drawOptions(); - - display.render( emptyDialogRestorer.rect() ); + refreshWindow(); } }