From 5dc47dd4e9cf49a7a84214d827ec1f76cc3eb516 Mon Sep 17 00:00:00 2001 From: Ihar Hubchyk Date: Sat, 2 Nov 2024 16:26:26 +0800 Subject: [PATCH] Add support of Evil interface for Scenario Information dialog (#9193) --- src/fheroes2/agg/agg_image.cpp | 31 +++++++++++++++++++++++++ src/fheroes2/agg/icn.h | 2 ++ src/fheroes2/dialog/dialog_gameinfo.cpp | 5 ++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/fheroes2/agg/agg_image.cpp b/src/fheroes2/agg/agg_image.cpp index 55dee31404..c0659c5f44 100644 --- a/src/fheroes2/agg/agg_image.cpp +++ b/src/fheroes2/agg/agg_image.cpp @@ -5070,6 +5070,37 @@ namespace return true; } + case ICN::SCENIBKG_EVIL: { + const int32_t originalId = ICN::SCENIBKG; + loadICN( originalId ); + + if ( _icnVsSprite[originalId].size() != 1 ) { + return true; + } + + _icnVsSprite[id].resize( 1 ); + + const auto & originalImage = _icnVsSprite[originalId][0]; + auto & outputImage = _icnVsSprite[id][0]; + + outputImage = originalImage; + convertToEvilInterface( outputImage, { 0, 0, outputImage.width(), outputImage.height() } ); + + loadICN( ICN::METALLIC_BORDERED_TEXTBOX_EVIL ); + if ( _icnVsSprite[ICN::METALLIC_BORDERED_TEXTBOX_EVIL].empty() ) { + return true; + } + + const auto & evilTextBox = _icnVsSprite[ICN::METALLIC_BORDERED_TEXTBOX_EVIL][0]; + + // The original text area is shorter than one we are using so we need to make 2 image copy operations to compensate this. + const int32_t textWidth = 361; + fheroes2::Copy( evilTextBox, 0, 0, outputImage, 46, 23, textWidth / 2, evilTextBox.height() ); + fheroes2::Copy( evilTextBox, evilTextBox.width() - ( textWidth - textWidth / 2 ), 0, outputImage, 46 + textWidth / 2, 23, ( textWidth - textWidth / 2 ), + evilTextBox.height() ); + + return true; + } default: break; } diff --git a/src/fheroes2/agg/icn.h b/src/fheroes2/agg/icn.h index 65b384a8bd..a32cc6ff04 100644 --- a/src/fheroes2/agg/icn.h +++ b/src/fheroes2/agg/icn.h @@ -1126,6 +1126,8 @@ namespace ICN BUTTON_LANGUAGE_GOOD, BUTTON_LANGUAGE_EVIL, + SCENIBKG_EVIL, + // IMPORTANT! Put any new entry just above this one. LASTICN }; diff --git a/src/fheroes2/dialog/dialog_gameinfo.cpp b/src/fheroes2/dialog/dialog_gameinfo.cpp index 1a06b399a0..675f37feff 100644 --- a/src/fheroes2/dialog/dialog_gameinfo.cpp +++ b/src/fheroes2/dialog/dialog_gameinfo.cpp @@ -84,7 +84,8 @@ void Dialog::GameInfo() // setup cursor const CursorRestorer cursorRestorer( true, Cursor::POINTER ); - const fheroes2::Sprite & window = fheroes2::AGG::GetICN( ICN::SCENIBKG, 0 ); + const bool isEvilInterface = conf.isEvilInterfaceEnabled(); + const fheroes2::Sprite & window = fheroes2::AGG::GetICN( isEvilInterface ? ICN::SCENIBKG_EVIL : ICN::SCENIBKG, 0 ); const fheroes2::Point dialogOffset( ( display.width() - window.width() - DIALOG_SHADOW_OFFSET_X ) / 2, ( display.height() - window.height() ) / 2 ); const fheroes2::Point shadowOffset( dialogOffset.x + DIALOG_SHADOW_OFFSET_X, dialogOffset.y + DIALOG_SHADOW_OFFSET_Y / 2 ); @@ -150,7 +151,7 @@ void Dialog::GameInfo() text.setUniformVerticalAlignment( false ); text.draw( shadowOffset.x + CONDITION_DESCRIPTION_OFFSET, shadowOffset.y + 398, CONDITION_DESCRIPTION_WIDTH, display ); - const int buttonOkIcnId = ICN::BUTTON_SMALL_OKAY_GOOD; + const int buttonOkIcnId = isEvilInterface ? ICN::BUTTON_SMALL_OKAY_EVIL : ICN::BUTTON_SMALL_OKAY_GOOD; fheroes2::Button buttonOk( shadowOffset.x + OK_BUTTON_OFFSET - fheroes2::AGG::GetICN( buttonOkIcnId, 0 ).width() / 2, shadowOffset.y + 426, buttonOkIcnId, 0, 1 ); buttonOk.draw();