Add support to load/save state.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
7c4f50c4fa
commit
3a620f8b92
6 changed files with 104 additions and 1 deletions
|
@ -177,6 +177,8 @@ void Preferences::setData(const Data & data)
|
|||
on_hd_7_clicked(data.hdInSlot7);
|
||||
|
||||
joystick->setCurrentText(data.joystick);
|
||||
|
||||
save_state->setText(data.saveState);
|
||||
}
|
||||
|
||||
Preferences::Data Preferences::getData() const
|
||||
|
@ -202,6 +204,8 @@ Preferences::Data Preferences::getData() const
|
|||
data.joystickId = 0;
|
||||
}
|
||||
|
||||
data.saveState = save_state->text();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -275,3 +279,12 @@ void Preferences::on_hd_7_clicked(bool checked)
|
|||
browse_hd1->setEnabled(checked);
|
||||
browse_hd2->setEnabled(checked);
|
||||
}
|
||||
|
||||
void Preferences::on_browse_ss_clicked()
|
||||
{
|
||||
const QString name = QFileDialog::getSaveFileName(this, QString(), save_state->text());
|
||||
if (!name.isEmpty())
|
||||
{
|
||||
save_state->setText(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ public:
|
|||
|
||||
std::vector<QString> disks;
|
||||
std::vector<QString> hds;
|
||||
|
||||
QString saveState;
|
||||
};
|
||||
|
||||
explicit Preferences(QWidget *parent);
|
||||
|
@ -44,6 +46,8 @@ private slots:
|
|||
|
||||
void on_hd_7_clicked(bool checked);
|
||||
|
||||
void on_browse_ss_clicked();
|
||||
|
||||
private:
|
||||
std::vector<QComboBox *> myDisks;
|
||||
std::vector<QComboBox *> myHDs;
|
||||
|
|
|
@ -276,6 +276,39 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="advanced">
|
||||
<attribute name="title">
|
||||
<string>Advanced</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Save State</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Filename</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="save_state"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="browse_ss">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="registry">
|
||||
<attribute name="title">
|
||||
<string>Registry</string>
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <QMdiSubWindow>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -170,7 +171,10 @@ QApple::QApple(QWidget *parent) :
|
|||
|
||||
actionStart->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
|
||||
actionPause->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
|
||||
actionReboot->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward));
|
||||
actionReboot->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward));
|
||||
|
||||
actionSave_state->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
|
||||
actionLoad_state->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton));
|
||||
|
||||
myEmulator = new Emulator(mdiArea);
|
||||
myEmulatorWindow = mdiArea->addSubWindow(myEmulator, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint);
|
||||
|
@ -334,6 +338,13 @@ void QApple::on_actionOptions_triggered()
|
|||
currentOptions.joystickId = 0;
|
||||
}
|
||||
|
||||
const char* saveState = Snapshot_GetFilename();
|
||||
if (saveState)
|
||||
{
|
||||
currentOptions.saveState = QString::fromUtf8(saveState);;
|
||||
}
|
||||
|
||||
|
||||
QSettings settings; // the function will "modify" it
|
||||
myPreferences.setup(currentOptions, settings);
|
||||
|
||||
|
@ -397,6 +408,26 @@ void QApple::on_actionOptions_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
if (currentOptions.saveState != newOptions.saveState)
|
||||
{
|
||||
const std::string name = newOptions.saveState.toStdString();
|
||||
Snapshot_SetFilename(name);
|
||||
RegSaveString(TEXT(REG_CONFIG), REGVALUE_SAVESTATE_FILENAME, 1, name.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QApple::on_actionSave_state_triggered()
|
||||
{
|
||||
Snapshot_SaveState();
|
||||
}
|
||||
|
||||
void QApple::on_actionLoad_state_triggered()
|
||||
{
|
||||
emit endEmulator();
|
||||
Snapshot_LoadState();
|
||||
myEmulatorWindow->setWindowTitle(g_pAppTitle);
|
||||
myEmulator->redrawScreen();
|
||||
}
|
||||
|
|
|
@ -45,6 +45,10 @@ private slots:
|
|||
|
||||
void on_actionOptions_triggered();
|
||||
|
||||
void on_actionSave_state_triggered();
|
||||
|
||||
void on_actionLoad_state_triggered();
|
||||
|
||||
private:
|
||||
|
||||
void stopTimer();
|
||||
|
|
|
@ -62,6 +62,14 @@
|
|||
</property>
|
||||
<addaction name="actionOptions"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionLoad_state"/>
|
||||
<addaction name="actionSave_state"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuSystem"/>
|
||||
<addaction name="menuVideo"/>
|
||||
<addaction name="menuTools"/>
|
||||
|
@ -145,6 +153,16 @@
|
|||
<string>Change</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLoad_state">
|
||||
<property name="text">
|
||||
<string>Load state</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_state">
|
||||
<property name="text">
|
||||
<string>Save state</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
|
Loading…
Add table
Reference in a new issue