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>
|
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-07-15 21:59:05 +00:00
|
|
|
#include "DolphinWX/AuiToolBar.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/WxUtils.h"
|
2014-10-19 10:45:40 +00:00
|
|
|
|
2016-07-15 21:59:05 +00:00
|
|
|
class CWatchToolbar : public DolphinAuiToolBar
|
2014-10-24 11:24:17 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-06-24 08:43:46 +00:00
|
|
|
CWatchToolbar(CWatchWindow* parent, const wxWindowID id)
|
2016-07-15 21:59:05 +00:00
|
|
|
: DolphinAuiToolBar(parent, id, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_TEXT)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2018-04-12 05:56:15 +00:00
|
|
|
InitialiseThemedBitmaps();
|
2014-10-24 11:24:17 +00:00
|
|
|
|
2018-04-12 05:56:15 +00:00
|
|
|
AddTool(ID_LOAD, _("Load"), m_Bitmaps[Toolbar_Load]);
|
2016-06-24 08:43:46 +00:00
|
|
|
Bind(wxEVT_TOOL, &CWatchWindow::Event_LoadAll, parent, ID_LOAD);
|
2014-10-24 11:24:17 +00:00
|
|
|
|
2018-04-12 05:56:15 +00:00
|
|
|
AddTool(ID_SAVE, _("Save"), m_Bitmaps[Toolbar_Save]);
|
2016-06-24 08:43:46 +00:00
|
|
|
Bind(wxEVT_TOOL, &CWatchWindow::Event_SaveAll, parent, ID_SAVE);
|
|
|
|
}
|
2014-10-24 11:24:17 +00:00
|
|
|
|
2018-04-12 05:56:15 +00:00
|
|
|
void ReloadBitmaps()
|
|
|
|
{
|
|
|
|
Freeze();
|
|
|
|
|
|
|
|
InitialiseThemedBitmaps();
|
|
|
|
for (int i = 0; i < ID_NUM; ++i)
|
|
|
|
SetToolBitmap(i, m_Bitmaps[i]);
|
|
|
|
|
|
|
|
Thaw();
|
|
|
|
}
|
|
|
|
|
2014-10-24 11:24:17 +00:00
|
|
|
private:
|
2016-06-24 08:43:46 +00:00
|
|
|
enum
|
|
|
|
{
|
2018-04-12 05:56:15 +00:00
|
|
|
Toolbar_Load,
|
|
|
|
Toolbar_Save,
|
2016-06-24 08:43:46 +00:00
|
|
|
Num_Bitmaps
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2018-04-12 05:56:15 +00:00
|
|
|
ID_LOAD = 0,
|
|
|
|
ID_SAVE,
|
|
|
|
ID_NUM
|
2016-06-24 08:43:46 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 05:56:15 +00:00
|
|
|
void InitialiseThemedBitmaps()
|
|
|
|
{
|
|
|
|
wxSize bitmap_size = FromDIP(wxSize(24, 24));
|
|
|
|
SetToolBitmapSize(bitmap_size);
|
|
|
|
|
|
|
|
static const std::array<const char* const, Num_Bitmaps> m_image_names{
|
|
|
|
{"debugger_load", "debugger_save"}};
|
|
|
|
|
|
|
|
for (std::size_t i = 0; i < m_image_names.size(); ++i)
|
|
|
|
{
|
|
|
|
m_Bitmaps[i] =
|
|
|
|
WxUtils::LoadScaledThemeBitmap(m_image_names[i], this, bitmap_size, wxDefaultSize,
|
|
|
|
WxUtils::LSI_SCALE_DOWN | WxUtils::LSI_ALIGN_CENTER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
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);
|
|
|
|
|
2018-04-12 05:56:15 +00:00
|
|
|
m_watch_toolbar = new CWatchToolbar(this, wxID_ANY);
|
|
|
|
|
|
|
|
m_mgr.AddPane(m_watch_toolbar, wxAuiPaneInfo()
|
|
|
|
.ToolbarPane()
|
|
|
|
.Top()
|
|
|
|
.LeftDockable(true)
|
|
|
|
.RightDockable(true)
|
|
|
|
.BottomDockable(false)
|
|
|
|
.Floatable(false));
|
2016-06-24 08:43:46 +00:00
|
|
|
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)
|
2016-10-03 07:29:50 +00:00
|
|
|
m_GPRGridView->Repopulate();
|
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;
|
2016-10-29 12:42:43 +00:00
|
|
|
ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetGameID() + ".ini",
|
2016-06-24 08:43:46 +00:00
|
|
|
false);
|
|
|
|
ini.SetLines("Watches", PowerPC::watches.GetStrings());
|
2016-10-29 12:42:43 +00:00
|
|
|
ini.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetGameID() + ".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;
|
|
|
|
|
2016-10-29 12:42:43 +00:00
|
|
|
if (!ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetGameID() + ".ini",
|
2016-06-24 08:43:46 +00:00
|
|
|
false))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ini.GetLines("Watches", &watches, false))
|
|
|
|
{
|
|
|
|
PowerPC::watches.Clear();
|
|
|
|
PowerPC::watches.AddFromStrings(watches);
|
|
|
|
}
|
|
|
|
|
|
|
|
NotifyUpdate();
|
2014-10-24 11:24:17 +00:00
|
|
|
}
|
2018-04-12 05:56:15 +00:00
|
|
|
|
|
|
|
void CWatchWindow::ReloadBitmaps()
|
|
|
|
{
|
|
|
|
m_watch_toolbar->ReloadBitmaps();
|
|
|
|
}
|