all repos — mgba @ 6d8a34a6dcb5c819a978933bf47f3396ab6a7d3a

mGBA Game Boy Advance Emulator

Qt: Unify state saving/loading flags
Jeffrey Pfau jeffrey@endrift.com
Sun, 24 Jan 2016 18:25:07 -0800
commit

6d8a34a6dcb5c819a978933bf47f3396ab6a7d3a

parent

0501944b5abccaceb9046091bf21f39ec7696d22

M src/platform/qt/CheatsView.cppsrc/platform/qt/CheatsView.cpp

@@ -31,6 +31,7 @@ connect(m_ui.save, SIGNAL(clicked()), this, SLOT(save()));

connect(m_ui.addSet, SIGNAL(clicked()), this, SLOT(addSet())); connect(m_ui.remove, SIGNAL(clicked()), this, SLOT(removeSet())); connect(controller, SIGNAL(gameStopped(GBAThread*)), &m_model, SLOT(invalidated())); + connect(controller, SIGNAL(stateLoaded(GBAThread*)), &m_model, SLOT(invalidated())); connect(m_ui.add, &QPushButton::clicked, [this]() { enterCheat(GBACheatAddLine);
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -58,6 +58,8 @@ , m_multiplayer(nullptr)

, m_stateSlot(1) , m_backupLoadState(nullptr) , m_backupSaveState(nullptr) + , m_saveStateFlags(SAVESTATE_SCREENSHOT | SAVESTATE_SAVEDATA | SAVESTATE_CHEATS) + , m_loadStateFlags(SAVESTATE_SCREENSHOT) { m_renderer = new GBAVideoSoftwareRenderer; GBAVideoSoftwareRendererCreate(m_renderer);

@@ -112,7 +114,7 @@ context->gba->video.renderer->disableBG[3] = !controller->m_videoLayers[3];

context->gba->video.renderer->disableOBJ = !controller->m_videoLayers[4]; controller->m_fpsTarget = context->fpsTarget; - if (context->dirs.state && GBALoadState(context, context->dirs.state, 0, SAVESTATE_SCREENSHOT)) { + if (context->dirs.state && GBALoadState(context, context->dirs.state, 0, controller->m_loadStateFlags)) { VFile* vf = GBAGetState(context->gba, context->dirs.state, 0, true); if (vf) { vf->truncate(vf, 0);

@@ -141,7 +143,7 @@ if (!context) {

return false; } GameController* controller = static_cast<GameController*>(context->userData); - if (!GBASaveState(context, context->dirs.state, 0, true)) { + if (!GBASaveState(context, context->dirs.state, 0, controller->m_saveStateFlags)) { return false; } QMetaObject::invokeMethod(controller, "closeGame");

@@ -710,7 +712,7 @@ if (!controller->m_backupLoadState) {

controller->m_backupLoadState = new GBASerializedState; } GBASerialize(context->gba, controller->m_backupLoadState); - if (GBALoadState(context, context->dirs.state, controller->m_stateSlot, SAVESTATE_SCREENSHOT)) { + if (GBALoadState(context, context->dirs.state, controller->m_stateSlot, controller->m_loadStateFlags)) { controller->frameAvailable(controller->m_drawContext); controller->stateLoaded(context); }

@@ -733,7 +735,7 @@ controller->m_backupSaveState.resize(vf->size(vf));

vf->read(vf, controller->m_backupSaveState.data(), controller->m_backupSaveState.size()); vf->close(vf); } - GBASaveState(context, context->dirs.state, controller->m_stateSlot, SAVESTATE_SCREENSHOT | EXTDATA_SAVEDATA); + GBASaveState(context, context->dirs.state, controller->m_stateSlot, controller->m_saveStateFlags); }); }
M src/platform/qt/GameController.hsrc/platform/qt/GameController.h

@@ -209,6 +209,8 @@

int m_stateSlot; GBASerializedState* m_backupLoadState; QByteArray m_backupSaveState; + int m_saveStateFlags; + int m_loadStateFlags; InputController* m_inputController; MultiplayerController* m_multiplayer;