diff --git a/src/gui/wxgui/AudioDebuggerWindow.cpp b/src/gui/wxgui/AudioDebuggerWindow.cpp index eb30974f..12a0edf6 100644 --- a/src/gui/wxgui/AudioDebuggerWindow.cpp +++ b/src/gui/wxgui/AudioDebuggerWindow.cpp @@ -3,6 +3,7 @@ #include "Cafe/OS/libs/snd_core/ax.h" #include "Cafe/OS/libs/snd_core/ax_internal.h" +#include "wxgui/helpers/wxHelpers.h" enum { @@ -24,6 +25,8 @@ wxEND_EVENT_TABLE() AudioDebuggerWindow::AudioDebuggerWindow(wxFrame& parent) : wxFrame(&parent, wxID_ANY, _("AX voice viewer"), wxDefaultPosition, wxSize(1126, 580), wxCLOSE_BOX | wxCLIP_CHILDREN | wxCAPTION | wxRESIZE_BORDER) { + wxHelper::BindEscapeCloses(this); + wxPanel* mainPane = new wxPanel(this); wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); diff --git a/src/gui/wxgui/CemuUpdateWindow.cpp b/src/gui/wxgui/CemuUpdateWindow.cpp index 53674a58..32302a48 100644 --- a/src/gui/wxgui/CemuUpdateWindow.cpp +++ b/src/gui/wxgui/CemuUpdateWindow.cpp @@ -21,6 +21,7 @@ #include #include #include +#include "wxgui/helpers/wxHelpers.h" wxDECLARE_EVENT(wxEVT_RESULT, wxCommandEvent); @@ -33,6 +34,8 @@ CemuUpdateWindow::CemuUpdateWindow(wxWindow* parent) : wxDialog(parent, wxID_ANY, _("Cemu update"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxCLOSE_BOX) { + wxHelper::BindEscapeCloses(this); + auto* sizer = new wxBoxSizer(wxVERTICAL); m_gauge = new wxGauge(this, wxID_ANY, 100, wxDefaultPosition, wxSize(500, 20), wxGA_HORIZONTAL); m_gauge->SetValue(0); diff --git a/src/gui/wxgui/ChecksumTool.cpp b/src/gui/wxgui/ChecksumTool.cpp index bcaba6b9..6790c972 100644 --- a/src/gui/wxgui/ChecksumTool.cpp +++ b/src/gui/wxgui/ChecksumTool.cpp @@ -85,6 +85,8 @@ ChecksumTool::ChecksumTool(wxWindow* parent, wxTitleManagerList::TitleEntry& ent formatWxString(_("Title checksum of {:08x}-{:08x}"), (uint32) (entry.title_id >> 32), (uint32) (entry.title_id & 0xFFFFFFFF)), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxFRAME_TOOL_WINDOW | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxCLOSE_BOX), m_entry(entry) { + wxHelper::BindEscapeCloses(this); + m_info = CafeTitleList::GetTitleInfoByUID(m_entry.location_uid); if (!m_info.IsValid()) diff --git a/src/gui/wxgui/DownloadCustomGraphicPackWindow.cpp b/src/gui/wxgui/DownloadCustomGraphicPackWindow.cpp index f261061d..1b4a3c30 100644 --- a/src/gui/wxgui/DownloadCustomGraphicPackWindow.cpp +++ b/src/gui/wxgui/DownloadCustomGraphicPackWindow.cpp @@ -16,6 +16,7 @@ #include #include +#include "wxgui/helpers/wxHelpers.h" static size_t curlDownloadFile_writeData(void *ptr, size_t size, size_t nmemb, DownloadCustomGraphicPackWindow::curlDownloadFileState_t* downloadState) { @@ -67,6 +68,8 @@ DownloadCustomGraphicPackWindow::DownloadCustomGraphicPackWindow(wxWindow* paren : wxDialog(parent, wxID_ANY, _("Download Graphic Pack from URL"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxCLOSE_BOX), m_stage(StageDone), m_currentStage(StageDone) { + wxHelper::BindEscapeCloses(this); + auto* sizer = new wxBoxSizer(wxVERTICAL); m_urlField = new wxTextCtrl(this, wxID_ANY, wxEmptyString); diff --git a/src/gui/wxgui/DownloadGraphicPacksWindow.cpp b/src/gui/wxgui/DownloadGraphicPacksWindow.cpp index 08e98fc0..5fbaf3d0 100644 --- a/src/gui/wxgui/DownloadGraphicPacksWindow.cpp +++ b/src/gui/wxgui/DownloadGraphicPacksWindow.cpp @@ -11,6 +11,7 @@ #include "Common/FileStream.h" #include "Cafe/CafeSystem.h" +#include "wxgui/helpers/wxHelpers.h" struct DownloadGraphicPacksWindow::curlDownloadFileState_t { @@ -294,6 +295,8 @@ DownloadGraphicPacksWindow::DownloadGraphicPacksWindow(wxWindow* parent) : wxDialog(parent, wxID_ANY, _("Checking version..."), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxCLOSE_BOX), m_threadState(ThreadRunning), m_stage(StageCheckVersion), m_currentStage(StageCheckVersion) { + wxHelper::BindEscapeCloses(this); + auto* sizer = new wxBoxSizer(wxVERTICAL); m_processBar = new wxGauge(this, wxID_ANY, 100, wxDefaultPosition, wxSize(500, 20), wxGA_HORIZONTAL); diff --git a/src/gui/wxgui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp b/src/gui/wxgui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp index 5015fc5d..d08226df 100644 --- a/src/gui/wxgui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp +++ b/src/gui/wxgui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp @@ -37,6 +37,8 @@ EmulatedUSBDeviceFrame::EmulatedUSBDeviceFrame(wxWindow* parent) : wxFrame(parent, wxID_ANY, _("Emulated USB Devices"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL) { + wxHelper::BindEscapeCloses(this); + SetIcon(wxICON(X_BOX)); auto& config = GetConfig(); @@ -330,6 +332,8 @@ void EmulatedUSBDeviceFrame::ClearSkylander(uint8 slot) CreateSkylanderDialog::CreateSkylanderDialog(wxWindow* parent, uint8 slot) : wxDialog(parent, wxID_ANY, _("Skylander Figure Creator"), wxDefaultPosition, wxSize(500, 150)) { + wxHelper::BindEscapeCloses(this); + auto* sizer = new wxBoxSizer(wxVERTICAL); auto* comboRow = new wxBoxSizer(wxHORIZONTAL); @@ -511,6 +515,8 @@ void EmulatedUSBDeviceFrame::ClearFigure(uint8 slot) CreateInfinityFigureDialog::CreateInfinityFigureDialog(wxWindow* parent, uint8 slot) : wxDialog(parent, wxID_ANY, _("Infinity Figure Creator"), wxDefaultPosition, wxSize(500, 150)) { + wxHelper::BindEscapeCloses(this); + auto* sizer = new wxBoxSizer(wxVERTICAL); auto* comboRow = new wxBoxSizer(wxHORIZONTAL); @@ -686,6 +692,8 @@ void EmulatedUSBDeviceFrame::MoveMinifig(uint8 pad, uint8 index) CreateDimensionFigureDialog::CreateDimensionFigureDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, _("Dimensions Figure Creator"), wxDefaultPosition, wxSize(500, 200)) { + wxHelper::BindEscapeCloses(this); + auto* sizer = new wxBoxSizer(wxVERTICAL); auto* comboRow = new wxBoxSizer(wxHORIZONTAL); @@ -774,6 +782,8 @@ wxString CreateDimensionFigureDialog::GetFilePath() const MoveDimensionFigureDialog::MoveDimensionFigureDialog(EmulatedUSBDeviceFrame* parent, uint8 currentIndex) : wxDialog(parent, wxID_ANY, _("Dimensions Figure Mover"), wxDefaultPosition, wxSize(700, 300)) { + wxHelper::BindEscapeCloses(this); + auto* sizer = new wxGridSizer(2, 5, 10, 10); std::array, 7> ids = parent->GetCurrentMinifigs(); diff --git a/src/gui/wxgui/GameProfileWindow.cpp b/src/gui/wxgui/GameProfileWindow.cpp index 5962133e..b63b8837 100644 --- a/src/gui/wxgui/GameProfileWindow.cpp +++ b/src/gui/wxgui/GameProfileWindow.cpp @@ -18,6 +18,8 @@ GameProfileWindow::GameProfileWindow(wxWindow* parent, uint64_t title_id) : wxFrame(parent, wxID_ANY, _("Edit game profile"), wxDefaultPosition, wxSize{ 390, 350 }, wxCLOSE_BOX | wxCLIP_CHILDREN | wxCAPTION | wxRESIZE_BORDER | wxTAB_TRAVERSAL | wxSYSTEM_MENU), m_title_id(title_id) { + wxHelper::BindEscapeCloses(this); + SetIcon(wxICON(X_GAME_PROFILE)); m_game_profile.Reset(); diff --git a/src/gui/wxgui/GameUpdateWindow.cpp b/src/gui/wxgui/GameUpdateWindow.cpp index 253a7610..ab52edf9 100644 --- a/src/gui/wxgui/GameUpdateWindow.cpp +++ b/src/gui/wxgui/GameUpdateWindow.cpp @@ -138,6 +138,8 @@ GameUpdateWindow::GameUpdateWindow(wxWindow& parent, const fs::path& filePath) : wxDialog(&parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxCLOSE_BOX), m_thread_state(ThreadRunning) { + wxHelper::BindEscapeCloses(this); + try { #if BOOST_OS_WINDOWS diff --git a/src/gui/wxgui/GeneralSettings2.cpp b/src/gui/wxgui/GeneralSettings2.cpp index f1435fba..4677de6c 100644 --- a/src/gui/wxgui/GeneralSettings2.cpp +++ b/src/gui/wxgui/GeneralSettings2.cpp @@ -1079,6 +1079,8 @@ wxPanel* GeneralSettings2::AddDebugPage(wxNotebook* notebook) GeneralSettings2::GeneralSettings2(wxWindow* parent, bool game_launched) : wxDialog(parent, wxID_ANY, _("General settings"), wxDefaultPosition, wxDefaultSize, wxCLOSE_BOX | wxCLIP_CHILDREN | wxCAPTION | wxRESIZE_BORDER), m_game_launched(game_launched) { + wxHelper::BindEscapeCloses(this); + SetIcon(wxICON(X_SETTINGS)); auto* sizer = new wxBoxSizer(wxVERTICAL); diff --git a/src/gui/wxgui/GettingStartedDialog.cpp b/src/gui/wxgui/GettingStartedDialog.cpp index df3c940e..2c56d380 100644 --- a/src/gui/wxgui/GettingStartedDialog.cpp +++ b/src/gui/wxgui/GettingStartedDialog.cpp @@ -22,6 +22,7 @@ #endif #include "wxHelper.h" +#include "wxgui/helpers/wxHelpers.h" wxDEFINE_EVENT(EVT_REFRESH_FIRST_PAGE, wxCommandEvent); // used to refresh the first page after the language change @@ -247,6 +248,8 @@ void GettingStartedDialog::OnClose(wxCloseEvent& event) GettingStartedDialog::GettingStartedDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, _("Getting started"), wxDefaultPosition, { 740,530 }, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { + wxHelper::BindEscapeCloses(this); + auto* sizer = new wxBoxSizer(wxVERTICAL); m_notebook = new wxSimplebook(this, wxID_ANY); diff --git a/src/gui/wxgui/GraphicPacksWindow2.cpp b/src/gui/wxgui/GraphicPacksWindow2.cpp index 21e25b07..d6646d1e 100644 --- a/src/gui/wxgui/GraphicPacksWindow2.cpp +++ b/src/gui/wxgui/GraphicPacksWindow2.cpp @@ -198,6 +198,8 @@ GraphicPacksWindow2::GraphicPacksWindow2(wxWindow* parent, uint64_t title_id_fil : wxDialog(parent, wxID_ANY, _("Graphic packs"), wxDefaultPosition, wxSize(1000,670), wxCLOSE_BOX | wxCLIP_CHILDREN | wxCAPTION | wxRESIZE_BORDER), m_installed_games(CafeTitleList::GetAllTitleIds()) { + wxHelper::BindEscapeCloses(this); + if (title_id_filter != 0) m_filter = fmt::format("{:x}", title_id_filter); diff --git a/src/gui/wxgui/LoggingWindow.cpp b/src/gui/wxgui/LoggingWindow.cpp index 6c6ca6c3..f9029fa9 100644 --- a/src/gui/wxgui/LoggingWindow.cpp +++ b/src/gui/wxgui/LoggingWindow.cpp @@ -6,12 +6,15 @@ #include #include #include +#include "wxgui/helpers/wxHelpers.h" wxDEFINE_EVENT(EVT_LOG, wxLogEvent); LoggingWindow::LoggingWindow(wxFrame* parent) : wxFrame(parent, wxID_ANY, _("Logging window"), wxDefaultPosition, wxSize(800, 600), wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL) { + wxHelper::BindEscapeCloses(this); + auto* sizer = new wxBoxSizer( wxVERTICAL ); { auto filter_row = new wxBoxSizer( wxHORIZONTAL ); diff --git a/src/gui/wxgui/MainWindow.cpp b/src/gui/wxgui/MainWindow.cpp index cac5db85..3ac0a7f0 100644 --- a/src/gui/wxgui/MainWindow.cpp +++ b/src/gui/wxgui/MainWindow.cpp @@ -1896,6 +1896,7 @@ public: CemuAboutDialog(wxWindow* parent = NULL) : wxDialog(NULL, wxID_ANY, _("About Cemu"), wxDefaultPosition, wxSize(500, 700)) { + wxHelper::BindEscapeCloses(this); Create(parent); } @@ -2207,7 +2208,7 @@ void MainWindow::RecreateMenu() if (m_game_launched) m_fileMenu->Enable(MAINFRAME_MENU_ID_FILE_CLEAR_SPOTPASS_CACHE, false); m_fileMenu->AppendSeparator(); - m_exitMenuItem = m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_EXIT, _("&Exit")); + m_exitMenuItem = m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_EXIT, _("&Exit\tCtrl+Q")); m_menuBar->Append(m_fileMenu, _("&File")); // options->account submenu m_optionsAccountMenu = new wxMenu(); diff --git a/src/gui/wxgui/MemorySearcherTool.cpp b/src/gui/wxgui/MemorySearcherTool.cpp index 5cdfacc4..5b2ea855 100644 --- a/src/gui/wxgui/MemorySearcherTool.cpp +++ b/src/gui/wxgui/MemorySearcherTool.cpp @@ -50,6 +50,8 @@ const wxString kDataTypeNames[] = {kDatatypeFloat,kDatatypeDouble,/*DATATYPE_STR MemorySearcherTool::MemorySearcherTool(wxFrame* parent) : wxFrame(parent, wxID_ANY, _("Memory Searcher"), wxDefaultPosition, wxSize(600, 540), wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL) { + wxHelper::BindEscapeCloses(this); + this->SetSizeHints(wxDefaultSize, wxDefaultSize); this->wxTopLevelWindowBase::SetMinSize(wxSize(600, 540)); diff --git a/src/gui/wxgui/TitleManager.cpp b/src/gui/wxgui/TitleManager.cpp index a4e191c9..fa29bfaa 100644 --- a/src/gui/wxgui/TitleManager.cpp +++ b/src/gui/wxgui/TitleManager.cpp @@ -233,6 +233,8 @@ wxPanel* TitleManager::CreateDownloadManagerPage() TitleManager::TitleManager(wxWindow* parent, TitleManagerPage default_page) : wxFrame(parent, wxID_ANY, _("Title Manager"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL) { + wxHelper::BindEscapeCloses(this); + SetIcon(wxICON(X_BOX)); auto* sizer = new wxBoxSizer(wxVERTICAL); diff --git a/src/gui/wxgui/debugger/BreakpointWindow.cpp b/src/gui/wxgui/debugger/BreakpointWindow.cpp index 8dc449d9..6695850f 100644 --- a/src/gui/wxgui/debugger/BreakpointWindow.cpp +++ b/src/gui/wxgui/debugger/BreakpointWindow.cpp @@ -7,6 +7,7 @@ #include "Cafe/HW/Espresso/Debugger/Debugger.h" #include "Cemu/ExpressionParser/ExpressionParser.h" +#include "wxgui/helpers/wxHelpers.h" enum { @@ -28,6 +29,8 @@ enum ItemColumns BreakpointWindow::BreakpointWindow(DebuggerWindow2& parent, const wxPoint& main_position, const wxSize& main_size) : wxFrame(&parent, wxID_ANY, _("Breakpoints"), wxDefaultPosition, wxSize(420, 250), wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT) { + wxHelper::BindEscapeCloses(this); + this->SetSizeHints(wxDefaultSize, wxDefaultSize); wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL); diff --git a/src/gui/wxgui/debugger/DebuggerWindow2.cpp b/src/gui/wxgui/debugger/DebuggerWindow2.cpp index d4e8bc2e..9f976194 100644 --- a/src/gui/wxgui/debugger/DebuggerWindow2.cpp +++ b/src/gui/wxgui/debugger/DebuggerWindow2.cpp @@ -26,6 +26,7 @@ #include "Cemu/Logging/CemuLogging.h" #include "resource/embedded/resources.h" +#include "wxgui/helpers/wxHelpers.h" enum { @@ -421,6 +422,8 @@ DebuggerWindow2::DebuggerWindow2(wxFrame& parent, const wxRect& display_size) : wxFrame(&parent, wxID_ANY, _("PPC Debugger"), wxDefaultPosition, wxSize(1280, 300), wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT), m_module_address(0) { + wxHelper::BindEscapeCloses(this); + g_debuggerDispatcher.SetDebuggerCallbacks(this); const auto file = ActiveSettings::GetConfigPath("debugger/config.xml"); diff --git a/src/gui/wxgui/debugger/DumpWindow.cpp b/src/gui/wxgui/debugger/DumpWindow.cpp index f152e8f6..d6eba6ef 100644 --- a/src/gui/wxgui/debugger/DumpWindow.cpp +++ b/src/gui/wxgui/debugger/DumpWindow.cpp @@ -4,6 +4,7 @@ #include "wxgui/debugger/DebuggerWindow2.h" #include "Cafe/HW/Espresso/Debugger/Debugger.h" #include "wxgui/debugger/DumpCtrl.h" +#include "wxgui/helpers/wxHelpers.h" enum { @@ -17,6 +18,8 @@ enum DumpWindow::DumpWindow(DebuggerWindow2& parent, const wxPoint& main_position, const wxSize& main_size) : wxFrame(&parent, wxID_ANY, _("Memory Dump"), wxDefaultPosition, wxSize(600, 250), wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT) { + wxHelper::BindEscapeCloses(this); + wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL); m_dump_ctrl = new DumpCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxScrolledWindowStyle); main_sizer->Add(m_dump_ctrl, 1, wxEXPAND); diff --git a/src/gui/wxgui/debugger/ModuleWindow.cpp b/src/gui/wxgui/debugger/ModuleWindow.cpp index cadf2e6a..174f9078 100644 --- a/src/gui/wxgui/debugger/ModuleWindow.cpp +++ b/src/gui/wxgui/debugger/ModuleWindow.cpp @@ -10,6 +10,7 @@ #include "Cafe/OS/RPL/rpl_structs.h" #include "Cafe/GraphicPack/GraphicPack2.h" +#include "wxgui/helpers/wxHelpers.h" enum ItemColumns { @@ -21,6 +22,8 @@ enum ItemColumns ModuleWindow::ModuleWindow(DebuggerWindow2& parent, const wxPoint& main_position, const wxSize& main_size) : wxFrame(&parent, wxID_ANY, _("Modules"), wxDefaultPosition, wxSize(420, 250), wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT) { + wxHelper::BindEscapeCloses(this); + this->SetSizeHints(wxDefaultSize, wxDefaultSize); wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL); diff --git a/src/gui/wxgui/debugger/RegisterWindow.cpp b/src/gui/wxgui/debugger/RegisterWindow.cpp index 17167176..92baf05a 100644 --- a/src/gui/wxgui/debugger/RegisterWindow.cpp +++ b/src/gui/wxgui/debugger/RegisterWindow.cpp @@ -8,6 +8,7 @@ #include "Cafe/OS/RPL/rpl.h" #include "Cafe/OS/RPL/rpl_structs.h" #include "Cafe/HW/Espresso/EspressoISA.h" +#include "wxgui/helpers/wxHelpers.h" enum { @@ -31,6 +32,8 @@ RegisterWindow::RegisterWindow(DebuggerWindow2& parent, const wxPoint& main_posi : wxFrame(&parent, wxID_ANY, _("Registers"), wxDefaultPosition, wxSize(400, 975), wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT), m_prev_snapshot({}), m_show_double_values(true), m_context_ctrl(nullptr) { + wxHelper::BindEscapeCloses(this); + SetSizeHints(wxDefaultSize, wxDefaultSize); SetMaxSize({ 400, 975 }); this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); diff --git a/src/gui/wxgui/debugger/SymbolWindow.cpp b/src/gui/wxgui/debugger/SymbolWindow.cpp index 663e599d..a76a6d25 100644 --- a/src/gui/wxgui/debugger/SymbolWindow.cpp +++ b/src/gui/wxgui/debugger/SymbolWindow.cpp @@ -3,6 +3,7 @@ #include "wxgui/debugger/DebuggerWindow2.h" #include "Cafe/HW/Espresso/Debugger/Debugger.h" #include "Cafe/OS/RPL/rpl_symbol_storage.h" +#include "wxgui/helpers/wxHelpers.h" enum ItemColumns { @@ -14,6 +15,8 @@ enum ItemColumns SymbolWindow::SymbolWindow(DebuggerWindow2& parent, const wxPoint& main_position, const wxSize& main_size) : wxFrame(&parent, wxID_ANY, _("Symbols"), wxDefaultPosition, wxSize(600, 250), wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT) { + wxHelper::BindEscapeCloses(this); + wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL); m_symbol_ctrl = new SymbolListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); main_sizer->Add(m_symbol_ctrl, 1, wxEXPAND); diff --git a/src/gui/wxgui/dialogs/CreateAccount/wxCreateAccountDialog.cpp b/src/gui/wxgui/dialogs/CreateAccount/wxCreateAccountDialog.cpp index dbe17be4..78051c9f 100644 --- a/src/gui/wxgui/dialogs/CreateAccount/wxCreateAccountDialog.cpp +++ b/src/gui/wxgui/dialogs/CreateAccount/wxCreateAccountDialog.cpp @@ -13,6 +13,8 @@ wxCreateAccountDialog::wxCreateAccountDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, _("Create new account")) { + wxHelper::BindEscapeCloses(this); + auto* main_sizer = new wxFlexGridSizer(0, 2, 0, 0); main_sizer->AddGrowableCol(1); main_sizer->SetFlexibleDirection(wxBOTH); diff --git a/src/gui/wxgui/dialogs/SaveImport/SaveImportWindow.cpp b/src/gui/wxgui/dialogs/SaveImport/SaveImportWindow.cpp index be463377..c40289cb 100644 --- a/src/gui/wxgui/dialogs/SaveImport/SaveImportWindow.cpp +++ b/src/gui/wxgui/dialogs/SaveImport/SaveImportWindow.cpp @@ -22,6 +22,8 @@ SaveImportWindow::SaveImportWindow(wxWindow* parent, uint64 title_id) : wxDialog(parent, wxID_ANY, _("Import save entry"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxFRAME_TOOL_WINDOW | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxCLOSE_BOX), m_title_id(title_id) { + wxHelper::BindEscapeCloses(this); + auto* sizer = new wxBoxSizer(wxVERTICAL); { diff --git a/src/gui/wxgui/dialogs/SaveImport/SaveTransfer.cpp b/src/gui/wxgui/dialogs/SaveImport/SaveTransfer.cpp index 9e6ed6a7..770441e6 100644 --- a/src/gui/wxgui/dialogs/SaveImport/SaveTransfer.cpp +++ b/src/gui/wxgui/dialogs/SaveImport/SaveTransfer.cpp @@ -18,6 +18,8 @@ SaveTransfer::SaveTransfer(wxWindow* parent, uint64 title_id, const wxString& so : wxDialog(parent, wxID_ANY, _("Save transfer"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxFRAME_TOOL_WINDOW | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxCLOSE_BOX), m_title_id(title_id), m_source_id(source_id) { + wxHelper::BindEscapeCloses(this); + auto* sizer = new wxBoxSizer(wxVERTICAL); { diff --git a/src/gui/wxgui/helpers/wxHelpers.h b/src/gui/wxgui/helpers/wxHelpers.h index fa42338b..d40a430b 100644 --- a/src/gui/wxgui/helpers/wxHelpers.h +++ b/src/gui/wxgui/helpers/wxHelpers.h @@ -2,8 +2,27 @@ #include "interface/WindowSystem.h" #include +#include #include #include +#include + +namespace wxHelper +{ + // Use CHAR_HOOK rather than wxDialog::SetEscapeId so the key is caught + // before a focused child control (notebook, combobox, ...) can consume it. + inline void BindEscapeCloses(wxWindow* target) + { + target->Bind(wxEVT_CHAR_HOOK, [target](wxKeyEvent& event) { + if (event.GetKeyCode() == WXK_ESCAPE) + { + target->Close(); + return; + } + event.Skip(); + }); + } +} template <> struct fmt::formatter : formatter diff --git a/src/gui/wxgui/input/HotkeySettings.cpp b/src/gui/wxgui/input/HotkeySettings.cpp index d84ffa1b..7fc00139 100644 --- a/src/gui/wxgui/input/HotkeySettings.cpp +++ b/src/gui/wxgui/input/HotkeySettings.cpp @@ -135,6 +135,17 @@ struct HotkeyEntry HotkeySettings::HotkeySettings(wxWindow* parent) : wxFrame(parent, wxID_ANY, _("Hotkey Settings")) { + // Esc closes the window, but yield to in-progress key capture so its own + // cancel path (OnKeyUp -> IsValidKeycodeUp rejects WXK_ESCAPE) still runs. + Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& event) { + if (event.GetKeyCode() == WXK_ESCAPE && !m_activeInputButton) + { + Close(); + return; + } + event.Skip(); + }); + SetIcon(wxICON(X_HOTKEY_SETTINGS)); m_sizer = new wxFlexGridSizer(0, 3, 5, 5); diff --git a/src/gui/wxgui/input/InputAPIAddWindow.cpp b/src/gui/wxgui/input/InputAPIAddWindow.cpp index b10a2c75..e2fefd4b 100644 --- a/src/gui/wxgui/input/InputAPIAddWindow.cpp +++ b/src/gui/wxgui/input/InputAPIAddWindow.cpp @@ -25,6 +25,8 @@ InputAPIAddWindow::InputAPIAddWindow(wxWindow* parent, const wxPoint& position, const std::vector& controllers) : wxDialog(parent, wxID_ANY, "Add input API", position, wxDefaultSize, wxCAPTION), m_controllers(controllers) { + wxHelper::BindEscapeCloses(this); + this->SetSizeHints(wxDefaultSize, wxDefaultSize); auto* sizer = new wxBoxSizer(wxVERTICAL); diff --git a/src/gui/wxgui/input/InputSettings2.cpp b/src/gui/wxgui/input/InputSettings2.cpp index d77e1430..b40f629d 100644 --- a/src/gui/wxgui/input/InputSettings2.cpp +++ b/src/gui/wxgui/input/InputSettings2.cpp @@ -69,6 +69,8 @@ using wxControllerPageData = wxCustomData; InputSettings2::InputSettings2(wxWindow* parent) : wxDialog(parent, wxID_ANY, _("Input settings")) { + wxHelper::BindEscapeCloses(this); + this->SetSizeHints(wxDefaultSize, wxDefaultSize); g_inputConfigWindowHasFocus = true; diff --git a/src/gui/wxgui/input/PairingDialog.cpp b/src/gui/wxgui/input/PairingDialog.cpp index 9bf2870f..bda961eb 100644 --- a/src/gui/wxgui/input/PairingDialog.cpp +++ b/src/gui/wxgui/input/PairingDialog.cpp @@ -9,6 +9,7 @@ #include #include #include +#include "wxgui/helpers/wxHelpers.h" #endif wxDECLARE_EVENT(wxEVT_PROGRESS_PAIR, wxCommandEvent); @@ -17,6 +18,8 @@ wxDEFINE_EVENT(wxEVT_PROGRESS_PAIR, wxCommandEvent); PairingDialog::PairingDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, _("Pairing..."), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxCLOSE_BOX) { + wxHelper::BindEscapeCloses(this); + auto* sizer = new wxBoxSizer(wxVERTICAL); m_gauge = new wxGauge(this, wxID_ANY, 100, wxDefaultPosition, wxSize(350, 20), wxGA_HORIZONTAL); m_gauge->SetValue(0); diff --git a/src/gui/wxgui/input/settings/DefaultControllerSettings.cpp b/src/gui/wxgui/input/settings/DefaultControllerSettings.cpp index c10c15ce..e52cf2a8 100644 --- a/src/gui/wxgui/input/settings/DefaultControllerSettings.cpp +++ b/src/gui/wxgui/input/settings/DefaultControllerSettings.cpp @@ -19,6 +19,8 @@ DefaultControllerSettings::DefaultControllerSettings(wxWindow* parent, const wxP : wxDialog(parent, wxID_ANY, _("Controller settings"), position, wxDefaultSize, wxDEFAULT_DIALOG_STYLE), m_controller(std::move(controller)) { + wxHelper::BindEscapeCloses(this); + m_settings = m_controller->get_settings(); m_rumble_backup = m_settings.rumble; diff --git a/src/gui/wxgui/input/settings/WiimoteControllerSettings.cpp b/src/gui/wxgui/input/settings/WiimoteControllerSettings.cpp index 320a895a..1b6979fd 100644 --- a/src/gui/wxgui/input/settings/WiimoteControllerSettings.cpp +++ b/src/gui/wxgui/input/settings/WiimoteControllerSettings.cpp @@ -20,6 +20,8 @@ WiimoteControllerSettings::WiimoteControllerSettings(wxWindow* parent, const wxP : wxDialog(parent, wxID_ANY, _("Controller settings"), position, wxDefaultSize, wxDEFAULT_DIALOG_STYLE), m_controller(std::move(controller)) { + wxHelper::BindEscapeCloses(this); + m_settings = m_controller->get_settings(); m_rumble_backup = m_settings.rumble; m_packet_delay_backup = m_controller->get_packet_delay(); diff --git a/src/gui/wxgui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp b/src/gui/wxgui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp index 5f7da298..5e426d6c 100644 --- a/src/gui/wxgui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp +++ b/src/gui/wxgui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp @@ -40,6 +40,8 @@ wxBEGIN_EVENT_TABLE(DebugPPCThreadsWindow, wxFrame) : wxFrame(&parent, wxID_ANY, _("PPC threads"), wxDefaultPosition, wxSize(930, 280), wxCLOSE_BOX | wxCLIP_CHILDREN | wxCAPTION | wxRESIZE_BORDER) { + wxHelper::BindEscapeCloses(this); + auto* sizer = new wxBoxSizer(wxVERTICAL); m_thread_list = new wxListView(this, GPLIST_ID, wxPoint(0, 0), wxSize(930, 240), wxLC_REPORT); diff --git a/src/gui/wxgui/windows/TextureRelationViewer/TextureRelationWindow.cpp b/src/gui/wxgui/windows/TextureRelationViewer/TextureRelationWindow.cpp index 52f9b19e..9470501b 100644 --- a/src/gui/wxgui/windows/TextureRelationViewer/TextureRelationWindow.cpp +++ b/src/gui/wxgui/windows/TextureRelationViewer/TextureRelationWindow.cpp @@ -2,6 +2,7 @@ #include "wxHelper.h" #include "TextureRelationWindow.h" #include "Cafe/HW/Latte/Core/LatteTexture.h" +#include "wxgui/helpers/wxHelpers.h" enum { @@ -37,6 +38,8 @@ void openTextureViewer(wxFrame& parentFrame) TextureRelationViewerWindow::TextureRelationViewerWindow(wxFrame& parent) : wxFrame(&parent, wxID_ANY, _("Texture cache"), wxDefaultPosition, wxSize(1000, 480), wxCLOSE_BOX | wxCLIP_CHILDREN | wxCAPTION | wxRESIZE_BORDER) { + wxHelper::BindEscapeCloses(this); + isTextureViewerOpen = true; this->showOnlyActive = false;