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

View File

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

View File

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

View File

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