-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify Button Layout to be similar to OG (#9385)
- Loading branch information
Showing
4 changed files
with
61 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) 2009 by Andrey Afletdinov <[email protected]> * | ||
|
@@ -34,7 +34,6 @@ | |
#include "castle_building_info.h" | ||
#include "cursor.h" | ||
#include "dialog.h" | ||
#include "game_hotkeys.h" | ||
#include "icn.h" | ||
#include "localevent.h" | ||
#include "m82.h" | ||
|
@@ -543,42 +542,21 @@ bool BuildingInfo::DialogBuyBuilding( bool buttons ) const | |
return false; | ||
} | ||
|
||
const bool isEvilInterface = Settings::Get().isEvilInterfaceEnabled(); | ||
const int buttonOkayIcnID = isEvilInterface ? ICN::UNIFORM_EVIL_OKAY_BUTTON : ICN::UNIFORM_GOOD_OKAY_BUTTON; | ||
|
||
pos.x = dialogRoi.x; | ||
pos.y = dialogRoi.y + dialogRoi.height - fheroes2::AGG::GetICN( buttonOkayIcnID, 0 ).height(); | ||
|
||
fheroes2::Button buttonOkay( pos.x, pos.y, buttonOkayIcnID, 0, 1 ); | ||
|
||
const int buttonCancelIcnID = isEvilInterface ? ICN::UNIFORM_EVIL_CANCEL_BUTTON : ICN::UNIFORM_GOOD_CANCEL_BUTTON; | ||
|
||
pos.x = dialogRoi.x + dialogRoi.width - fheroes2::AGG::GetICN( buttonCancelIcnID, 0 ).width(); | ||
pos.y = dialogRoi.y + dialogRoi.height - fheroes2::AGG::GetICN( buttonCancelIcnID, 0 ).height(); | ||
fheroes2::Button buttonCancel( pos.x, pos.y, buttonCancelIcnID, 0, 1 ); | ||
fheroes2::ButtonGroup buttonGroup( dialogRoi, Dialog::OK | Dialog::CANCEL ); | ||
fheroes2::ButtonBase & buttonOkay = buttonGroup.button( 0 ); | ||
const fheroes2::ButtonBase & buttonCancel = buttonGroup.button( 1 ); | ||
|
||
if ( BuildingStatus::ALLOW_BUILD != castle.CheckBuyBuilding( _buildingType ) ) { | ||
buttonOkay.disable(); | ||
} | ||
|
||
buttonOkay.draw(); | ||
buttonCancel.draw(); | ||
|
||
buttonGroup.draw(); | ||
display.render(); | ||
|
||
while ( le.HandleEvents() ) { | ||
if ( buttonOkay.isEnabled() ) { | ||
buttonOkay.drawOnState( le.isMouseLeftButtonPressedInArea( buttonOkay.area() ) ); | ||
} | ||
|
||
buttonCancel.drawOnState( le.isMouseLeftButtonPressedInArea( buttonCancel.area() ) ); | ||
|
||
if ( buttonOkay.isEnabled() && ( Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_OKAY ) || le.MouseClickLeft( buttonOkay.area() ) ) ) { | ||
return true; | ||
} | ||
|
||
if ( Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) || le.MouseClickLeft( buttonCancel.area() ) ) { | ||
break; | ||
const int result = buttonGroup.processEvents(); | ||
if ( result != Dialog::ZERO ) { | ||
return result == Dialog::OK; | ||
} | ||
|
||
if ( le.isMouseRightButtonPressedInArea( buttonOkay.area() ) ) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) 2009 by Andrey Afletdinov <[email protected]> * | ||
|
@@ -126,38 +126,22 @@ int Castle::DialogBuyHero( const Heroes * hero ) const | |
rbs.SetPos( dialogRoi.x, pos.y + heroDescriptionText.height( fheroes2::boxAreaWidthPx ) + spacer ); | ||
rbs.Redraw(); | ||
|
||
const bool isEvilInterface = Settings::Get().isEvilInterfaceEnabled(); | ||
const int okayButtonIcnID = isEvilInterface ? ICN::UNIFORM_EVIL_OKAY_BUTTON : ICN::UNIFORM_GOOD_OKAY_BUTTON; | ||
|
||
pos.y = dialogRoi.y + dialogRoi.height - fheroes2::AGG::GetICN( okayButtonIcnID, 0 ).height(); | ||
fheroes2::Button buttonOkay( dialogRoi.x, pos.y, okayButtonIcnID, 0, 1 ); | ||
fheroes2::ButtonGroup buttonGroup( dialogRoi, Dialog::OK | Dialog::CANCEL ); | ||
fheroes2::ButtonBase & buttonOkay = buttonGroup.button( 0 ); | ||
const fheroes2::ButtonBase & buttonCancel = buttonGroup.button( 1 ); | ||
|
||
if ( !AllowBuyHero() ) { | ||
buttonOkay.disable(); | ||
} | ||
|
||
const int cancelButtonIcnID = isEvilInterface ? ICN::UNIFORM_EVIL_CANCEL_BUTTON : ICN::UNIFORM_GOOD_CANCEL_BUTTON; | ||
|
||
pos.x = dialogRoi.x + dialogRoi.width - fheroes2::AGG::GetICN( cancelButtonIcnID, 0 ).width(); | ||
pos.y = dialogRoi.y + dialogRoi.height - fheroes2::AGG::GetICN( cancelButtonIcnID, 0 ).height(); | ||
fheroes2::Button buttonCancel( pos.x, pos.y, cancelButtonIcnID, 0, 1 ); | ||
|
||
buttonOkay.draw(); | ||
buttonCancel.draw(); | ||
|
||
buttonGroup.draw(); | ||
display.render(); | ||
|
||
LocalEvent & le = LocalEvent::Get(); | ||
while ( le.HandleEvents() ) { | ||
buttonOkay.drawOnState( le.isMouseLeftButtonPressedInArea( buttonOkay.area() ) ); | ||
buttonCancel.drawOnState( le.isMouseLeftButtonPressedInArea( buttonCancel.area() ) ); | ||
|
||
if ( buttonOkay.isEnabled() && ( le.MouseClickLeft( buttonOkay.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_OKAY ) ) ) { | ||
return Dialog::OK; | ||
} | ||
|
||
if ( le.MouseClickLeft( buttonCancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) { | ||
break; | ||
const int result = buttonGroup.processEvents(); | ||
if ( result != Dialog::ZERO ) { | ||
return result; | ||
} | ||
|
||
if ( le.isMouseRightButtonPressedInArea( heroPortraitArea ) ) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) 2009 by Andrey Afletdinov <[email protected]> * | ||
|
@@ -24,15 +24,13 @@ | |
#include "agg_image.h" | ||
#include "cursor.h" | ||
#include "dialog.h" // IWYU pragma: associated | ||
#include "game_hotkeys.h" | ||
#include "icn.h" | ||
#include "image.h" | ||
#include "localevent.h" | ||
#include "math_base.h" | ||
#include "payment.h" | ||
#include "resource.h" | ||
#include "screen.h" | ||
#include "settings.h" | ||
#include "translations.h" | ||
#include "ui_button.h" | ||
#include "ui_text.h" | ||
|
@@ -41,8 +39,6 @@ int Dialog::BuyBoat( bool enable ) | |
{ | ||
fheroes2::Display & display = fheroes2::Display::instance(); | ||
|
||
const bool isEvilInterface = Settings::Get().isEvilInterfaceEnabled(); | ||
|
||
// setup cursor | ||
const CursorRestorer cursorRestorer( true, Cursor::POINTER ); | ||
|
||
|
@@ -71,43 +67,24 @@ int Dialog::BuyBoat( bool enable ) | |
rbs.Redraw(); | ||
|
||
// buttons | ||
const int buttonOkayICN = isEvilInterface ? ICN::UNIFORM_EVIL_OKAY_BUTTON : ICN::UNIFORM_GOOD_OKAY_BUTTON; | ||
dst_pt.x = box_rt.x; | ||
dst_pt.y = box_rt.y + box_rt.height - fheroes2::AGG::GetICN( buttonOkayICN, 0 ).height(); | ||
fheroes2::Button buttonOkay( dst_pt.x, dst_pt.y, buttonOkayICN, 0, 1 ); | ||
|
||
const int buttonCancelICN = isEvilInterface ? ICN::UNIFORM_EVIL_CANCEL_BUTTON : ICN::UNIFORM_GOOD_CANCEL_BUTTON; | ||
|
||
dst_pt.x = box_rt.x + box_rt.width - fheroes2::AGG::GetICN( buttonCancelICN, 0 ).width(); | ||
dst_pt.y = box_rt.y + box_rt.height - fheroes2::AGG::GetICN( buttonCancelICN, 0 ).height(); | ||
fheroes2::Button buttonCancel( dst_pt.x, dst_pt.y, buttonCancelICN, 0, 1 ); | ||
fheroes2::ButtonGroup buttonGroup( box_rt, Dialog::OK | Dialog::CANCEL ); | ||
fheroes2::ButtonBase & buttonOkay = buttonGroup.button( 0 ); | ||
|
||
if ( !enable ) { | ||
buttonOkay.press(); | ||
buttonOkay.disable(); | ||
} | ||
|
||
buttonOkay.draw(); | ||
buttonCancel.draw(); | ||
|
||
buttonGroup.draw(); | ||
display.render(); | ||
|
||
LocalEvent & le = LocalEvent::Get(); | ||
|
||
// message loop | ||
while ( le.HandleEvents() ) { | ||
if ( buttonOkay.isEnabled() ) { | ||
buttonOkay.drawOnState( le.isMouseLeftButtonPressedInArea( buttonOkay.area() ) ); | ||
} | ||
|
||
buttonCancel.drawOnState( le.isMouseLeftButtonPressedInArea( buttonCancel.area() ) ); | ||
|
||
if ( buttonOkay.isEnabled() && ( Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_OKAY ) || le.MouseClickLeft( buttonOkay.area() ) ) ) { | ||
return Dialog::OK; | ||
} | ||
|
||
if ( Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) || le.MouseClickLeft( buttonCancel.area() ) ) { | ||
return Dialog::CANCEL; | ||
const int result = buttonGroup.processEvents(); | ||
if ( result != Dialog::ZERO ) { | ||
return result; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters