Qt: Load/save the most recent savestate slot
Jeffrey Pfau jeffrey@endrift.com
Sun, 10 May 2015 23:13:33 -0700
4 files changed,
26 insertions(+),
6 deletions(-)
M
CHANGES
→
CHANGES
@@ -15,6 +15,7 @@ - Remappable controls for tilt and gyroscope sensors
- 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
M
src/platform/qt/GameController.cpp
→
src/platform/qt/GameController.cpp
@@ -45,6 +45,7 @@ , m_turbo(false)
, m_turboForced(false) , m_inputController(nullptr) , m_multiplayer(nullptr) + , m_stateSlot(1) { m_renderer = new GBAVideoSoftwareRenderer; GBAVideoSoftwareRendererCreate(m_renderer);@@ -504,7 +505,9 @@ threadContinue();
} void GameController::loadState(int slot) { - m_stateSlot = 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::saveState(int slot) { - m_stateSlot = 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);
M
src/platform/qt/GameController.h
→
src/platform/qt/GameController.h
@@ -113,8 +113,8 @@ void keyReleased(int key);
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);
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -637,15 +637,29 @@ QMenu* quickLoadMenu = fileMenu->addMenu(tr("Quick load"));
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);