DolphinWX: Make the main config dialog modeless

This commit is contained in:
Lioncash 2016-11-05 20:53:40 -04:00
parent bfa9cc2736
commit c2d00d25fe
8 changed files with 81 additions and 41 deletions

View File

@ -2,6 +2,9 @@
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "DolphinWX/Config/ConfigMain.h"
#include <wx/debug.h>
#include <wx/notebook.h> #include <wx/notebook.h>
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/sizer.h> #include <wx/sizer.h>
@ -10,16 +13,15 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/Movie.h"
#include "Core/NetPlayProto.h" #include "Core/NetPlayProto.h"
#include "DolphinWX/Config/AdvancedConfigPane.h" #include "DolphinWX/Config/AdvancedConfigPane.h"
#include "DolphinWX/Config/AudioConfigPane.h" #include "DolphinWX/Config/AudioConfigPane.h"
#include "DolphinWX/Config/ConfigMain.h"
#include "DolphinWX/Config/GameCubeConfigPane.h" #include "DolphinWX/Config/GameCubeConfigPane.h"
#include "DolphinWX/Config/GeneralConfigPane.h" #include "DolphinWX/Config/GeneralConfigPane.h"
#include "DolphinWX/Config/InterfaceConfigPane.h" #include "DolphinWX/Config/InterfaceConfigPane.h"
#include "DolphinWX/Config/PathConfigPane.h" #include "DolphinWX/Config/PathConfigPane.h"
#include "DolphinWX/Config/WiiConfigPane.h" #include "DolphinWX/Config/WiiConfigPane.h"
#include "DolphinWX/GameListCtrl.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
// Sent by child panes to signify that the game list should // 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_CLOSE_WINDOW, &CConfigMain::OnClose, this);
Bind(wxEVT_BUTTON, &CConfigMain::OnCloseButton, this, wxID_CLOSE); Bind(wxEVT_BUTTON, &CConfigMain::OnCloseButton, this, wxID_CLOSE);
Bind(wxEVT_SHOW, &CConfigMain::OnShow, this);
Bind(wxDOLPHIN_CFG_REFRESH_LIST, &CConfigMain::OnSetRefreshGameListOnClose, this); Bind(wxDOLPHIN_CFG_REFRESH_LIST, &CConfigMain::OnSetRefreshGameListOnClose, this);
wxDialog::SetExtraStyle(GetExtraStyle() & ~wxWS_EX_BLOCK_EVENTS); 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_id)
switch (tab)
{ {
case ID_GENERALPAGE:
case ID_DISPLAYPAGE:
case ID_AUDIOPAGE: 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; break;
} }
} }
@ -96,16 +107,22 @@ void CConfigMain::CreateGUIControls()
SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED); SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED);
SetLayoutAdaptationLevel(wxDIALOG_ADAPTATION_STANDARD_SIZER); SetLayoutAdaptationLevel(wxDIALOG_ADAPTATION_STANDARD_SIZER);
SetSizerAndFit(main_sizer); SetSizerAndFit(main_sizer);
Center();
SetFocus();
} }
void CConfigMain::OnClose(wxCloseEvent& WXUNUSED(event)) 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(); 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)) void CConfigMain::OnCloseButton(wxCommandEvent& WXUNUSED(event))

View File

@ -21,7 +21,7 @@ public:
long style = wxDEFAULT_DIALOG_STYLE); long style = wxDEFAULT_DIALOG_STYLE);
virtual ~CConfigMain(); virtual ~CConfigMain();
void SetSelectedTab(int tab); void SetSelectedTab(wxWindowID tab_id);
enum enum
{ {
@ -39,6 +39,7 @@ private:
void CreateGUIControls(); void CreateGUIControls();
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
void OnCloseButton(wxCommandEvent& event); void OnCloseButton(wxCommandEvent& event);
void OnShow(wxShowEvent& event);
void OnSetRefreshGameListOnClose(wxCommandEvent& event); void OnSetRefreshGameListOnClose(wxCommandEvent& event);
wxNotebook* Notebook; wxNotebook* Notebook;

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "DolphinWX/Frame.h"
#include <atomic> #include <atomic>
#include <cstddef> #include <cstddef>
#include <fstream> #include <fstream>
@ -49,8 +51,8 @@
#include "Core/Movie.h" #include "Core/Movie.h"
#include "Core/State.h" #include "Core/State.h"
#include "DolphinWX/Config/ConfigMain.h"
#include "DolphinWX/Debugger/CodeWindow.h" #include "DolphinWX/Debugger/CodeWindow.h"
#include "DolphinWX/Frame.h"
#include "DolphinWX/GameListCtrl.h" #include "DolphinWX/GameListCtrl.h"
#include "DolphinWX/Globals.h" #include "DolphinWX/Globals.h"
#include "DolphinWX/LogWindow.h" #include "DolphinWX/LogWindow.h"
@ -310,6 +312,8 @@ CFrame::CFrame(wxFrame* parent, wxWindowID id, const wxString& title, wxRect geo
{ {
BindEvents(); BindEvents();
m_main_config_dialog = new CConfigMain(this);
for (int i = 0; i <= IDM_CODE_WINDOW - IDM_LOG_WINDOW; i++) for (int i = 0; i <= IDM_CODE_WINDOW - IDM_LOG_WINDOW; i++)
bFloatWindow[i] = false; bFloatWindow[i] = false;
@ -488,6 +492,7 @@ void CFrame::BindEvents()
BindMenuBarEvents(); BindMenuBarEvents();
Bind(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, &CFrame::OnReloadThemeBitmaps, this); Bind(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, &CFrame::OnReloadThemeBitmaps, this);
Bind(DOLPHIN_EVT_RELOAD_GAMELIST, &CFrame::OnReloadGameList, this);
} }
bool CFrame::RendererIsFullscreen() bool CFrame::RendererIsFullscreen()

View File

@ -27,6 +27,7 @@
// Class declarations // Class declarations
class CGameListCtrl; class CGameListCtrl;
class CCodeWindow; class CCodeWindow;
class CConfigMain;
class CLogWindow; class CLogWindow;
class FifoPlayerDlg; class FifoPlayerDlg;
class LogConfigWindow; class LogConfigWindow;
@ -108,7 +109,7 @@ public:
void UpdateWiiMenuChoice(wxMenuItem* WiiMenuItem = nullptr); void UpdateWiiMenuChoice(wxMenuItem* WiiMenuItem = nullptr);
static void ConnectWiimote(int wm_idx, bool connect); static void ConnectWiimote(int wm_idx, bool connect);
void UpdateTitle(const std::string& str); void UpdateTitle(const std::string& str);
void OpenGeneralConfiguration(int tab = -1); void OpenGeneralConfiguration(wxWindowID tab_id = wxID_ANY);
const CGameListCtrl* GetGameListCtrl() const; const CGameListCtrl* GetGameListCtrl() const;
wxMenuBar* GetMenuBar() const override; wxMenuBar* GetMenuBar() const override;
@ -143,6 +144,7 @@ public:
private: private:
CGameListCtrl* m_GameListCtrl = nullptr; CGameListCtrl* m_GameListCtrl = nullptr;
CConfigMain* m_main_config_dialog = nullptr;
wxPanel* m_Panel = nullptr; wxPanel* m_Panel = nullptr;
CRenderFrame* m_RenderFrame = nullptr; CRenderFrame* m_RenderFrame = nullptr;
wxWindow* m_RenderParent = nullptr; wxWindow* m_RenderParent = nullptr;
@ -236,6 +238,7 @@ private:
void OnHelp(wxCommandEvent& event); void OnHelp(wxCommandEvent& event);
void OnReloadThemeBitmaps(wxCommandEvent& event); void OnReloadThemeBitmaps(wxCommandEvent& event);
void OnReloadGameList(wxCommandEvent& event);
void OnEnableMenuItemIfCoreInitialized(wxUpdateUIEvent& event); void OnEnableMenuItemIfCoreInitialized(wxUpdateUIEvent& event);
void OnEnableMenuItemIfCoreUninitialized(wxUpdateUIEvent& event); void OnEnableMenuItemIfCoreUninitialized(wxUpdateUIEvent& event);

View File

@ -256,18 +256,13 @@ wxToolBar* CFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& na
return new MainToolBar{type, this, id, wxDefaultPosition, wxDefaultSize, style}; 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_id > wxID_ANY)
if (tab > -1) m_main_config_dialog->SetSelectedTab(tab_id);
config_main.SetSelectedTab(tab);
HotkeyManagerEmu::Enable(false); m_main_config_dialog->Show();
if (config_main.ShowModal() == wxID_OK) m_main_config_dialog->SetFocus();
UpdateGameList();
HotkeyManagerEmu::Enable(true);
UpdateGUI();
} }
// Menu items // Menu items
@ -734,13 +729,11 @@ void CFrame::OnBootDrive(wxCommandEvent& event)
BootGame(drives[event.GetId() - IDM_DRIVE1]); BootGame(drives[event.GetId() - IDM_DRIVE1]);
} }
// Refresh the file list and browse for a favorites directory
void CFrame::OnRefresh(wxCommandEvent& WXUNUSED(event)) void CFrame::OnRefresh(wxCommandEvent& WXUNUSED(event))
{ {
UpdateGameList(); UpdateGameList();
} }
// Create screenshot
void CFrame::OnScreenshot(wxCommandEvent& WXUNUSED(event)) void CFrame::OnScreenshot(wxCommandEvent& WXUNUSED(event))
{ {
Core::SaveScreenShot(); Core::SaveScreenShot();
@ -1067,6 +1060,11 @@ void CFrame::OnReloadThemeBitmaps(wxCommandEvent& WXUNUSED(event))
UpdateGameList(); UpdateGameList();
} }
void CFrame::OnReloadGameList(wxCommandEvent& WXUNUSED(event))
{
UpdateGameList();
}
void CFrame::OnEnableMenuItemIfCoreInitialized(wxUpdateUIEvent& event) void CFrame::OnEnableMenuItemIfCoreInitialized(wxUpdateUIEvent& event)
{ {
event.Enable(Core::GetState() != Core::CORE_UNINITIALIZED); event.Enable(Core::GetState() != Core::CORE_UNINITIALIZED);
@ -1531,8 +1529,9 @@ void CFrame::UpdateGUI()
void CFrame::UpdateGameList() void CFrame::UpdateGameList()
{ {
if (m_GameListCtrl) wxCommandEvent event{DOLPHIN_EVT_RELOAD_GAMELIST, GetId()};
m_GameListCtrl->ReloadList(); event.SetEventObject(this);
wxPostEvent(m_GameListCtrl, event);
} }
void CFrame::GameListChanged(wxCommandEvent& event) void CFrame::GameListChanged(wxCommandEvent& event)

View File

@ -155,6 +155,8 @@ static int CompareGameListItems(const GameListItem* iso1, const GameListItem* is
return 0; return 0;
} }
wxDEFINE_EVENT(DOLPHIN_EVT_RELOAD_GAMELIST, wxCommandEvent);
CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos,
const wxSize& size, long style) const wxSize& size, long style)
: wxListCtrl(parent, id, pos, size, style), toolTip(nullptr) : 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::OnChangeDisc, this, IDM_LIST_CHANGE_DISC);
Bind(wxEVT_MENU, &CGameListCtrl::OnNetPlayHost, this, IDM_START_NETPLAY); 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); 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()); std::sort(m_ISOFiles.begin(), m_ISOFiles.end());
} }
void CGameListCtrl::OnReloadGameList(wxCommandEvent& WXUNUSED(event))
{
ReloadList();
}
void CGameListCtrl::OnLocalIniModified(wxCommandEvent& ev) void CGameListCtrl::OnLocalIniModified(wxCommandEvent& ev)
{ {
ev.Skip(); ev.Skip();

View File

@ -31,6 +31,8 @@ public:
} }
}; };
wxDECLARE_EVENT(DOLPHIN_EVT_RELOAD_GAMELIST, wxCommandEvent);
class CGameListCtrl : public wxListCtrl class CGameListCtrl : public wxListCtrl
{ {
public: public:
@ -38,8 +40,6 @@ public:
long style); long style);
~CGameListCtrl(); ~CGameListCtrl();
void ReloadList();
void BrowseForDirectory(); void BrowseForDirectory();
const GameListItem* GetISO(size_t index) const; const GameListItem* GetISO(size_t index) const;
const GameListItem* GetSelectedISO() const; const GameListItem* GetSelectedISO() const;
@ -67,17 +67,9 @@ public:
#endif #endif
private: private:
std::vector<int> m_FlagImageIndex; void ReloadList();
std::vector<int> m_PlatformImageIndex;
std::vector<int> m_EmuStateImageIndex;
std::vector<int> m_utility_game_banners;
std::vector<std::unique_ptr<GameListItem>> m_ISOFiles;
void ClearIsoFiles() { m_ISOFiles.clear(); } void ClearIsoFiles() { m_ISOFiles.clear(); }
int last_column;
int last_sort;
wxSize lastpos;
wxEmuStateTip* toolTip;
void InitBitmaps(); void InitBitmaps();
void UpdateItemAtColumn(long _Index, int column); void UpdateItemAtColumn(long _Index, int column);
void InsertItemInReportView(long _Index); void InsertItemInReportView(long _Index);
@ -85,6 +77,7 @@ private:
void ScanForISOs(); void ScanForISOs();
// events // events
void OnReloadGameList(wxCommandEvent& event);
void OnLeftClick(wxMouseEvent& event); void OnLeftClick(wxMouseEvent& event);
void OnRightClick(wxMouseEvent& event); void OnRightClick(wxMouseEvent& event);
void OnMouseMotion(wxMouseEvent& event); void OnMouseMotion(wxMouseEvent& event);
@ -113,4 +106,15 @@ private:
static bool CompressCB(const std::string& text, float percent, void* arg); static bool CompressCB(const std::string& text, float percent, void* arg);
static bool MultiCompressCB(const std::string& text, float percent, void* arg); static bool MultiCompressCB(const std::string& text, float percent, void* arg);
static bool WiiCompressWarning(); static bool WiiCompressWarning();
std::vector<int> m_FlagImageIndex;
std::vector<int> m_PlatformImageIndex;
std::vector<int> m_EmuStateImageIndex;
std::vector<int> m_utility_game_banners;
std::vector<std::unique_ptr<GameListItem>> m_ISOFiles;
int last_column;
int last_sort;
wxSize lastpos;
wxEmuStateTip* toolTip;
}; };

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "DolphinWX/ISOProperties.h"
#include <array> #include <array>
#include <cinttypes> #include <cinttypes>
#include <cstddef> #include <cstddef>
@ -63,11 +65,11 @@
#include "DiscIO/VolumeCreator.h" #include "DiscIO/VolumeCreator.h"
#include "DolphinWX/Cheats/ActionReplayCodesPanel.h" #include "DolphinWX/Cheats/ActionReplayCodesPanel.h"
#include "DolphinWX/Cheats/GeckoCodeDiag.h" #include "DolphinWX/Cheats/GeckoCodeDiag.h"
#include "DolphinWX/Config/ConfigMain.h"
#include "DolphinWX/DolphinSlider.h" #include "DolphinWX/DolphinSlider.h"
#include "DolphinWX/Frame.h" #include "DolphinWX/Frame.h"
#include "DolphinWX/Globals.h" #include "DolphinWX/Globals.h"
#include "DolphinWX/ISOFile.h" #include "DolphinWX/ISOFile.h"
#include "DolphinWX/ISOProperties.h"
#include "DolphinWX/Main.h" #include "DolphinWX/Main.h"
#include "DolphinWX/PatchAddEdit.h" #include "DolphinWX/PatchAddEdit.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
@ -133,7 +135,7 @@ private:
void OnConfigureClicked(wxCommandEvent&) void OnConfigureClicked(wxCommandEvent&)
{ {
main_frame->OpenGeneralConfiguration(); main_frame->OpenGeneralConfiguration(CConfigMain::ID_GENERALPAGE);
UpdateState(); UpdateState();
} }