From 300d222327352c2d50d07f097b6dc9cc20c27a8c Mon Sep 17 00:00:00 2001 From: zenseii Date: Tue, 5 Sep 2023 03:30:09 +0200 Subject: [PATCH 01/18] Make the SKIP button translatable --- src/fheroes2/agg/agg_image.cpp | 25 +++++++++++++++++++++++- src/fheroes2/agg/icn.h | 2 ++ src/fheroes2/battle/battle_interface.cpp | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 546d60a7750..d54d4583fc1 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -159,7 +159,8 @@ namespace ICN::BUTTON_VIEWWORLD_EXIT_GOOD, ICN::BUTTON_VIEWWORLD_EXIT_EVIL, ICN::BUTTON_VERTICAL_DISMISS, - ICN::BUTTON_VERTICAL_EXIT }; + ICN::BUTTON_VERTICAL_EXIT, + ICN::BUTTON_SKIP }; #ifndef NDEBUG bool isLanguageDependentIcnId( const int id ) @@ -1905,6 +1906,27 @@ namespace fheroes2 break; } + case ICN::BUTTON_SKIP: { + _icnVsSprite[id].resize( 2 ); + const int32_t originalId = ICN::TEXTBAR; + + if ( useOriginalResources() ) { + _icnVsSprite[id][0] = GetICN( originalId, 0 ); + _icnVsSprite[id][1] = GetICN( originalId, 1 ); + break; + } + + for ( int i = 0; i < _icnVsSprite[id].size(); ++i ) { + Sprite & out = _icnVsSprite[id][i]; + out = GetICN( originalId, i ); + // Clean the button + Fill( out, 4 - i, 3, 41, 30, getButtonFillingColor( i == 0 ) ); + } + + renderTextOnButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "SKIP" ), { 5, 4 }, { 4, 5 }, { 41, 30 }, fheroes2::FontColor::WHITE ); + + break; + } default: // You're calling this function for non-specified ICN id. Check your logic! // Did you add a new image for one language without generating a default @@ -2507,6 +2529,7 @@ namespace fheroes2 case ICN::BUTTON_VIEWWORLD_EXIT_EVIL: case ICN::BUTTON_VERTICAL_DISMISS: case ICN::BUTTON_VERTICAL_EXIT: + case ICN::BUTTON_SKIP: generateLanguageSpecificImages( id ); return true; case ICN::PHOENIX: diff --git a/src/fheroes2/agg/icn.h b/src/fheroes2/agg/icn.h index 975c03d32f7..c42f1256a81 100644 --- a/src/fheroes2/agg/icn.h +++ b/src/fheroes2/agg/icn.h @@ -1078,6 +1078,8 @@ namespace ICN BUTTON_VERTICAL_DISMISS, BUTTON_VERTICAL_EXIT, + BUTTON_SKIP, + GAME_OPTION_ICON, // IMPORTANT! Put any new entry just above this one. diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index da0f50fde62..5dfdfe4dcf7 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -1248,7 +1248,7 @@ Battle::Interface::Interface( Arena & battleArena, const int32_t tileIndex ) btn_auto.setPosition( area.x, satusOffsetY ); btn_settings.setPosition( area.x, area.y + area.height - settingsRect.height ); - btn_skip.setICNInfo( ICN::TEXTBAR, 0, 1 ); + btn_skip.setICNInfo( ICN::BUTTON_SKIP, 0, 1 ); btn_skip.setPosition( area.x + area.width - btn_skip.area().width, area.y + area.height - btn_skip.area().height ); status.SetPosition( area.x + settingsRect.width, satusOffsetY ); From cc8438a922143fa98ecb631118fff3de30d087ab Mon Sep 17 00:00:00 2001 From: zenseii Date: Tue, 5 Sep 2023 03:30:42 +0200 Subject: [PATCH 02/18] Add skip text to Russian and Norwegian POs --- files/lang/nb.po | 11 +++++++---- files/lang/ru.po | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/files/lang/nb.po b/files/lang/nb.po index 95b1fedda67..59c2dc518da 100644 --- a/files/lang/nb.po +++ b/files/lang/nb.po @@ -1,12 +1,12 @@ # Norwegian translation for fheroes2 # Copyright (C) 2021 - 2022 fheroes2 team # This file is distributed under the same license as the fheroes2 package. -# +# msgid "" msgstr "" "Project-Id-Version: fheroes2\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-09-03 18:11+0200\n" +"POT-Creation-Date: 2023-09-05 03:19+0200\n" "PO-Revision-Date: 2023-09-03 18:42+0200\n" "Last-Translator: fheroes2 team \n" "Language-Team: \n" @@ -225,6 +225,9 @@ msgstr "" "A\n" "T" +msgid "SKIP" +msgstr "" + msgid "Warrior" msgstr "Kriger" @@ -5190,7 +5193,7 @@ msgstr "" msgid "Handicap" msgstr "Handikap" -# +# msgid "" "This lets you change the handicap of a particular player. Only humans may be " "handicapped. Handicapped players start with fewer resources and earn 15 or " @@ -5215,7 +5218,7 @@ msgstr "" msgid "Mild Handicap" msgstr "Lett handikap" -# +# msgid "" "Mild handicapped players start with fewer resources and earn 15% fewer " "resources per turn." diff --git a/files/lang/ru.po b/files/lang/ru.po index 6ecfb4fe779..aa997de2570 100644 --- a/files/lang/ru.po +++ b/files/lang/ru.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: fheroes2\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-09-04 01:25+0000\n" -"PO-Revision-Date: 2023-08-10 16:59+0300\n" +"POT-Creation-Date: 2023-09-05 03:19+0200\n" +"PO-Revision-Date: 2023-09-05 03:21+0200\n" "Last-Translator: fheroes2 team \n" "Language-Team: <>\n" "Language: ru\n" @@ -19,7 +19,7 @@ msgstr "" "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " "n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" "X-Launchpad-Export-Date: 2013-10-09 02:01+0000\n" -"X-Generator: Poedit 3.3.2\n" +"X-Generator: Poedit 3.2.2\n" msgid "" "BATTLE\n" @@ -216,6 +216,9 @@ msgid "" "T" msgstr "" +msgid "SKIP" +msgstr "ПРОП" + msgid "Warrior" msgstr "Воин" From a913b029026f49f51a73ef21fb704f317828e3fd Mon Sep 17 00:00:00 2001 From: zenseii Date: Tue, 5 Sep 2023 21:24:47 +0200 Subject: [PATCH 03/18] Update agg_image.cpp --- src/fheroes2/agg/agg_image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 8ba45b6a615..b17cff6a9e8 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -1918,7 +1918,7 @@ namespace fheroes2 break; } - for ( int i = 0; i < _icnVsSprite[id].size(); ++i ) { + for ( int32_t i = 0; i < static_cast( _icnVsSprite[id].size() ); ++i ) { Sprite & out = _icnVsSprite[id][i]; out = GetICN( originalId, i ); // Clean the button From 0d6592acb158145e075fd2019982ec38cc8a0229 Mon Sep 17 00:00:00 2001 From: zenseii Date: Wed, 8 Nov 2023 15:29:01 +0100 Subject: [PATCH 04/18] Make AUTO button translateable --- src/fheroes2/agg/agg_image.cpp | 25 +++++++++++++++++++++++- src/fheroes2/agg/icn.h | 1 + src/fheroes2/battle/battle_interface.cpp | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 10d90aed159..8dab6a3ddeb 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -164,7 +164,8 @@ namespace ICN::BUTTON_HSCORES_VERTICAL_STANDARD, ICN::DISMISS_HERO_DISABLED_BUTTON, ICN::NEW_CAMPAIGN_DISABLED_BUTTON, - ICN::BUTTON_SKIP }; + ICN::BUTTON_SKIP, + ICN::BUTTON_AUTO }; #ifndef NDEBUG bool isLanguageDependentIcnId( const int id ) @@ -1938,6 +1939,27 @@ namespace fheroes2 break; } + case ICN::BUTTON_AUTO: { + _icnVsSprite[id].resize( 2 ); + const int32_t originalId = ICN::TEXTBAR; + + if ( useOriginalResources() ) { + _icnVsSprite[id][0] = GetICN( originalId, 4 ); + _icnVsSprite[id][1] = GetICN( originalId, 5 ); + break; + } + + for ( int32_t i = 0; i < static_cast( _icnVsSprite[id].size() ); ++i ) { + Sprite & out = _icnVsSprite[id][i]; + out = GetICN( originalId, 4 + i ); + // Clean the button + Fill( out, 4 - i, 2 + i, 41, 13, getButtonFillingColor( i == 0 ) ); + } + + renderTextOnButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO" ), { 4, 2 }, { 3, 3 }, { 41, 13 }, fheroes2::FontColor::WHITE ); + + break; + } case ICN::BUTTON_HSCORES_VERTICAL_CAMPAIGN: case ICN::BUTTON_HSCORES_VERTICAL_EXIT: case ICN::BUTTON_HSCORES_VERTICAL_STANDARD: { @@ -2599,6 +2621,7 @@ namespace fheroes2 case ICN::BUTTON_VERTICAL_DISMISS: case ICN::BUTTON_VERTICAL_EXIT: case ICN::BUTTON_SKIP: + case ICN::BUTTON_AUTO: case ICN::BUTTON_HSCORES_VERTICAL_CAMPAIGN: case ICN::BUTTON_HSCORES_VERTICAL_EXIT: case ICN::BUTTON_HSCORES_VERTICAL_STANDARD: diff --git a/src/fheroes2/agg/icn.h b/src/fheroes2/agg/icn.h index 28c86446a2a..73b13c9a13c 100644 --- a/src/fheroes2/agg/icn.h +++ b/src/fheroes2/agg/icn.h @@ -1081,6 +1081,7 @@ namespace ICN BUTTON_HSCORES_VERTICAL_STANDARD, BUTTON_SKIP, + BUTTON_AUTO, GAME_OPTION_ICON, diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index d0fd327ea1d..4a305b2fd52 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -1246,7 +1246,7 @@ Battle::Interface::Interface( Arena & battleArena, const int32_t tileIndex ) // As '_mainSurface' is used to prepare battlefield screen to render on display it does not need to have a transform layer. _mainSurface._disableTransformLayer(); - btn_auto.setICNInfo( ICN::TEXTBAR, 4, 5 ); + btn_auto.setICNInfo( ICN::BUTTON_AUTO, 0, 1 ); btn_settings.setICNInfo( ICN::TEXTBAR, 6, 7 ); // opponents From d9ce4ea7a21dfd26e84979b12ae8e3ce0924e343 Mon Sep 17 00:00:00 2001 From: zenseii Date: Wed, 8 Nov 2023 16:37:24 +0100 Subject: [PATCH 05/18] Adjust AUTO button's width to text's width --- src/fheroes2/agg/agg_image.cpp | 33 +++++++++++++++++++++++++-------- src/fheroes2/agg/icn.h | 1 + src/fheroes2/gui/ui_button.cpp | 8 ++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 8dab6a3ddeb..3d12b66bac8 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -1949,14 +1949,7 @@ namespace fheroes2 break; } - for ( int32_t i = 0; i < static_cast( _icnVsSprite[id].size() ); ++i ) { - Sprite & out = _icnVsSprite[id][i]; - out = GetICN( originalId, 4 + i ); - // Clean the button - Fill( out, 4 - i, 2 + i, 41, 13, getButtonFillingColor( i == 0 ) ); - } - - renderTextOnButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO" ), { 4, 2 }, { 3, 3 }, { 41, 13 }, fheroes2::FontColor::WHITE ); + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO" ), ICN::EMPTY_GOOD_BATTLE_BUTTON, ICN::UNKNOWN ); break; } @@ -4237,6 +4230,30 @@ namespace fheroes2 return true; } + case ICN::EMPTY_GOOD_BATTLE_BUTTON: { + const int originalID = ICN::TEXTBAR; + loadICN( originalID ); + + if ( _icnVsSprite[originalID].size() < 3 ) { + return true; + } + _icnVsSprite[id].resize( 2 ); + + for ( int32_t i = 0; i < static_cast( _icnVsSprite[id].size() ); ++i ) { + const Sprite & original = GetICN( originalID, 4 + i ); + + Sprite & out = _icnVsSprite[id][i]; + // the empty button needs to shortened by 1 px so that when it is divided by 3 in resizeButton() in ui_tools it will give an integer result + out.resize( original.width() - 1, original.height() ); + + Copy( original, 0, 0, out, 0, 0, original.width() - 5 - i, original.height() ); + Copy( original, original.width() - 4 - i, 0, out, original.width() - 5 - i, 0, 4 + i, original.height() ); + + Fill( out, 4 - i, 2 + i, 40, 13, getButtonFillingColor( i == 0 ) ); + } + + return true; + } case ICN::EMPTY_GOOD_MEDIUM_BUTTON: case ICN::EMPTY_EVIL_MEDIUM_BUTTON: { const bool isGoodInterface = ( id == ICN::EMPTY_GOOD_MEDIUM_BUTTON ); diff --git a/src/fheroes2/agg/icn.h b/src/fheroes2/agg/icn.h index 73b13c9a13c..47318dd6381 100644 --- a/src/fheroes2/agg/icn.h +++ b/src/fheroes2/agg/icn.h @@ -997,6 +997,7 @@ namespace ICN EMPTY_POL_BUTTON, EMPTY_GUILDWELL_BUTTON, EMPTY_VERTICAL_GOOD_BUTTON, + EMPTY_GOOD_BATTLE_BUTTON, BUTTON_STANDARD_GAME, BUTTON_CAMPAIGN_GAME, diff --git a/src/fheroes2/gui/ui_button.cpp b/src/fheroes2/gui/ui_button.cpp index da022062dea..6754e139ad0 100644 --- a/src/fheroes2/gui/ui_button.cpp +++ b/src/fheroes2/gui/ui_button.cpp @@ -127,6 +127,14 @@ namespace releasedOffset = { 5, 52 }; pressedOffset = { 4, 53 }; break; + case ICN::EMPTY_GOOD_BATTLE_BUTTON: + font = fheroes2::FontColor::WHITE; + textMargin = 1 + 1; + minimumTextAreaWidth = 41; + backgroundBorders = 4 + 4; + releasedOffset = { 4, 1 }; + pressedOffset = { 3, 2 }; + break; default: // Was a new empty button template added? assert( 0 ); From 3a39cb761ed0a97fdd11c96a0757f536990cb385 Mon Sep 17 00:00:00 2001 From: zenseii Date: Wed, 8 Nov 2023 16:39:40 +0100 Subject: [PATCH 06/18] Adjust status bar position according to AUTO width --- src/fheroes2/battle/battle_interface.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 4a305b2fd52..12182fe01f3 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -1259,15 +1259,15 @@ Battle::Interface::Interface( Arena & battleArena, const int32_t tileIndex ) const fheroes2::Rect & area = border.GetArea(); - const fheroes2::Rect settingsRect = btn_settings.area(); - const int32_t satusOffsetY = area.y + area.height - settingsRect.height - btn_auto.area().height; - btn_auto.setPosition( area.x, satusOffsetY ); - btn_settings.setPosition( area.x, area.y + area.height - settingsRect.height ); + const fheroes2::Rect autoButtonRect = btn_auto.area(); + const int32_t statusOffsetY = area.y + area.height - autoButtonRect.height - btn_auto.area().height; + btn_auto.setPosition( area.x, statusOffsetY ); + btn_settings.setPosition( area.x, area.y + area.height - autoButtonRect.height ); btn_skip.setICNInfo( ICN::BUTTON_SKIP, 0, 1 ); btn_skip.setPosition( area.x + area.width - btn_skip.area().width, area.y + area.height - btn_skip.area().height ); - status.SetPosition( area.x + settingsRect.width, satusOffsetY ); + status.SetPosition( area.x + autoButtonRect.width, statusOffsetY ); listlog = std::make_unique(); From b405328b24d6a743d9f93dd412de1f4b9fae09b2 Mon Sep 17 00:00:00 2001 From: zenseii Date: Wed, 8 Nov 2023 16:41:39 +0100 Subject: [PATCH 07/18] Code style --- src/fheroes2/agg/agg_image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 3d12b66bac8..738ebee4186 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -4252,7 +4252,7 @@ namespace fheroes2 Fill( out, 4 - i, 2 + i, 40, 13, getButtonFillingColor( i == 0 ) ); } - return true; + return true; } case ICN::EMPTY_GOOD_MEDIUM_BUTTON: case ICN::EMPTY_EVIL_MEDIUM_BUTTON: { From b1e417d7f518759eaf1602c49233f8ef0b3efb8c Mon Sep 17 00:00:00 2001 From: zenseii Date: Wed, 8 Nov 2023 16:42:37 +0100 Subject: [PATCH 08/18] code style --- src/fheroes2/agg/agg_image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 738ebee4186..82eda4a652b 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -4252,7 +4252,7 @@ namespace fheroes2 Fill( out, 4 - i, 2 + i, 40, 13, getButtonFillingColor( i == 0 ) ); } - return true; + return true; } case ICN::EMPTY_GOOD_MEDIUM_BUTTON: case ICN::EMPTY_EVIL_MEDIUM_BUTTON: { From 165109e5073b84bba2cbd481db56eda38f7adef7 Mon Sep 17 00:00:00 2001 From: zenseii Date: Wed, 8 Nov 2023 21:56:56 +0100 Subject: [PATCH 09/18] Auto-adjust SKIP according to text width --- src/fheroes2/agg/agg_image.cpp | 33 +++++++++++++++++++++++++-------- src/fheroes2/agg/icn.h | 1 + src/fheroes2/gui/ui_button.cpp | 8 ++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 82eda4a652b..4f3658b53e6 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -1928,14 +1928,7 @@ namespace fheroes2 break; } - for ( int32_t i = 0; i < static_cast( _icnVsSprite[id].size() ); ++i ) { - Sprite & out = _icnVsSprite[id][i]; - out = GetICN( originalId, i ); - // Clean the button - Fill( out, 4 - i, 3, 41, 30, getButtonFillingColor( i == 0 ) ); - } - - renderTextOnButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "SKIP" ), { 5, 4 }, { 4, 5 }, { 41, 30 }, fheroes2::FontColor::WHITE ); + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "SKIP" ), ICN::EMPTY_GOOD_SKIP_BUTTON, ICN::UNKNOWN ); break; } @@ -4254,6 +4247,30 @@ namespace fheroes2 return true; } + case ICN::EMPTY_GOOD_SKIP_BUTTON: { + const int originalID = ICN::TEXTBAR; + loadICN( originalID ); + + if ( _icnVsSprite[originalID].size() < 3 ) { + return true; + } + _icnVsSprite[id].resize( 2 ); + + for ( int32_t i = 0; i < static_cast( _icnVsSprite[id].size() ); ++i ) { + const Sprite & original = GetICN( originalID, 0 + i ); + + Sprite & out = _icnVsSprite[id][i]; + // the empty button needs to shortened by 1 px so that when it is divided by 3 in resizeButton() in ui_tools it will give an integer result + out.resize( original.width() - 1, original.height() ); + + Copy( original, 0, 0, out, 0, 0, original.width() - 5 - i, original.height() ); + Copy( original, original.width() - 4 - i, 0, out, original.width() - 5 - i, 0, 4 + i, original.height() ); + + Fill( out, 4 - i, 3, 40, 30 + 2 * i, getButtonFillingColor( i == 0 ) ); + } + + return true; + } case ICN::EMPTY_GOOD_MEDIUM_BUTTON: case ICN::EMPTY_EVIL_MEDIUM_BUTTON: { const bool isGoodInterface = ( id == ICN::EMPTY_GOOD_MEDIUM_BUTTON ); diff --git a/src/fheroes2/agg/icn.h b/src/fheroes2/agg/icn.h index 47318dd6381..d7064116f60 100644 --- a/src/fheroes2/agg/icn.h +++ b/src/fheroes2/agg/icn.h @@ -998,6 +998,7 @@ namespace ICN EMPTY_GUILDWELL_BUTTON, EMPTY_VERTICAL_GOOD_BUTTON, EMPTY_GOOD_BATTLE_BUTTON, + EMPTY_GOOD_SKIP_BUTTON, BUTTON_STANDARD_GAME, BUTTON_CAMPAIGN_GAME, diff --git a/src/fheroes2/gui/ui_button.cpp b/src/fheroes2/gui/ui_button.cpp index 6754e139ad0..f55618127c1 100644 --- a/src/fheroes2/gui/ui_button.cpp +++ b/src/fheroes2/gui/ui_button.cpp @@ -135,6 +135,14 @@ namespace releasedOffset = { 4, 1 }; pressedOffset = { 3, 2 }; break; + case ICN::EMPTY_GOOD_SKIP_BUTTON: + font = fheroes2::FontColor::WHITE; + textMargin = 1 + 1; + minimumTextAreaWidth = 40; + backgroundBorders = 4 + 4; + releasedOffset = { 4, 11 }; + pressedOffset = { 3, 12 }; + break; default: // Was a new empty button template added? assert( 0 ); From d850a6e74ff00ae3f1f68c72976948c22f1716eb Mon Sep 17 00:00:00 2001 From: zenseii Date: Thu, 9 Nov 2023 23:57:16 +0100 Subject: [PATCH 10/18] Remove unused half-height skip button Leftover from when we had the WAIT button --- src/fheroes2/agg/agg_image.cpp | 13 ------------- src/fheroes2/agg/icn.h | 1 - 2 files changed, 14 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 4f3658b53e6..23937efa338 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -2505,19 +2505,6 @@ namespace fheroes2 } } return true; - case ICN::BATTLESKIP: - _icnVsSprite[id].resize( 2 ); - for ( uint32_t i = 0; i < 2; ++i ) { - Sprite & out = _icnVsSprite[id][i]; - out = GetICN( ICN::TEXTBAR, 4 + i ); - - // clean the button - Blit( GetICN( ICN::SYSTEM, 11 + i ), 3, 8, out, 3, 1, 43, 14 ); - - // add 'skip' - Blit( GetICN( ICN::TEXTBAR, i ), 3, 10, out, 3, 0, 43, 14 ); - } - return true; case ICN::BUYMAX: case ICN::BUTTON_NEW_GAME_GOOD: case ICN::BUTTON_NEW_GAME_EVIL: diff --git a/src/fheroes2/agg/icn.h b/src/fheroes2/agg/icn.h index d7064116f60..07ce02289e9 100644 --- a/src/fheroes2/agg/icn.h +++ b/src/fheroes2/agg/icn.h @@ -909,7 +909,6 @@ namespace ICN ROUTERED, YELLOW_FONT, YELLOW_SMALLFONT, - BATTLESKIP, BUYMAX, BTNBATTLEONLY, BTNGIFT_GOOD, From 7c4cc37f2e25e58949c7d36aa02b889441e585d0 Mon Sep 17 00:00:00 2001 From: zenseii Date: Fri, 10 Nov 2023 01:12:29 +0100 Subject: [PATCH 11/18] Auto-adjust Status Bar to button widths --- src/fheroes2/agg/agg_image.cpp | 40 +++++++++++++++++++++++- src/fheroes2/agg/icn.h | 2 ++ src/fheroes2/battle/battle_interface.cpp | 4 +-- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 23937efa338..f38bd1c463a 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -165,7 +165,8 @@ namespace ICN::DISMISS_HERO_DISABLED_BUTTON, ICN::NEW_CAMPAIGN_DISABLED_BUTTON, ICN::BUTTON_SKIP, - ICN::BUTTON_AUTO }; + ICN::BUTTON_AUTO, + ICN::STATUSBAR_BATTLE }; #ifndef NDEBUG bool isLanguageDependentIcnId( const int id ) @@ -4349,6 +4350,43 @@ namespace fheroes2 return true; } + case ICN::STATUSBAR_BATTLE: { + const int32_t originalId = ICN::TEXTBAR; + loadICN( originalId ); + + if ( _icnVsSprite[originalId].size() < 15 ) { + return true; + } + + _icnVsSprite[id].resize( 2 ); + const Sprite & originalTopHalf = GetICN( originalId, 8 ); + const Sprite & originalBottomHalf = GetICN( originalId, 9 ); + + Sprite & topHalf = _icnVsSprite[id][0]; + Sprite & bottomHalf = _icnVsSprite[id][1]; + + const int32_t buttonAutoWidth = fheroes2::AGG::GetICN( ICN::BUTTON_AUTO, 0 ).width(); + const int32_t buttonSkipWidth = fheroes2::AGG::GetICN( ICN::BUTTON_SKIP, 0 ).width(); + const int32_t originalButtonAutoWidth = fheroes2::AGG::GetICN( originalId, 4 ).width(); + const int32_t originalButtonSkipWidth = fheroes2::AGG::GetICN( originalId, 0 ).width(); + const int32_t topBarHeight = originalTopHalf.height(); + const int32_t bottomBarHeight = originalBottomHalf.height(); + + const int32_t moreThanOriginalButtonsWidth = ( ( buttonAutoWidth + buttonSkipWidth ) - ( originalButtonAutoWidth + originalButtonSkipWidth ) ); + + topHalf.resize( originalTopHalf.width() - moreThanOriginalButtonsWidth, topBarHeight ); + bottomHalf.resize( originalBottomHalf.width() - moreThanOriginalButtonsWidth, bottomBarHeight ); + + fheroes2::Copy( originalTopHalf, 0, 0, topHalf, 0, 0, fheroes2::Display::DEFAULT_WIDTH / 2 - buttonAutoWidth, topBarHeight ); + fheroes2::Copy( originalTopHalf, originalTopHalf.width() - fheroes2::Display::DEFAULT_WIDTH / 2 + buttonSkipWidth - 1, 0, topHalf, + fheroes2::Display::DEFAULT_WIDTH / 2 - buttonAutoWidth, 0, fheroes2::Display::DEFAULT_WIDTH / 2 - buttonSkipWidth + 1, topBarHeight ); + + fheroes2::Copy( originalBottomHalf, 0, 0, bottomHalf, 0, 0, fheroes2::Display::DEFAULT_WIDTH / 2 - buttonAutoWidth, bottomBarHeight ); + fheroes2::Copy( originalBottomHalf, originalBottomHalf.width() - fheroes2::Display::DEFAULT_WIDTH / 2 + buttonSkipWidth - 1, 0, bottomHalf, + fheroes2::Display::DEFAULT_WIDTH / 2 - buttonAutoWidth, 0, fheroes2::Display::DEFAULT_WIDTH / 2 - buttonSkipWidth + 1, bottomBarHeight ); + + return true; + } case ICN::BRCREST: { LoadOriginalICN( id ); // First sprite in this ICN has incorrect transparent pixel at position 30x5. diff --git a/src/fheroes2/agg/icn.h b/src/fheroes2/agg/icn.h index 07ce02289e9..75df61fcee0 100644 --- a/src/fheroes2/agg/icn.h +++ b/src/fheroes2/agg/icn.h @@ -1086,6 +1086,8 @@ namespace ICN GAME_OPTION_ICON, + STATUSBAR_BATTLE, + // IMPORTANT! Put any new entry just above this one. LASTICN }; diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 12182fe01f3..6c7c13c3337 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -923,8 +923,8 @@ bool Battle::OpponentSprite::updateAnimationState() } Battle::Status::Status() - : back1( fheroes2::AGG::GetICN( ICN::TEXTBAR, 8 ) ) - , back2( fheroes2::AGG::GetICN( ICN::TEXTBAR, 9 ) ) + : back1( fheroes2::AGG::GetICN( ICN::STATUSBAR_BATTLE, 0 ) ) + , back2( fheroes2::AGG::GetICN( ICN::STATUSBAR_BATTLE, 1 ) ) , listlog( nullptr ) { width = back1.width(); From fdfdfc7d214c47fe6bc0fa563bfbcc1c4ceea000 Mon Sep 17 00:00:00 2001 From: zenseii Date: Fri, 10 Nov 2023 01:12:58 +0100 Subject: [PATCH 12/18] Code style --- src/fheroes2/agg/agg_image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index f38bd1c463a..e2c1cc0dc53 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -4376,7 +4376,7 @@ namespace fheroes2 topHalf.resize( originalTopHalf.width() - moreThanOriginalButtonsWidth, topBarHeight ); bottomHalf.resize( originalBottomHalf.width() - moreThanOriginalButtonsWidth, bottomBarHeight ); - + fheroes2::Copy( originalTopHalf, 0, 0, topHalf, 0, 0, fheroes2::Display::DEFAULT_WIDTH / 2 - buttonAutoWidth, topBarHeight ); fheroes2::Copy( originalTopHalf, originalTopHalf.width() - fheroes2::Display::DEFAULT_WIDTH / 2 + buttonSkipWidth - 1, 0, topHalf, fheroes2::Display::DEFAULT_WIDTH / 2 - buttonAutoWidth, 0, fheroes2::Display::DEFAULT_WIDTH / 2 - buttonSkipWidth + 1, topBarHeight ); From 10703535940fefae55e0751018973d9a18d08cb1 Mon Sep 17 00:00:00 2001 From: zenseii Date: Fri, 10 Nov 2023 01:13:23 +0100 Subject: [PATCH 13/18] Add Russian AUTO text --- files/lang/ru.po | 3 +++ 1 file changed, 3 insertions(+) diff --git a/files/lang/ru.po b/files/lang/ru.po index 762ed37daad..d6d341feb39 100644 --- a/files/lang/ru.po +++ b/files/lang/ru.po @@ -268,6 +268,9 @@ msgstr "" msgid "SKIP" msgstr "ПРОП" +msgid "AUTO" +msgstr "АВТО" + msgid "Warrior" msgstr "Воин" From 95d98f6860a66143567da7dab7d3b90008328e29 Mon Sep 17 00:00:00 2001 From: zenseii Date: Fri, 10 Nov 2023 01:18:54 +0100 Subject: [PATCH 14/18] Simplify variable name --- src/fheroes2/agg/agg_image.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index e2c1cc0dc53..25bc09ea7a4 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -4372,10 +4372,10 @@ namespace fheroes2 const int32_t topBarHeight = originalTopHalf.height(); const int32_t bottomBarHeight = originalBottomHalf.height(); - const int32_t moreThanOriginalButtonsWidth = ( ( buttonAutoWidth + buttonSkipWidth ) - ( originalButtonAutoWidth + originalButtonSkipWidth ) ); + const int32_t excessWidth = ( ( buttonAutoWidth + buttonSkipWidth ) - ( originalButtonAutoWidth + originalButtonSkipWidth ) ); - topHalf.resize( originalTopHalf.width() - moreThanOriginalButtonsWidth, topBarHeight ); - bottomHalf.resize( originalBottomHalf.width() - moreThanOriginalButtonsWidth, bottomBarHeight ); + topHalf.resize( originalTopHalf.width() - excessWidth, topBarHeight ); + bottomHalf.resize( originalBottomHalf.width() - excessWidth, bottomBarHeight ); fheroes2::Copy( originalTopHalf, 0, 0, topHalf, 0, 0, fheroes2::Display::DEFAULT_WIDTH / 2 - buttonAutoWidth, topBarHeight ); fheroes2::Copy( originalTopHalf, originalTopHalf.width() - fheroes2::Display::DEFAULT_WIDTH / 2 + buttonSkipWidth - 1, 0, topHalf, From 506ce366f256b165c99fb7755dd43d710300deb4 Mon Sep 17 00:00:00 2001 From: zenseii Date: Fri, 10 Nov 2023 02:28:25 +0100 Subject: [PATCH 15/18] Auto-adjust width of battle settings button --- src/fheroes2/agg/agg_image.cpp | 43 ++++++++++++++++++++++++ src/fheroes2/agg/icn.h | 1 + src/fheroes2/battle/battle_interface.cpp | 2 +- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 25bc09ea7a4..8717f88a65f 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -166,6 +166,7 @@ namespace ICN::NEW_CAMPAIGN_DISABLED_BUTTON, ICN::BUTTON_SKIP, ICN::BUTTON_AUTO, + ICN::BUTTON_BATTLE_SETTINGS, ICN::STATUSBAR_BATTLE }; #ifndef NDEBUG @@ -4350,6 +4351,48 @@ namespace fheroes2 return true; } + case ICN::BUTTON_BATTLE_SETTINGS: { + const int32_t originalId = ICN::TEXTBAR; + loadICN( originalId ); + + if ( _icnVsSprite[originalId].size() < 15 ) { + return true; + } + + _icnVsSprite[id].resize( 2 ); + + if ( useOriginalResources() ) { + _icnVsSprite[id][0] = GetICN( originalId, 6 ); + _icnVsSprite[id][1] = GetICN( originalId, 7 ); + return true; + } + + const Sprite & autoButtonReleased = GetICN( ICN::BUTTON_AUTO, 0 ); + const Sprite & autoButtonPressed = GetICN( ICN::BUTTON_AUTO, 1 ); + + Sprite & released = _icnVsSprite[id][0]; + Sprite & pressed = _icnVsSprite[id][1]; + + const int32_t buttonWidth = autoButtonReleased.width(); + + released.resize( buttonWidth, autoButtonReleased.height() + 1 ); + pressed.resize( buttonWidth, autoButtonPressed.height() + 1 ); + + // We need to add 1 pixel in height because the Settings button should be 1 pixel higher than the AUTO button. + Copy( autoButtonReleased, 0, 0, released, 0, 0, buttonWidth, 10 ); + Copy( autoButtonReleased, 0, 9, released, 0, 10, buttonWidth, 9 ); + + Copy( autoButtonPressed, 0, 0, pressed, 0, 0, buttonWidth, 10 ); + Copy( autoButtonPressed, 0, 9, pressed, 0, 10, buttonWidth, 9 ); + + Fill( released, 4, 2, buttonWidth - 8, 14, getButtonFillingColor( true ) ); + Fill( pressed, 3, 3, buttonWidth - 8, 14, getButtonFillingColor( false ) ); + + Copy( GetICN( originalId, 6 ), 12, 2, released, buttonWidth / 2 - 27 / 2, 2, 27, 14 ); + Copy( GetICN( originalId, 7 ), 11, 3, pressed, buttonWidth / 2 - 27 / 2 - 1, 3, 27, 14 ); + + return true; + } case ICN::STATUSBAR_BATTLE: { const int32_t originalId = ICN::TEXTBAR; loadICN( originalId ); diff --git a/src/fheroes2/agg/icn.h b/src/fheroes2/agg/icn.h index 75df61fcee0..40a999f264d 100644 --- a/src/fheroes2/agg/icn.h +++ b/src/fheroes2/agg/icn.h @@ -1083,6 +1083,7 @@ namespace ICN BUTTON_SKIP, BUTTON_AUTO, + BUTTON_BATTLE_SETTINGS, GAME_OPTION_ICON, diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 6c7c13c3337..56dd9851e0e 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -1247,7 +1247,7 @@ Battle::Interface::Interface( Arena & battleArena, const int32_t tileIndex ) _mainSurface._disableTransformLayer(); btn_auto.setICNInfo( ICN::BUTTON_AUTO, 0, 1 ); - btn_settings.setICNInfo( ICN::TEXTBAR, 6, 7 ); + btn_settings.setICNInfo( ICN::BUTTON_BATTLE_SETTINGS, 0, 1 ); // opponents _opponent1 = arena.GetCommander1() ? std::make_unique( _surfaceInnerArea, arena.GetCommander1(), false ) : nullptr; From 5a875841368b28fa9aebca2c8188a756eeeab813 Mon Sep 17 00:00:00 2001 From: zenseii Date: Fri, 10 Nov 2023 02:29:00 +0100 Subject: [PATCH 16/18] Use original resources for settings bar if original language is used. --- src/fheroes2/agg/agg_image.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 8717f88a65f..6bd7b403da2 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -4402,6 +4402,13 @@ namespace fheroes2 } _icnVsSprite[id].resize( 2 ); + + if ( useOriginalResources() ) { + _icnVsSprite[id][0] = GetICN( originalId, 8 ); + _icnVsSprite[id][1] = GetICN( originalId, 9 ); + return true; + } + const Sprite & originalTopHalf = GetICN( originalId, 8 ); const Sprite & originalBottomHalf = GetICN( originalId, 9 ); From 6243d2fe75de8221760f12bb9356a94d6c43eb04 Mon Sep 17 00:00:00 2001 From: zenseii Date: Fri, 10 Nov 2023 02:47:37 +0100 Subject: [PATCH 17/18] Revert Y offset changes It turned out that the Settings button is 1 pixel higher than the AUTO button. --- src/fheroes2/battle/battle_interface.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 56dd9851e0e..1d8cc6c163d 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -1259,15 +1259,15 @@ Battle::Interface::Interface( Arena & battleArena, const int32_t tileIndex ) const fheroes2::Rect & area = border.GetArea(); - const fheroes2::Rect autoButtonRect = btn_auto.area(); - const int32_t statusOffsetY = area.y + area.height - autoButtonRect.height - btn_auto.area().height; + const fheroes2::Rect settingsButtonRect = btn_settings.area(); + const int32_t statusOffsetY = area.y + area.height - settingsButtonRect.height - btn_auto.area().height; btn_auto.setPosition( area.x, statusOffsetY ); - btn_settings.setPosition( area.x, area.y + area.height - autoButtonRect.height ); + btn_settings.setPosition( area.x, area.y + area.height - settingsButtonRect.height ); btn_skip.setICNInfo( ICN::BUTTON_SKIP, 0, 1 ); btn_skip.setPosition( area.x + area.width - btn_skip.area().width, area.y + area.height - btn_skip.area().height ); - status.SetPosition( area.x + autoButtonRect.width, statusOffsetY ); + status.SetPosition( area.x + settingsButtonRect.width, statusOffsetY ); listlog = std::make_unique(); From 0b2741472a5a42085b2005ab651849f1688fd354 Mon Sep 17 00:00:00 2001 From: zenseii Date: Fri, 10 Nov 2023 03:30:10 +0100 Subject: [PATCH 18/18] Add Norwegian translation for SKIP --- files/lang/nb.po | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/files/lang/nb.po b/files/lang/nb.po index 504ca903091..edd738e856c 100644 --- a/files/lang/nb.po +++ b/files/lang/nb.po @@ -1,13 +1,13 @@ # Norwegian translation for fheroes2 # Copyright (C) 2021 - 2022 fheroes2 team # This file is distributed under the same license as the fheroes2 package. -# +# msgid "" msgstr "" "Project-Id-Version: fheroes2\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-11-05 08:25+0000\n" -"PO-Revision-Date: 2023-09-03 18:42+0200\n" +"PO-Revision-Date: 2023-11-10 03:17+0100\n" "Last-Translator: fheroes2 team \n" "Language-Team: \n" "Language: nb_NO\n" @@ -15,7 +15,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 3.2.2\n" +"X-Generator: Poedit 3.4.1\n" msgid "" "BATTLE\n" @@ -226,7 +226,7 @@ msgstr "" "T" msgid "SKIP" -msgstr "" +msgstr "PASS" msgid "" "C\n" @@ -5331,7 +5331,7 @@ msgstr "" msgid "Handicap" msgstr "Handikap" -# +# msgid "" "This lets you change the handicap of a particular player. Only humans may be " "handicapped. Handicapped players start with fewer resources and earn 15 or " @@ -5356,7 +5356,7 @@ msgstr "" msgid "Mild Handicap" msgstr "Lett handikap" -# +# msgid "" "Mild handicapped players start with fewer resources and earn 15% fewer " "resources per turn."