From b2e88a846fd013e040fd021d6135e12da667f793 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Mon, 18 Mar 2024 19:20:52 +0100 Subject: [PATCH 01/52] Initial dialog with empty buttons --- src/fheroes2/battle/battle_interface.cpp | 39 +++++++++++++++++++++++- src/fheroes2/battle/battle_interface.h | 1 + 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 88bf0ea4157..a47f1f118aa 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3202,6 +3202,43 @@ void Battle::Interface::EventAutoFinish( Actions & actions ) humanturn_exit = true; } +void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions ) { + LocalEvent & le = LocalEvent::Get(); + + fheroes2::Display & display = fheroes2::Display::instance(); + + Dialog::FrameBox box( 100, true ); + const fheroes2::Rect roiArea = box.GetArea(); + fheroes2::Button cancel( roiArea.x + roiArea.width / 2 - fheroes2::AGG::GetICN(ICN::UNIFORM_GOOD_CANCEL_BUTTON,0).width()/2, roiArea.y + roiArea.height - 20, ICN::UNIFORM_GOOD_CANCEL_BUTTON, 0, 1 ); + fheroes2::ButtonSprite autoResolve( roiArea.x, roiArea.y + 40, fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 0 ), + fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 1 ) ); + fheroes2::ButtonSprite autoCombat( roiArea.x + roiArea.width - fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 0 ).width(), roiArea.y + 40, + fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 0 ), + fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 1 ) ); + + cancel.draw(); + autoResolve.draw(); + autoCombat.draw(); + display.render(); + while ( le.HandleEvents() ) { + le.MousePressLeft( cancel.area() ) ? cancel.drawOnPress() : cancel.drawOnRelease(); + le.MousePressLeft( autoResolve.area() ) ? autoResolve.drawOnPress() : autoResolve.drawOnRelease(); + le.MousePressLeft( autoCombat.area() ) ? autoCombat.drawOnPress() : autoCombat.drawOnRelease(); + + + if ( le.MouseClickLeft( cancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { + return; + } + else if ( le.MouseClickLeft( autoResolve.area() ) ) { + EventAutoFinish( actions ); + } + else if ( le.MouseClickLeft( autoCombat.area() ) ) { + EventStartAutoBattle( unit, actions ); + } + display.render( roiArea ); + } +} + void Battle::Interface::ButtonAutoAction( const Unit & unit, Actions & actions ) { LocalEvent & le = LocalEvent::Get(); @@ -3209,7 +3246,7 @@ void Battle::Interface::ButtonAutoAction( const Unit & unit, Actions & actions ) le.MousePressLeft( btn_auto.area() ) ? btn_auto.drawOnPress() : btn_auto.drawOnRelease(); if ( le.MouseClickLeft( btn_auto.area() ) ) { - EventStartAutoBattle( unit, actions ); + OpenAutoModeDialog( unit, actions ); } } diff --git a/src/fheroes2/battle/battle_interface.h b/src/fheroes2/battle/battle_interface.h index d3724dfae7d..ee5768bb539 100644 --- a/src/fheroes2/battle/battle_interface.h +++ b/src/fheroes2/battle/battle_interface.h @@ -394,6 +394,7 @@ namespace Battle void _openBattleSettingsDialog(); void EventStartAutoBattle( const Unit & unit, Actions & actions ); void EventAutoFinish( Actions & actions ); + void ShowAutoModeDialog( const Unit & unit, Actions & actions ); void EventShowOptions(); void ButtonAutoAction( const Unit & unit, Actions & actions ); void ButtonSettingsAction(); From 07c1d5af176f142a635fd50ab017e42d5fad1e84 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Tue, 19 Mar 2024 14:14:30 +0100 Subject: [PATCH 02/52] Fix missing declaration name change --- src/fheroes2/battle/battle_interface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/battle/battle_interface.h b/src/fheroes2/battle/battle_interface.h index ee5768bb539..b8e9216e21f 100644 --- a/src/fheroes2/battle/battle_interface.h +++ b/src/fheroes2/battle/battle_interface.h @@ -394,7 +394,7 @@ namespace Battle void _openBattleSettingsDialog(); void EventStartAutoBattle( const Unit & unit, Actions & actions ); void EventAutoFinish( Actions & actions ); - void ShowAutoModeDialog( const Unit & unit, Actions & actions ); + void OpenAutoModeDialog( const Unit & unit, Actions & actions ); void EventShowOptions(); void ButtonAutoAction( const Unit & unit, Actions & actions ); void ButtonSettingsAction(); From 82a88e1123ba65d3a4712ee882a099ee7653de7e Mon Sep 17 00:00:00 2001 From: Zenseii Date: Tue, 19 Mar 2024 14:16:27 +0100 Subject: [PATCH 03/52] Add returns --- src/fheroes2/battle/battle_interface.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index a47f1f118aa..2a422003918 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3231,9 +3231,11 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions } else if ( le.MouseClickLeft( autoResolve.area() ) ) { EventAutoFinish( actions ); + return; } else if ( le.MouseClickLeft( autoCombat.area() ) ) { EventStartAutoBattle( unit, actions ); + return; } display.render( roiArea ); } From c82d307b7a0f26405aa453a2832d19d0a9cd9213 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Tue, 19 Mar 2024 14:19:00 +0100 Subject: [PATCH 04/52] code style --- 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 2a422003918..0dd8fa70c4c 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3202,19 +3202,20 @@ void Battle::Interface::EventAutoFinish( Actions & actions ) humanturn_exit = true; } -void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions ) { +void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions ) +{ LocalEvent & le = LocalEvent::Get(); fheroes2::Display & display = fheroes2::Display::instance(); Dialog::FrameBox box( 100, true ); const fheroes2::Rect roiArea = box.GetArea(); - fheroes2::Button cancel( roiArea.x + roiArea.width / 2 - fheroes2::AGG::GetICN(ICN::UNIFORM_GOOD_CANCEL_BUTTON,0).width()/2, roiArea.y + roiArea.height - 20, ICN::UNIFORM_GOOD_CANCEL_BUTTON, 0, 1 ); + fheroes2::Button cancel( roiArea.x + roiArea.width / 2 - fheroes2::AGG::GetICN( ICN::UNIFORM_GOOD_CANCEL_BUTTON, 0 ).width() / 2, roiArea.y + roiArea.height - 20, + ICN::UNIFORM_GOOD_CANCEL_BUTTON, 0, 1 ); fheroes2::ButtonSprite autoResolve( roiArea.x, roiArea.y + 40, fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 0 ), fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 1 ) ); fheroes2::ButtonSprite autoCombat( roiArea.x + roiArea.width - fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 0 ).width(), roiArea.y + 40, - fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 0 ), - fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 1 ) ); + fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 0 ), fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 1 ) ); cancel.draw(); autoResolve.draw(); @@ -3225,7 +3226,6 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions le.MousePressLeft( autoResolve.area() ) ? autoResolve.drawOnPress() : autoResolve.drawOnRelease(); le.MousePressLeft( autoCombat.area() ) ? autoCombat.drawOnPress() : autoCombat.drawOnRelease(); - if ( le.MouseClickLeft( cancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { return; } From 38fb591f2a95015ed852a5fb09f787a819d70472 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 22 Mar 2024 15:14:26 +0100 Subject: [PATCH 05/52] Add To-dos --- src/fheroes2/battle/battle_interface.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 0dd8fa70c4c..3bd080b8011 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3207,7 +3207,8 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions LocalEvent & le = LocalEvent::Get(); fheroes2::Display & display = fheroes2::Display::instance(); - + // To-do: add buttons with text. Need tall buttons. Either make them in AGG_image.cpp or make resize make buttons according to height. + // To-do: use fheroes2::getTextAdaptedButton() needs parameter for button height. Dialog::FrameBox box( 100, true ); const fheroes2::Rect roiArea = box.GetArea(); fheroes2::Button cancel( roiArea.x + roiArea.width / 2 - fheroes2::AGG::GetICN( ICN::UNIFORM_GOOD_CANCEL_BUTTON, 0 ).width() / 2, roiArea.y + roiArea.height - 20, @@ -3217,6 +3218,8 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions fheroes2::ButtonSprite autoCombat( roiArea.x + roiArea.width - fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 0 ).width(), roiArea.y + 40, fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 0 ), fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 1 ) ); + // To-do: add a title and a header to the dialog. "Automatic Battle Mode" and Choose an automatic battle mode: + cancel.draw(); autoResolve.draw(); autoCombat.draw(); @@ -3226,6 +3229,8 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions le.MousePressLeft( autoResolve.area() ) ? autoResolve.drawOnPress() : autoResolve.drawOnRelease(); le.MousePressLeft( autoCombat.area() ) ? autoCombat.drawOnPress() : autoCombat.drawOnRelease(); + // To-do: add right-click infos for the buttons. + if ( le.MouseClickLeft( cancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { return; } From d5099d1739af525ba658034b7c8f12e5dd6a667e Mon Sep 17 00:00:00 2001 From: Zenseii Date: Wed, 9 Oct 2024 12:23:16 +0200 Subject: [PATCH 06/52] Generate text-adapted buttons --- src/fheroes2/battle/battle_interface.cpp | 26 +++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index b80b626c3aa..ed458f71c12 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3222,27 +3222,33 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions LocalEvent & le = LocalEvent::Get(); fheroes2::Display & display = fheroes2::Display::instance(); - // To-do: add buttons with text. Need tall buttons. Either make them in AGG_image.cpp or make resize make buttons according to height. - // To-do: use fheroes2::getTextAdaptedButton() needs parameter for button height. + Dialog::FrameBox box( 100, true ); const fheroes2::Rect roiArea = box.GetArea(); fheroes2::Button cancel( roiArea.x + roiArea.width / 2 - fheroes2::AGG::GetICN( ICN::UNIFORM_GOOD_CANCEL_BUTTON, 0 ).width() / 2, roiArea.y + roiArea.height - 20, ICN::UNIFORM_GOOD_CANCEL_BUTTON, 0, 1 ); - fheroes2::ButtonSprite autoResolve( roiArea.x, roiArea.y + 40, fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 0 ), - fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 1 ) ); - fheroes2::ButtonSprite autoCombat( roiArea.x + roiArea.width - fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 0 ).width(), roiArea.y + 40, - fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 0 ), fheroes2::AGG::GetICN( ICN::EMPTY_GOOD_MEDIUM_BUTTON, 1 ) ); - // To-do: add a title and a header to the dialog. "Automatic Battle Mode" and Choose an automatic battle mode: + fheroes2::Sprite releasedCombatButton; + fheroes2::Sprite pressedCombatButton; + fheroes2::Sprite releasedResolveButton; + fheroes2::Sprite pressedResolveButton; + + fheroes2::getTextAdaptedButton( releasedCombatButton, pressedCombatButton, _( "AUTO-\nCOMBAT" ), ICN::EMPTY_GOOD_BUTTON, ICN::UNIFORMBAK_GOOD ); + fheroes2::getTextAdaptedButton( releasedResolveButton, pressedResolveButton, _( "AUTO-\nRESOLVE" ), ICN::EMPTY_GOOD_BUTTON, ICN::UNIFORMBAK_GOOD ); + + fheroes2::ButtonSprite autoCombat( roiArea.x, roiArea.y + 40, releasedCombatButton, pressedCombatButton ); + fheroes2::ButtonSprite autoResolve( roiArea.x + roiArea.width - releasedCombatButton.width(), roiArea.y + 40, releasedResolveButton, pressedResolveButton ); + + // To-do: add a title and a header to the dialog. "Automatic Battle Modes" and Choose an automatic battle mode: cancel.draw(); autoResolve.draw(); autoCombat.draw(); display.render(); while ( le.HandleEvents() ) { - le.MousePressLeft( cancel.area() ) ? cancel.drawOnPress() : cancel.drawOnRelease(); - le.MousePressLeft( autoResolve.area() ) ? autoResolve.drawOnPress() : autoResolve.drawOnRelease(); - le.MousePressLeft( autoCombat.area() ) ? autoCombat.drawOnPress() : autoCombat.drawOnRelease(); + le.isMouseLeftButtonPressedInArea( cancel.area() ) ? cancel.drawOnPress() : cancel.drawOnRelease(); + le.isMouseLeftButtonPressedInArea( autoResolve.area() ) ? autoResolve.drawOnPress() : autoResolve.drawOnRelease(); + le.isMouseLeftButtonPressedInArea( autoCombat.area() ) ? autoCombat.drawOnPress() : autoCombat.drawOnRelease(); // To-do: add right-click infos for the buttons. From cd9ba4b3e0af6249ca4e6f209897bec0f0a0ee72 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 10 Oct 2024 15:43:41 +0200 Subject: [PATCH 07/52] Const and else ifs --- src/fheroes2/battle/battle_interface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index ed458f71c12..467edde5812 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3223,7 +3223,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions fheroes2::Display & display = fheroes2::Display::instance(); - Dialog::FrameBox box( 100, true ); + const Dialog::FrameBox box( 100, true ); const fheroes2::Rect roiArea = box.GetArea(); fheroes2::Button cancel( roiArea.x + roiArea.width / 2 - fheroes2::AGG::GetICN( ICN::UNIFORM_GOOD_CANCEL_BUTTON, 0 ).width() / 2, roiArea.y + roiArea.height - 20, ICN::UNIFORM_GOOD_CANCEL_BUTTON, 0, 1 ); @@ -3255,11 +3255,11 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions if ( le.MouseClickLeft( cancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { return; } - else if ( le.MouseClickLeft( autoResolve.area() ) ) { + if ( le.MouseClickLeft( autoResolve.area() ) ) { EventAutoFinish( actions ); return; } - else if ( le.MouseClickLeft( autoCombat.area() ) ) { + if ( le.MouseClickLeft( autoCombat.area() ) ) { EventStartAutoBattle( unit, actions ); return; } From 0bb5241520c8a76b88a590b74a2fed5a678a8f81 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 3 Jan 2025 16:53:45 +0100 Subject: [PATCH 08/52] Generate buttons in agg_image.cpp --- src/fheroes2/agg/agg_image.cpp | 32 +++++++++++++++++++++++++++++++- src/fheroes2/agg/icn.h | 5 +++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index ed5780ffe49..7d0c9f033ca 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -188,7 +188,11 @@ namespace ICN::BUTTON_EVENTS_GOOD, ICN::BUTTON_EVENTS_EVIL, ICN::BUTTON_LANGUAGE_GOOD, - ICN::BUTTON_LANGUAGE_EVIL }; + ICN::BUTTON_LANGUAGE_EVIL, + ICN::BUTTON_AUTO_COMBAT_GOOD, + ICN::BUTTON_AUTO_COMBAT_EVIL, + ICN::BUTTON_AUTO_RESOLVE_GOOD, + ICN::BUTTON_AUTO_RESOLVE_EVIL }; #ifndef NDEBUG bool isLanguageDependentIcnId( const int id ) @@ -2127,6 +2131,28 @@ namespace break; } + case ICN::BUTTON_AUTO_COMBAT_GOOD: + case ICN::BUTTON_AUTO_COMBAT_EVIL: { + _icnVsSprite[id].resize( 2 ); + + const bool isEvilInterface = ( id == ICN::BUTTON_AUTO_COMBAT_EVIL ); + + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO-\nCOMBAT" ), isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, + isEvilInterface ? ICN::UNIFORMBAK_EVIL: ICN::UNIFORMBAK_GOOD ); + + break; + } + case ICN::BUTTON_AUTO_RESOLVE_GOOD: + case ICN::BUTTON_AUTO_RESOLVE_EVIL: { + _icnVsSprite[id].resize( 2 ); + + const bool isEvilInterface = ( id == ICN::BUTTON_AUTO_RESOLVE_EVIL ); + + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO-\nRESOLVE" ), + isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::UNIFORMBAK_EVIL : ICN::UNIFORMBAK_GOOD ); + + 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 @@ -2839,6 +2865,10 @@ namespace case ICN::BUTTON_EVENTS_EVIL: case ICN::BUTTON_LANGUAGE_GOOD: case ICN::BUTTON_LANGUAGE_EVIL: + case ICN::BUTTON_AUTO_COMBAT_GOOD: + case ICN::BUTTON_AUTO_COMBAT_EVIL: + case ICN::BUTTON_AUTO_RESOLVE_GOOD: + case ICN::BUTTON_AUTO_RESOLVE_EVIL: generateLanguageSpecificImages( id ); return true; case ICN::PHOENIX: diff --git a/src/fheroes2/agg/icn.h b/src/fheroes2/agg/icn.h index c4b269c4b9c..2eb7fd1d4e5 100644 --- a/src/fheroes2/agg/icn.h +++ b/src/fheroes2/agg/icn.h @@ -1126,6 +1126,11 @@ namespace ICN BUTTON_LANGUAGE_GOOD, BUTTON_LANGUAGE_EVIL, + BUTTON_AUTO_COMBAT_GOOD, + BUTTON_AUTO_COMBAT_EVIL, + BUTTON_AUTO_RESOLVE_GOOD, + BUTTON_AUTO_RESOLVE_EVIL, + SCENIBKG_EVIL, // IMPORTANT! Put any new entry just above this one. From 0be0ca9416178f785b662ea990bde07705968851 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 3 Jan 2025 16:54:55 +0100 Subject: [PATCH 09/52] Add header and title, move button generation, use drawOnState, exit dialog only upon action change --- src/fheroes2/battle/battle_interface.cpp | 47 +++++++++++++++--------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index f1af7366102..7f2c721b63f 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3211,32 +3211,41 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions fheroes2::Display & display = fheroes2::Display::instance(); - const Dialog::FrameBox box( 100, true ); - const fheroes2::Rect roiArea = box.GetArea(); - fheroes2::Button cancel( roiArea.x + roiArea.width / 2 - fheroes2::AGG::GetICN( ICN::UNIFORM_GOOD_CANCEL_BUTTON, 0 ).width() / 2, roiArea.y + roiArea.height - 20, - ICN::UNIFORM_GOOD_CANCEL_BUTTON, 0, 1 ); + fheroes2::Text title( _( "Automatic Battle Modes" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::YELLOW } ); + fheroes2::Text header( _( "Choose an automatic battle mode:" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::WHITE } ); + + const bool isEvilInterface = Settings::Get().isEvilInterfaceEnabled(); + + const int autoCombatButtonICN = isEvilInterface ? ICN::BUTTON_AUTO_COMBAT_EVIL : ICN::BUTTON_AUTO_COMBAT_GOOD; + const int autoResolveButtonICN = isEvilInterface ? ICN::BUTTON_AUTO_RESOLVE_EVIL : ICN::BUTTON_AUTO_RESOLVE_GOOD; + const int cancelButtonICN = isEvilInterface ? ICN::UNIFORM_EVIL_CANCEL_BUTTON : ICN::UNIFORM_GOOD_CANCEL_BUTTON; - fheroes2::Sprite releasedCombatButton; - fheroes2::Sprite pressedCombatButton; - fheroes2::Sprite releasedResolveButton; - fheroes2::Sprite pressedResolveButton; + const fheroes2::Sprite & autoResolveButtonReleased = fheroes2::AGG::GetICN( autoResolveButtonICN, 0 ); + const fheroes2::Sprite & cancelButtonReleased = fheroes2::AGG::GetICN( cancelButtonICN, 0 ); + + const Dialog::FrameBox box( title.height() + 7 + header.height() + 7 + autoResolveButtonReleased.height() + 15, true ); + const fheroes2::Rect roiArea = box.GetArea(); - fheroes2::getTextAdaptedButton( releasedCombatButton, pressedCombatButton, _( "AUTO-\nCOMBAT" ), ICN::EMPTY_GOOD_BUTTON, ICN::UNIFORMBAK_GOOD ); - fheroes2::getTextAdaptedButton( releasedResolveButton, pressedResolveButton, _( "AUTO-\nRESOLVE" ), ICN::EMPTY_GOOD_BUTTON, ICN::UNIFORMBAK_GOOD ); + fheroes2::Button cancel( roiArea.x + roiArea.width / 2 - cancelButtonReleased.width() / 2, roiArea.y + roiArea.height - 25, cancelButtonICN, 0, 1 ); - fheroes2::ButtonSprite autoCombat( roiArea.x, roiArea.y + 40, releasedCombatButton, pressedCombatButton ); - fheroes2::ButtonSprite autoResolve( roiArea.x + roiArea.width - releasedCombatButton.width(), roiArea.y + 40, releasedResolveButton, pressedResolveButton ); + const int32_t buttonPlacementYOffset = roiArea.y + title.height( roiArea.width ) + 7 + header.height( roiArea.width ) + 7; - // To-do: add a title and a header to the dialog. "Automatic Battle Modes" and Choose an automatic battle mode: + fheroes2::ButtonSprite autoCombat( roiArea.x, buttonPlacementYOffset, fheroes2::AGG::GetICN( autoCombatButtonICN, 0 ), + fheroes2::AGG::GetICN( autoCombatButtonICN, 1 ) ); + fheroes2::ButtonSprite autoResolve( roiArea.x + roiArea.width - autoResolveButtonReleased.width(), buttonPlacementYOffset, autoResolveButtonReleased, + fheroes2::AGG::GetICN( autoResolveButtonICN, 1 ) ); + header.draw( roiArea.x, roiArea.y + title.height( roiArea.width ) + 7, roiArea.width, display ); + title.draw( roiArea.x, roiArea.y, roiArea.width, display ); cancel.draw(); autoResolve.draw(); autoCombat.draw(); display.render(); + while ( le.HandleEvents() ) { - le.isMouseLeftButtonPressedInArea( cancel.area() ) ? cancel.drawOnPress() : cancel.drawOnRelease(); - le.isMouseLeftButtonPressedInArea( autoResolve.area() ) ? autoResolve.drawOnPress() : autoResolve.drawOnRelease(); - le.isMouseLeftButtonPressedInArea( autoCombat.area() ) ? autoCombat.drawOnPress() : autoCombat.drawOnRelease(); + autoResolve.drawOnState( le.isMouseLeftButtonPressedInArea( autoResolve.area() ) ); + autoCombat.drawOnState( le.isMouseLeftButtonPressedInArea( autoCombat.area() ) ); + cancel.drawOnState( le.isMouseLeftButtonPressedInArea( cancel.area() ) ); // To-do: add right-click infos for the buttons. @@ -3245,13 +3254,15 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions } if ( le.MouseClickLeft( autoResolve.area() ) ) { EventAutoFinish( actions ); - return; + display.render( roiArea ); } if ( le.MouseClickLeft( autoCombat.area() ) ) { EventStartAutoBattle( unit, actions ); + display.render( roiArea ); + } + if ( !actions.empty() ) { return; } - display.render( roiArea ); } } From ef6b34f970c7642c41aa4d0f8c0c5c5de1fb7e7d Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 3 Jan 2025 16:55:14 +0100 Subject: [PATCH 10/52] style nit --- src/fheroes2/battle/battle_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 7f2c721b63f..e4987093805 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3213,7 +3213,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions fheroes2::Text title( _( "Automatic Battle Modes" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::YELLOW } ); fheroes2::Text header( _( "Choose an automatic battle mode:" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::WHITE } ); - + const bool isEvilInterface = Settings::Get().isEvilInterfaceEnabled(); const int autoCombatButtonICN = isEvilInterface ? ICN::BUTTON_AUTO_COMBAT_EVIL : ICN::BUTTON_AUTO_COMBAT_GOOD; From 7125508cde594f1041955364e9e6d4e1d122cef5 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 3 Jan 2025 17:07:37 +0100 Subject: [PATCH 11/52] remove dash --- src/fheroes2/agg/agg_image.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 7d0c9f033ca..76090b1e1ca 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -2137,7 +2137,7 @@ namespace const bool isEvilInterface = ( id == ICN::BUTTON_AUTO_COMBAT_EVIL ); - getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO-\nCOMBAT" ), isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO\nCOMBAT" ), isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::UNIFORMBAK_EVIL: ICN::UNIFORMBAK_GOOD ); break; @@ -2148,7 +2148,7 @@ namespace const bool isEvilInterface = ( id == ICN::BUTTON_AUTO_RESOLVE_EVIL ); - getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO-\nRESOLVE" ), + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO\nRESOLVE" ), isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::UNIFORMBAK_EVIL : ICN::UNIFORMBAK_GOOD ); break; From b91bb9caf85dafa4401f56a1fad1ba52b0a2d8ad Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 3 Jan 2025 17:07:52 +0100 Subject: [PATCH 12/52] Add right click infos --- src/fheroes2/battle/battle_interface.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index e4987093805..85d8a30fd6b 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3247,8 +3247,6 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions autoCombat.drawOnState( le.isMouseLeftButtonPressedInArea( autoCombat.area() ) ); cancel.drawOnState( le.isMouseLeftButtonPressedInArea( cancel.area() ) ); - // To-do: add right-click infos for the buttons. - if ( le.MouseClickLeft( cancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { return; } @@ -3263,6 +3261,19 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions if ( !actions.empty() ) { return; } + + if ( le.isMouseRightButtonPressedInArea( cancel.area() ) ) { + fheroes2::showStandardTextMessage( _( "Cancel" ), _( "Exit this menu." ), Dialog::ZERO ); + } + else if ( le.isMouseRightButtonPressedInArea( autoCombat.area() ) ) { + fheroes2::showStandardTextMessage( _( "Auto Combat" ), + _( "Lets the computer play out the battle for you.\n\nYou can interrupt it at any time by pressing any key." ), + Dialog::ZERO ); + } + else if ( le.isMouseRightButtonPressedInArea( autoResolve.area() ) ) { + fheroes2::showStandardTextMessage( _( "Auto Resolve" ), + _( "The battle will be resolved instantly by the computer from the current state.\n\nThis cannot be reverted." ), Dialog::ZERO ); + } } } From 58c03256ad40542b8360fe3f9ab79bbbbca0a5b2 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 3 Jan 2025 17:08:17 +0100 Subject: [PATCH 13/52] style nit --- src/fheroes2/battle/battle_interface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 85d8a30fd6b..1581fbda87a 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3272,7 +3272,8 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions } else if ( le.isMouseRightButtonPressedInArea( autoResolve.area() ) ) { fheroes2::showStandardTextMessage( _( "Auto Resolve" ), - _( "The battle will be resolved instantly by the computer from the current state.\n\nThis cannot be reverted." ), Dialog::ZERO ); + _( "The battle will be resolved instantly by the computer from the current state.\n\nThis cannot be reverted." ), + Dialog::ZERO ); } } } From bccdfc98c840466dae1be6b15a4504b242637382 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 3 Jan 2025 17:10:15 +0100 Subject: [PATCH 14/52] Copyright years --- src/fheroes2/agg/agg_image.cpp | 2 +- src/fheroes2/battle/battle_interface.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 76090b1e1ca..28cfe5d04a5 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * fheroes2: https://github.com/ihhub/fheroes2 * - * Copyright (C) 2021 - 2024 * + * Copyright (C) 2021 - 2025 * * * * 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 * diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 1581fbda87a..b5c425effe8 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * fheroes2: https://github.com/ihhub/fheroes2 * - * Copyright (C) 2019 - 2024 * + * Copyright (C) 2019 - 2025 * * * * Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 * * Copyright (C) 2010 by Andrey Afletdinov * From 71709a9a4574424317dd0fe3daa3b2368133bd65 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 3 Jan 2025 17:11:02 +0100 Subject: [PATCH 15/52] Code style --- src/fheroes2/agg/agg_image.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 28cfe5d04a5..778ed76beae 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -2137,8 +2137,8 @@ namespace const bool isEvilInterface = ( id == ICN::BUTTON_AUTO_COMBAT_EVIL ); - getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO\nCOMBAT" ), isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, - isEvilInterface ? ICN::UNIFORMBAK_EVIL: ICN::UNIFORMBAK_GOOD ); + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO\nCOMBAT" ), + isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::UNIFORMBAK_EVIL : ICN::UNIFORMBAK_GOOD ); break; } From 3fb0fa851ad22afccda0212ab8bce9cf8ef9d7fc Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 3 Jan 2025 17:24:04 +0100 Subject: [PATCH 16/52] cache texts --- src/fheroes2/battle/battle_interface.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index b5c425effe8..55c8335b9a0 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3211,8 +3211,8 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions fheroes2::Display & display = fheroes2::Display::instance(); - fheroes2::Text title( _( "Automatic Battle Modes" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::YELLOW } ); - fheroes2::Text header( _( "Choose an automatic battle mode:" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::WHITE } ); + const fheroes2::Text title( _( "Automatic Battle Modes" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::YELLOW } ); + const fheroes2::Text header( _( "Choose an automatic battle mode:" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::WHITE } ); const bool isEvilInterface = Settings::Get().isEvilInterfaceEnabled(); @@ -3272,8 +3272,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions } else if ( le.isMouseRightButtonPressedInArea( autoResolve.area() ) ) { fheroes2::showStandardTextMessage( _( "Auto Resolve" ), - _( "The battle will be resolved instantly by the computer from the current state.\n\nThis cannot be reverted." ), - Dialog::ZERO ); + _( "Instantly resolves the battle by the computer from the current state.\n\nThis cannot be reverted." ), Dialog::ZERO ); } } } From c06ccb837397cdb6663e8bd4e1c2b36a16cc9832 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 3 Jan 2025 17:28:56 +0100 Subject: [PATCH 17/52] it -> this --- src/fheroes2/battle/battle_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 55c8335b9a0..f5bf579eb60 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3267,7 +3267,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions } else if ( le.isMouseRightButtonPressedInArea( autoCombat.area() ) ) { fheroes2::showStandardTextMessage( _( "Auto Combat" ), - _( "Lets the computer play out the battle for you.\n\nYou can interrupt it at any time by pressing any key." ), + _( "Lets the computer play out the battle for you.\n\nYou can interrupt this at any time by pressing any key." ), Dialog::ZERO ); } else if ( le.isMouseRightButtonPressedInArea( autoResolve.area() ) ) { From 8b97660461c3f69369eeb478866887de6defd39a Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 3 Jan 2025 17:36:43 +0100 Subject: [PATCH 18/52] Account for multi-lined texts --- src/fheroes2/battle/battle_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index f5bf579eb60..898b1df8523 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3223,7 +3223,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions const fheroes2::Sprite & autoResolveButtonReleased = fheroes2::AGG::GetICN( autoResolveButtonICN, 0 ); const fheroes2::Sprite & cancelButtonReleased = fheroes2::AGG::GetICN( cancelButtonICN, 0 ); - const Dialog::FrameBox box( title.height() + 7 + header.height() + 7 + autoResolveButtonReleased.height() + 15, true ); + const Dialog::FrameBox box( title.height( title.width() ) + 7 + header.height( header.width() ) + 7 + autoResolveButtonReleased.height() + 15, true ); const fheroes2::Rect roiArea = box.GetArea(); fheroes2::Button cancel( roiArea.x + roiArea.width / 2 - cancelButtonReleased.width() / 2, roiArea.y + roiArea.height - 25, cancelButtonICN, 0, 1 ); From fa73da612f46a5e2757b935f3f73ca4e8e68d91a Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 10 Jan 2025 16:28:59 +0100 Subject: [PATCH 19/52] Separate the text body blocks to avoid adding duplicated translation lines --- src/fheroes2/battle/battle_interface.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 898b1df8523..6bcd6f42c88 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3266,9 +3266,10 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions fheroes2::showStandardTextMessage( _( "Cancel" ), _( "Exit this menu." ), Dialog::ZERO ); } else if ( le.isMouseRightButtonPressedInArea( autoCombat.area() ) ) { - fheroes2::showStandardTextMessage( _( "Auto Combat" ), - _( "Lets the computer play out the battle for you.\n\nYou can interrupt this at any time by pressing any key." ), - Dialog::ZERO ); + std::string msg = _( "Allows the computer to fight out the battle for you." ); + msg += "\n\n"; + msg += _( "You can interrupt this at any time by pressing any key." ); + fheroes2::showStandardTextMessage( _( "Auto Combat" ), msg, Dialog::ZERO ); } else if ( le.isMouseRightButtonPressedInArea( autoResolve.area() ) ) { fheroes2::showStandardTextMessage( _( "Auto Resolve" ), From 9d5645f30bcc0c0137aea6c83ddf69e6254ea0db Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 10 Jan 2025 16:32:41 +0100 Subject: [PATCH 20/52] separate auto resolve info text blocks add translation context --- src/fheroes2/battle/battle_interface.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 6bcd6f42c88..cee09e385fc 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3268,12 +3268,14 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions else if ( le.isMouseRightButtonPressedInArea( autoCombat.area() ) ) { std::string msg = _( "Allows the computer to fight out the battle for you." ); msg += "\n\n"; - msg += _( "You can interrupt this at any time by pressing any key." ); + msg += _( "autoBattle|This can be interrupted at any time by pressing any key." ); fheroes2::showStandardTextMessage( _( "Auto Combat" ), msg, Dialog::ZERO ); } else if ( le.isMouseRightButtonPressedInArea( autoResolve.area() ) ) { - fheroes2::showStandardTextMessage( _( "Auto Resolve" ), - _( "Instantly resolves the battle by the computer from the current state.\n\nThis cannot be reverted." ), Dialog::ZERO ); + std::string msg = _( "Instantly resolves the battle by the computer from the current state." ); + msg += "\n\n"; + msg += _( "autoResolve|This cannot be reverted." ); + fheroes2::showStandardTextMessage( _( "Auto Resolve" ), msg, Dialog::ZERO ); } } } From b59ddbadbffb913a53abfb0312c0f6b07baef61c Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 10 Jan 2025 16:37:09 +0100 Subject: [PATCH 21/52] Remove duplicated todo It's already present in width()'s header --- src/fheroes2/gui/ui_button.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fheroes2/gui/ui_button.cpp b/src/fheroes2/gui/ui_button.cpp index 887c6001397..e66a2480616 100644 --- a/src/fheroes2/gui/ui_button.cpp +++ b/src/fheroes2/gui/ui_button.cpp @@ -724,7 +724,6 @@ namespace fheroes2 const fheroes2::Text pressedText( supportedText, { fheroes2::FontSize::BUTTON_PRESSED, buttonFont } ); // We need to pass an argument to width() so that it correctly accounts for multi-lined texts. - // TODO: Remove the need for the argument once width() has been improved to handle this. const int32_t textWidth = releasedText.width( maximumTextArea.width ); assert( textWidth > 0 ); From 6e23a1f3998084f1882a1e100f726488380e174d Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 10 Jan 2025 17:50:24 +0100 Subject: [PATCH 22/52] Add button shine --- src/fheroes2/gui/ui_button.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/fheroes2/gui/ui_button.cpp b/src/fheroes2/gui/ui_button.cpp index f1bec3ccd49..6f0eb909d03 100644 --- a/src/fheroes2/gui/ui_button.cpp +++ b/src/fheroes2/gui/ui_button.cpp @@ -173,6 +173,28 @@ namespace return output; } + void addButtonShine( fheroes2::Sprite & buttonImage, const int emptyButtonIcnID ) + { + const bool isGoodButton = ( emptyButtonIcnID == ICN::EMPTY_GOOD_BUTTON ); + if ( isGoodButton || emptyButtonIcnID == ICN::EMPTY_EVIL_BUTTON ) { + const uint8_t firstColor = 10; + const uint8_t secondColor = isGoodButton ? 38 : 15; + const uint8_t lastColor = isGoodButton ? 39 : 16; + // Left side shine + fheroes2::SetPixel( buttonImage, 11, 4, firstColor ); + fheroes2::SetPixel( buttonImage, 13, 4, firstColor ); + fheroes2::SetPixel( buttonImage, 9, 6, firstColor ); + fheroes2::SetPixel( buttonImage, 10, 5, secondColor ); + fheroes2::SetPixel( buttonImage, 12, 5, secondColor ); + fheroes2::SetPixel( buttonImage, 8, 7, lastColor ); + fheroes2::SetPixel( buttonImage, 15, 4, lastColor ); + // Right-side shine + fheroes2::SetPixel( buttonImage, buttonImage.width() - 9, 4, firstColor ); + fheroes2::SetPixel( buttonImage, buttonImage.width() - 7, 4, firstColor ); + fheroes2::DrawLine( buttonImage, { buttonImage.width() - 10, 5 }, { buttonImage.width() - 11, 6 }, secondColor ); + fheroes2::SetPixel( buttonImage, buttonImage.width() - 8, 5, secondColor ); + } + } void getButtonSpecificValues( const int emptyButtonIcnID, fheroes2::FontColor & font, fheroes2::Point & textAreaBorders, fheroes2::Size & minimumTextArea, fheroes2::Size & maximumTextArea, fheroes2::Size & backgroundBorders, fheroes2::Point & releasedOffset, @@ -767,6 +789,9 @@ namespace fheroes2 if ( buttonBackgroundIcnID != ICN::UNKNOWN ) { makeTransparentBackground( released, pressed, buttonBackgroundIcnID ); } + if ( emptyButtonIcnID == ICN::EMPTY_EVIL_BUTTON || emptyButtonIcnID == ICN::EMPTY_GOOD_BUTTON ) { + addButtonShine( released, emptyButtonIcnID ); + } const fheroes2::Size releasedTextSize( releasedText.width( textAreaWidth ), releasedText.height( textAreaWidth ) ); const fheroes2::Size pressedTextSize( pressedText.width( textAreaWidth ), pressedText.height( textAreaWidth ) ); From 0c75e6adf4845201d5cc8229aa4070e54a51c839 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 10 Jan 2025 17:55:47 +0100 Subject: [PATCH 23/52] Paraphrase auto resolve text --- src/fheroes2/battle/battle_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index a8bb48bc439..acb93d742ad 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3272,7 +3272,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions fheroes2::showStandardTextMessage( _( "Auto Combat" ), msg, Dialog::ZERO ); } else if ( le.isMouseRightButtonPressedInArea( autoResolve.area() ) ) { - std::string msg = _( "Instantly resolves the battle by the computer from the current state." ); + std::string msg = _( "Instantly resolves the battle from the current state." ); msg += "\n\n"; msg += _( "autoResolve|This cannot be reverted." ); fheroes2::showStandardTextMessage( _( "Auto Resolve" ), msg, Dialog::ZERO ); From 1f11f7f2ff3b44b76372c844db681c656ec18c4c Mon Sep 17 00:00:00 2001 From: Zenseii Date: Sun, 12 Jan 2025 22:35:22 +0100 Subject: [PATCH 24/52] Change to stone background --- src/fheroes2/agg/agg_image.cpp | 4 +- src/fheroes2/battle/battle_interface.cpp | 62 +++++++++++++----------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 778ed76beae..9984853f9eb 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -2138,7 +2138,7 @@ namespace const bool isEvilInterface = ( id == ICN::BUTTON_AUTO_COMBAT_EVIL ); getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO\nCOMBAT" ), - isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::UNIFORMBAK_EVIL : ICN::UNIFORMBAK_GOOD ); + isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK ); break; } @@ -2149,7 +2149,7 @@ namespace const bool isEvilInterface = ( id == ICN::BUTTON_AUTO_RESOLVE_EVIL ); getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO\nRESOLVE" ), - isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::UNIFORMBAK_EVIL : ICN::UNIFORMBAK_GOOD ); + isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK ); break; } diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index acb93d742ad..c9f95ec2ae8 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3207,11 +3207,9 @@ void Battle::Interface::EventAutoFinish( Actions & actions ) void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions ) { - LocalEvent & le = LocalEvent::Get(); - fheroes2::Display & display = fheroes2::Display::instance(); - const fheroes2::Text title( _( "Automatic Battle Modes" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::YELLOW } ); + const fheroes2::Text title( _( "Automatic Battle" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::YELLOW } ); const fheroes2::Text header( _( "Choose an automatic battle mode:" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::WHITE } ); const bool isEvilInterface = Settings::Get().isEvilInterfaceEnabled(); @@ -3223,55 +3221,63 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions const fheroes2::Sprite & autoResolveButtonReleased = fheroes2::AGG::GetICN( autoResolveButtonICN, 0 ); const fheroes2::Sprite & cancelButtonReleased = fheroes2::AGG::GetICN( cancelButtonICN, 0 ); - const Dialog::FrameBox box( title.height( title.width() ) + 7 + header.height( header.width() ) + 7 + autoResolveButtonReleased.height() + 15, true ); - const fheroes2::Rect roiArea = box.GetArea(); + fheroes2::StandardWindow background( 289, + 7 + title.height( title.width() ) + 7 + header.height( header.width() ) + 7 + autoResolveButtonReleased.height() + 7 + + cancelButtonReleased.height() + 15, + true, display ); - fheroes2::Button cancel( roiArea.x + roiArea.width / 2 - cancelButtonReleased.width() / 2, roiArea.y + roiArea.height - 25, cancelButtonICN, 0, 1 ); + fheroes2::Button buttonAutoCombat; + fheroes2::Button buttonAutoResolve; + fheroes2::Button buttonCancel; - const int32_t buttonPlacementYOffset = roiArea.y + title.height( roiArea.width ) + 7 + header.height( roiArea.width ) + 7; + const int32_t largeButtonsXOffset = 30; + const int32_t largeButtonsYOffset = 15; - fheroes2::ButtonSprite autoCombat( roiArea.x, buttonPlacementYOffset, fheroes2::AGG::GetICN( autoCombatButtonICN, 0 ), - fheroes2::AGG::GetICN( autoCombatButtonICN, 1 ) ); - fheroes2::ButtonSprite autoResolve( roiArea.x + roiArea.width - autoResolveButtonReleased.width(), buttonPlacementYOffset, autoResolveButtonReleased, - fheroes2::AGG::GetICN( autoResolveButtonICN, 1 ) ); + background.renderButton( buttonAutoCombat, isEvilInterface ? ICN::BUTTON_AUTO_COMBAT_EVIL : ICN::BUTTON_AUTO_COMBAT_GOOD, 0, 1, { largeButtonsXOffset, 0 }, + fheroes2::StandardWindow::Padding::CENTER_LEFT ); + background.renderButton( buttonAutoResolve, isEvilInterface ? ICN::BUTTON_AUTO_RESOLVE_EVIL : ICN::BUTTON_AUTO_RESOLVE_GOOD, 0, 1, { largeButtonsXOffset, 0 }, + fheroes2::StandardWindow::Padding::CENTER_RIGHT ); + background.renderButton( buttonCancel, isEvilInterface ? ICN::BUTTON_SMALL_CANCEL_EVIL : ICN::BUTTON_SMALL_CANCEL_GOOD, 0, 1, { 0, 11 }, + fheroes2::StandardWindow::Padding::BOTTOM_CENTER ); - header.draw( roiArea.x, roiArea.y + title.height( roiArea.width ) + 7, roiArea.width, display ); - title.draw( roiArea.x, roiArea.y, roiArea.width, display ); - cancel.draw(); - autoResolve.draw(); - autoCombat.draw(); - display.render(); + const fheroes2::Rect roiArea = background.activeArea(); + + header.draw( roiArea.x, roiArea.y + 7 + title.height( roiArea.width ) + 7, roiArea.width, display ); + title.draw( roiArea.x, roiArea.y + 7, roiArea.width, display ); + + display.render( background.totalArea() ); + LocalEvent & le = LocalEvent::Get(); while ( le.HandleEvents() ) { - autoResolve.drawOnState( le.isMouseLeftButtonPressedInArea( autoResolve.area() ) ); - autoCombat.drawOnState( le.isMouseLeftButtonPressedInArea( autoCombat.area() ) ); - cancel.drawOnState( le.isMouseLeftButtonPressedInArea( cancel.area() ) ); + buttonAutoCombat.drawOnState( le.isMouseLeftButtonPressedInArea( buttonAutoCombat.area() ) ); + buttonAutoResolve.drawOnState( le.isMouseLeftButtonPressedInArea( buttonAutoResolve.area() ) ); + buttonCancel.drawOnState( le.isMouseLeftButtonPressedInArea( buttonCancel.area() ) ); - if ( le.MouseClickLeft( cancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { + if ( le.MouseClickLeft( buttonCancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { return; } - if ( le.MouseClickLeft( autoResolve.area() ) ) { - EventAutoFinish( actions ); + else if ( le.MouseClickLeft( buttonAutoCombat.area() ) ) { + EventStartAutoBattle( unit, actions ); display.render( roiArea ); } - if ( le.MouseClickLeft( autoCombat.area() ) ) { - EventStartAutoBattle( unit, actions ); + else if ( le.MouseClickLeft( buttonAutoResolve.area() ) ) { + EventAutoFinish( actions ); display.render( roiArea ); } if ( !actions.empty() ) { return; } - if ( le.isMouseRightButtonPressedInArea( cancel.area() ) ) { + if ( le.isMouseRightButtonPressedInArea( buttonCancel.area() ) ) { fheroes2::showStandardTextMessage( _( "Cancel" ), _( "Exit this menu." ), Dialog::ZERO ); } - else if ( le.isMouseRightButtonPressedInArea( autoCombat.area() ) ) { + else if ( le.isMouseRightButtonPressedInArea( buttonAutoCombat.area() ) ) { std::string msg = _( "Allows the computer to fight out the battle for you." ); msg += "\n\n"; msg += _( "autoBattle|This can be interrupted at any time by pressing any key." ); fheroes2::showStandardTextMessage( _( "Auto Combat" ), msg, Dialog::ZERO ); } - else if ( le.isMouseRightButtonPressedInArea( autoResolve.area() ) ) { + else if ( le.isMouseRightButtonPressedInArea( buttonAutoResolve.area() ) ) { std::string msg = _( "Instantly resolves the battle from the current state." ); msg += "\n\n"; msg += _( "autoResolve|This cannot be reverted." ); From 48154ed7d795db4815f8a393b9693be3b5bf4b45 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Mon, 13 Jan 2025 08:48:22 +0100 Subject: [PATCH 25/52] Dymanic background width, paraphrasing --- src/fheroes2/battle/battle_interface.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index c9f95ec2ae8..9050ee4a0c2 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3219,20 +3219,22 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions const int cancelButtonICN = isEvilInterface ? ICN::UNIFORM_EVIL_CANCEL_BUTTON : ICN::UNIFORM_GOOD_CANCEL_BUTTON; const fheroes2::Sprite & autoResolveButtonReleased = fheroes2::AGG::GetICN( autoResolveButtonICN, 0 ); + const fheroes2::Sprite & autoCombatButtonReleased = fheroes2::AGG::GetICN( autoCombatButtonICN, 0 ); const fheroes2::Sprite & cancelButtonReleased = fheroes2::AGG::GetICN( cancelButtonICN, 0 ); - fheroes2::StandardWindow background( 289, - 7 + title.height( title.width() ) + 7 + header.height( header.width() ) + 7 + autoResolveButtonReleased.height() + 7 - + cancelButtonReleased.height() + 15, - true, display ); + const int32_t largeButtonsXOffset = 30; + const int32_t largeButtonsYOffset = 15; + + const int32_t backgroundWidth = largeButtonsXOffset + autoResolveButtonReleased.width() + 17 + autoCombatButtonReleased.width() + largeButtonsXOffset; + const int32_t backgroundHeight = 7 + title.height( backgroundWidth ) + 7 + header.height( backgroundWidth ) + 7 + autoResolveButtonReleased.height() + 7 + + cancelButtonReleased.height() + largeButtonsYOffset; + + fheroes2::StandardWindow background( backgroundWidth, backgroundHeight, true, display ); fheroes2::Button buttonAutoCombat; fheroes2::Button buttonAutoResolve; fheroes2::Button buttonCancel; - const int32_t largeButtonsXOffset = 30; - const int32_t largeButtonsYOffset = 15; - background.renderButton( buttonAutoCombat, isEvilInterface ? ICN::BUTTON_AUTO_COMBAT_EVIL : ICN::BUTTON_AUTO_COMBAT_GOOD, 0, 1, { largeButtonsXOffset, 0 }, fheroes2::StandardWindow::Padding::CENTER_LEFT ); background.renderButton( buttonAutoResolve, isEvilInterface ? ICN::BUTTON_AUTO_RESOLVE_EVIL : ICN::BUTTON_AUTO_RESOLVE_GOOD, 0, 1, { largeButtonsXOffset, 0 }, @@ -3242,9 +3244,8 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions const fheroes2::Rect roiArea = background.activeArea(); - header.draw( roiArea.x, roiArea.y + 7 + title.height( roiArea.width ) + 7, roiArea.width, display ); - title.draw( roiArea.x, roiArea.y + 7, roiArea.width, display ); - + title.draw( roiArea.x, roiArea.y + 7, backgroundWidth, display ); + header.draw( roiArea.x, roiArea.y + 7 + title.height( backgroundWidth) + 7, backgroundWidth, display ); display.render( background.totalArea() ); LocalEvent & le = LocalEvent::Get(); @@ -3274,7 +3275,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions else if ( le.isMouseRightButtonPressedInArea( buttonAutoCombat.area() ) ) { std::string msg = _( "Allows the computer to fight out the battle for you." ); msg += "\n\n"; - msg += _( "autoBattle|This can be interrupted at any time by pressing any key." ); + msg += _( "autoCombat|This can be interrupted at any time by pressing any key." ); fheroes2::showStandardTextMessage( _( "Auto Combat" ), msg, Dialog::ZERO ); } else if ( le.isMouseRightButtonPressedInArea( buttonAutoResolve.area() ) ) { From 744f9fc329cd2477764bc15501d7a499d110e931 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Mon, 13 Jan 2025 10:25:23 +0100 Subject: [PATCH 26/52] Paraphrasing, dialog dynamic size cleanup --- src/fheroes2/battle/battle_interface.cpp | 34 +++++++++++------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 2ada6713d34..926f026ce6e 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -2872,13 +2872,13 @@ void Battle::Interface::HumanBattleTurn( const Unit & unit, Actions & actions, s else if ( le.isMouseCursorPosInArea( _buttonAuto.area() ) ) { cursor.SetThemes( Cursor::WAR_POINTER ); - msg = _( "Enable auto combat" ); + msg = _( "Automatic battle modes" ); if ( le.MouseClickLeft( _buttonAuto.area() ) ) { - EventStartAutoBattle( unit, actions ); + OpenAutoModeDialog( unit, actions ); } else if ( le.isMouseRightButtonPressed() ) { - fheroes2::showStandardTextMessage( _( "Auto Combat" ), _( "Allows the computer to fight out the battle for you." ), Dialog::ZERO ); + fheroes2::showStandardTextMessage( _( "Automatic Battle" ), _( "Choose between solving the battle through Auto Combat or Auto Resolve." ), Dialog::ZERO ); } } else if ( le.isMouseCursorPosInArea( _buttonSettings.area() ) ) { @@ -3228,9 +3228,6 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions { fheroes2::Display & display = fheroes2::Display::instance(); - const fheroes2::Text title( _( "Automatic Battle" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::YELLOW } ); - const fheroes2::Text header( _( "Choose an automatic battle mode:" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::WHITE } ); - const bool isEvilInterface = Settings::Get().isEvilInterfaceEnabled(); const int autoCombatButtonICN = isEvilInterface ? ICN::BUTTON_AUTO_COMBAT_EVIL : ICN::BUTTON_AUTO_COMBAT_GOOD; @@ -3241,12 +3238,16 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions const fheroes2::Sprite & autoCombatButtonReleased = fheroes2::AGG::GetICN( autoCombatButtonICN, 0 ); const fheroes2::Sprite & cancelButtonReleased = fheroes2::AGG::GetICN( cancelButtonICN, 0 ); - const int32_t largeButtonsXOffset = 30; - const int32_t largeButtonsYOffset = 15; + const int32_t autoButtonsXOffset = 20; + const int32_t autoButtonsYOffset = 15; + const int32_t titleYOffset = 16; + const int32_t buttonSeparation = 37; + + const fheroes2::Text title( _( "Automatic Battle" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::YELLOW } ); - const int32_t backgroundWidth = largeButtonsXOffset + autoResolveButtonReleased.width() + 17 + autoCombatButtonReleased.width() + largeButtonsXOffset; - const int32_t backgroundHeight = 7 + title.height( backgroundWidth ) + 7 + header.height( backgroundWidth ) + 7 + autoResolveButtonReleased.height() + 7 - + cancelButtonReleased.height() + largeButtonsYOffset; + const int32_t backgroundWidth = autoButtonsXOffset * 2 + autoResolveButtonReleased.width() + buttonSeparation + autoCombatButtonReleased.width(); + const int32_t backgroundHeight + = titleYOffset + title.height( backgroundWidth ) + autoResolveButtonReleased.height() + cancelButtonReleased.height() + autoButtonsYOffset + 28; fheroes2::StandardWindow background( backgroundWidth, backgroundHeight, true, display ); @@ -3254,17 +3255,16 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions fheroes2::Button buttonAutoResolve; fheroes2::Button buttonCancel; - background.renderButton( buttonAutoCombat, isEvilInterface ? ICN::BUTTON_AUTO_COMBAT_EVIL : ICN::BUTTON_AUTO_COMBAT_GOOD, 0, 1, { largeButtonsXOffset, 0 }, + background.renderButton( buttonAutoCombat, isEvilInterface ? ICN::BUTTON_AUTO_COMBAT_EVIL : ICN::BUTTON_AUTO_COMBAT_GOOD, 0, 1, { autoButtonsXOffset, 0 }, fheroes2::StandardWindow::Padding::CENTER_LEFT ); - background.renderButton( buttonAutoResolve, isEvilInterface ? ICN::BUTTON_AUTO_RESOLVE_EVIL : ICN::BUTTON_AUTO_RESOLVE_GOOD, 0, 1, { largeButtonsXOffset, 0 }, + background.renderButton( buttonAutoResolve, isEvilInterface ? ICN::BUTTON_AUTO_RESOLVE_EVIL : ICN::BUTTON_AUTO_RESOLVE_GOOD, 0, 1, { autoButtonsXOffset, 0 }, fheroes2::StandardWindow::Padding::CENTER_RIGHT ); background.renderButton( buttonCancel, isEvilInterface ? ICN::BUTTON_SMALL_CANCEL_EVIL : ICN::BUTTON_SMALL_CANCEL_GOOD, 0, 1, { 0, 11 }, fheroes2::StandardWindow::Padding::BOTTOM_CENTER ); const fheroes2::Rect roiArea = background.activeArea(); + title.draw( roiArea.x, roiArea.y + titleYOffset, backgroundWidth, display ); - title.draw( roiArea.x, roiArea.y + 7, backgroundWidth, display ); - header.draw( roiArea.x, roiArea.y + 7 + title.height( backgroundWidth) + 7, backgroundWidth, display ); display.render( background.totalArea() ); LocalEvent & le = LocalEvent::Get(); @@ -3278,11 +3278,9 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions } else if ( le.MouseClickLeft( buttonAutoCombat.area() ) ) { EventStartAutoBattle( unit, actions ); - display.render( roiArea ); } else if ( le.MouseClickLeft( buttonAutoResolve.area() ) ) { EventAutoFinish( actions ); - display.render( roiArea ); } if ( !actions.empty() ) { return; @@ -3294,7 +3292,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions else if ( le.isMouseRightButtonPressedInArea( buttonAutoCombat.area() ) ) { std::string msg = _( "Allows the computer to fight out the battle for you." ); msg += "\n\n"; - msg += _( "autoCombat|This can be interrupted at any time by pressing any key." ); + msg += _( "autoCombat|This can be interrupted at any time by pressing the Auto Combat hotkey, or by a right- or left-click." ); fheroes2::showStandardTextMessage( _( "Auto Combat" ), msg, Dialog::ZERO ); } else if ( le.isMouseRightButtonPressedInArea( buttonAutoResolve.area() ) ) { From 2b5c1b95c099f57745c7ff00398cb1de68f4b008 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Mon, 13 Jan 2025 10:25:50 +0100 Subject: [PATCH 27/52] Make normal buttons have extra margin when they have multi-lined button text --- src/fheroes2/gui/ui_button.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fheroes2/gui/ui_button.cpp b/src/fheroes2/gui/ui_button.cpp index 6f0eb909d03..ba76aec9036 100644 --- a/src/fheroes2/gui/ui_button.cpp +++ b/src/fheroes2/gui/ui_button.cpp @@ -778,6 +778,10 @@ namespace fheroes2 const int32_t textHeight = releasedText.height( textAreaWidth ); assert( textHeight > 0 ); + // Add extra y margin for multilined texts on normal buttons + if ( ( emptyButtonIcnID == ICN::EMPTY_EVIL_BUTTON || emptyButtonIcnID == ICN::EMPTY_GOOD_BUTTON ) && textHeight > 17 ) { + textAreaMargins.y += 16; + } const int32_t borderedTextHeight = textHeight + textAreaMargins.y; const int32_t textAreaHeight = std::clamp( borderedTextHeight, minimumTextArea.height, maximumTextArea.height ); From 560c352a784416ca5f4372722f86fac61a03aa5e Mon Sep 17 00:00:00 2001 From: Zenseii Date: Mon, 13 Jan 2025 10:34:46 +0100 Subject: [PATCH 28/52] else if to if --- src/fheroes2/battle/battle_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 926f026ce6e..6bb7d92631a 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3276,7 +3276,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions if ( le.MouseClickLeft( buttonCancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { return; } - else if ( le.MouseClickLeft( buttonAutoCombat.area() ) ) { + if ( le.MouseClickLeft( buttonAutoCombat.area() ) ) { EventStartAutoBattle( unit, actions ); } else if ( le.MouseClickLeft( buttonAutoResolve.area() ) ) { From 4bc6e707b431cffd63a29dfb5e33615000deff8c Mon Sep 17 00:00:00 2001 From: Zenseii Date: Mon, 13 Jan 2025 13:05:31 +0100 Subject: [PATCH 29/52] Add hotkeys, expand description description improvements --- src/fheroes2/battle/battle_interface.cpp | 8 ++++---- src/fheroes2/gui/ui_button.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 6bb7d92631a..6360e87e74e 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -2878,7 +2878,7 @@ void Battle::Interface::HumanBattleTurn( const Unit & unit, Actions & actions, s OpenAutoModeDialog( unit, actions ); } else if ( le.isMouseRightButtonPressed() ) { - fheroes2::showStandardTextMessage( _( "Automatic Battle" ), _( "Choose between solving the battle through Auto Combat or Auto Resolve." ), Dialog::ZERO ); + fheroes2::showStandardTextMessage( _( "Automatic Battle" ), _( "Choose whether to fight out the battle through Auto Combat or Auto Resolve." ), Dialog::ZERO ); } } else if ( le.isMouseCursorPosInArea( _buttonSettings.area() ) ) { @@ -3276,10 +3276,10 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions if ( le.MouseClickLeft( buttonCancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { return; } - if ( le.MouseClickLeft( buttonAutoCombat.area() ) ) { + if ( le.MouseClickLeft( buttonAutoCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_AUTO_SWITCH ) ) { EventStartAutoBattle( unit, actions ); } - else if ( le.MouseClickLeft( buttonAutoResolve.area() ) ) { + else if ( le.MouseClickLeft( buttonAutoResolve.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_AUTO_FINISH ) ) { EventAutoFinish( actions ); } if ( !actions.empty() ) { @@ -3292,7 +3292,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions else if ( le.isMouseRightButtonPressedInArea( buttonAutoCombat.area() ) ) { std::string msg = _( "Allows the computer to fight out the battle for you." ); msg += "\n\n"; - msg += _( "autoCombat|This can be interrupted at any time by pressing the Auto Combat hotkey, or by a right- or left-click." ); + msg += _( "autoCombat|This can be interrupted at any point by either pressing the Auto Combat hotkey or the default cancel key, or by right- or left-clicking anywhere." ); fheroes2::showStandardTextMessage( _( "Auto Combat" ), msg, Dialog::ZERO ); } else if ( le.isMouseRightButtonPressedInArea( buttonAutoResolve.area() ) ) { diff --git a/src/fheroes2/gui/ui_button.cpp b/src/fheroes2/gui/ui_button.cpp index ba76aec9036..1e491a3bc86 100644 --- a/src/fheroes2/gui/ui_button.cpp +++ b/src/fheroes2/gui/ui_button.cpp @@ -778,7 +778,7 @@ namespace fheroes2 const int32_t textHeight = releasedText.height( textAreaWidth ); assert( textHeight > 0 ); - // Add extra y margin for multilined texts on normal buttons + // Add extra y-margin for multi-lined texts on normal buttons. if ( ( emptyButtonIcnID == ICN::EMPTY_EVIL_BUTTON || emptyButtonIcnID == ICN::EMPTY_GOOD_BUTTON ) && textHeight > 17 ) { textAreaMargins.y += 16; } From 8b9112c9b450ab7b7653472f0b001cff088e7227 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Mon, 13 Jan 2025 13:07:20 +0100 Subject: [PATCH 30/52] Code style --- src/fheroes2/battle/battle_interface.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 6360e87e74e..4cec1446ffc 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -2878,7 +2878,8 @@ void Battle::Interface::HumanBattleTurn( const Unit & unit, Actions & actions, s OpenAutoModeDialog( unit, actions ); } else if ( le.isMouseRightButtonPressed() ) { - fheroes2::showStandardTextMessage( _( "Automatic Battle" ), _( "Choose whether to fight out the battle through Auto Combat or Auto Resolve." ), Dialog::ZERO ); + fheroes2::showStandardTextMessage( _( "Automatic Battle" ), _( "Choose whether to fight out the battle through Auto Combat or Auto Resolve." ), + Dialog::ZERO ); } } else if ( le.isMouseCursorPosInArea( _buttonSettings.area() ) ) { @@ -3292,7 +3293,8 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions else if ( le.isMouseRightButtonPressedInArea( buttonAutoCombat.area() ) ) { std::string msg = _( "Allows the computer to fight out the battle for you." ); msg += "\n\n"; - msg += _( "autoCombat|This can be interrupted at any point by either pressing the Auto Combat hotkey or the default cancel key, or by right- or left-clicking anywhere." ); + msg += _( + "autoCombat|This can be interrupted at any point by either pressing the Auto Combat hotkey or the default cancel key, or by right- or left-clicking anywhere." ); fheroes2::showStandardTextMessage( _( "Auto Combat" ), msg, Dialog::ZERO ); } else if ( le.isMouseRightButtonPressedInArea( buttonAutoResolve.area() ) ) { From 9c7f070016defb55f8a60e5be9b8f1d427426cbf Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Tue, 14 Jan 2025 19:52:19 +0300 Subject: [PATCH 31/52] Rename the symbols and hotkeys related to auto combat and instant combat --- src/fheroes2/ai/ai_battle.cpp | 14 ++--- src/fheroes2/ai/ai_battle.h | 4 +- src/fheroes2/battle/battle_action.cpp | 24 ++++----- src/fheroes2/battle/battle_arena.cpp | 27 +++++----- src/fheroes2/battle/battle_arena.h | 14 ++--- src/fheroes2/battle/battle_command.cpp | 6 +-- src/fheroes2/battle/battle_command.h | 10 ++-- src/fheroes2/battle/battle_interface.cpp | 69 ++++++++++++------------ src/fheroes2/battle/battle_interface.h | 8 +-- src/fheroes2/game/game_hotkeys.cpp | 25 +++++++-- src/fheroes2/game/game_hotkeys.h | 6 +-- 11 files changed, 110 insertions(+), 97 deletions(-) diff --git a/src/fheroes2/ai/ai_battle.cpp b/src/fheroes2/ai/ai_battle.cpp index 1dcf6e87f2a..3bda4373ecd 100644 --- a/src/fheroes2/ai/ai_battle.cpp +++ b/src/fheroes2/ai/ai_battle.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * fheroes2: https://github.com/ihhub/fheroes2 * - * Copyright (C) 2024 * + * Copyright (C) 2024 - 2025 * * * * 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 * @@ -659,13 +659,13 @@ bool AI::BattlePlanner::isLimitOfTurnsExceeded( const Battle::Arena & arena, Bat // We have gone beyond the limit on the number of turns without deaths and have to stop if ( _numberOfRemainingTurnsWithoutDeaths == 0 ) { - // If this is an auto battle (and not the instant battle, because the battle UI is present), then turn it off until the end of the battle - if ( arena.AutoBattleInProgress() && Battle::Arena::GetInterface() != nullptr ) { - assert( arena.CanToggleAutoBattle() ); + // If this is an auto combat (and not the instant combat, because the battle UI is present), then turn it off until the end of the battle + if ( arena.AutoCombatInProgress() && Battle::Arena::GetInterface() != nullptr ) { + assert( arena.CanToggleAutoCombat() ); - actions.emplace_back( Battle::Command::AUTO_SWITCH, currentColor ); + actions.emplace_back( Battle::Command::TOGGLE_AUTO_COMBAT, currentColor ); - DEBUG_LOG( DBG_BATTLE, DBG_INFO, Color::String( currentColor ) << " has used up the limit of turns without deaths, auto battle is turned off" ) + DEBUG_LOG( DBG_BATTLE, DBG_INFO, Color::String( currentColor ) << " has used up the limit of turns without deaths, auto combat is turned off" ) } // Otherwise the attacker's hero should retreat else { @@ -711,7 +711,7 @@ Battle::Actions AI::BattlePlanner::planUnitTurn( Battle::Arena & arena, const Ba return Outcome::ContinueBattle; } - // Human-controlled heroes should not retreat or surrender during auto/instant battles + // Human-controlled heroes should not retreat or surrender during auto/instant combat if ( actualHero->isControlHuman() ) { return Outcome::ContinueBattle; } diff --git a/src/fheroes2/ai/ai_battle.h b/src/fheroes2/ai/ai_battle.h index 56cce8f24f1..0a673fc1b9b 100644 --- a/src/fheroes2/ai/ai_battle.h +++ b/src/fheroes2/ai/ai_battle.h @@ -1,6 +1,6 @@ /*************************************************************************** * fheroes2: https://github.com/ihhub/fheroes2 * - * Copyright (C) 2024 * + * Copyright (C) 2024 - 2025 * * * * 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 * @@ -112,7 +112,7 @@ namespace AI int32_t spellDurationMultiplier( const Battle::Unit & target ) const; // When this limit of turns without deaths is exceeded for an attacking AI-controlled hero, - // the auto battle should be interrupted (one way or another) + // the auto combat should be interrupted (one way or another) static const uint32_t MAX_TURNS_WITHOUT_DEATHS = 50; // Member variables related to the logic of checking the limit of the number of turns diff --git a/src/fheroes2/battle/battle_action.cpp b/src/fheroes2/battle/battle_action.cpp index 06f99045599..794d5b0a117 100644 --- a/src/fheroes2/battle/battle_action.cpp +++ b/src/fheroes2/battle/battle_action.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * fheroes2: https://github.com/ihhub/fheroes2 * - * Copyright (C) 2019 - 2024 * + * Copyright (C) 2019 - 2025 * * * * Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 * * Copyright (C) 2010 by Andrey Afletdinov * @@ -424,11 +424,11 @@ void Battle::Arena::ApplyAction( Command & cmd ) ApplyActionSurrender( cmd ); break; - case CommandType::AUTO_SWITCH: - ApplyActionAutoSwitch( cmd ); + case CommandType::TOGGLE_AUTO_COMBAT: + ApplyActionToggleAutoCombat( cmd ); break; - case CommandType::AUTO_FINISH: - ApplyActionAutoFinish( cmd ); + case CommandType::INSTANT_COMBAT: + ApplyActionInstantCombat( cmd ); break; default: @@ -1325,7 +1325,7 @@ void Battle::Arena::ApplyActionCatapult( Command & cmd ) } } -void Battle::Arena::ApplyActionAutoSwitch( Command & cmd ) +void Battle::Arena::ApplyActionToggleAutoCombat( Command & cmd ) { const auto checkParameters = []( const int color ) { const Arena * arena = GetArena(); @@ -1355,22 +1355,22 @@ void Battle::Arena::ApplyActionAutoSwitch( Command & cmd ) return; } - _autoBattleColors ^= color; + _autoCombatColors ^= color; - DEBUG_LOG( DBG_BATTLE, DBG_TRACE, "color: " << Color::String( color ) << ", status: " << ( ( _autoBattleColors & color ) ? "on" : "off" ) ) + DEBUG_LOG( DBG_BATTLE, DBG_TRACE, "color: " << Color::String( color ) << ", status: " << ( ( _autoCombatColors & color ) ? "on" : "off" ) ) if ( _interface ) { const Player * player = Players::Get( color ); assert( player ); - std::string msg = ( _autoBattleColors & color ) ? _( "%{name} has turned on the auto battle" ) : _( "%{name} has turned off the auto battle" ); + std::string msg = ( _autoCombatColors & color ) ? _( "%{name} has turned on the auto combat" ) : _( "%{name} has turned off the auto combat" ); StringReplace( msg, "%{name}", player->GetName() ); _interface->setStatus( msg, true ); } } -void Battle::Arena::ApplyActionAutoFinish( const Command & /* cmd */ ) +void Battle::Arena::ApplyActionInstantCombat( const Command & /* cmd */ ) { const int army1Control = GetForce1().GetControl(); const int army2Control = GetForce2().GetControl(); @@ -1391,10 +1391,10 @@ void Battle::Arena::ApplyActionAutoFinish( const Command & /* cmd */ ) const int army2Color = GetArmy2Color(); if ( army1Control & CONTROL_HUMAN ) { - _autoBattleColors |= army1Color; + _autoCombatColors |= army1Color; } if ( army2Control & CONTROL_HUMAN ) { - _autoBattleColors |= army2Color; + _autoCombatColors |= army2Color; } _interface.reset(); diff --git a/src/fheroes2/battle/battle_arena.cpp b/src/fheroes2/battle/battle_arena.cpp index c5001abbc72..49f226b6f7f 100644 --- a/src/fheroes2/battle/battle_arena.cpp +++ b/src/fheroes2/battle/battle_arena.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * fheroes2: https://github.com/ihhub/fheroes2 * - * Copyright (C) 2019 - 2024 * + * Copyright (C) 2019 - 2025 * * * * Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 * * Copyright (C) 2010 by Andrey Afletdinov * @@ -362,7 +362,6 @@ Battle::Arena::Arena( Army & army1, Army & army2, const int32_t tileIndex, const castle = nullptr; } - // init interface if ( isShowInterface ) { _interface = std::make_unique( *this, tileIndex ); board.SetArea( _interface->GetArea() ); @@ -372,12 +371,12 @@ Battle::Arena::Arena( Army & army1, Army & army2, const int32_t tileIndex, const _interface->SetOrderOfUnits( _orderOfUnits ); } else { - // no interface - force auto battle mode for human player + // There is no interface - force the auto combat mode for the human player if ( army1.isControlHuman() ) { - _autoBattleColors |= army1.GetColor(); + _autoCombatColors |= army1.GetColor(); } if ( army2.isControlHuman() ) { - _autoBattleColors |= army2.GetColor(); + _autoCombatColors |= army2.GetColor(); } } @@ -484,8 +483,8 @@ void Battle::Arena::UnitTurn( const Units & orderHistory ) } if ( !actions.empty() ) { - // Pending actions from the user interface (such as toggling auto battle) have "already occurred" and - // therefore should be handled first, before any other actions. Just skip the rest of the branches. + // Pending actions from the user interface (such as toggling the auto combat on/off) have "already occurred" + // and therefore should be handled first, before any other actions. Just skip the rest of the branches. } else if ( _currentUnit->GetSpeed() == Speed::STANDING ) { // Unit has either finished its turn, is dead, or has become immovable due to some spell. Even if the @@ -506,7 +505,7 @@ void Battle::Arena::UnitTurn( const Units & orderHistory ) _bridge->SetPassability( *_currentUnit ); } - if ( ( _currentUnit->GetCurrentControl() & CONTROL_AI ) || ( _currentUnit->GetCurrentColor() & _autoBattleColors ) ) { + if ( ( _currentUnit->GetCurrentControl() & CONTROL_AI ) || ( _currentUnit->GetCurrentColor() & _autoCombatColors ) ) { AI::BattlePlanner::Get().BattleTurn( *this, *_currentUnit, actions ); } else { @@ -1432,14 +1431,14 @@ Battle::Result & Battle::Arena::GetResult() return result_game; } -bool Battle::Arena::AutoBattleInProgress() const +bool Battle::Arena::AutoCombatInProgress() const { if ( _currentUnit == nullptr ) { return false; } - if ( _autoBattleColors & GetCurrentColor() ) { - // Auto battle mode cannot be enabled for a player controlled by AI + if ( _autoCombatColors & GetCurrentColor() ) { + // Auto combat mode cannot be enabled for a player controlled by AI assert( !( GetCurrentForce().GetControl() & CONTROL_AI ) ); return true; @@ -1448,7 +1447,7 @@ bool Battle::Arena::AutoBattleInProgress() const return false; } -bool Battle::Arena::EnemyOfAIHasAutoBattleInProgress() const +bool Battle::Arena::EnemyOfAIHasAutoCombatInProgress() const { if ( _currentUnit == nullptr ) { return false; @@ -1464,10 +1463,10 @@ bool Battle::Arena::EnemyOfAIHasAutoBattleInProgress() const return false; } - return ( _autoBattleColors & enemyForce.GetColor() ); + return ( _autoCombatColors & enemyForce.GetColor() ); } -bool Battle::Arena::CanToggleAutoBattle() const +bool Battle::Arena::CanToggleAutoCombat() const { if ( _currentUnit == nullptr ) { return false; diff --git a/src/fheroes2/battle/battle_arena.h b/src/fheroes2/battle/battle_arena.h index aecd1edba22..c2dc3bfe425 100644 --- a/src/fheroes2/battle/battle_arena.h +++ b/src/fheroes2/battle/battle_arena.h @@ -104,9 +104,9 @@ namespace Battle void Turns(); bool BattleValid() const; - bool AutoBattleInProgress() const; - bool EnemyOfAIHasAutoBattleInProgress() const; - bool CanToggleAutoBattle() const; + bool AutoCombatInProgress() const; + bool EnemyOfAIHasAutoCombatInProgress() const; + bool CanToggleAutoCombat() const; uint32_t GetTurnNumber() const { @@ -284,8 +284,8 @@ namespace Battle void ApplyActionSpellCast( Command & cmd ); void ApplyActionTower( Command & cmd ); void ApplyActionCatapult( Command & cmd ); - void ApplyActionAutoSwitch( Command & cmd ); - void ApplyActionAutoFinish( const Command & cmd ); + void ApplyActionToggleAutoCombat( Command & cmd ); + void ApplyActionInstantCombat( const Command & cmd ); void ApplyActionSpellSummonElemental( const Command & cmd, const Spell & spell ); void ApplyActionSpellMirrorImage( Command & cmd ); @@ -343,8 +343,8 @@ namespace Battle int _covrIcnId{ ICN::UNKNOWN }; uint32_t _turnNumber{ 0 }; - // A set of colors of players for whom the auto-battle mode is enabled - int _autoBattleColors{ 0 }; + // A set of colors of players for whom the auto combat mode is enabled + int _autoCombatColors{ 0 }; // This random number generator should only be used in code that is equally used by both AI and the human // player - that is, in code related to the processing of battle commands. It cannot be safely used in other diff --git a/src/fheroes2/battle/battle_command.cpp b/src/fheroes2/battle/battle_command.cpp index 45e7d307a8b..974bd65ab1c 100644 --- a/src/fheroes2/battle/battle_command.cpp +++ b/src/fheroes2/battle/battle_command.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * fheroes2: https://github.com/ihhub/fheroes2 * - * Copyright (C) 2019 - 2023 * + * Copyright (C) 2019 - 2025 * * * * Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 * * Copyright (C) 2012 by Andrey Afletdinov * @@ -63,8 +63,8 @@ uint32_t Battle::Command::updateSeed( uint32_t seed ) const break; // These commands should never affect the seed generation - case CommandType::AUTO_SWITCH: - case CommandType::AUTO_FINISH: + case CommandType::TOGGLE_AUTO_COMBAT: + case CommandType::INSTANT_COMBAT: break; default: diff --git a/src/fheroes2/battle/battle_command.h b/src/fheroes2/battle/battle_command.h index fa681d1139a..3c9e0535e06 100644 --- a/src/fheroes2/battle/battle_command.h +++ b/src/fheroes2/battle/battle_command.h @@ -46,8 +46,8 @@ namespace Battle RETREAT, SURRENDER, SKIP, - AUTO_SWITCH, - AUTO_FINISH + TOGGLE_AUTO_COMBAT, + INSTANT_COMBAT }; class Command final : public std::vector @@ -62,8 +62,8 @@ namespace Battle static constexpr std::integral_constant RETREAT{}; static constexpr std::integral_constant SURRENDER{}; static constexpr std::integral_constant SKIP{}; - static constexpr std::integral_constant AUTO_SWITCH{}; - static constexpr std::integral_constant AUTO_FINISH{}; + static constexpr std::integral_constant TOGGLE_AUTO_COMBAT{}; + static constexpr std::integral_constant INSTANT_COMBAT{}; template explicit Command( std::integral_constant /* tag */, const Types... params ) @@ -107,7 +107,7 @@ namespace Battle // UID static_assert( sizeof...( params ) == 1 ); } - else if constexpr ( cmd == CommandType::AUTO_SWITCH ) { + else if constexpr ( cmd == CommandType::TOGGLE_AUTO_COMBAT ) { // Color static_assert( sizeof...( params ) == 1 ); } diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 4cec1446ffc..6c39095a69b 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -2693,10 +2693,10 @@ int Battle::Interface::GetBattleSpellCursor( std::string & statusMsg ) const void Battle::Interface::getPendingActions( Actions & actions ) { - if ( _interruptAutoBattleForColor ) { - actions.emplace_back( Command::AUTO_SWITCH, _interruptAutoBattleForColor ); + if ( _interruptAutoCombatForColor ) { + actions.emplace_back( Command::TOGGLE_AUTO_COMBAT, _interruptAutoCombatForColor ); - _interruptAutoBattleForColor = 0; + _interruptAutoCombatForColor = 0; } } @@ -2801,13 +2801,13 @@ void Battle::Interface::HumanBattleTurn( const Unit & unit, Actions & actions, s else if ( Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_OPTIONS ) ) { EventShowOptions(); } - // Switch the auto battle mode on - else if ( Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_AUTO_SWITCH ) ) { - EventStartAutoBattle( unit, actions ); + // Switch the auto combat mode on + else if ( Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_TOGGLE_AUTO_COMBAT ) ) { + EventStartAutoCombat( unit, actions ); } - // Finish the battle in auto mode - else if ( Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_AUTO_FINISH ) ) { - EventAutoFinish( actions ); + // Instantly finish the battle in auto mode + else if ( Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_INSTANT_COMBAT ) ) { + EventInstantCombat( actions ); } // Cast the spell else if ( Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_CAST_SPELL ) ) { @@ -2872,13 +2872,13 @@ void Battle::Interface::HumanBattleTurn( const Unit & unit, Actions & actions, s else if ( le.isMouseCursorPosInArea( _buttonAuto.area() ) ) { cursor.SetThemes( Cursor::WAR_POINTER ); - msg = _( "Automatic battle modes" ); + msg = _( "Automatic combat modes" ); if ( le.MouseClickLeft( _buttonAuto.area() ) ) { OpenAutoModeDialog( unit, actions ); } else if ( le.isMouseRightButtonPressed() ) { - fheroes2::showStandardTextMessage( _( "Automatic Battle" ), _( "Choose whether to fight out the battle through Auto Combat or Auto Resolve." ), + fheroes2::showStandardTextMessage( _( "Automatic Combat" ), _( "Choose whether to fight out the battle through Auto Combat or Auto Resolve." ), Dialog::ZERO ); } } @@ -3196,30 +3196,29 @@ void Battle::Interface::EventShowOptions() humanturn_redraw = true; } -void Battle::Interface::EventStartAutoBattle( const Unit & unit, Actions & actions ) +void Battle::Interface::EventStartAutoCombat( const Unit & unit, Actions & actions ) { // TODO: remove these temporary assertions - assert( arena.CanToggleAutoBattle() ); - assert( !arena.AutoBattleInProgress() ); + assert( arena.CanToggleAutoCombat() ); + assert( !arena.AutoCombatInProgress() ); - int startAutoBattle = fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to enable auto combat?" ), Dialog::YES | Dialog::NO ); - if ( startAutoBattle != Dialog::YES ) { + if ( fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to enable auto combat?" ), Dialog::YES | Dialog::NO ) != Dialog::YES ) { return; } - actions.emplace_back( Command::AUTO_SWITCH, unit.GetCurrentOrArmyColor() ); + actions.emplace_back( Command::TOGGLE_AUTO_COMBAT, unit.GetCurrentOrArmyColor() ); humanturn_redraw = true; humanturn_exit = true; } -void Battle::Interface::EventAutoFinish( Actions & actions ) +void Battle::Interface::EventInstantCombat( Actions & actions ) { - if ( fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to finish the battle in auto mode?" ), Dialog::YES | Dialog::NO ) != Dialog::YES ) { + if ( fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to finish the battle instantly in auto mode?" ), Dialog::YES | Dialog::NO ) != Dialog::YES ) { return; } - actions.emplace_back( Command::AUTO_FINISH ); + actions.emplace_back( Command::INSTANT_COMBAT ); humanturn_redraw = true; humanturn_exit = true; @@ -3244,7 +3243,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions const int32_t titleYOffset = 16; const int32_t buttonSeparation = 37; - const fheroes2::Text title( _( "Automatic Battle" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::YELLOW } ); + const fheroes2::Text title( _( "Automatic Combat" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::YELLOW } ); const int32_t backgroundWidth = autoButtonsXOffset * 2 + autoResolveButtonReleased.width() + buttonSeparation + autoCombatButtonReleased.width(); const int32_t backgroundHeight @@ -3277,11 +3276,11 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions if ( le.MouseClickLeft( buttonCancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { return; } - if ( le.MouseClickLeft( buttonAutoCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_AUTO_SWITCH ) ) { - EventStartAutoBattle( unit, actions ); + if ( le.MouseClickLeft( buttonAutoCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_TOGGLE_AUTO_COMBAT ) ) { + EventStartAutoCombat( unit, actions ); } - else if ( le.MouseClickLeft( buttonAutoResolve.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_AUTO_FINISH ) ) { - EventAutoFinish( actions ); + else if ( le.MouseClickLeft( buttonAutoResolve.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_INSTANT_COMBAT ) ) { + EventInstantCombat( actions ); } if ( !actions.empty() ) { return; @@ -6501,39 +6500,39 @@ void Battle::Interface::CheckGlobalEvents( LocalEvent & le ) } } - // Check if auto battle interruption was requested. - InterruptAutoBattleIfRequested( le ); + // Check if auto combat interruption was requested. + InterruptAutoCombatIfRequested( le ); } -void Battle::Interface::InterruptAutoBattleIfRequested( LocalEvent & le ) +void Battle::Interface::InterruptAutoCombatIfRequested( LocalEvent & le ) { // Interrupt only if automation is currently on. - if ( !arena.AutoBattleInProgress() && !arena.EnemyOfAIHasAutoBattleInProgress() ) { + if ( !arena.AutoCombatInProgress() && !arena.EnemyOfAIHasAutoCombatInProgress() ) { return; } - if ( !le.MouseClickLeft() && !le.MouseClickRight() && !Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_AUTO_SWITCH ) + if ( !le.MouseClickLeft() && !le.MouseClickRight() && !Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_TOGGLE_AUTO_COMBAT ) && !Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { return; } - // Identify which color requested the auto battle interrupt. + // Identify which color requested the auto combat interruption. int color = arena.GetCurrentColor(); if ( arena.GetCurrentForce().GetControl() & CONTROL_AI ) { color = arena.GetOppositeColor( color ); } // The battle interruption is already scheduled, no need for the dialog. - if ( color == _interruptAutoBattleForColor ) { + if ( color == _interruptAutoCombatForColor ) { return; } - // Right now there should be no pending auto battle interruptions. - assert( _interruptAutoBattleForColor == 0 ); + // Right now there should be no pending auto combat interruptions. + assert( _interruptAutoCombatForColor == 0 ); const int interrupt = fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to interrupt the auto combat?" ), Dialog::YES | Dialog::NO ); if ( interrupt == Dialog::YES ) { - _interruptAutoBattleForColor = color; + _interruptAutoCombatForColor = color; } } diff --git a/src/fheroes2/battle/battle_interface.h b/src/fheroes2/battle/battle_interface.h index 86e9b04277b..a98ae321d0a 100644 --- a/src/fheroes2/battle/battle_interface.h +++ b/src/fheroes2/battle/battle_interface.h @@ -414,14 +414,14 @@ namespace Battle void SwitchAllUnitsAnimation( const int32_t animationState ) const; void UpdateContourColor(); void CheckGlobalEvents( LocalEvent & ); - void InterruptAutoBattleIfRequested( LocalEvent & le ); + void InterruptAutoCombatIfRequested( LocalEvent & le ); void SetHeroAnimationReactionToTroopDeath( const int32_t deathColor ) const; void ProcessingHeroDialogResult( const int result, Actions & actions ); void _openBattleSettingsDialog(); - void EventStartAutoBattle( const Unit & unit, Actions & actions ); - void EventAutoFinish( Actions & actions ); + void EventStartAutoCombat( const Unit & unit, Actions & actions ); + void EventInstantCombat( Actions & actions ); void OpenAutoModeDialog( const Unit & unit, Actions & actions ); void EventShowOptions(); void MouseLeftClickBoardAction( const int themes, const Cell & cell, const bool isConfirmed, Actions & actions ); @@ -459,7 +459,7 @@ namespace Battle uint32_t animation_flags_frame{ 0 }; int catapult_frame{ 0 }; - int _interruptAutoBattleForColor{ 0 }; + int _interruptAutoCombatForColor{ 0 }; // The Channel ID of pre-battle sound. Used to check it is over to start the battle music. std::optional _preBattleSoundChannelId{ -1 }; diff --git a/src/fheroes2/game/game_hotkeys.cpp b/src/fheroes2/game/game_hotkeys.cpp index 4df9820230e..58b8567d836 100644 --- a/src/fheroes2/game/game_hotkeys.cpp +++ b/src/fheroes2/game/game_hotkeys.cpp @@ -269,10 +269,10 @@ namespace = { Game::HotKeyCategory::BATTLE, gettext_noop( "hotkey|retreat from battle" ), fheroes2::Key::KEY_R }; hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::BATTLE_SURRENDER )] = { Game::HotKeyCategory::BATTLE, gettext_noop( "hotkey|surrender during battle" ), fheroes2::Key::KEY_S }; - hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::BATTLE_AUTO_SWITCH )] - = { Game::HotKeyCategory::BATTLE, gettext_noop( "hotkey|toggle battle auto mode" ), fheroes2::Key::KEY_A }; - hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::BATTLE_AUTO_FINISH )] - = { Game::HotKeyCategory::BATTLE, gettext_noop( "hotkey|finish the battle in auto mode" ), fheroes2::Key::KEY_Q }; + hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::BATTLE_TOGGLE_AUTO_COMBAT )] + = { Game::HotKeyCategory::BATTLE, gettext_noop( "hotkey|toggle auto combat mode" ), fheroes2::Key::KEY_A }; + hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::BATTLE_INSTANT_COMBAT )] + = { Game::HotKeyCategory::BATTLE, gettext_noop( "hotkey|instant combat" ), fheroes2::Key::KEY_Q }; hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::BATTLE_OPTIONS )] = { Game::HotKeyCategory::BATTLE, gettext_noop( "hotkey|battle options" ), fheroes2::Key::KEY_O }; hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::BATTLE_SKIP )] @@ -432,7 +432,22 @@ void Game::HotKeysLoad( const std::string & filename ) const char * eventName = _( hotKeyEventInfo[eventId].name ); std::string value = config.StrParams( eventName ); if ( value.empty() ) { - continue; + // TODO: remove this temporary workaround + if ( eventName == std::string_view( "toggle auto combat mode" ) ) { + value = config.StrParams( "toggle battle auto mode" ); + if ( value.empty() ) { + continue; + } + } + else if ( eventName == std::string_view( "instant combat" ) ) { + value = config.StrParams( "finish the battle in auto mode" ); + if ( value.empty() ) { + continue; + } + } + else { + continue; + } } value = StringUpper( value ); diff --git a/src/fheroes2/game/game_hotkeys.h b/src/fheroes2/game/game_hotkeys.h index d0c58d702d8..ad9afdd6885 100644 --- a/src/fheroes2/game/game_hotkeys.h +++ b/src/fheroes2/game/game_hotkeys.h @@ -1,6 +1,6 @@ /*************************************************************************** * fheroes2: https://github.com/ihhub/fheroes2 * - * Copyright (C) 2022 - 2024 * + * Copyright (C) 2022 - 2025 * * * * 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 * @@ -136,8 +136,8 @@ namespace Game BATTLE_RETREAT, BATTLE_SURRENDER, - BATTLE_AUTO_SWITCH, - BATTLE_AUTO_FINISH, + BATTLE_TOGGLE_AUTO_COMBAT, + BATTLE_INSTANT_COMBAT, BATTLE_OPTIONS, BATTLE_SKIP, BATTLE_CAST_SPELL, From 3120a9f6f471a5715c1146e6e077c69b7b7a289e Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Tue, 14 Jan 2025 20:09:27 +0300 Subject: [PATCH 32/52] Apply the IWYU suggestions --- src/fheroes2/game/game_hotkeys.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fheroes2/game/game_hotkeys.cpp b/src/fheroes2/game/game_hotkeys.cpp index 58b8567d836..2d05c5bddda 100644 --- a/src/fheroes2/game/game_hotkeys.cpp +++ b/src/fheroes2/game/game_hotkeys.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include From d1218f9aaa2ecb33aef6acc3a23f95d58da56746 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 16 Jan 2025 17:39:07 +0100 Subject: [PATCH 33/52] Auto Resolve -> Quick Combat Paraphrasings --- src/fheroes2/agg/agg_image.cpp | 2 +- src/fheroes2/battle/battle_interface.cpp | 28 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 9984853f9eb..3980b097931 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -2148,7 +2148,7 @@ namespace const bool isEvilInterface = ( id == ICN::BUTTON_AUTO_RESOLVE_EVIL ); - getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "AUTO\nRESOLVE" ), + getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "QUICK\nCOMBAT" ), isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK ); break; diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 6c39095a69b..dbc632a31e2 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -2878,7 +2878,7 @@ void Battle::Interface::HumanBattleTurn( const Unit & unit, Actions & actions, s OpenAutoModeDialog( unit, actions ); } else if ( le.isMouseRightButtonPressed() ) { - fheroes2::showStandardTextMessage( _( "Automatic Combat" ), _( "Choose whether to fight out the battle through Auto Combat or Auto Resolve." ), + fheroes2::showStandardTextMessage( _( "Automatic Combat Modes" ), _( "Choose whether to proceed the combat in auto combat mode or in quick combat mode." ), Dialog::ZERO ); } } @@ -3231,8 +3231,8 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions const bool isEvilInterface = Settings::Get().isEvilInterfaceEnabled(); const int autoCombatButtonICN = isEvilInterface ? ICN::BUTTON_AUTO_COMBAT_EVIL : ICN::BUTTON_AUTO_COMBAT_GOOD; - const int autoResolveButtonICN = isEvilInterface ? ICN::BUTTON_AUTO_RESOLVE_EVIL : ICN::BUTTON_AUTO_RESOLVE_GOOD; - const int cancelButtonICN = isEvilInterface ? ICN::UNIFORM_EVIL_CANCEL_BUTTON : ICN::UNIFORM_GOOD_CANCEL_BUTTON; + const int autoResolveButtonICN = isEvilInterface ? ICN::BUTTON_QUICK_COMBAT_EVIL : ICN::BUTTON_QUICK_COMBAT_GOOD; + const int cancelButtonICN = isEvilInterface ? ICN::BUTTON_SMALL_CANCEL_EVIL : ICN::BUTTON_SMALL_CANCEL_GOOD; const fheroes2::Sprite & autoResolveButtonReleased = fheroes2::AGG::GetICN( autoResolveButtonICN, 0 ); const fheroes2::Sprite & autoCombatButtonReleased = fheroes2::AGG::GetICN( autoCombatButtonICN, 0 ); @@ -3243,7 +3243,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions const int32_t titleYOffset = 16; const int32_t buttonSeparation = 37; - const fheroes2::Text title( _( "Automatic Combat" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::YELLOW } ); + const fheroes2::Text title( _( "Automatic Combat Modes" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::YELLOW } ); const int32_t backgroundWidth = autoButtonsXOffset * 2 + autoResolveButtonReleased.width() + buttonSeparation + autoCombatButtonReleased.width(); const int32_t backgroundHeight @@ -3252,12 +3252,12 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions fheroes2::StandardWindow background( backgroundWidth, backgroundHeight, true, display ); fheroes2::Button buttonAutoCombat; - fheroes2::Button buttonAutoResolve; + fheroes2::Button buttonQuickCombat; fheroes2::Button buttonCancel; background.renderButton( buttonAutoCombat, isEvilInterface ? ICN::BUTTON_AUTO_COMBAT_EVIL : ICN::BUTTON_AUTO_COMBAT_GOOD, 0, 1, { autoButtonsXOffset, 0 }, fheroes2::StandardWindow::Padding::CENTER_LEFT ); - background.renderButton( buttonAutoResolve, isEvilInterface ? ICN::BUTTON_AUTO_RESOLVE_EVIL : ICN::BUTTON_AUTO_RESOLVE_GOOD, 0, 1, { autoButtonsXOffset, 0 }, + background.renderButton( buttonQuickCombat, isEvilInterface ? ICN::BUTTON_QUICK_COMBAT_EVIL : ICN::BUTTON_QUICK_COMBAT_GOOD, 0, 1, { autoButtonsXOffset, 0 }, fheroes2::StandardWindow::Padding::CENTER_RIGHT ); background.renderButton( buttonCancel, isEvilInterface ? ICN::BUTTON_SMALL_CANCEL_EVIL : ICN::BUTTON_SMALL_CANCEL_GOOD, 0, 1, { 0, 11 }, fheroes2::StandardWindow::Padding::BOTTOM_CENTER ); @@ -3270,7 +3270,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions while ( le.HandleEvents() ) { buttonAutoCombat.drawOnState( le.isMouseLeftButtonPressedInArea( buttonAutoCombat.area() ) ); - buttonAutoResolve.drawOnState( le.isMouseLeftButtonPressedInArea( buttonAutoResolve.area() ) ); + buttonQuickCombat.drawOnState( le.isMouseLeftButtonPressedInArea( buttonQuickCombat.area() ) ); buttonCancel.drawOnState( le.isMouseLeftButtonPressedInArea( buttonCancel.area() ) ); if ( le.MouseClickLeft( buttonCancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { @@ -3279,7 +3279,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions if ( le.MouseClickLeft( buttonAutoCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_TOGGLE_AUTO_COMBAT ) ) { EventStartAutoCombat( unit, actions ); } - else if ( le.MouseClickLeft( buttonAutoResolve.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_INSTANT_COMBAT ) ) { + else if ( le.MouseClickLeft( buttonQuickCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_INSTANT_COMBAT ) ) { EventInstantCombat( actions ); } if ( !actions.empty() ) { @@ -3290,17 +3290,17 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions fheroes2::showStandardTextMessage( _( "Cancel" ), _( "Exit this menu." ), Dialog::ZERO ); } else if ( le.isMouseRightButtonPressedInArea( buttonAutoCombat.area() ) ) { - std::string msg = _( "Allows the computer to fight out the battle for you." ); + std::string msg = _( "The computer continues the combat for you at the currently set combat speed." ); msg += "\n\n"; msg += _( - "autoCombat|This can be interrupted at any point by either pressing the Auto Combat hotkey or the default cancel key, or by right- or left-clicking anywhere." ); + "autoCombat|This can be interrupted at any moment by pressing the Auto Combat hotkey or the default Cancel key, or by left or right clicking anywhere on the game screen." ); fheroes2::showStandardTextMessage( _( "Auto Combat" ), msg, Dialog::ZERO ); } - else if ( le.isMouseRightButtonPressedInArea( buttonAutoResolve.area() ) ) { - std::string msg = _( "Instantly resolves the battle from the current state." ); + else if ( le.isMouseRightButtonPressedInArea( buttonQuickCombat.area() ) ) { + std::string msg = _( "The combat is quickly resolved from the current state." ); msg += "\n\n"; - msg += _( "autoResolve|This cannot be reverted." ); - fheroes2::showStandardTextMessage( _( "Auto Resolve" ), msg, Dialog::ZERO ); + msg += _( "quickCombat|This action cannot be undone once executed." ); + fheroes2::showStandardTextMessage( _( "Quick Combat" ), msg, Dialog::ZERO ); } } } From 460640573571d1a9ce08555a269fbdc900f0f571 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 16 Jan 2025 18:05:49 +0100 Subject: [PATCH 34/52] Address comments from #9094 --- src/fheroes2/battle/battle_interface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index dbc632a31e2..91c8f4f503f 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3202,7 +3202,7 @@ void Battle::Interface::EventStartAutoCombat( const Unit & unit, Actions & actio assert( arena.CanToggleAutoCombat() ); assert( !arena.AutoCombatInProgress() ); - if ( fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to enable auto combat?" ), Dialog::YES | Dialog::NO ) != Dialog::YES ) { + if ( fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to enable the auto combat mode?" ), Dialog::YES | Dialog::NO ) != Dialog::YES ) { return; } @@ -3214,7 +3214,7 @@ void Battle::Interface::EventStartAutoCombat( const Unit & unit, Actions & actio void Battle::Interface::EventInstantCombat( Actions & actions ) { - if ( fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to finish the battle instantly in auto mode?" ), Dialog::YES | Dialog::NO ) != Dialog::YES ) { + if ( fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to resolve the battle in the quick combat mode?" ), Dialog::YES | Dialog::NO ) != Dialog::YES ) { return; } @@ -6530,7 +6530,7 @@ void Battle::Interface::InterruptAutoCombatIfRequested( LocalEvent & le ) // Right now there should be no pending auto combat interruptions. assert( _interruptAutoCombatForColor == 0 ); - const int interrupt = fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to interrupt the auto combat?" ), Dialog::YES | Dialog::NO ); + const int interrupt = fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to interrupt the auto combat mode?" ), Dialog::YES | Dialog::NO ); if ( interrupt == Dialog::YES ) { _interruptAutoCombatForColor = color; } From 493b7d36352dea386872778f9606c0b657704553 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 16 Jan 2025 18:07:49 +0100 Subject: [PATCH 35/52] Code style --- src/fheroes2/battle/battle_interface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 91c8f4f503f..da8f6d57b53 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3214,7 +3214,8 @@ void Battle::Interface::EventStartAutoCombat( const Unit & unit, Actions & actio void Battle::Interface::EventInstantCombat( Actions & actions ) { - if ( fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to resolve the battle in the quick combat mode?" ), Dialog::YES | Dialog::NO ) != Dialog::YES ) { + if ( fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to resolve the battle in the quick combat mode?" ), Dialog::YES | Dialog::NO ) + != Dialog::YES ) { return; } From 44e12ccd646eb90c9b4bbf53e8871723a164d947 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 16 Jan 2025 18:15:07 +0100 Subject: [PATCH 36/52] Address @ihhub comments --- src/fheroes2/battle/battle_interface.cpp | 3 +-- src/fheroes2/gui/ui_button.cpp | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index da8f6d57b53..f924b801e34 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3227,8 +3227,6 @@ void Battle::Interface::EventInstantCombat( Actions & actions ) void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions ) { - fheroes2::Display & display = fheroes2::Display::instance(); - const bool isEvilInterface = Settings::Get().isEvilInterfaceEnabled(); const int autoCombatButtonICN = isEvilInterface ? ICN::BUTTON_AUTO_COMBAT_EVIL : ICN::BUTTON_AUTO_COMBAT_GOOD; @@ -3250,6 +3248,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions const int32_t backgroundHeight = titleYOffset + title.height( backgroundWidth ) + autoResolveButtonReleased.height() + cancelButtonReleased.height() + autoButtonsYOffset + 28; + fheroes2::Display & display = fheroes2::Display::instance(); fheroes2::StandardWindow background( backgroundWidth, backgroundHeight, true, display ); fheroes2::Button buttonAutoCombat; diff --git a/src/fheroes2/gui/ui_button.cpp b/src/fheroes2/gui/ui_button.cpp index 1e491a3bc86..2d15868f6e7 100644 --- a/src/fheroes2/gui/ui_button.cpp +++ b/src/fheroes2/gui/ui_button.cpp @@ -173,6 +173,7 @@ namespace return output; } + void addButtonShine( fheroes2::Sprite & buttonImage, const int emptyButtonIcnID ) { const bool isGoodButton = ( emptyButtonIcnID == ICN::EMPTY_GOOD_BUTTON ); From e2dd498eca642a181a90cf608d247290c6d37eea Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 16 Jan 2025 18:54:05 +0100 Subject: [PATCH 37/52] Change auto resolve button ICN to quick combat --- src/fheroes2/agg/agg_image.cpp | 14 +++++++------- src/fheroes2/agg/icn.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 3980b097931..ef06fb4cefb 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -191,8 +191,8 @@ namespace ICN::BUTTON_LANGUAGE_EVIL, ICN::BUTTON_AUTO_COMBAT_GOOD, ICN::BUTTON_AUTO_COMBAT_EVIL, - ICN::BUTTON_AUTO_RESOLVE_GOOD, - ICN::BUTTON_AUTO_RESOLVE_EVIL }; + ICN::BUTTON_QUICK_COMBAT_GOOD, + ICN::BUTTON_QUICK_COMBAT_EVIL }; #ifndef NDEBUG bool isLanguageDependentIcnId( const int id ) @@ -2142,11 +2142,11 @@ namespace break; } - case ICN::BUTTON_AUTO_RESOLVE_GOOD: - case ICN::BUTTON_AUTO_RESOLVE_EVIL: { + case ICN::BUTTON_QUICK_COMBAT_GOOD: + case ICN::BUTTON_QUICK_COMBAT_EVIL: { _icnVsSprite[id].resize( 2 ); - const bool isEvilInterface = ( id == ICN::BUTTON_AUTO_RESOLVE_EVIL ); + const bool isEvilInterface = ( id == ICN::BUTTON_QUICK_COMBAT_EVIL ); getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "QUICK\nCOMBAT" ), isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK ); @@ -2867,8 +2867,8 @@ namespace case ICN::BUTTON_LANGUAGE_EVIL: case ICN::BUTTON_AUTO_COMBAT_GOOD: case ICN::BUTTON_AUTO_COMBAT_EVIL: - case ICN::BUTTON_AUTO_RESOLVE_GOOD: - case ICN::BUTTON_AUTO_RESOLVE_EVIL: + case ICN::BUTTON_QUICK_COMBAT_GOOD: + case ICN::BUTTON_QUICK_COMBAT_EVIL: generateLanguageSpecificImages( id ); return true; case ICN::PHOENIX: diff --git a/src/fheroes2/agg/icn.h b/src/fheroes2/agg/icn.h index 2eb7fd1d4e5..9ae928f0e44 100644 --- a/src/fheroes2/agg/icn.h +++ b/src/fheroes2/agg/icn.h @@ -1128,8 +1128,8 @@ namespace ICN BUTTON_AUTO_COMBAT_GOOD, BUTTON_AUTO_COMBAT_EVIL, - BUTTON_AUTO_RESOLVE_GOOD, - BUTTON_AUTO_RESOLVE_EVIL, + BUTTON_QUICK_COMBAT_GOOD, + BUTTON_QUICK_COMBAT_EVIL, SCENIBKG_EVIL, From 8f01bd86dab82811d9929178b02fc82723ffde4d Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 16 Jan 2025 19:07:48 +0100 Subject: [PATCH 38/52] Change settings names --- src/fheroes2/dialog/dialog_system_options.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fheroes2/dialog/dialog_system_options.cpp b/src/fheroes2/dialog/dialog_system_options.cpp index ce0d77511a8..edb0f55eb7d 100644 --- a/src/fheroes2/dialog/dialog_system_options.cpp +++ b/src/fheroes2/dialog/dialog_system_options.cpp @@ -184,14 +184,14 @@ namespace const Settings & conf = Settings::Get(); if ( conf.BattleAutoResolve() ) { const bool spellcast = conf.BattleAutoSpellcast(); - std::string value = spellcast ? _( "Auto Resolve" ) : _( "Auto, No Spells" ); + std::string value = spellcast ? _( "Quick Combat" ) : _( "Quick, No Spells" ); const fheroes2::Sprite & autoBattleIcon = fheroes2::AGG::GetICN( ICN::CSPANEL, spellcast ? 7 : 6 ); fheroes2::drawOption( optionRoi, autoBattleIcon, _( "Battles" ), std::move( value ), fheroes2::UiOptionTextWidth::THREE_ELEMENTS_ROW ); } else { const fheroes2::Sprite & autoBattleIcon = fheroes2::AGG::GetICN( ICN::SPANEL, 18 ); - fheroes2::drawOption( optionRoi, autoBattleIcon, _( "Battles" ), _( "autoBattle|Manual" ), fheroes2::UiOptionTextWidth::THREE_ELEMENTS_ROW ); + fheroes2::drawOption( optionRoi, autoBattleIcon, _( "Battles" ), _( "combatMode|Manual" ), fheroes2::UiOptionTextWidth::THREE_ELEMENTS_ROW ); } } From 1d36d611d05b09bd8e6e4fd96633ace90153b7ae Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 16 Jan 2025 19:13:30 +0100 Subject: [PATCH 39/52] Copyright year --- src/fheroes2/dialog/dialog_system_options.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/dialog/dialog_system_options.cpp b/src/fheroes2/dialog/dialog_system_options.cpp index edb0f55eb7d..635a99b11c5 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 - 2024 * + * Copyright (C) 2021 - 2025 * * * * 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 * From 67e9998b7c5ffbac18893b664e3d4dda9d006f14 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 16 Jan 2025 19:42:37 +0100 Subject: [PATCH 40/52] change references from instant to quick --- src/fheroes2/ai/ai_battle.cpp | 4 ++-- src/fheroes2/battle/battle_action.cpp | 4 ++-- src/fheroes2/battle/battle_arena.cpp | 2 +- src/fheroes2/battle/battle_command.cpp | 2 +- src/fheroes2/battle/battle_command.h | 4 ++-- src/fheroes2/battle/battle_interface.cpp | 12 ++++++------ src/fheroes2/game/game_hotkeys.cpp | 8 ++++---- src/fheroes2/game/game_hotkeys.h | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/fheroes2/ai/ai_battle.cpp b/src/fheroes2/ai/ai_battle.cpp index 3bda4373ecd..567d9e65f64 100644 --- a/src/fheroes2/ai/ai_battle.cpp +++ b/src/fheroes2/ai/ai_battle.cpp @@ -659,7 +659,7 @@ bool AI::BattlePlanner::isLimitOfTurnsExceeded( const Battle::Arena & arena, Bat // We have gone beyond the limit on the number of turns without deaths and have to stop if ( _numberOfRemainingTurnsWithoutDeaths == 0 ) { - // If this is an auto combat (and not the instant combat, because the battle UI is present), then turn it off until the end of the battle + // If this is an auto combat (and not a quick combat, because the battle UI is present), then turn it off until the end of the battle if ( arena.AutoCombatInProgress() && Battle::Arena::GetInterface() != nullptr ) { assert( arena.CanToggleAutoCombat() ); @@ -711,7 +711,7 @@ Battle::Actions AI::BattlePlanner::planUnitTurn( Battle::Arena & arena, const Ba return Outcome::ContinueBattle; } - // Human-controlled heroes should not retreat or surrender during auto/instant combat + // Human-controlled heroes should not retreat or surrender during auto/quick combat if ( actualHero->isControlHuman() ) { return Outcome::ContinueBattle; } diff --git a/src/fheroes2/battle/battle_action.cpp b/src/fheroes2/battle/battle_action.cpp index 794d5b0a117..93702f674e6 100644 --- a/src/fheroes2/battle/battle_action.cpp +++ b/src/fheroes2/battle/battle_action.cpp @@ -427,8 +427,8 @@ void Battle::Arena::ApplyAction( Command & cmd ) case CommandType::TOGGLE_AUTO_COMBAT: ApplyActionToggleAutoCombat( cmd ); break; - case CommandType::INSTANT_COMBAT: - ApplyActionInstantCombat( cmd ); + case CommandType::QUICK_COMBAT: + ApplyActionQuickCombat( cmd ); break; default: diff --git a/src/fheroes2/battle/battle_arena.cpp b/src/fheroes2/battle/battle_arena.cpp index 49f226b6f7f..fa55d23946e 100644 --- a/src/fheroes2/battle/battle_arena.cpp +++ b/src/fheroes2/battle/battle_arena.cpp @@ -1438,7 +1438,7 @@ bool Battle::Arena::AutoCombatInProgress() const } if ( _autoCombatColors & GetCurrentColor() ) { - // Auto combat mode cannot be enabled for a player controlled by AI + // Auto combat mode cannot be enabled for a player controlled by the AI assert( !( GetCurrentForce().GetControl() & CONTROL_AI ) ); return true; diff --git a/src/fheroes2/battle/battle_command.cpp b/src/fheroes2/battle/battle_command.cpp index 974bd65ab1c..64313254528 100644 --- a/src/fheroes2/battle/battle_command.cpp +++ b/src/fheroes2/battle/battle_command.cpp @@ -64,7 +64,7 @@ uint32_t Battle::Command::updateSeed( uint32_t seed ) const // These commands should never affect the seed generation case CommandType::TOGGLE_AUTO_COMBAT: - case CommandType::INSTANT_COMBAT: + case CommandType::QUICK_COMBAT: break; default: diff --git a/src/fheroes2/battle/battle_command.h b/src/fheroes2/battle/battle_command.h index 3c9e0535e06..124c8f7cf95 100644 --- a/src/fheroes2/battle/battle_command.h +++ b/src/fheroes2/battle/battle_command.h @@ -47,7 +47,7 @@ namespace Battle SURRENDER, SKIP, TOGGLE_AUTO_COMBAT, - INSTANT_COMBAT + QUICK_COMBAT }; class Command final : public std::vector @@ -63,7 +63,7 @@ namespace Battle static constexpr std::integral_constant SURRENDER{}; static constexpr std::integral_constant SKIP{}; static constexpr std::integral_constant TOGGLE_AUTO_COMBAT{}; - static constexpr std::integral_constant INSTANT_COMBAT{}; + static constexpr std::integral_constant QUICK_COMBAT{}; template explicit Command( std::integral_constant /* tag */, const Types... params ) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index f924b801e34..d889a4c1400 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -2806,8 +2806,8 @@ void Battle::Interface::HumanBattleTurn( const Unit & unit, Actions & actions, s EventStartAutoCombat( unit, actions ); } // Instantly finish the battle in auto mode - else if ( Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_INSTANT_COMBAT ) ) { - EventInstantCombat( actions ); + else if ( Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_QUICK_COMBAT ) ) { + EventQuickCombat( actions ); } // Cast the spell else if ( Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_CAST_SPELL ) ) { @@ -3212,14 +3212,14 @@ void Battle::Interface::EventStartAutoCombat( const Unit & unit, Actions & actio humanturn_exit = true; } -void Battle::Interface::EventInstantCombat( Actions & actions ) +void Battle::Interface::EventQuickCombat( Actions & actions ) { if ( fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to resolve the battle in the quick combat mode?" ), Dialog::YES | Dialog::NO ) != Dialog::YES ) { return; } - actions.emplace_back( Command::INSTANT_COMBAT ); + actions.emplace_back( Command::QUICK_COMBAT ); humanturn_redraw = true; humanturn_exit = true; @@ -3279,8 +3279,8 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions if ( le.MouseClickLeft( buttonAutoCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_TOGGLE_AUTO_COMBAT ) ) { EventStartAutoCombat( unit, actions ); } - else if ( le.MouseClickLeft( buttonQuickCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_INSTANT_COMBAT ) ) { - EventInstantCombat( actions ); + else if ( le.MouseClickLeft( buttonQuickCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_QUICK_COMBAT ) ) { + EventQuickCombat( actions ); } if ( !actions.empty() ) { return; diff --git a/src/fheroes2/game/game_hotkeys.cpp b/src/fheroes2/game/game_hotkeys.cpp index 2d05c5bddda..3d83ed0e3e6 100644 --- a/src/fheroes2/game/game_hotkeys.cpp +++ b/src/fheroes2/game/game_hotkeys.cpp @@ -272,8 +272,8 @@ namespace = { Game::HotKeyCategory::BATTLE, gettext_noop( "hotkey|surrender during battle" ), fheroes2::Key::KEY_S }; hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::BATTLE_TOGGLE_AUTO_COMBAT )] = { Game::HotKeyCategory::BATTLE, gettext_noop( "hotkey|toggle auto combat mode" ), fheroes2::Key::KEY_A }; - hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::BATTLE_INSTANT_COMBAT )] - = { Game::HotKeyCategory::BATTLE, gettext_noop( "hotkey|instant combat" ), fheroes2::Key::KEY_Q }; + hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::BATTLE_QUICK_COMBAT )] + = { Game::HotKeyCategory::BATTLE, gettext_noop( "hotkey|quick combat" ), fheroes2::Key::KEY_Q }; hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::BATTLE_OPTIONS )] = { Game::HotKeyCategory::BATTLE, gettext_noop( "hotkey|battle options" ), fheroes2::Key::KEY_O }; hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::BATTLE_SKIP )] @@ -440,8 +440,8 @@ void Game::HotKeysLoad( const std::string & filename ) continue; } } - else if ( eventName == std::string_view( "instant combat" ) ) { - value = config.StrParams( "finish the battle in auto mode" ); + else if ( eventName == std::string_view( "quick combat" ) ) { + value = config.StrParams( "resolve the battle in quick combat mode" ); if ( value.empty() ) { continue; } diff --git a/src/fheroes2/game/game_hotkeys.h b/src/fheroes2/game/game_hotkeys.h index ad9afdd6885..916eb1a75a0 100644 --- a/src/fheroes2/game/game_hotkeys.h +++ b/src/fheroes2/game/game_hotkeys.h @@ -137,7 +137,7 @@ namespace Game BATTLE_RETREAT, BATTLE_SURRENDER, BATTLE_TOGGLE_AUTO_COMBAT, - BATTLE_INSTANT_COMBAT, + BATTLE_QUICK_COMBAT, BATTLE_OPTIONS, BATTLE_SKIP, BATTLE_CAST_SPELL, From 0511cc52dbb0f14ef816a2c5317215c09849198c Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 16 Jan 2025 19:49:34 +0100 Subject: [PATCH 41/52] Fix fheroes2.key replacement add some missing instant combat replacements --- src/fheroes2/battle/battle_action.cpp | 2 +- src/fheroes2/battle/battle_arena.h | 2 +- src/fheroes2/battle/battle_interface.h | 2 +- src/fheroes2/game/game_hotkeys.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fheroes2/battle/battle_action.cpp b/src/fheroes2/battle/battle_action.cpp index 93702f674e6..78f81d6382c 100644 --- a/src/fheroes2/battle/battle_action.cpp +++ b/src/fheroes2/battle/battle_action.cpp @@ -1370,7 +1370,7 @@ void Battle::Arena::ApplyActionToggleAutoCombat( Command & cmd ) } } -void Battle::Arena::ApplyActionInstantCombat( const Command & /* cmd */ ) +void Battle::Arena::ApplyActionQuickCombat( const Command & /* cmd */ ) { const int army1Control = GetForce1().GetControl(); const int army2Control = GetForce2().GetControl(); diff --git a/src/fheroes2/battle/battle_arena.h b/src/fheroes2/battle/battle_arena.h index c2dc3bfe425..4306c97098b 100644 --- a/src/fheroes2/battle/battle_arena.h +++ b/src/fheroes2/battle/battle_arena.h @@ -285,7 +285,7 @@ namespace Battle void ApplyActionTower( Command & cmd ); void ApplyActionCatapult( Command & cmd ); void ApplyActionToggleAutoCombat( Command & cmd ); - void ApplyActionInstantCombat( const Command & cmd ); + void ApplyActionQuickCombat( const Command & cmd ); void ApplyActionSpellSummonElemental( const Command & cmd, const Spell & spell ); void ApplyActionSpellMirrorImage( Command & cmd ); diff --git a/src/fheroes2/battle/battle_interface.h b/src/fheroes2/battle/battle_interface.h index a98ae321d0a..75a76d3ee66 100644 --- a/src/fheroes2/battle/battle_interface.h +++ b/src/fheroes2/battle/battle_interface.h @@ -421,7 +421,7 @@ namespace Battle void _openBattleSettingsDialog(); void EventStartAutoCombat( const Unit & unit, Actions & actions ); - void EventInstantCombat( Actions & actions ); + void EventQuickCombat( Actions & actions ); void OpenAutoModeDialog( const Unit & unit, Actions & actions ); void EventShowOptions(); void MouseLeftClickBoardAction( const int themes, const Cell & cell, const bool isConfirmed, Actions & actions ); diff --git a/src/fheroes2/game/game_hotkeys.cpp b/src/fheroes2/game/game_hotkeys.cpp index 3d83ed0e3e6..a5ccdc5504b 100644 --- a/src/fheroes2/game/game_hotkeys.cpp +++ b/src/fheroes2/game/game_hotkeys.cpp @@ -441,7 +441,7 @@ void Game::HotKeysLoad( const std::string & filename ) } } else if ( eventName == std::string_view( "quick combat" ) ) { - value = config.StrParams( "resolve the battle in quick combat mode" ); + value = config.StrParams( "finish the battle in auto mode" ); if ( value.empty() ) { continue; } From 8a9955f5faf117f8efa44bd166cbf6050262a905 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 16 Jan 2025 19:54:44 +0100 Subject: [PATCH 42/52] last missing "resolve" references --- 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 d889a4c1400..ecafcb0c2cd 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -2805,7 +2805,7 @@ void Battle::Interface::HumanBattleTurn( const Unit & unit, Actions & actions, s else if ( Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_TOGGLE_AUTO_COMBAT ) ) { EventStartAutoCombat( unit, actions ); } - // Instantly finish the battle in auto mode + // Resolve the combat in quick combat mode else if ( Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_QUICK_COMBAT ) ) { EventQuickCombat( actions ); } @@ -3230,10 +3230,10 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions const bool isEvilInterface = Settings::Get().isEvilInterfaceEnabled(); const int autoCombatButtonICN = isEvilInterface ? ICN::BUTTON_AUTO_COMBAT_EVIL : ICN::BUTTON_AUTO_COMBAT_GOOD; - const int autoResolveButtonICN = isEvilInterface ? ICN::BUTTON_QUICK_COMBAT_EVIL : ICN::BUTTON_QUICK_COMBAT_GOOD; + const int quickCombatButtonICN = isEvilInterface ? ICN::BUTTON_QUICK_COMBAT_EVIL : ICN::BUTTON_QUICK_COMBAT_GOOD; const int cancelButtonICN = isEvilInterface ? ICN::BUTTON_SMALL_CANCEL_EVIL : ICN::BUTTON_SMALL_CANCEL_GOOD; - const fheroes2::Sprite & autoResolveButtonReleased = fheroes2::AGG::GetICN( autoResolveButtonICN, 0 ); + const fheroes2::Sprite & quickCombatButtonReleased = fheroes2::AGG::GetICN( quickCombatButtonICN, 0 ); const fheroes2::Sprite & autoCombatButtonReleased = fheroes2::AGG::GetICN( autoCombatButtonICN, 0 ); const fheroes2::Sprite & cancelButtonReleased = fheroes2::AGG::GetICN( cancelButtonICN, 0 ); @@ -3244,9 +3244,9 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions const fheroes2::Text title( _( "Automatic Combat Modes" ), { fheroes2::FontSize::NORMAL, fheroes2::FontColor::YELLOW } ); - const int32_t backgroundWidth = autoButtonsXOffset * 2 + autoResolveButtonReleased.width() + buttonSeparation + autoCombatButtonReleased.width(); + const int32_t backgroundWidth = autoButtonsXOffset * 2 + quickCombatButtonReleased.width() + buttonSeparation + autoCombatButtonReleased.width(); const int32_t backgroundHeight - = titleYOffset + title.height( backgroundWidth ) + autoResolveButtonReleased.height() + cancelButtonReleased.height() + autoButtonsYOffset + 28; + = titleYOffset + title.height( backgroundWidth ) + quickCombatButtonReleased.height() + cancelButtonReleased.height() + autoButtonsYOffset + 28; fheroes2::Display & display = fheroes2::Display::instance(); fheroes2::StandardWindow background( backgroundWidth, backgroundHeight, true, display ); From 74f365f3516d713c2c9aae1911ca67d48099a868 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 16 Jan 2025 20:32:37 +0100 Subject: [PATCH 43/52] Last paraphrasing --- src/fheroes2/battle/battle_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index ecafcb0c2cd..2fc64b90aa5 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -2878,7 +2878,7 @@ void Battle::Interface::HumanBattleTurn( const Unit & unit, Actions & actions, s OpenAutoModeDialog( unit, actions ); } else if ( le.isMouseRightButtonPressed() ) { - fheroes2::showStandardTextMessage( _( "Automatic Combat Modes" ), _( "Choose whether to proceed the combat in auto combat mode or in quick combat mode." ), + fheroes2::showStandardTextMessage( _( "Automatic Combat Modes" ), _( "Choose between proceeding the combat in auto combat mode or in quick combat mode." ), Dialog::ZERO ); } } From a77b5a8a703a443827b76c53b9f27720ad70269d Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 16 Jan 2025 21:31:19 +0100 Subject: [PATCH 44/52] small consistency correction --- src/fheroes2/gui/ui_button.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/gui/ui_button.cpp b/src/fheroes2/gui/ui_button.cpp index 2d15868f6e7..3022688f679 100644 --- a/src/fheroes2/gui/ui_button.cpp +++ b/src/fheroes2/gui/ui_button.cpp @@ -181,7 +181,7 @@ namespace const uint8_t firstColor = 10; const uint8_t secondColor = isGoodButton ? 38 : 15; const uint8_t lastColor = isGoodButton ? 39 : 16; - // Left side shine + // Left-side shine fheroes2::SetPixel( buttonImage, 11, 4, firstColor ); fheroes2::SetPixel( buttonImage, 13, 4, firstColor ); fheroes2::SetPixel( buttonImage, 9, 6, firstColor ); From e4cc7cc6276cb1301d61c8cfd2ff19723f8786ac Mon Sep 17 00:00:00 2001 From: Zenseii Date: Thu, 16 Jan 2025 22:12:52 +0100 Subject: [PATCH 45/52] paraphrasing --- src/fheroes2/battle/battle_interface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 2fc64b90aa5..274ec6de9a7 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3293,13 +3293,13 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions std::string msg = _( "The computer continues the combat for you at the currently set combat speed." ); msg += "\n\n"; msg += _( - "autoCombat|This can be interrupted at any moment by pressing the Auto Combat hotkey or the default Cancel key, or by left or right clicking anywhere on the game screen." ); + "autoCombat|This can be interrupted at any moment by pressing the Auto Combat hotkey or the default Cancel key, or by performing a left or right click anywhere on the game screen." ); fheroes2::showStandardTextMessage( _( "Auto Combat" ), msg, Dialog::ZERO ); } else if ( le.isMouseRightButtonPressedInArea( buttonQuickCombat.area() ) ) { - std::string msg = _( "The combat is quickly resolved from the current state." ); + std::string msg = _( "The combat is resolved from the current state and ended." ); msg += "\n\n"; - msg += _( "quickCombat|This action cannot be undone once executed." ); + msg += _( "quickCombat|This cannot be undone." ); fheroes2::showStandardTextMessage( _( "Quick Combat" ), msg, Dialog::ZERO ); } } From 8ac43963ab58a64c59592ed4cdd0a19b4d4aafd4 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 17 Jan 2025 12:14:56 +0100 Subject: [PATCH 46/52] change to agreed phrasings --- src/fheroes2/battle/battle_interface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 274ec6de9a7..394ca36828b 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3290,14 +3290,14 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions fheroes2::showStandardTextMessage( _( "Cancel" ), _( "Exit this menu." ), Dialog::ZERO ); } else if ( le.isMouseRightButtonPressedInArea( buttonAutoCombat.area() ) ) { - std::string msg = _( "The computer continues the combat for you at the currently set combat speed." ); + std::string msg = _( "The computer continues the combat for you." ); msg += "\n\n"; msg += _( "autoCombat|This can be interrupted at any moment by pressing the Auto Combat hotkey or the default Cancel key, or by performing a left or right click anywhere on the game screen." ); fheroes2::showStandardTextMessage( _( "Auto Combat" ), msg, Dialog::ZERO ); } else if ( le.isMouseRightButtonPressedInArea( buttonQuickCombat.area() ) ) { - std::string msg = _( "The combat is resolved from the current state and ended." ); + std::string msg = _( "The combat is resolved from the current state." ); msg += "\n\n"; msg += _( "quickCombat|This cannot be undone." ); fheroes2::showStandardTextMessage( _( "Quick Combat" ), msg, Dialog::ZERO ); From 31b1dad9d60a03497e32b3e7d22f359e535945df Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Fri, 17 Jan 2025 14:17:10 +0300 Subject: [PATCH 47/52] Simplify the logic --- src/fheroes2/battle/battle_interface.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 394ca36828b..4d9b18d6b89 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3278,11 +3278,10 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions } if ( le.MouseClickLeft( buttonAutoCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_TOGGLE_AUTO_COMBAT ) ) { EventStartAutoCombat( unit, actions ); + return; } else if ( le.MouseClickLeft( buttonQuickCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_QUICK_COMBAT ) ) { EventQuickCombat( actions ); - } - if ( !actions.empty() ) { return; } From 2a1196b8f78c7659070196713bc9048af0f1bd58 Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Fri, 17 Jan 2025 14:22:57 +0300 Subject: [PATCH 48/52] Remove extra else --- src/fheroes2/battle/battle_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 4d9b18d6b89..1cafa82e508 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3280,7 +3280,7 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions EventStartAutoCombat( unit, actions ); return; } - else if ( le.MouseClickLeft( buttonQuickCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_QUICK_COMBAT ) ) { + if ( le.MouseClickLeft( buttonQuickCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_QUICK_COMBAT ) ) { EventQuickCombat( actions ); return; } From 247ec2da758030557e8822251a274c00af9b0ecd Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Fri, 17 Jan 2025 14:34:57 +0300 Subject: [PATCH 49/52] Rework the logic a bit --- src/fheroes2/battle/battle_interface.cpp | 19 +++++++++++-------- src/fheroes2/battle/battle_interface.h | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 1cafa82e508..b91a0d41a9c 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3196,33 +3196,37 @@ void Battle::Interface::EventShowOptions() humanturn_redraw = true; } -void Battle::Interface::EventStartAutoCombat( const Unit & unit, Actions & actions ) +bool Battle::Interface::EventStartAutoCombat( const Unit & unit, Actions & actions ) { // TODO: remove these temporary assertions assert( arena.CanToggleAutoCombat() ); assert( !arena.AutoCombatInProgress() ); if ( fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to enable the auto combat mode?" ), Dialog::YES | Dialog::NO ) != Dialog::YES ) { - return; + return false; } actions.emplace_back( Command::TOGGLE_AUTO_COMBAT, unit.GetCurrentOrArmyColor() ); humanturn_redraw = true; humanturn_exit = true; + + return true; } -void Battle::Interface::EventQuickCombat( Actions & actions ) +bool Battle::Interface::EventQuickCombat( Actions & actions ) { if ( fheroes2::showStandardTextMessage( {}, _( "Are you sure you want to resolve the battle in the quick combat mode?" ), Dialog::YES | Dialog::NO ) != Dialog::YES ) { - return; + return false; } actions.emplace_back( Command::QUICK_COMBAT ); humanturn_redraw = true; humanturn_exit = true; + + return true; } void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions ) @@ -3276,12 +3280,11 @@ void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions if ( le.MouseClickLeft( buttonCancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { return; } - if ( le.MouseClickLeft( buttonAutoCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_TOGGLE_AUTO_COMBAT ) ) { - EventStartAutoCombat( unit, actions ); + if ( ( le.MouseClickLeft( buttonAutoCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_TOGGLE_AUTO_COMBAT ) ) + && EventStartAutoCombat( unit, actions ) ) { return; } - if ( le.MouseClickLeft( buttonQuickCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_QUICK_COMBAT ) ) { - EventQuickCombat( actions ); + if ( ( le.MouseClickLeft( buttonQuickCombat.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::BATTLE_QUICK_COMBAT ) ) && EventQuickCombat( actions ) ) { return; } diff --git a/src/fheroes2/battle/battle_interface.h b/src/fheroes2/battle/battle_interface.h index 75a76d3ee66..b1854bf5b78 100644 --- a/src/fheroes2/battle/battle_interface.h +++ b/src/fheroes2/battle/battle_interface.h @@ -420,8 +420,8 @@ namespace Battle void ProcessingHeroDialogResult( const int result, Actions & actions ); void _openBattleSettingsDialog(); - void EventStartAutoCombat( const Unit & unit, Actions & actions ); - void EventQuickCombat( Actions & actions ); + bool EventStartAutoCombat( const Unit & unit, Actions & actions ); + bool EventQuickCombat( Actions & actions ); void OpenAutoModeDialog( const Unit & unit, Actions & actions ); void EventShowOptions(); void MouseLeftClickBoardAction( const int themes, const Cell & cell, const bool isConfirmed, Actions & actions ); From a0c22a8a9a038ac5dd019357bcd24f6f46b882b1 Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Fri, 17 Jan 2025 14:59:32 +0300 Subject: [PATCH 50/52] Revert the wording --- src/fheroes2/dialog/dialog_system_options.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fheroes2/dialog/dialog_system_options.cpp b/src/fheroes2/dialog/dialog_system_options.cpp index 635a99b11c5..093451a348a 100644 --- a/src/fheroes2/dialog/dialog_system_options.cpp +++ b/src/fheroes2/dialog/dialog_system_options.cpp @@ -184,7 +184,7 @@ namespace const Settings & conf = Settings::Get(); if ( conf.BattleAutoResolve() ) { const bool spellcast = conf.BattleAutoSpellcast(); - std::string value = spellcast ? _( "Quick Combat" ) : _( "Quick, No Spells" ); + std::string value = spellcast ? _( "Auto Resolve" ) : _( "Auto, No Spells" ); const fheroes2::Sprite & autoBattleIcon = fheroes2::AGG::GetICN( ICN::CSPANEL, spellcast ? 7 : 6 ); fheroes2::drawOption( optionRoi, autoBattleIcon, _( "Battles" ), std::move( value ), fheroes2::UiOptionTextWidth::THREE_ELEMENTS_ROW ); From 7ccae8f9cb88eaf573e176ff6e64adc365a160b1 Mon Sep 17 00:00:00 2001 From: Zenseii Date: Fri, 17 Jan 2025 13:07:51 +0100 Subject: [PATCH 51/52] Set cursor with yellow outline --- src/fheroes2/battle/battle_interface.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index b91a0d41a9c..d066fc80d09 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3231,6 +3231,7 @@ bool Battle::Interface::EventQuickCombat( Actions & actions ) void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions ) { + Cursor::Get().SetThemes( Cursor::POINTER ); const bool isEvilInterface = Settings::Get().isEvilInterfaceEnabled(); const int autoCombatButtonICN = isEvilInterface ? ICN::BUTTON_AUTO_COMBAT_EVIL : ICN::BUTTON_AUTO_COMBAT_GOOD; From 32366c4ba01b388a4869e3fa497e7496c228ea3f Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Fri, 17 Jan 2025 15:26:55 +0300 Subject: [PATCH 52/52] Add an empty line :) --- src/fheroes2/battle/battle_interface.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index d066fc80d09..7b940605295 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -3232,6 +3232,7 @@ bool Battle::Interface::EventQuickCombat( Actions & actions ) void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions ) { Cursor::Get().SetThemes( Cursor::POINTER ); + const bool isEvilInterface = Settings::Get().isEvilInterfaceEnabled(); const int autoCombatButtonICN = isEvilInterface ? ICN::BUTTON_AUTO_COMBAT_EVIL : ICN::BUTTON_AUTO_COMBAT_GOOD;