Skip to content

Commit

Permalink
Add support of Evil interface for Scenario Information dialog (#9193)
Browse files Browse the repository at this point in the history
  • Loading branch information
ihhub authored Nov 2, 2024
1 parent 0ef7526 commit 5dc47dd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
31 changes: 31 additions & 0 deletions src/fheroes2/agg/agg_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions src/fheroes2/agg/icn.h
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,8 @@ namespace ICN
BUTTON_LANGUAGE_GOOD,
BUTTON_LANGUAGE_EVIL,

SCENIBKG_EVIL,

// IMPORTANT! Put any new entry just above this one.
LASTICN
};
Expand Down
5 changes: 3 additions & 2 deletions src/fheroes2/dialog/dialog_gameinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 5dc47dd

Please sign in to comment.