Merge pull request #4434 from lioncash/path

PathConfigPane: Eliminate main frame global usage
This commit is contained in:
Mat M 2016-11-10 07:31:31 -05:00 committed by GitHub
commit 0b9562b0d5
4 changed files with 27 additions and 20 deletions

View File

@ -21,7 +21,6 @@
#include "DiscIO/NANDContentLoader.h" #include "DiscIO/NANDContentLoader.h"
#include "DolphinWX/Config/ConfigMain.h" #include "DolphinWX/Config/ConfigMain.h"
#include "DolphinWX/Frame.h" #include "DolphinWX/Frame.h"
#include "DolphinWX/Main.h"
#include "DolphinWX/WxEventUtils.h" #include "DolphinWX/WxEventUtils.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
@ -226,7 +225,9 @@ void PathConfigPane::OnNANDRootChanged(wxCommandEvent& event)
DiscIO::CNANDContentManager::Access().ClearCache(); DiscIO::CNANDContentManager::Access().ClearCache();
main_frame->UpdateWiiMenuChoice(); wxCommandEvent update_event{DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, GetId()};
update_event.SetEventObject(this);
AddPendingEvent(update_event);
} }
void PathConfigPane::OnDumpPathChanged(wxCommandEvent& event) void PathConfigPane::OnDumpPathChanged(wxCommandEvent& event)

View File

@ -226,6 +226,7 @@ bool CRenderFrame::ShowFullScreen(bool show, long style)
wxDEFINE_EVENT(wxEVT_HOST_COMMAND, wxCommandEvent); wxDEFINE_EVENT(wxEVT_HOST_COMMAND, wxCommandEvent);
wxDEFINE_EVENT(DOLPHIN_EVT_LOCAL_INI_CHANGED, wxCommandEvent); wxDEFINE_EVENT(DOLPHIN_EVT_LOCAL_INI_CHANGED, wxCommandEvent);
wxDEFINE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent); wxDEFINE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent);
wxDEFINE_EVENT(DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, wxCommandEvent);
// Event tables // Event tables
BEGIN_EVENT_TABLE(CFrame, CRenderFrame) BEGIN_EVENT_TABLE(CFrame, CRenderFrame)
@ -493,6 +494,7 @@ void CFrame::BindEvents()
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); Bind(DOLPHIN_EVT_RELOAD_GAMELIST, &CFrame::OnReloadGameList, this);
Bind(DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, &CFrame::OnUpdateLoadWiiMenuItem, this);
} }
bool CFrame::RendererIsFullscreen() bool CFrame::RendererIsFullscreen()

View File

@ -61,6 +61,7 @@ private:
}; };
wxDECLARE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent); wxDECLARE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent);
wxDECLARE_EVENT(DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, wxCommandEvent);
class CFrame : public CRenderFrame class CFrame : public CRenderFrame
{ {
@ -106,7 +107,6 @@ public:
bool RendererIsFullscreen(); bool RendererIsFullscreen();
void DoFullscreen(bool bF); void DoFullscreen(bool bF);
void ToggleDisplayMode(bool bFullscreen); void ToggleDisplayMode(bool bFullscreen);
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(wxWindowID tab_id = wxID_ANY); void OpenGeneralConfiguration(wxWindowID tab_id = wxID_ANY);
@ -242,6 +242,9 @@ private:
void OnUpdateInterpreterMenuItem(wxUpdateUIEvent& event); void OnUpdateInterpreterMenuItem(wxUpdateUIEvent& event);
void OnUpdateLoadWiiMenuItem(wxCommandEvent&);
void UpdateLoadWiiMenuItem() const;
void OnOpen(wxCommandEvent& event); // File menu void OnOpen(wxCommandEvent& event); // File menu
void DoOpen(bool Boot); void DoOpen(bool Boot);
void OnRefresh(wxCommandEvent& event); void OnRefresh(wxCommandEvent& event);

View File

@ -1072,6 +1072,11 @@ void CFrame::OnUpdateInterpreterMenuItem(wxUpdateUIEvent& event)
event.Check(SConfig::GetInstance().iCPUCore == PowerPC::CORE_INTERPRETER); event.Check(SConfig::GetInstance().iCPUCore == PowerPC::CORE_INTERPRETER);
} }
void CFrame::OnUpdateLoadWiiMenuItem(wxCommandEvent& WXUNUSED(event))
{
UpdateLoadWiiMenuItem();
}
void CFrame::ClearStatusBar() void CFrame::ClearStatusBar()
{ {
if (this->GetStatusBar()->IsEnabled()) if (this->GetStatusBar()->IsEnabled())
@ -1184,32 +1189,28 @@ void CFrame::OnInstallWAD(wxCommandEvent& event)
u64 titleID = DiscIO::CNANDContentManager::Access().Install_WiiWAD(fileName); u64 titleID = DiscIO::CNANDContentManager::Access().Install_WiiWAD(fileName);
if (titleID == TITLEID_SYSMENU) if (titleID == TITLEID_SYSMENU)
{ {
UpdateWiiMenuChoice(); UpdateLoadWiiMenuItem();
} }
} }
void CFrame::UpdateWiiMenuChoice(wxMenuItem* WiiMenuItem) void CFrame::UpdateLoadWiiMenuItem() const
{ {
if (!WiiMenuItem) auto* const menu_item = GetMenuBar()->FindItem(IDM_LOAD_WII_MENU);
{
WiiMenuItem = GetMenuBar()->FindItem(IDM_LOAD_WII_MENU);
}
const DiscIO::CNANDContentLoader& SysMenu_Loader = const auto& sys_menu_loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(
DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, TITLEID_SYSMENU, Common::FROM_CONFIGURED_ROOT);
Common::FROM_CONFIGURED_ROOT);
if (SysMenu_Loader.IsValid()) if (sys_menu_loader.IsValid())
{ {
int sysmenuVersion = SysMenu_Loader.GetTitleVersion(); const int version = sys_menu_loader.GetTitleVersion();
char sysmenuRegion = SysMenu_Loader.GetCountryChar(); const char region = sys_menu_loader.GetCountryChar();
WiiMenuItem->Enable(); menu_item->Enable();
WiiMenuItem->SetItemLabel( menu_item->SetItemLabel(wxString::Format(_("Load Wii System Menu %d%c"), version, region));
wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion));
} }
else else
{ {
WiiMenuItem->Enable(false); menu_item->Enable(false);
WiiMenuItem->SetItemLabel(_("Load Wii System Menu")); menu_item->SetItemLabel(_("Load Wii System Menu"));
} }
} }