/
VideoPanel.cpp
381 lines (291 loc) · 12 KB
/
VideoPanel.cpp
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2010 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "App.h"
#include "Dialogs/ConfigurationDialog.h"
#include "ConfigurationPanels.h"
#include <wx/spinctrl.h>
using namespace pxSizerFlags;
// --------------------------------------------------------------------------------------
// FramelimiterPanel Implementations
// --------------------------------------------------------------------------------------
Panels::FramelimiterPanel::FramelimiterPanel( wxWindow* parent )
: BaseApplicableConfigPanel_SpecificConfig( parent )
{
m_check_LimiterDisable = new pxCheckBox( this, _("Disable Framelimiting"),
_("Uncaps FPS. Toggle in-game by pressing F4. Useful for running benchmarks." ) );
m_check_LimiterDisable->SetToolTip( pxEt( L"Note that when Framelimiting is disabled, Turbo and SlowMotion modes will not be available either."
) );
m_spin_NominalPct = new wxSpinCtrl(this);
m_spin_SlomoPct = new wxSpinCtrl(this);
m_spin_TurboPct = new wxSpinCtrl(this);
m_text_BaseNtsc = CreateNumericalTextCtrl( this, 7 );
m_text_BasePal = CreateNumericalTextCtrl( this, 7 );
m_spin_NominalPct ->SetRange( 10, 1000 );
m_spin_SlomoPct ->SetRange( 5, 1000 );
m_spin_TurboPct ->SetRange( 10, 1000 );
// ------------------------------------------------------------
// Sizers and Layouts
*this += m_check_LimiterDisable | StdExpand();
wxFlexGridSizer& s_spins( *new wxFlexGridSizer( 5 ) );
s_spins.AddGrowableCol( 0 );
s_spins += Label(_("Base Framerate Adjust:")) | StdExpand();
s_spins += 5;
s_spins += m_spin_NominalPct | pxBorder(wxTOP, 3);
s_spins += Label(L"%") | StdExpand();
s_spins += 5;
s_spins += Label(_("Slow Motion Adjust:")) | StdExpand();
s_spins += 5;
s_spins += m_spin_SlomoPct | pxBorder(wxTOP, 3);
s_spins += Label(L"%") | StdExpand();
s_spins += 5;
s_spins += Label(_("Turbo Adjust:")) | StdExpand();
s_spins += 5;
s_spins += m_spin_TurboPct | pxBorder(wxTOP, 3);
s_spins += Label(L"%" ) | StdExpand();
s_spins += 5;
wxFlexGridSizer& s_fps( *new wxFlexGridSizer( 5 ) );
s_fps.AddGrowableCol( 0 );
s_fps += Label(_("NTSC Framerate:")) | StdExpand();
s_fps += 5;
s_fps += m_text_BaseNtsc | pxBorder(wxTOP, 2).Right();
s_fps += Label(_("FPS")) | StdExpand();
s_fps += 5;
s_fps += Label(_("PAL Framerate:")) | StdExpand();
s_fps += 5;
s_fps += m_text_BasePal | pxBorder(wxTOP, 2).Right();
s_fps += Label(_("FPS")) | StdExpand();
s_fps += 5;
*this += s_spins | pxExpand;
*this += 5;
*this += s_fps | pxExpand;
AppStatusEvent_OnSettingsApplied();
}
void Panels::FramelimiterPanel::AppStatusEvent_OnSettingsApplied()
{
ApplyConfigToGui( *g_Conf );
}
void Panels::FramelimiterPanel::ApplyConfigToGui( AppConfig& configToApply, int flags )
{
const AppConfig::FramerateOptions& appfps( configToApply.Framerate );
const Pcsx2Config::GSOptions& gsconf( configToApply.EmuOptions.GS );
if( ! (flags & AppConfig::APPLY_FLAG_FROM_PRESET) ){ //Presets don't control these: only change if config doesn't come from preset.
m_check_LimiterDisable->SetValue( !gsconf.FrameLimitEnable );
m_spin_TurboPct ->SetValue( appfps.TurboScalar.Raw );
m_spin_SlomoPct ->SetValue( appfps.SlomoScalar.Raw );
m_spin_TurboPct ->Enable( 1 );
m_spin_SlomoPct ->Enable( 1 );
}
m_text_BaseNtsc ->ChangeValue( gsconf.FramerateNTSC.ToString() );
m_text_BasePal ->ChangeValue( gsconf.FrameratePAL.ToString() );
m_spin_NominalPct ->SetValue( appfps.NominalScalar.Raw );
m_spin_NominalPct ->Enable(!configToApply.EnablePresets);
// Vsync timing controls only on devel builds / via manual ini editing
#ifdef PCSX2_DEVBUILD
m_text_BaseNtsc ->Enable(!configToApply.EnablePresets);
m_text_BasePal ->Enable(!configToApply.EnablePresets);
#else
m_text_BaseNtsc ->Enable( 0 );
m_text_BasePal ->Enable( 0 );
#endif
}
void Panels::FramelimiterPanel::Apply()
{
AppConfig::FramerateOptions& appfps( g_Conf->Framerate );
Pcsx2Config::GSOptions& gsconf( g_Conf->EmuOptions.GS );
gsconf.FrameLimitEnable = !m_check_LimiterDisable->GetValue();
appfps.NominalScalar.Raw = m_spin_NominalPct ->GetValue();
appfps.TurboScalar.Raw = m_spin_TurboPct ->GetValue();
appfps.SlomoScalar.Raw = m_spin_SlomoPct ->GetValue();
try {
gsconf.FramerateNTSC = Fixed100::FromString( m_text_BaseNtsc->GetValue() );
gsconf.FrameratePAL = Fixed100::FromString( m_text_BasePal->GetValue() );
}
catch( Exception::ParseError& )
{
throw Exception::CannotApplySettings( this )
.SetDiagMsg(pxsFmt(
L"Error while parsing either NTSC or PAL framerate settings.\n\tNTSC Input = %s\n\tPAL Input = %s",
WX_STR(m_text_BaseNtsc->GetValue()), WX_STR(m_text_BasePal->GetValue())
) )
.SetUserMsg(_t("Error while parsing either NTSC or PAL framerate settings. Settings must be valid floating point numerics."));
}
appfps.SanityCheck();
// If the user has a command line override specified, we need to disable it
// so that their changes take effect
wxGetApp().Overrides.ProfilingMode = false;
}
// --------------------------------------------------------------------------------------
// FrameSkipPanel Implementations
// --------------------------------------------------------------------------------------
Panels::FrameSkipPanel::FrameSkipPanel( wxWindow* parent )
: BaseApplicableConfigPanel_SpecificConfig( parent )
{
const RadioPanelItem FrameskipOptions[] =
{
RadioPanelItem(
_("Disabled [default]")
),
RadioPanelItem(
_("Skip when on Turbo only (TAB to enable)")
),
RadioPanelItem(
_("Constant skipping"),
wxEmptyString,
_("Normal and Turbo limit rates skip frames. Slow motion mode will still disable frameskipping.")
),
};
m_radio_SkipMode = new pxRadioPanel( this, FrameskipOptions );
m_radio_SkipMode->Realize();
m_spin_FramesToDraw = new wxSpinCtrl(this);
m_spin_FramesToSkip = new wxSpinCtrl(this);
// Set tooltips for spinners.
// ------------------------------------------------------------
// Sizers and Layouts
*this += m_radio_SkipMode;
wxFlexGridSizer& s_spins( *new wxFlexGridSizer( 4 ) );
//s_spins.AddGrowableCol( 0 );
s_spins += m_spin_FramesToDraw | pxBorder(wxTOP, 2);
s_spins += 10;
s_spins += Label(_("Frames to Draw")) | StdExpand();
s_spins += 10;
s_spins += m_spin_FramesToSkip | pxBorder(wxTOP, 2);
s_spins += 10;
s_spins += Label(_("Frames to Skip")) | StdExpand();
s_spins += 10;
*this += s_spins | StdExpand();
*this += Text( pxE( L"Notice: Due to PS2 hardware design, precise frame skipping is impossible. Enabling it will cause severe graphical errors in some games." )
) | StdExpand();
*this += 24; // Extends the right box to match the left one. Only works with (Windows) 100% dpi.
AppStatusEvent_OnSettingsApplied();
}
void Panels::FrameSkipPanel::AppStatusEvent_OnSettingsApplied()
{
ApplyConfigToGui( *g_Conf );
}
void Panels::FrameSkipPanel::ApplyConfigToGui( AppConfig& configToApply, int flags )
{
const AppConfig::FramerateOptions& appfps( configToApply.Framerate );
const Pcsx2Config::GSOptions& gsconf( configToApply.EmuOptions.GS );
m_radio_SkipMode->SetSelection( appfps.SkipOnLimit ? 2 : (appfps.SkipOnTurbo ? 1 : 0) );
m_spin_FramesToDraw->SetValue( gsconf.FramesToDraw );
m_spin_FramesToDraw->Enable(!configToApply.EnablePresets);
m_spin_FramesToSkip->SetValue( gsconf.FramesToSkip );
m_spin_FramesToSkip->Enable(!configToApply.EnablePresets);
this->Enable(!configToApply.EnablePresets);
}
void Panels::FrameSkipPanel::Apply()
{
AppConfig::FramerateOptions& appfps( g_Conf->Framerate );
Pcsx2Config::GSOptions& gsconf( g_Conf->EmuOptions.GS );
gsconf.FramesToDraw = m_spin_FramesToDraw->GetValue();
gsconf.FramesToSkip = m_spin_FramesToSkip->GetValue();
switch( m_radio_SkipMode->GetSelection() )
{
case 0:
appfps.SkipOnLimit = false;
appfps.SkipOnTurbo = false;
gsconf.FrameSkipEnable = false;
break;
case 1:
appfps.SkipOnLimit = false;
appfps.SkipOnTurbo = true;
//gsconf.FrameSkipEnable = true;
break;
case 2:
appfps.SkipOnLimit = true;
appfps.SkipOnTurbo = true;
gsconf.FrameSkipEnable = true;
break;
}
appfps.SanityCheck();
}
// --------------------------------------------------------------------------------------
// VideoPanel Implementation
// --------------------------------------------------------------------------------------
Panels::VideoPanel::VideoPanel( wxWindow* parent ) :
BaseApplicableConfigPanel_SpecificConfig( parent )
{
wxPanelWithHelpers* left = new wxPanelWithHelpers( this, wxVERTICAL );
wxPanelWithHelpers* right = new wxPanelWithHelpers( this, wxVERTICAL );
m_check_SynchronousGS = new pxCheckBox( left, _("Use Synchronized MTGS"),
_t("For troubleshooting potential bugs in the MTGS only, as it is potentially very slow.")
);
m_spinner_VsyncQueue = new wxSpinCtrl(left);
m_spinner_VsyncQueue->SetRange(0, 3);
m_restore_defaults = new wxButton(right, wxID_DEFAULT, _("Restore Defaults"));
m_spinner_VsyncQueue->SetToolTip( pxEt(L"Setting this to a lower value improves input lag, a value around 2 or 3 will slightly improve framerates. (Default is 2)"));
m_check_SynchronousGS->SetToolTip( pxEt( L"Enable this if you think MTGS thread sync is causing crashes or graphical errors. For debugging to see if GS is running at the correct speed."));
//GSWindowSettingsPanel* winpan = new GSWindowSettingsPanel( left );
//winpan->AddFrame(_("Display/Window"));
m_span = new FrameSkipPanel( right );
m_span->AddFrame(_("Frame Skipping"));
m_fpan = new FramelimiterPanel( left );
m_fpan->AddFrame(_("Framelimiter"));
wxFlexGridSizer* s_table = new wxFlexGridSizer( 2 );
wxGridSizer* s_vsyncs = new wxGridSizer( 2 );
s_table->AddGrowableCol( 0, 1 );
s_table->AddGrowableCol( 1, 1 );
*right += m_span | pxExpand;
*right += 5;
*right += m_restore_defaults | StdButton();
*left += m_fpan | pxExpand;
*left += 5;
*s_vsyncs += Label(_("Vsyncs in MTGS Queue:")) | StdExpand();
*s_vsyncs += m_spinner_VsyncQueue | pxBorder(wxTOP, -2).Right();
*left += s_vsyncs | StdExpand();
*left += 2;
*left += m_check_SynchronousGS | StdExpand();
*s_table += left | StdExpand();
*s_table += right | StdExpand();
*this += s_table | pxExpand;
Bind(wxEVT_BUTTON, &VideoPanel::Defaults_Click, this, wxID_DEFAULT);
AppStatusEvent_OnSettingsApplied();
}
void Panels::VideoPanel::Defaults_Click(wxCommandEvent& evt)
{
AppConfig config = *g_Conf;
config.EmuOptions.GS = Pcsx2Config::GSOptions();
config.Framerate = AppConfig::FramerateOptions();
VideoPanel::ApplyConfigToGui(config);
m_fpan->ApplyConfigToGui(config);
m_span->ApplyConfigToGui(config);
evt.Skip();
}
void Panels::VideoPanel::OnOpenWindowSettings( wxCommandEvent& evt )
{
AppOpenDialog<Dialogs::ComponentsConfigDialog>( this );
// don't evt.skip, this prevents the Apply button from being activated. :)
}
void Panels::VideoPanel::Apply()
{
g_Conf->EmuOptions.GS.SynchronousMTGS = m_check_SynchronousGS->GetValue();
g_Conf->EmuOptions.GS.VsyncQueueSize = m_spinner_VsyncQueue->GetValue();
}
void Panels::VideoPanel::AppStatusEvent_OnSettingsApplied()
{
ApplyConfigToGui(*g_Conf);
}
void Panels::VideoPanel::ApplyConfigToGui( AppConfig& configToApply, int flags ){
m_check_SynchronousGS->SetValue( configToApply.EmuOptions.GS.SynchronousMTGS );
m_spinner_VsyncQueue->SetValue( configToApply.EmuOptions.GS.VsyncQueueSize );
m_check_SynchronousGS->Enable(!configToApply.EnablePresets);
if( flags & AppConfig::APPLY_FLAG_MANUALLY_PROPAGATE )
{
m_span->ApplyConfigToGui( configToApply, true );
m_fpan->ApplyConfigToGui( configToApply, true );
}
Layout();
}