From 472b88f7d26bc3d04742368b37879a58dac0e95a Mon Sep 17 00:00:00 2001 From: a1exsh Date: Tue, 19 Oct 2021 18:01:10 +0200 Subject: [PATCH] Close certain dialogs containing only one Exit button with Enter key (#4443) --- src/fheroes2/battle/battle_dialogs.cpp | 2 +- src/fheroes2/castle/castle_dialog.cpp | 2 +- src/fheroes2/dialog/dialog_adventure.cpp | 2 +- src/fheroes2/dialog/dialog_armyinfo.cpp | 2 +- src/fheroes2/dialog/dialog_file.cpp | 2 +- src/fheroes2/heroes/heroes_dialog.cpp | 2 +- src/fheroes2/kingdom/kingdom_overview.cpp | 2 +- src/fheroes2/kingdom/view_world.cpp | 2 +- src/fheroes2/spell/spell_book.cpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/fheroes2/battle/battle_dialogs.cpp b/src/fheroes2/battle/battle_dialogs.cpp index ff954d6997c..1894c3391b5 100644 --- a/src/fheroes2/battle/battle_dialogs.cpp +++ b/src/fheroes2/battle/battle_dialogs.cpp @@ -280,7 +280,7 @@ void Battle::DialogBattleSettings( void ) RedrawBattleSettings( optionAreas ); saveConfiguration = true; } - else if ( Game::HotKeyPressEvent( Game::EVENT_DEFAULT_EXIT ) || le.MouseClickLeft( btn_ok.area() ) ) { + else if ( HotKeyCloseWindow || le.MouseClickLeft( btn_ok.area() ) ) { break; } } diff --git a/src/fheroes2/castle/castle_dialog.cpp b/src/fheroes2/castle/castle_dialog.cpp index ad50e1f8707..38c952662e0 100644 --- a/src/fheroes2/castle/castle_dialog.cpp +++ b/src/fheroes2/castle/castle_dialog.cpp @@ -352,7 +352,7 @@ int Castle::OpenDialog( bool readonly ) le.MousePressLeft( buttonExit.area() ) ? buttonExit.drawOnPress() : buttonExit.drawOnRelease(); // Check buttons for closing this castle's window. - if ( le.MouseClickLeft( buttonExit.area() ) || Game::HotKeyPressEvent( Game::EVENT_DEFAULT_EXIT ) ) { + if ( le.MouseClickLeft( buttonExit.area() ) || HotKeyCloseWindow ) { result = Dialog::CANCEL; break; } diff --git a/src/fheroes2/dialog/dialog_adventure.cpp b/src/fheroes2/dialog/dialog_adventure.cpp index e03e71bf9d4..75d49f6966b 100644 --- a/src/fheroes2/dialog/dialog_adventure.cpp +++ b/src/fheroes2/dialog/dialog_adventure.cpp @@ -95,7 +95,7 @@ int Dialog::AdventureOptions( bool enabledig ) result = Dialog::DIG; break; } - if ( le.MouseClickLeft( buttonCancel.area() ) || Game::HotKeyPressEvent( Game::EVENT_DEFAULT_EXIT ) ) { + if ( le.MouseClickLeft( buttonCancel.area() ) || HotKeyCloseWindow ) { result = Dialog::CANCEL; break; } diff --git a/src/fheroes2/dialog/dialog_armyinfo.cpp b/src/fheroes2/dialog/dialog_armyinfo.cpp index 87c7b024521..b315a182bc4 100644 --- a/src/fheroes2/dialog/dialog_armyinfo.cpp +++ b/src/fheroes2/dialog/dialog_armyinfo.cpp @@ -241,7 +241,7 @@ int Dialog::ArmyInfo( const Troop & troop, int flags, bool isReflected ) break; } // exit - if ( le.MouseClickLeft( buttonExit.area() ) || Game::HotKeyPressEvent( Game::EVENT_DEFAULT_EXIT ) ) { + if ( le.MouseClickLeft( buttonExit.area() ) || HotKeyCloseWindow ) { result = Dialog::CANCEL; break; } diff --git a/src/fheroes2/dialog/dialog_file.cpp b/src/fheroes2/dialog/dialog_file.cpp index 18066dad943..2df796bb584 100644 --- a/src/fheroes2/dialog/dialog_file.cpp +++ b/src/fheroes2/dialog/dialog_file.cpp @@ -102,7 +102,7 @@ fheroes2::GameMode Dialog::FileOptions() break; } } - else if ( le.MouseClickLeft( buttonCancel.area() ) || Game::HotKeyPressEvent( Game::EVENT_DEFAULT_EXIT ) ) { + else if ( le.MouseClickLeft( buttonCancel.area() ) || HotKeyCloseWindow ) { result = fheroes2::GameMode::CANCEL; break; } diff --git a/src/fheroes2/heroes/heroes_dialog.cpp b/src/fheroes2/heroes/heroes_dialog.cpp index 5a96c1883ce..fbf25d13201 100644 --- a/src/fheroes2/heroes/heroes_dialog.cpp +++ b/src/fheroes2/heroes/heroes_dialog.cpp @@ -247,7 +247,7 @@ int Heroes::OpenDialog( bool readonly /* = false */, bool fade /* = false */, bo } // exit - if ( le.MouseClickLeft( buttonExit.area() ) || Game::HotKeyPressEvent( Game::EVENT_DEFAULT_EXIT ) ) + if ( le.MouseClickLeft( buttonExit.area() ) || HotKeyCloseWindow ) return Dialog::CANCEL; // heroes troops diff --git a/src/fheroes2/kingdom/kingdom_overview.cpp b/src/fheroes2/kingdom/kingdom_overview.cpp index 2031a0b7420..1176e856791 100644 --- a/src/fheroes2/kingdom/kingdom_overview.cpp +++ b/src/fheroes2/kingdom/kingdom_overview.cpp @@ -721,7 +721,7 @@ void Kingdom::openOverviewDialog() } // Exit this dialog. - if ( le.MouseClickLeft( buttonExit.area() ) || Game::HotKeyPressEvent( Game::EVENT_DEFAULT_EXIT ) ) + if ( le.MouseClickLeft( buttonExit.area() ) || HotKeyCloseWindow ) break; // switch view: heroes/castle diff --git a/src/fheroes2/kingdom/view_world.cpp b/src/fheroes2/kingdom/view_world.cpp index ac0999e42e5..e528a93fa37 100644 --- a/src/fheroes2/kingdom/view_world.cpp +++ b/src/fheroes2/kingdom/view_world.cpp @@ -577,7 +577,7 @@ void ViewWorld::ViewWorldWindow( const int color, const ViewWorldMode mode, Inte bool changed = false; - if ( le.MouseClickLeft( buttonExit.area() ) || Game::HotKeyPressEvent( Game::EVENT_DEFAULT_EXIT ) ) { + if ( le.MouseClickLeft( buttonExit.area() ) || HotKeyCloseWindow ) { break; } else if ( le.MouseClickLeft( buttonZoom.area() ) ) { diff --git a/src/fheroes2/spell/spell_book.cpp b/src/fheroes2/spell/spell_book.cpp index e596fc6aa25..5dda989d325 100644 --- a/src/fheroes2/spell/spell_book.cpp +++ b/src/fheroes2/spell/spell_book.cpp @@ -267,7 +267,7 @@ Spell SpellBook::Open( const HeroBase & hero, const Filter displayableSpells, co else if ( le.MousePressRight( next_list ) ) { Dialog::Message( "", _( "View next page" ), Font::BIG ); } - else if ( le.MouseClickLeft( clos_rt ) || Game::HotKeyPressEvent( Game::EVENT_DEFAULT_EXIT ) ) + else if ( le.MouseClickLeft( clos_rt ) || HotKeyCloseWindow ) break; else if ( le.MouseClickLeft( pos ) ) { const int32_t index = GetRectIndex( coords, le.GetMouseCursor() );