2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2014-10-19 10:45:40 +00:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <cstddef>
|
2014-10-24 11:24:17 +00:00
|
|
|
|
2016-06-24 10:16:10 +00:00
|
|
|
// clang-format off
|
2014-10-24 11:24:17 +00:00
|
|
|
#include <wx/bitmap.h>
|
2016-06-24 10:16:10 +00:00
|
|
|
#include <wx/aui/auibar.h>
|
2014-10-19 10:45:40 +00:00
|
|
|
#include <wx/panel.h>
|
2016-06-24 10:16:10 +00:00
|
|
|
// clang-format on
|
2014-10-19 10:45:40 +00:00
|
|
|
|
2014-10-24 11:24:17 +00:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/IniFile.h"
|
2014-10-24 13:13:53 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
2014-10-24 11:24:17 +00:00
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2014-10-19 10:45:40 +00:00
|
|
|
#include "DolphinWX/Debugger/WatchView.h"
|
|
|
|
#include "DolphinWX/Debugger/WatchWindow.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/WxUtils.h"
|
2014-10-19 10:45:40 +00:00
|
|
|
|
2014-10-24 11:24:17 +00:00
|
|
|
class CWatchToolbar : public wxAuiToolBar
|
|
|
|
{
|
|
|
|
public:
|
2016-06-24 08:43:46 +00:00
|
|
|
CWatchToolbar(CWatchWindow* parent, const wxWindowID id)
|
|
|
|
: wxAuiToolBar(parent, id, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_TEXT)
|
|
|
|
{
|
|
|
|
SetToolBitmapSize(wxSize(16, 16));
|
2014-10-24 11:24:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
m_Bitmaps[Toolbar_File] = WxUtils::LoadResourceBitmap("toolbar_debugger_delete");
|
2014-10-24 11:24:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
AddTool(ID_LOAD, _("Load"), m_Bitmaps[Toolbar_File]);
|
|
|
|
Bind(wxEVT_TOOL, &CWatchWindow::Event_LoadAll, parent, ID_LOAD);
|
2014-10-24 11:24:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
AddTool(ID_SAVE, _("Save"), m_Bitmaps[Toolbar_File]);
|
|
|
|
Bind(wxEVT_TOOL, &CWatchWindow::Event_SaveAll, parent, ID_SAVE);
|
|
|
|
}
|
2014-10-24 11:24:17 +00:00
|
|
|
|
|
|
|
private:
|
2016-06-24 08:43:46 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
Toolbar_File,
|
|
|
|
Num_Bitmaps
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ID_LOAD,
|
|
|
|
ID_SAVE
|
|
|
|
};
|
|
|
|
|
|
|
|
wxBitmap m_Bitmaps[Num_Bitmaps];
|
2014-10-24 11:24:17 +00:00
|
|
|
};
|
2014-10-19 10:45:40 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
CWatchWindow::CWatchWindow(wxWindow* parent, wxWindowID id, const wxPoint& position,
|
|
|
|
const wxSize& size, long style, const wxString& name)
|
|
|
|
: wxPanel(parent, id, position, size, style, name), m_GPRGridView(nullptr)
|
2014-10-19 10:45:40 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_mgr.SetManagedWindow(this);
|
|
|
|
m_mgr.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE);
|
|
|
|
|
|
|
|
m_GPRGridView = new CWatchView(this);
|
|
|
|
|
|
|
|
m_mgr.AddPane(new CWatchToolbar(this, wxID_ANY), wxAuiPaneInfo()
|
|
|
|
.ToolbarPane()
|
|
|
|
.Top()
|
|
|
|
.LeftDockable(true)
|
|
|
|
.RightDockable(true)
|
|
|
|
.BottomDockable(false)
|
|
|
|
.Floatable(false));
|
|
|
|
m_mgr.AddPane(m_GPRGridView, wxAuiPaneInfo().CenterPane());
|
|
|
|
m_mgr.Update();
|
2014-10-19 10:45:40 +00:00
|
|
|
}
|
|
|
|
|
2014-10-24 13:13:53 +00:00
|
|
|
CWatchWindow::~CWatchWindow()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_mgr.UnInit();
|
2014-10-24 13:13:53 +00:00
|
|
|
}
|
|
|
|
|
2014-10-19 10:45:40 +00:00
|
|
|
void CWatchWindow::NotifyUpdate()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
if (m_GPRGridView != nullptr)
|
|
|
|
m_GPRGridView->Update();
|
2014-10-19 10:45:40 +00:00
|
|
|
}
|
2014-10-24 11:24:17 +00:00
|
|
|
|
|
|
|
void CWatchWindow::Event_SaveAll(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SaveAll();
|
2014-10-24 11:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWatchWindow::SaveAll()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
IniFile ini;
|
|
|
|
ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetUniqueID() + ".ini",
|
|
|
|
false);
|
|
|
|
ini.SetLines("Watches", PowerPC::watches.GetStrings());
|
|
|
|
ini.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetUniqueID() + ".ini");
|
2014-10-24 13:13:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWatchWindow::Event_LoadAll(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
LoadAll();
|
2014-10-24 11:24:17 +00:00
|
|
|
}
|
|
|
|
|
2014-10-24 13:13:53 +00:00
|
|
|
void CWatchWindow::LoadAll()
|
2014-10-24 11:24:17 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
IniFile ini;
|
|
|
|
Watches::TWatchesStr watches;
|
|
|
|
|
|
|
|
if (!ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetUniqueID() +
|
|
|
|
".ini",
|
|
|
|
false))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ini.GetLines("Watches", &watches, false))
|
|
|
|
{
|
|
|
|
PowerPC::watches.Clear();
|
|
|
|
PowerPC::watches.AddFromStrings(watches);
|
|
|
|
}
|
|
|
|
|
|
|
|
NotifyUpdate();
|
2014-10-24 11:24:17 +00:00
|
|
|
}
|