/[pcsx2_0.9.7]/trunk/pcsx2/gui/Panels/LogOptionsPanels.cpp
ViewVC logotype

Contents of /trunk/pcsx2/gui/Panels/LogOptionsPanels.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 1 month ago) by william
File size: 9632 byte(s)
re-commit (had local access denied errors when committing)
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16 #include "PrecompiledHeader.h"
17 #include "LogOptionsPanels.h"
18
19 #include "Utilities/IniInterface.h"
20 #include "DebugTools/Debug.h"
21
22 #include <wx/statline.h>
23
24
25 using namespace pxSizerFlags;
26
27 Panels::eeLogOptionsPanel::eeLogOptionsPanel( LogOptionsPanel* parent )
28 : BaseCpuLogOptionsPanel( parent, L"EE Logs" )
29 {
30 SetMinWidth( 300 );
31
32 m_miscGroup = new wxStaticBoxSizer( wxVERTICAL, this, L"General" );
33
34 m_disasmPanel = new CheckedStaticBox( this, wxVERTICAL, L"Disasm" );
35 m_hwPanel = new CheckedStaticBox( this, wxVERTICAL, L"Registers" );
36 m_evtPanel = new CheckedStaticBox( this, wxVERTICAL, L"Events" );
37
38 wxFlexGridSizer& eeTable( *new wxFlexGridSizer( 2, 5 ) );
39
40 eeTable.AddGrowableCol(0);
41 eeTable.AddGrowableCol(1);
42
43 eeTable += m_miscGroup | SubGroup();
44 eeTable += m_hwPanel | SubGroup();
45 eeTable += m_evtPanel | SubGroup();
46 eeTable += m_disasmPanel | SubGroup();
47
48 ThisSizer += 4;
49 ThisSizer += eeTable | pxExpand;
50
51 SetValue( true );
52 }
53
54 Panels::iopLogOptionsPanel::iopLogOptionsPanel( LogOptionsPanel* parent )
55 : BaseCpuLogOptionsPanel( parent, L"IOP Logs" )
56 {
57 SetMinWidth( 280 );
58
59 m_miscGroup = new wxStaticBoxSizer( wxVERTICAL, this, L"General" );
60
61 m_disasmPanel = new CheckedStaticBox( this, wxVERTICAL, L"Disasm" );
62 m_hwPanel = new CheckedStaticBox( this, wxVERTICAL, L"Registers" );
63 m_evtPanel = new CheckedStaticBox( this, wxVERTICAL, L"Events" );
64
65 wxFlexGridSizer& iopTable( *new wxFlexGridSizer( 2, 5 ) );
66
67 iopTable.AddGrowableCol(0);
68 iopTable.AddGrowableCol(1);
69
70 iopTable += m_miscGroup | SubGroup();
71 iopTable += m_hwPanel | SubGroup();
72 iopTable += m_evtPanel | SubGroup();
73 iopTable += m_disasmPanel | SubGroup();
74
75 ThisSizer += 4;
76 ThisSizer += iopTable | pxExpand;
77
78 SetValue( true );
79 }
80
81 CheckedStaticBox* Panels::eeLogOptionsPanel::GetStaticBox( const wxString& subgroup ) const
82 {
83 if (0 == subgroup.CmpNoCase( L"Disasm" )) return m_disasmPanel;
84 if (0 == subgroup.CmpNoCase( L"Registers" )) return m_hwPanel;
85 if (0 == subgroup.CmpNoCase( L"Events" )) return m_evtPanel;
86
87 return NULL;
88 }
89
90 CheckedStaticBox* Panels::iopLogOptionsPanel::GetStaticBox( const wxString& subgroup ) const
91 {
92 if (0 == subgroup.CmpNoCase( L"Disasm" )) return m_disasmPanel;
93 if (0 == subgroup.CmpNoCase( L"Registers" )) return m_hwPanel;
94 if (0 == subgroup.CmpNoCase( L"Events" )) return m_evtPanel;
95
96 return NULL;
97 }
98
99
100 void Panels::eeLogOptionsPanel::OnSettingsChanged()
101 {
102 const TraceLogFilters& conf( g_Conf->EmuOptions.Trace );
103
104 SetValue( conf.EE.m_EnableAll );
105
106 m_disasmPanel ->SetValue( conf.EE.m_EnableDisasm );
107 m_evtPanel ->SetValue( conf.EE.m_EnableEvents );
108 m_hwPanel ->SetValue( conf.EE.m_EnableRegisters );
109 }
110
111 void Panels::iopLogOptionsPanel::OnSettingsChanged()
112 {
113 const TraceLogFilters& conf( g_Conf->EmuOptions.Trace );
114
115 SetValue( conf.IOP.m_EnableAll );
116
117 m_disasmPanel ->SetValue( conf.IOP.m_EnableDisasm );
118 m_evtPanel ->SetValue( conf.IOP.m_EnableEvents );
119 m_hwPanel ->SetValue( conf.IOP.m_EnableRegisters );
120 }
121
122 static SysTraceLog * const traceLogList[] =
123 {
124 &SysTrace.SIF,
125
126 &SysTrace.EE.Bios,
127 &SysTrace.EE.Memory,
128
129 &SysTrace.EE.R5900,
130 &SysTrace.EE.COP0,
131 &SysTrace.EE.COP1,
132 &SysTrace.EE.COP2,
133 &SysTrace.EE.Cache,
134
135 &SysTrace.EE.KnownHw,
136 &SysTrace.EE.UnknownHw,
137 &SysTrace.EE.DMAhw,
138 &SysTrace.EE.IPU,
139 &SysTrace.EE.GIFtag,
140 &SysTrace.EE.VIFcode,
141
142 &SysTrace.EE.DMAC,
143 &SysTrace.EE.Counters,
144 &SysTrace.EE.SPR,
145 &SysTrace.EE.VIF,
146 &SysTrace.EE.GIF,
147
148
149 // IOP Section
150
151 &SysTrace.IOP.Bios,
152 &SysTrace.IOP.Memcards,
153 &SysTrace.IOP.PAD,
154
155 &SysTrace.IOP.R3000A,
156 &SysTrace.IOP.COP2,
157 &SysTrace.IOP.Memory,
158
159 &SysTrace.IOP.KnownHw,
160 &SysTrace.IOP.UnknownHw,
161 &SysTrace.IOP.DMAhw,
162 &SysTrace.IOP.DMAC,
163 &SysTrace.IOP.Counters,
164 &SysTrace.IOP.CDVD,
165 };
166
167 static const uint traceLogCount = ArraySize(traceLogList);
168
169 void SysTraceLog_LoadSaveSettings( IniInterface& ini )
170 {
171 ScopedIniGroup path(ini, L"TraceLogSources");
172
173 for (uint i=0; i<traceLogCount; ++i)
174 {
175 if (SysTraceLog* log = traceLogList[i])
176 {
177 pxAssertMsg(log->GetName(), "Trace log without a name!" );
178 ini.Entry( log->GetCategory() + L"." + log->GetShortName(), log->Enabled, false );
179 }
180 }
181 }
182
183 static bool traceLogEnabled( const wxString& ident )
184 {
185 // Brute force search for now. not enough different source logs to
186 // justify using a hash table, and switching over to a "complex" class
187 // type from the current simple array initializer requires effort to
188 // avoid C++ global initializer dependency hell.
189
190 for( uint i=0; i<traceLogCount; ++i )
191 {
192 if( 0 == ident.CmpNoCase(traceLogList[i]->GetCategory()) )
193 return traceLogList[i]->Enabled;
194 }
195
196 pxFailDev( wxsFormat(L"Invalid or unknown TraceLog identifier: %s", ident.c_str()) );
197 return false;
198 }
199
200 // --------------------------------------------------------------------------------------
201 // LogOptionsPanel Implementations
202 // --------------------------------------------------------------------------------------
203 Panels::LogOptionsPanel::LogOptionsPanel(wxWindow* parent )
204 : BaseApplicableConfigPanel( parent )
205 , m_checks( traceLogCount )
206 {
207 wxStaticBoxSizer& s_misc = *new wxStaticBoxSizer( wxHORIZONTAL, this, L"Misc" );
208
209 m_eeSection = new eeLogOptionsPanel( this );
210 m_iopSection = new iopLogOptionsPanel( this );
211
212 for( uint i = 0; i<traceLogCount; ++i )
213 {
214 const SysTraceLog& item = *traceLogList[i];
215
216 pxAssertMsg(item.GetName(), "Trace log without a name!" );
217
218 wxStringTokenizer token( item.GetCategory(), L"." );
219 wxSizer* addsizer = NULL;
220 wxWindow* addparent = NULL;
221
222 const wxString cpu(token.GetNextToken());
223 if( BaseCpuLogOptionsPanel* cpupanel = GetCpuPanel(cpu))
224 {
225 const wxString group(token.GetNextToken());
226 if( CheckedStaticBox* cpugroup = cpupanel->GetStaticBox(group))
227 {
228 addsizer = &cpugroup->ThisSizer;
229 addparent = cpugroup;
230 }
231 else
232 {
233 addsizer = cpupanel->GetMiscGroup();
234 addparent = cpupanel;
235 }
236 }
237 else
238 {
239 addsizer = &s_misc;
240 addparent = this;
241 }
242
243 *addsizer += m_checks[i] = new pxCheckBox( addparent, item.GetName() );
244 if( m_checks[i] && item.HasDescription() )
245 m_checks[i]->SetToolTip(item.GetDescription());
246 }
247
248 m_masterEnabler = new pxCheckBox( this, _("Enable Trace Logging"),
249 _("Trace logs are all written to emulog.txt. Toggle trace logging at any time using F10.") );
250 m_masterEnabler->SetToolTip( _("Warning: Enabling trace logs is typically very slow, and is a leading cause of 'What happened to my FPS?' problems. :)") );
251
252 wxFlexGridSizer& topSizer = *new wxFlexGridSizer( 2 );
253
254 topSizer.AddGrowableCol(0);
255 topSizer.AddGrowableCol(1);
256
257 topSizer += m_eeSection | StdExpand();
258 topSizer += m_iopSection | StdExpand();
259
260 *this += m_masterEnabler | StdExpand();
261 *this += new wxStaticLine( this ) | StdExpand().Border(wxLEFT | wxRIGHT, 20);
262 *this += 5;
263 *this += topSizer | StdExpand();
264 *this += s_misc | StdSpace().Centre();
265
266 Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(LogOptionsPanel::OnCheckBoxClicked) );
267 }
268
269 Panels::BaseCpuLogOptionsPanel* Panels::LogOptionsPanel::GetCpuPanel( const wxString& token ) const
270 {
271 if( token == L"EE" ) return m_eeSection;
272 if( token == L"IOP" ) return m_iopSection;
273
274 return NULL;
275 }
276
277 void Panels::LogOptionsPanel::AppStatusEvent_OnSettingsApplied()
278 {
279 TraceLogFilters& conf( g_Conf->EmuOptions.Trace );
280
281 m_masterEnabler->SetValue( conf.Enabled );
282
283 m_eeSection->OnSettingsChanged();
284 m_iopSection->OnSettingsChanged();
285
286 for (uint i=0; i<traceLogCount; ++i)
287 {
288 if (!traceLogList[i] || !m_checks[i]) continue;
289 m_checks[i]->SetValue(traceLogList[i]->Enabled);
290 }
291 OnUpdateEnableAll();
292 }
293
294 void Panels::LogOptionsPanel::OnUpdateEnableAll()
295 {
296 bool enabled( m_masterEnabler->GetValue() );
297
298 m_eeSection->Enable( enabled );
299 m_iopSection->Enable( enabled );
300 }
301
302 void Panels::LogOptionsPanel::OnCheckBoxClicked(wxCommandEvent &evt)
303 {
304 m_IsDirty = true;
305 if( evt.GetId() == m_masterEnabler->GetWxPtr()->GetId() )
306 OnUpdateEnableAll();
307 }
308
309 void Panels::LogOptionsPanel::Apply()
310 {
311 if( !m_IsDirty ) return;
312
313 g_Conf->EmuOptions.Trace.Enabled = m_masterEnabler->GetValue();
314
315 m_eeSection->Apply();
316 m_iopSection->Apply();
317
318 m_IsDirty = false;
319
320 for( uint i = 0; i<traceLogCount; ++i )
321 {
322 if (!traceLogList[i] || !m_checks[i]) continue;
323 traceLogList[i]->Enabled = m_checks[i]->IsChecked();
324 }
325 }
326
327 #define GetSet( cpu, name ) SysTrace.cpu.name.Enabled = m_##name->GetValue()
328
329 void Panels::eeLogOptionsPanel::Apply()
330 {
331 TraceFiltersEE& conf( g_Conf->EmuOptions.Trace.EE );
332
333 conf.m_EnableAll = GetValue();
334 conf.m_EnableDisasm = m_disasmPanel->GetValue();
335 conf.m_EnableRegisters = m_hwPanel->GetValue();
336 conf.m_EnableEvents = m_evtPanel->GetValue();
337 }
338
339 void Panels::iopLogOptionsPanel::Apply()
340 {
341 TraceFiltersIOP& conf( g_Conf->EmuOptions.Trace.IOP );
342
343 conf.m_EnableAll = GetValue();
344 conf.m_EnableDisasm = m_disasmPanel->GetValue();
345 conf.m_EnableRegisters = m_hwPanel->GetValue();
346 conf.m_EnableEvents = m_evtPanel->GetValue();
347 }
348

  ViewVC Help
Powered by ViewVC 1.1.22