diff --git a/Source/Core/DolphinWX/Config/ConfigMain.cpp b/Source/Core/DolphinWX/Config/ConfigMain.cpp index 9e570e3e86..48fd35ab96 100644 --- a/Source/Core/DolphinWX/Config/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Config/ConfigMain.cpp @@ -2,6 +2,9 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "DolphinWX/Config/ConfigMain.h" + +#include #include #include #include @@ -10,16 +13,15 @@ #include "Common/CommonTypes.h" #include "Core/ConfigManager.h" #include "Core/Core.h" -#include "Core/Movie.h" #include "Core/NetPlayProto.h" #include "DolphinWX/Config/AdvancedConfigPane.h" #include "DolphinWX/Config/AudioConfigPane.h" -#include "DolphinWX/Config/ConfigMain.h" #include "DolphinWX/Config/GameCubeConfigPane.h" #include "DolphinWX/Config/GeneralConfigPane.h" #include "DolphinWX/Config/InterfaceConfigPane.h" #include "DolphinWX/Config/PathConfigPane.h" #include "DolphinWX/Config/WiiConfigPane.h" +#include "DolphinWX/GameListCtrl.h" #include "DolphinWX/WxUtils.h" // Sent by child panes to signify that the game list should @@ -35,6 +37,7 @@ CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title, Bind(wxEVT_CLOSE_WINDOW, &CConfigMain::OnClose, this); Bind(wxEVT_BUTTON, &CConfigMain::OnCloseButton, this, wxID_CLOSE); + Bind(wxEVT_SHOW, &CConfigMain::OnShow, this); Bind(wxDOLPHIN_CFG_REFRESH_LIST, &CConfigMain::OnSetRefreshGameListOnClose, this); wxDialog::SetExtraStyle(GetExtraStyle() & ~wxWS_EX_BLOCK_EVENTS); @@ -46,14 +49,22 @@ CConfigMain::~CConfigMain() { } -void CConfigMain::SetSelectedTab(int tab) +void CConfigMain::SetSelectedTab(wxWindowID tab_id) { - // TODO : this is just a quick and dirty way to do it, possible cleanup - - switch (tab) + switch (tab_id) { + case ID_GENERALPAGE: + case ID_DISPLAYPAGE: case ID_AUDIOPAGE: - Notebook->SetSelection(2); + case ID_GAMECUBEPAGE: + case ID_WIIPAGE: + case ID_PATHSPAGE: + case ID_ADVANCEDPAGE: + Notebook->SetSelection(Notebook->FindPage(Notebook->FindWindowById(tab_id))); + break; + + default: + wxASSERT_MSG(false, wxString::Format("Invalid tab page ID specified (%d)", tab_id)); break; } } @@ -96,16 +107,22 @@ void CConfigMain::CreateGUIControls() SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED); SetLayoutAdaptationLevel(wxDIALOG_ADAPTATION_STANDARD_SIZER); SetSizerAndFit(main_sizer); - Center(); - SetFocus(); } void CConfigMain::OnClose(wxCloseEvent& WXUNUSED(event)) { - EndModal((m_refresh_game_list_on_close) ? wxID_OK : wxID_CANCEL); + Hide(); - // Save the config. Dolphin crashes too often to only save the settings on closing SConfig::GetInstance().SaveSettings(); + + if (m_refresh_game_list_on_close) + AddPendingEvent(wxCommandEvent{DOLPHIN_EVT_RELOAD_GAMELIST}); +} + +void CConfigMain::OnShow(wxShowEvent& event) +{ + if (event.IsShown()) + CenterOnParent(); } void CConfigMain::OnCloseButton(wxCommandEvent& WXUNUSED(event)) diff --git a/Source/Core/DolphinWX/Config/ConfigMain.h b/Source/Core/DolphinWX/Config/ConfigMain.h index 3e4d965525..84c2f9121f 100644 --- a/Source/Core/DolphinWX/Config/ConfigMain.h +++ b/Source/Core/DolphinWX/Config/ConfigMain.h @@ -21,7 +21,7 @@ public: long style = wxDEFAULT_DIALOG_STYLE); virtual ~CConfigMain(); - void SetSelectedTab(int tab); + void SetSelectedTab(wxWindowID tab_id); enum { @@ -39,6 +39,7 @@ private: void CreateGUIControls(); void OnClose(wxCloseEvent& event); void OnCloseButton(wxCommandEvent& event); + void OnShow(wxShowEvent& event); void OnSetRefreshGameListOnClose(wxCommandEvent& event); wxNotebook* Notebook; diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index c966bf84f6..147e2a47b6 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "DolphinWX/Frame.h" + #include #include #include @@ -49,8 +51,8 @@ #include "Core/Movie.h" #include "Core/State.h" +#include "DolphinWX/Config/ConfigMain.h" #include "DolphinWX/Debugger/CodeWindow.h" -#include "DolphinWX/Frame.h" #include "DolphinWX/GameListCtrl.h" #include "DolphinWX/Globals.h" #include "DolphinWX/LogWindow.h" @@ -310,6 +312,8 @@ CFrame::CFrame(wxFrame* parent, wxWindowID id, const wxString& title, wxRect geo { BindEvents(); + m_main_config_dialog = new CConfigMain(this); + for (int i = 0; i <= IDM_CODE_WINDOW - IDM_LOG_WINDOW; i++) bFloatWindow[i] = false; @@ -488,6 +492,7 @@ void CFrame::BindEvents() BindMenuBarEvents(); Bind(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, &CFrame::OnReloadThemeBitmaps, this); + Bind(DOLPHIN_EVT_RELOAD_GAMELIST, &CFrame::OnReloadGameList, this); } bool CFrame::RendererIsFullscreen() diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index e2cf78c054..9a3d6d3729 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -27,6 +27,7 @@ // Class declarations class CGameListCtrl; class CCodeWindow; +class CConfigMain; class CLogWindow; class FifoPlayerDlg; class LogConfigWindow; @@ -108,7 +109,7 @@ public: void UpdateWiiMenuChoice(wxMenuItem* WiiMenuItem = nullptr); static void ConnectWiimote(int wm_idx, bool connect); void UpdateTitle(const std::string& str); - void OpenGeneralConfiguration(int tab = -1); + void OpenGeneralConfiguration(wxWindowID tab_id = wxID_ANY); const CGameListCtrl* GetGameListCtrl() const; wxMenuBar* GetMenuBar() const override; @@ -143,6 +144,7 @@ public: private: CGameListCtrl* m_GameListCtrl = nullptr; + CConfigMain* m_main_config_dialog = nullptr; wxPanel* m_Panel = nullptr; CRenderFrame* m_RenderFrame = nullptr; wxWindow* m_RenderParent = nullptr; @@ -236,6 +238,7 @@ private: void OnHelp(wxCommandEvent& event); void OnReloadThemeBitmaps(wxCommandEvent& event); + void OnReloadGameList(wxCommandEvent& event); void OnEnableMenuItemIfCoreInitialized(wxUpdateUIEvent& event); void OnEnableMenuItemIfCoreUninitialized(wxUpdateUIEvent& event); diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index cb4297585f..ee9903ea5a 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -256,18 +256,13 @@ wxToolBar* CFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& na return new MainToolBar{type, this, id, wxDefaultPosition, wxDefaultSize, style}; } -void CFrame::OpenGeneralConfiguration(int tab) +void CFrame::OpenGeneralConfiguration(wxWindowID tab_id) { - CConfigMain config_main(this); - if (tab > -1) - config_main.SetSelectedTab(tab); + if (tab_id > wxID_ANY) + m_main_config_dialog->SetSelectedTab(tab_id); - HotkeyManagerEmu::Enable(false); - if (config_main.ShowModal() == wxID_OK) - UpdateGameList(); - HotkeyManagerEmu::Enable(true); - - UpdateGUI(); + m_main_config_dialog->Show(); + m_main_config_dialog->SetFocus(); } // Menu items @@ -734,13 +729,11 @@ void CFrame::OnBootDrive(wxCommandEvent& event) BootGame(drives[event.GetId() - IDM_DRIVE1]); } -// Refresh the file list and browse for a favorites directory void CFrame::OnRefresh(wxCommandEvent& WXUNUSED(event)) { UpdateGameList(); } -// Create screenshot void CFrame::OnScreenshot(wxCommandEvent& WXUNUSED(event)) { Core::SaveScreenShot(); @@ -1067,6 +1060,11 @@ void CFrame::OnReloadThemeBitmaps(wxCommandEvent& WXUNUSED(event)) UpdateGameList(); } +void CFrame::OnReloadGameList(wxCommandEvent& WXUNUSED(event)) +{ + UpdateGameList(); +} + void CFrame::OnEnableMenuItemIfCoreInitialized(wxUpdateUIEvent& event) { event.Enable(Core::GetState() != Core::CORE_UNINITIALIZED); @@ -1531,8 +1529,9 @@ void CFrame::UpdateGUI() void CFrame::UpdateGameList() { - if (m_GameListCtrl) - m_GameListCtrl->ReloadList(); + wxCommandEvent event{DOLPHIN_EVT_RELOAD_GAMELIST, GetId()}; + event.SetEventObject(this); + wxPostEvent(m_GameListCtrl, event); } void CFrame::GameListChanged(wxCommandEvent& event) diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp index 1b5c27e167..a5e84e0002 100644 --- a/Source/Core/DolphinWX/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/GameListCtrl.cpp @@ -155,6 +155,8 @@ static int CompareGameListItems(const GameListItem* iso1, const GameListItem* is return 0; } +wxDEFINE_EVENT(DOLPHIN_EVT_RELOAD_GAMELIST, wxCommandEvent); + CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : wxListCtrl(parent, id, pos, size, style), toolTip(nullptr) @@ -180,6 +182,8 @@ CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoin Bind(wxEVT_MENU, &CGameListCtrl::OnChangeDisc, this, IDM_LIST_CHANGE_DISC); Bind(wxEVT_MENU, &CGameListCtrl::OnNetPlayHost, this, IDM_START_NETPLAY); + Bind(DOLPHIN_EVT_RELOAD_GAMELIST, &CGameListCtrl::OnReloadGameList, this); + wxTheApp->Bind(DOLPHIN_EVT_LOCAL_INI_CHANGED, &CGameListCtrl::OnLocalIniModified, this); } @@ -708,6 +712,11 @@ void CGameListCtrl::ScanForISOs() std::sort(m_ISOFiles.begin(), m_ISOFiles.end()); } +void CGameListCtrl::OnReloadGameList(wxCommandEvent& WXUNUSED(event)) +{ + ReloadList(); +} + void CGameListCtrl::OnLocalIniModified(wxCommandEvent& ev) { ev.Skip(); diff --git a/Source/Core/DolphinWX/GameListCtrl.h b/Source/Core/DolphinWX/GameListCtrl.h index 467271d68e..7854c7972f 100644 --- a/Source/Core/DolphinWX/GameListCtrl.h +++ b/Source/Core/DolphinWX/GameListCtrl.h @@ -31,6 +31,8 @@ public: } }; +wxDECLARE_EVENT(DOLPHIN_EVT_RELOAD_GAMELIST, wxCommandEvent); + class CGameListCtrl : public wxListCtrl { public: @@ -38,8 +40,6 @@ public: long style); ~CGameListCtrl(); - void ReloadList(); - void BrowseForDirectory(); const GameListItem* GetISO(size_t index) const; const GameListItem* GetSelectedISO() const; @@ -67,17 +67,9 @@ public: #endif private: - std::vector m_FlagImageIndex; - std::vector m_PlatformImageIndex; - std::vector m_EmuStateImageIndex; - std::vector m_utility_game_banners; - std::vector> m_ISOFiles; + void ReloadList(); void ClearIsoFiles() { m_ISOFiles.clear(); } - int last_column; - int last_sort; - wxSize lastpos; - wxEmuStateTip* toolTip; void InitBitmaps(); void UpdateItemAtColumn(long _Index, int column); void InsertItemInReportView(long _Index); @@ -85,6 +77,7 @@ private: void ScanForISOs(); // events + void OnReloadGameList(wxCommandEvent& event); void OnLeftClick(wxMouseEvent& event); void OnRightClick(wxMouseEvent& event); void OnMouseMotion(wxMouseEvent& event); @@ -113,4 +106,15 @@ private: static bool CompressCB(const std::string& text, float percent, void* arg); static bool MultiCompressCB(const std::string& text, float percent, void* arg); static bool WiiCompressWarning(); + + std::vector m_FlagImageIndex; + std::vector m_PlatformImageIndex; + std::vector m_EmuStateImageIndex; + std::vector m_utility_game_banners; + std::vector> m_ISOFiles; + + int last_column; + int last_sort; + wxSize lastpos; + wxEmuStateTip* toolTip; }; diff --git a/Source/Core/DolphinWX/ISOProperties.cpp b/Source/Core/DolphinWX/ISOProperties.cpp index fd716783ab..5bdf98c0c2 100644 --- a/Source/Core/DolphinWX/ISOProperties.cpp +++ b/Source/Core/DolphinWX/ISOProperties.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "DolphinWX/ISOProperties.h" + #include #include #include @@ -63,11 +65,11 @@ #include "DiscIO/VolumeCreator.h" #include "DolphinWX/Cheats/ActionReplayCodesPanel.h" #include "DolphinWX/Cheats/GeckoCodeDiag.h" +#include "DolphinWX/Config/ConfigMain.h" #include "DolphinWX/DolphinSlider.h" #include "DolphinWX/Frame.h" #include "DolphinWX/Globals.h" #include "DolphinWX/ISOFile.h" -#include "DolphinWX/ISOProperties.h" #include "DolphinWX/Main.h" #include "DolphinWX/PatchAddEdit.h" #include "DolphinWX/WxUtils.h" @@ -133,7 +135,7 @@ private: void OnConfigureClicked(wxCommandEvent&) { - main_frame->OpenGeneralConfiguration(); + main_frame->OpenGeneralConfiguration(CConfigMain::ID_GENERALPAGE); UpdateState(); }