Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PathConfigPane: Eliminate main frame global usage #4434

Merged
merged 2 commits into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions Source/Core/DolphinWX/Config/PathConfigPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "DiscIO/NANDContentLoader.h"
#include "DolphinWX/Config/ConfigMain.h"
#include "DolphinWX/Frame.h"
#include "DolphinWX/Main.h"
#include "DolphinWX/WxEventUtils.h"
#include "DolphinWX/WxUtils.h"

Expand Down Expand Up @@ -226,7 +225,9 @@ void PathConfigPane::OnNANDRootChanged(wxCommandEvent& event)

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)
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/DolphinWX/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ bool CRenderFrame::ShowFullScreen(bool show, long style)
wxDEFINE_EVENT(wxEVT_HOST_COMMAND, wxCommandEvent);
wxDEFINE_EVENT(DOLPHIN_EVT_LOCAL_INI_CHANGED, wxCommandEvent);
wxDEFINE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent);
wxDEFINE_EVENT(DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, wxCommandEvent);

// Event tables
BEGIN_EVENT_TABLE(CFrame, CRenderFrame)
Expand Down Expand Up @@ -493,6 +494,7 @@ void CFrame::BindEvents()

Bind(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, &CFrame::OnReloadThemeBitmaps, this);
Bind(DOLPHIN_EVT_RELOAD_GAMELIST, &CFrame::OnReloadGameList, this);
Bind(DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, &CFrame::OnUpdateLoadWiiMenuItem, this);
}

bool CFrame::RendererIsFullscreen()
Expand Down
5 changes: 4 additions & 1 deletion Source/Core/DolphinWX/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class CRenderFrame : public wxFrame
};

wxDECLARE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent);
wxDECLARE_EVENT(DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, wxCommandEvent);

class CFrame : public CRenderFrame
{
Expand Down Expand Up @@ -106,7 +107,6 @@ class CFrame : public CRenderFrame
bool RendererIsFullscreen();
void DoFullscreen(bool bF);
void ToggleDisplayMode(bool bFullscreen);
void UpdateWiiMenuChoice(wxMenuItem* WiiMenuItem = nullptr);
static void ConnectWiimote(int wm_idx, bool connect);
void UpdateTitle(const std::string& str);
void OpenGeneralConfiguration(wxWindowID tab_id = wxID_ANY);
Expand Down Expand Up @@ -242,6 +242,9 @@ class CFrame : public CRenderFrame

void OnUpdateInterpreterMenuItem(wxUpdateUIEvent& event);

void OnUpdateLoadWiiMenuItem(wxCommandEvent&);
void UpdateLoadWiiMenuItem() const;

void OnOpen(wxCommandEvent& event); // File menu
void DoOpen(bool Boot);
void OnRefresh(wxCommandEvent& event);
Expand Down
35 changes: 18 additions & 17 deletions Source/Core/DolphinWX/FrameTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,11 @@ void CFrame::OnUpdateInterpreterMenuItem(wxUpdateUIEvent& event)
event.Check(SConfig::GetInstance().iCPUCore == PowerPC::CORE_INTERPRETER);
}

void CFrame::OnUpdateLoadWiiMenuItem(wxCommandEvent& WXUNUSED(event))
{
UpdateLoadWiiMenuItem();
}

void CFrame::ClearStatusBar()
{
if (this->GetStatusBar()->IsEnabled())
Expand Down Expand Up @@ -1184,32 +1189,28 @@ void CFrame::OnInstallWAD(wxCommandEvent& event)
u64 titleID = DiscIO::CNANDContentManager::Access().Install_WiiWAD(fileName);
if (titleID == TITLEID_SYSMENU)
{
UpdateWiiMenuChoice();
UpdateLoadWiiMenuItem();
}
}

void CFrame::UpdateWiiMenuChoice(wxMenuItem* WiiMenuItem)
void CFrame::UpdateLoadWiiMenuItem() const
{
if (!WiiMenuItem)
{
WiiMenuItem = GetMenuBar()->FindItem(IDM_LOAD_WII_MENU);
}
auto* const menu_item = GetMenuBar()->FindItem(IDM_LOAD_WII_MENU);

const auto& sys_menu_loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(
TITLEID_SYSMENU, Common::FROM_CONFIGURED_ROOT);

const DiscIO::CNANDContentLoader& SysMenu_Loader =
DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU,
Common::FROM_CONFIGURED_ROOT);
if (SysMenu_Loader.IsValid())
if (sys_menu_loader.IsValid())
{
int sysmenuVersion = SysMenu_Loader.GetTitleVersion();
char sysmenuRegion = SysMenu_Loader.GetCountryChar();
WiiMenuItem->Enable();
WiiMenuItem->SetItemLabel(
wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion));
const int version = sys_menu_loader.GetTitleVersion();
const char region = sys_menu_loader.GetCountryChar();
menu_item->Enable();
menu_item->SetItemLabel(wxString::Format(_("Load Wii System Menu %d%c"), version, region));
}
else
{
WiiMenuItem->Enable(false);
WiiMenuItem->SetItemLabel(_("Load Wii System Menu"));
menu_item->Enable(false);
menu_item->SetItemLabel(_("Load Wii System Menu"));
}
}

Expand Down