@@ -44,6 +44,7 @@ StateRecorderDialog_t::StateRecorderDialog_t(QWidget *parent)
44
44
QGroupBox *frame, *frame1;
45
45
QGridLayout *grid, *memStatsGrid;
46
46
QSettings settings;
47
+ int opt;
47
48
48
49
setWindowTitle (" State Recorder Config" );
49
50
@@ -61,13 +62,22 @@ StateRecorderDialog_t::StateRecorderDialog_t(QWidget *parent)
61
62
62
63
snapSeconds->setMinimum (0 );
63
64
snapSeconds->setMaximum (60 );
64
- snapSeconds->setValue (3 );
65
65
snapMinutes->setMinimum (0 );
66
66
snapMinutes->setMaximum (60 );
67
- snapMinutes->setValue (0 );
68
67
historyDuration->setMinimum (1 );
69
68
historyDuration->setMaximum (180 );
70
- historyDuration->setValue (15 );
69
+
70
+ opt = 15 ;
71
+ g_config->getOption (" SDL.StateRecorderHistoryDurationMin" , &opt );
72
+ historyDuration->setValue (opt);
73
+
74
+ opt = 0 ;
75
+ g_config->getOption (" SDL.StateRecorderTimeBetweenSnapsMin" , &opt);
76
+ snapMinutes->setValue (opt);
77
+
78
+ opt = 3 ;
79
+ g_config->getOption (" SDL.StateRecorderTimeBetweenSnapsSec" , &opt);
80
+ snapSeconds->setValue (opt);
71
81
72
82
connect ( snapSeconds, SIGNAL (valueChanged (int )), this , SLOT (spinBoxValueChanged (int )) );
73
83
connect ( snapMinutes, SIGNAL (valueChanged (int )), this , SLOT (spinBoxValueChanged (int )) );
@@ -84,10 +94,34 @@ StateRecorderDialog_t::StateRecorderDialog_t(QWidget *parent)
84
94
grid->addWidget ( recorderEnable, 0 , 0 );
85
95
grid->addWidget ( frame , 1 , 0 );
86
96
97
+ frame = new QGroupBox (tr (" Compression Level:" ));
98
+ hbox = new QHBoxLayout ();
99
+
100
+ cmprLvlCbox = new QComboBox ();
101
+ cmprLvlCbox->addItem ( tr (" 0 - None" ), 0 );
102
+ cmprLvlCbox->addItem ( tr (" 1" ), 1 );
103
+ cmprLvlCbox->addItem ( tr (" 2" ), 2 );
104
+ cmprLvlCbox->addItem ( tr (" 3" ), 3 );
105
+ cmprLvlCbox->addItem ( tr (" 4" ), 4 );
106
+ cmprLvlCbox->addItem ( tr (" 5" ), 5 );
107
+ cmprLvlCbox->addItem ( tr (" 6" ), 6 );
108
+ cmprLvlCbox->addItem ( tr (" 7" ), 7 );
109
+ cmprLvlCbox->addItem ( tr (" 8" ), 8 );
110
+ cmprLvlCbox->addItem ( tr (" 9 - Max" ), 9 );
111
+
112
+ opt = 0 ;
113
+ g_config->getOption (" SDL.StateRecorderCompressionLevel" , &opt);
114
+ cmprLvlCbox->setCurrentIndex (opt);
115
+
116
+ hbox->addWidget (cmprLvlCbox);
117
+
118
+ frame->setLayout (hbox);
119
+ grid->addWidget ( frame, 1 , 1 );
120
+
87
121
frame1 = new QGroupBox (tr (" Time Between Snapshots:" ));
88
122
hbox1 = new QHBoxLayout ();
89
123
frame1->setLayout (hbox1);
90
- grid->addWidget ( frame1, 2 , 0 );
124
+ grid->addWidget ( frame1, 2 , 0 , 1 , 2 );
91
125
92
126
frame = new QGroupBox ();
93
127
hbox = new QHBoxLayout ();
@@ -118,7 +152,7 @@ StateRecorderDialog_t::StateRecorderDialog_t(QWidget *parent)
118
152
snapMemSizeLbl->setReadOnly (true );
119
153
totalMemUsageLbl->setReadOnly (true );
120
154
121
- grid->addWidget (frame, 1 , 2 , 2 , 2 );
155
+ grid->addWidget (frame, 1 , 3 , 2 , 2 );
122
156
frame->setLayout (memStatsGrid);
123
157
memStatsGrid->addWidget ( new QLabel ( tr (" Number of\n Snapshots:" ) ), 0 , 0 );
124
158
memStatsGrid->addWidget ( numSnapsLbl, 0 , 1 );
@@ -178,16 +212,38 @@ void StateRecorderDialog_t::closeWindow(void)
178
212
// ----------------------------------------------------------------------------
179
213
void StateRecorderDialog_t::applyChanges (void )
180
214
{
215
+ StateRecorderConfigData config;
216
+
217
+ config.historyDurationMinutes = static_cast <float >( historyDuration->value () );
218
+ config.timeBetweenSnapsMinutes = static_cast <float >( snapMinutes->value () ) +
219
+ ( static_cast <float >( snapSeconds->value () ) / 60 .0f );
220
+ config.compressionLevel = cmprLvlCbox->currentData ().toInt ();
221
+
222
+ FCEU_WRAPPER_LOCK ();
223
+ FCEU_StateRecorderSetEnabled ( recorderEnable->isChecked () );
224
+ FCEU_StateRecorderSetConfigData ( config );
225
+ if (FCEU_StateRecorderRunning ())
226
+ {
227
+ // TODO restart with new settings
228
+ }
229
+ FCEU_WRAPPER_UNLOCK ();
181
230
231
+ g_config->setOption (" SDL.StateRecorderHistoryDurationMin" , historyDuration->value () );
232
+ g_config->setOption (" SDL.StateRecorderTimeBetweenSnapsMin" , snapMinutes->value () );
233
+ g_config->setOption (" SDL.StateRecorderTimeBetweenSnapsSec" , snapSeconds->value () );
234
+ g_config->setOption (" SDL.StateRecorderEnable" , recorderEnable->isChecked () );
235
+ g_config->save ();
182
236
}
183
237
// ----------------------------------------------------------------------------
184
238
void StateRecorderDialog_t::enableChanged (int val)
185
239
{
186
240
bool ena = val ? true : false ;
187
241
242
+ FCEU_WRAPPER_LOCK ();
188
243
FCEU_StateRecorderSetEnabled ( ena );
244
+ FCEU_WRAPPER_UNLOCK ();
189
245
190
- g_config->setOption (" SDL.StateRecorderEnable" , ena);
246
+ g_config->setOption (" SDL.StateRecorderEnable" , ena );
191
247
g_config->save ();
192
248
}
193
249
// ----------------------------------------------------------------------------
@@ -218,12 +274,16 @@ void StateRecorderDialog_t::recalcMemoryUsage(void)
218
274
219
275
if (GameInfo)
220
276
{
277
+ FCEU_WRAPPER_LOCK ();
278
+
221
279
EMUFILE_MEMORY em;
222
280
int compressionLevel = 0 ;
223
281
224
282
FCEUSS_SaveMS ( &em, compressionLevel );
225
283
226
284
fsnapSize = static_cast <float >( em.size () ) / 1024 .0f ;
285
+
286
+ FCEU_WRAPPER_UNLOCK ();
227
287
}
228
288
229
289
if (fsnapSize >= oneKiloByte)
0 commit comments