summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinWX/Debugger/WatchWindow.cpp
diff options
context:
space:
mode:
authorJules Blok <jules.blok@gmail.com>2015-06-10 00:00:12 +0200
committerJules Blok <jules.blok@gmail.com>2015-06-10 00:00:12 +0200
commit7dfced21a2e5aac7195e0e1ad76468e30306766b (patch)
treebd671b639d3d911460b767caabad8fc8a759a6bf /Source/Core/DolphinWX/Debugger/WatchWindow.cpp
parentc25be031fc1031d795157d8344b87b7841145197 (diff)
parent7b0a65e295c784f9d573f2ef52d4e2a7b9bb2889 (diff)
Merge branch 'master' into stable
Diffstat (limited to 'Source/Core/DolphinWX/Debugger/WatchWindow.cpp')
-rw-r--r--Source/Core/DolphinWX/Debugger/WatchWindow.cpp121
1 files changed, 121 insertions, 0 deletions
diff --git a/Source/Core/DolphinWX/Debugger/WatchWindow.cpp b/Source/Core/DolphinWX/Debugger/WatchWindow.cpp
new file mode 100644
index 0000000000..e32847b1e7
--- /dev/null
+++ b/Source/Core/DolphinWX/Debugger/WatchWindow.cpp
@@ -0,0 +1,121 @@
+// Copyright 2008 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#include <cstddef>
+
+#include <wx/bitmap.h>
+#include <wx/panel.h>
+#include <wx/aui/auibar.h>
+
+#include "Common/FileUtil.h"
+#include "Common/IniFile.h"
+#include "Core/ConfigManager.h"
+#include "Core/PowerPC/PowerPC.h"
+#include "DolphinWX/WxUtils.h"
+#include "DolphinWX/Debugger/WatchView.h"
+#include "DolphinWX/Debugger/WatchWindow.h"
+
+extern "C" {
+#include "DolphinWX/resources/toolbar_debugger_delete.c"
+}
+
+class CWatchToolbar : public wxAuiToolBar
+{
+public:
+CWatchToolbar(CWatchWindow* parent, const wxWindowID id)
+ : wxAuiToolBar(parent, id, wxDefaultPosition, wxDefaultSize,
+ wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_TEXT)
+{
+ SetToolBitmapSize(wxSize(16, 16));
+
+ m_Bitmaps[Toolbar_File] = wxBitmap(wxGetBitmapFromMemory(toolbar_delete_png).ConvertToImage().Rescale(16, 16));
+
+ AddTool(ID_LOAD, _("Load"), m_Bitmaps[Toolbar_File]);
+ Bind(wxEVT_TOOL, &CWatchWindow::Event_LoadAll, parent, ID_LOAD);
+
+ AddTool(ID_SAVE, _("Save"), m_Bitmaps[Toolbar_File]);
+ Bind(wxEVT_TOOL, &CWatchWindow::Event_SaveAll, parent, ID_SAVE);
+}
+
+private:
+
+ enum
+ {
+ Toolbar_File,
+ Num_Bitmaps
+ };
+
+ enum
+ {
+ ID_LOAD,
+ ID_SAVE
+ };
+
+ wxBitmap m_Bitmaps[Num_Bitmaps];
+};
+
+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)
+{
+ 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();
+}
+
+CWatchWindow::~CWatchWindow()
+{
+ m_mgr.UnInit();
+}
+
+void CWatchWindow::NotifyUpdate()
+{
+ if (m_GPRGridView != nullptr)
+ m_GPRGridView->Update();
+}
+
+void CWatchWindow::Event_SaveAll(wxCommandEvent& WXUNUSED(event))
+{
+ SaveAll();
+}
+
+void CWatchWindow::SaveAll()
+{
+ IniFile ini;
+ ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() + ".ini", false);
+ ini.SetLines("Watches", PowerPC::watches.GetStrings());
+ ini.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() + ".ini");
+}
+
+void CWatchWindow::Event_LoadAll(wxCommandEvent& WXUNUSED(event))
+{
+ LoadAll();
+}
+
+void CWatchWindow::LoadAll()
+{
+ IniFile ini;
+ Watches::TWatchesStr watches;
+
+ if (!ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() + ".ini", false))
+ {
+ return;
+ }
+
+ if (ini.GetLines("Watches", &watches, false))
+ {
+ PowerPC::watches.Clear();
+ PowerPC::watches.AddFromStrings(watches);
+ }
+
+ NotifyUpdate();
+}