Updating Cheats manager when the ISO is changed etc.

The Cheats manager should be updated when the ISO is changed because it's non-modal

Removing code that read the ID from file because the cheats manager only has a use when an emulation is running (when the ID doesn't need to be read from the ISO again because it's in a variable). This fixes loading Gecko codes for .wad during an emulation because "VolumeHandler::GetVolume()" return false in this case
This commit is contained in:
John Peterson 2013-05-04 19:27:39 +02:00
parent 719f18a122
commit 7cc2e3146b
5 changed files with 57 additions and 22 deletions

View File

@ -14,6 +14,7 @@
#include "WxUtils.h"
#define MAX_CHEAT_SEARCH_RESULTS_DISPLAY 256
const std::string title = _("Cheats Manager");
extern std::vector<ActionReplay::ARCode> arCodes;
extern CFrame* main_frame;
@ -22,26 +23,15 @@ extern CFrame* main_frame;
static wxCheatsWindow *g_cheat_window;
wxCheatsWindow::wxCheatsWindow(wxWindow* const parent)
: wxDialog(parent, wxID_ANY, _("Cheats Manager"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxDIALOG_NO_PARENT)
: wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxDIALOG_NO_PARENT)
{
::g_cheat_window = this;
// Create the GUI controls
Init_ChildControls();
// Load Data
Load_ARCodes();
// Load Gecko Codes :/
{
const DiscIO::IVolume* const vol = VolumeHandler::GetVolume();
if (vol)
{
m_gameini_path = File::GetUserPath(D_GAMECONFIG_IDX) + vol->GetUniqueID() + ".ini";
m_gameini.Load(m_gameini_path);
m_geckocode_panel->LoadCodes(m_gameini, Core::g_CoreStartupParameter.GetUniqueID());
}
}
// load codes
UpdateGUI();
SetSize(wxSize(-1, 600));
Center();
@ -119,7 +109,7 @@ void wxCheatsWindow::Init_ChildControls()
m_Notebook_Main->AddPage(m_Tab_Log, _("Logging"));
// Button Strip
wxButton* const button_apply = new wxButton(panel, wxID_APPLY, _("Apply"), wxDefaultPosition, wxDefaultSize);
button_apply = new wxButton(panel, wxID_APPLY, _("Apply"), wxDefaultPosition, wxDefaultSize);
button_apply->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &wxCheatsWindow::OnEvent_ApplyChanges_Press, this);
wxButton* const button_cancel = new wxButton(panel, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize);
button_cancel->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &wxCheatsWindow::OnEvent_ButtonClose_Press, this);
@ -249,12 +239,34 @@ void wxCheatsWindow::OnEvent_Close(wxCloseEvent& ev)
Destroy();
}
// load codes for a new ISO ID
void wxCheatsWindow::UpdateGUI()
{
// load code
m_gameini_path = File::GetUserPath(D_GAMECONFIG_IDX) + Core::g_CoreStartupParameter.GetUniqueID() + ".ini";
m_gameini.Load(m_gameini_path);
Load_ARCodes();
Load_GeckoCodes();
// enable controls
button_apply->Enable(Core::IsRunning());
// write the ISO name in the title
if (Core::IsRunning())
SetTitle(title + ": " + Core::g_CoreStartupParameter.GetUniqueID() + " - " + Core::g_CoreStartupParameter.m_strName);
else
SetTitle(title);
}
void wxCheatsWindow::Load_ARCodes()
{
using namespace ActionReplay;
m_CheckListBox_CheatsList->Clear();
if (!Core::IsRunning())
return;
indexList.clear();
size_t size = GetCodeListSize();
for (size_t i = 0; i < size; i++)
@ -269,6 +281,11 @@ void wxCheatsWindow::Load_ARCodes()
}
}
void wxCheatsWindow::Load_GeckoCodes()
{
m_geckocode_panel->LoadCodes(m_gameini, Core::g_CoreStartupParameter.GetUniqueID(), true);
}
void wxCheatsWindow::OnEvent_CheatsList_ItemSelected(wxCommandEvent& WXUNUSED (event))
{
using namespace ActionReplay;

View File

@ -96,6 +96,7 @@ class wxCheatsWindow : public wxDialog
public:
wxCheatsWindow(wxWindow* const parent);
~wxCheatsWindow();
void UpdateGUI();
protected:
@ -105,6 +106,7 @@ class wxCheatsWindow : public wxDialog
};
// --- GUI Controls ---
wxButton* button_apply;
wxNotebook *m_Notebook_Main;
wxPanel *m_Tab_Cheats;
@ -134,6 +136,7 @@ class wxCheatsWindow : public wxDialog
void Init_ChildControls();
void Load_ARCodes();
void Load_GeckoCodes();
// --- Wx Events Handlers ---

View File

@ -1133,6 +1133,7 @@ void CFrame::OnConfigMain(wxCommandEvent& WXUNUSED (event))
CConfigMain ConfigMain(this);
if (ConfigMain.ShowModal() == wxID_OK)
m_GameListCtrl->Update();
UpdateGUI();
}
void CFrame::OnConfigGFX(wxCommandEvent& WXUNUSED (event))
@ -1568,6 +1569,9 @@ void CFrame::UpdateGUI()
if (DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).IsValid())
GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable(!Initialized);
// Tools
GetMenuBar()->FindItem(IDM_CHEATS)->Enable(SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats);
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE1)->Enable(RunningWii);
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE2)->Enable(RunningWii);
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE3)->Enable(RunningWii);
@ -1675,6 +1679,15 @@ void CFrame::UpdateGUI()
// Commit changes to manager
m_Mgr->Update();
// Update non-modal windows
if (g_CheatsWindow)
{
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats)
g_CheatsWindow->UpdateGUI();
else
g_CheatsWindow->Close();
}
}
void CFrame::UpdateGameList()

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include "GeckoCodeDiag.h"
#include "Core.h"
#include "WxUtils.h"
#include <SFML/Network/Http.hpp>
@ -59,10 +60,10 @@ CodeConfigPanel::CodeConfigPanel(wxWindow* const parent)
SetSizerAndFit(sizer_main);
}
void CodeConfigPanel::UpdateCodeList()
void CodeConfigPanel::UpdateCodeList(bool checkRunning)
{
// disable the button if it doesn't have an effect
btn_download->Enable(!m_gameid.empty());
btn_download->Enable((!checkRunning || Core::IsRunning()) && !m_gameid.empty());
m_listbox_gcodes->Clear();
// add the codes to the listbox
@ -80,14 +81,15 @@ void CodeConfigPanel::UpdateCodeList()
UpdateInfoBox(evt);
}
void CodeConfigPanel::LoadCodes(const IniFile& inifile, const std::string& gameid)
void CodeConfigPanel::LoadCodes(const IniFile& inifile, const std::string& gameid, bool checkRunning)
{
m_gameid = gameid;
m_gcodes.clear();
Gecko::LoadCodes(inifile, m_gcodes);
if (!checkRunning || Core::IsRunning())
Gecko::LoadCodes(inifile, m_gcodes);
UpdateCodeList();
UpdateCodeList(checkRunning);
}
void CodeConfigPanel::ToggleCode(wxCommandEvent& evt)

View File

@ -20,7 +20,7 @@ public:
CodeConfigPanel(wxWindow* const parent);
void LoadCodes(const IniFile& inifile, const std::string& gameid = "");
void LoadCodes(const IniFile& inifile, const std::string& gameid = "", bool checkRunning = false);
const std::vector<GeckoCode>& GetCodes() const { return m_gcodes; }
protected:
@ -29,7 +29,7 @@ protected:
void DownloadCodes(wxCommandEvent&);
//void ApplyChanges(wxCommandEvent&);
void UpdateCodeList();
void UpdateCodeList(bool checkRunning = false);
private:
std::vector<GeckoCode> m_gcodes;