1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <cstddef>
// clang-format off
#include <wx/bitmap.h>
#include <wx/panel.h>
// clang-format on
#include "Common/FileUtil.h"
#include "Common/IniFile.h"
#include "Core/ConfigManager.h"
#include "Core/PowerPC/PowerPC.h"
#include "DolphinWX/Debugger/WatchView.h"
#include "DolphinWX/Debugger/WatchWindow.h"
#include "DolphinWX/AuiToolBar.h"
#include "DolphinWX/WxUtils.h"
class CWatchToolbar : public DolphinAuiToolBar
{
public:
CWatchToolbar(CWatchWindow* parent, const wxWindowID id)
: DolphinAuiToolBar(parent, id, wxDefaultPosition, wxDefaultSize,
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_TEXT)
{
InitialiseThemedBitmaps();
AddTool(ID_LOAD, _("Load"), m_Bitmaps[Toolbar_Load]);
Bind(wxEVT_TOOL, &CWatchWindow::Event_LoadAll, parent, ID_LOAD);
AddTool(ID_SAVE, _("Save"), m_Bitmaps[Toolbar_Save]);
Bind(wxEVT_TOOL, &CWatchWindow::Event_SaveAll, parent, ID_SAVE);
}
void ReloadBitmaps()
{
Freeze();
InitialiseThemedBitmaps();
for (int i = 0; i < ID_NUM; ++i)
SetToolBitmap(i, m_Bitmaps[i]);
Thaw();
}
private:
enum
{
Toolbar_Load,
Toolbar_Save,
Num_Bitmaps
};
enum
{
ID_LOAD = 0,
ID_SAVE,
ID_NUM
};
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);
}
}
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_watch_toolbar = new CWatchToolbar(this, wxID_ANY);
m_mgr.AddPane(m_watch_toolbar, 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->Repopulate();
}
void CWatchWindow::Event_SaveAll(wxCommandEvent& WXUNUSED(event))
{
SaveAll();
}
void CWatchWindow::SaveAll()
{
IniFile ini;
ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetGameID() + ".ini",
false);
ini.SetLines("Watches", PowerPC::watches.GetStrings());
ini.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetGameID() + ".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().GetGameID() + ".ini",
false))
{
return;
}
if (ini.GetLines("Watches", &watches, false))
{
PowerPC::watches.Clear();
PowerPC::watches.AddFromStrings(watches);
}
NotifyUpdate();
}
void CWatchWindow::ReloadBitmaps()
{
m_watch_toolbar->ReloadBitmaps();
}
|