Qt: Load/save the most recent savestate slot

This commit is contained in:
Jeffrey Pfau 2015-05-10 23:13:33 -07:00
parent 4899e7267d
commit adee44f6e9
4 changed files with 26 additions and 6 deletions

View File

@ -15,6 +15,7 @@ Features:
- Status messages for actions taken while a game is running (e.g. save/load state)
- Memory inspector
- Screensaver can now be suspended while a game is running
- Load/save the most recent savestate slot
Bugfixes:
- GBA: Fix timers not updating timing when writing to only the reload register
- All: Fix sanitize-deb script not cleaning up after itself

View File

@ -45,6 +45,7 @@ GameController::GameController(QObject* parent)
, m_turboForced(false)
, m_inputController(nullptr)
, m_multiplayer(nullptr)
, m_stateSlot(1)
{
m_renderer = new GBAVideoSoftwareRenderer;
GBAVideoSoftwareRendererCreate(m_renderer);
@ -504,7 +505,9 @@ void GameController::setUseBIOS(bool use) {
}
void GameController::loadState(int slot) {
if (slot > 0) {
m_stateSlot = slot;
}
GBARunOnThread(&m_threadContext, [](GBAThread* context) {
GameController* controller = static_cast<GameController*>(context->userData);
GBALoadState(context, context->stateDir, controller->m_stateSlot);
@ -514,7 +517,9 @@ void GameController::loadState(int slot) {
}
void GameController::saveState(int slot) {
if (slot > 0) {
m_stateSlot = slot;
}
GBARunOnThread(&m_threadContext, [](GBAThread* context) {
GameController* controller = static_cast<GameController*>(context->userData);
GBASaveState(context, context->stateDir, controller->m_stateSlot, true);

View File

@ -113,8 +113,8 @@ public slots:
void clearKeys();
void setAudioBufferSamples(int samples);
void setFPSTarget(float fps);
void loadState(int slot);
void saveState(int slot);
void loadState(int slot = 0);
void saveState(int slot = 0);
void setVideoSync(bool);
void setAudioSync(bool);
void setFrameskip(int);

View File

@ -637,15 +637,29 @@ void Window::setupMenu(QMenuBar* menubar) {
QMenu* quickSaveMenu = fileMenu->addMenu(tr("Quick save"));
m_shortcutController->addMenu(quickLoadMenu);
m_shortcutController->addMenu(quickSaveMenu);
QAction* quickLoad = new QAction(tr("Load recent"), quickLoadMenu);
connect(quickLoad, SIGNAL(triggered()), m_controller, SLOT(loadState()));
m_gameActions.append(quickLoad);
addControlledAction(quickLoadMenu, quickLoad, "quickLoad");
QAction* quickSave = new QAction(tr("Save recent"), quickSaveMenu);
connect(quickSave, SIGNAL(triggered()), m_controller, SLOT(saveState()));
m_gameActions.append(quickSave);
addControlledAction(quickSaveMenu, quickSave, "quickSave");
quickLoadMenu->addSeparator();
quickSaveMenu->addSeparator();
int i;
for (i = 1; i < 10; ++i) {
QAction* quickLoad = new QAction(tr("State &%1").arg(i), quickLoadMenu);
quickLoad = new QAction(tr("State &%1").arg(i), quickLoadMenu);
quickLoad->setShortcut(tr("F%1").arg(i));
connect(quickLoad, &QAction::triggered, [this, i]() { m_controller->loadState(i); });
m_gameActions.append(quickLoad);
addControlledAction(quickLoadMenu, quickLoad, QString("quickLoad.%1").arg(i));
QAction* quickSave = new QAction(tr("State &%1").arg(i), quickSaveMenu);
quickSave = new QAction(tr("State &%1").arg(i), quickSaveMenu);
quickSave->setShortcut(tr("Shift+F%1").arg(i));
connect(quickSave, &QAction::triggered, [this, i]() { m_controller->saveState(i); });
m_gameActions.append(quickSave);