Qt: Ability to temporarily load a savegame

This commit is contained in:
Jeffrey Pfau 2016-08-22 10:33:59 -07:00
parent a088ad781a
commit c207675dfb
5 changed files with 23 additions and 12 deletions

View File

@ -10,6 +10,7 @@ Features:
- GUI: Add fast-forward - GUI: Add fast-forward
- Wii: 240p support - Wii: 240p support
- 3DS: Adjustable screen darkening - 3DS: Adjustable screen darkening
- Ability to temporarily load a savegame
Bugfixes: Bugfixes:
- SDL: Fix axes being mapped wrong - SDL: Fix axes being mapped wrong
- GBA Memory: Fix mirror on non-overdumped Classic NES games - GBA Memory: Fix mirror on non-overdumped Classic NES games

View File

@ -209,7 +209,8 @@ static bool _GBACoreLoadSave(struct mCore* core, struct VFile* vf) {
} }
static bool _GBACoreLoadTemporarySave(struct mCore* core, struct VFile* vf) { static bool _GBACoreLoadTemporarySave(struct mCore* core, struct VFile* vf) {
GBASavedataMask(core->board, vf); struct GBA* gba = core->board;
GBASavedataMask(&gba->memory.savedata, vf);
return true; // TODO: Return a real value return true; // TODO: Return a real value
} }

View File

@ -138,6 +138,11 @@ GameController::GameController(QObject* parent)
m_threadContext.resetCallback = [](mCoreThread* context) { m_threadContext.resetCallback = [](mCoreThread* context) {
GameController* controller = static_cast<GameController*>(context->userData); GameController* controller = static_cast<GameController*>(context->userData);
for (auto action : controller->m_resetActions) {
action();
}
controller->m_resetActions.clear();
unsigned width, height; unsigned width, height;
controller->m_threadContext.core->desiredVideoDimensions(controller->m_threadContext.core, &width, &height); controller->m_threadContext.core->desiredVideoDimensions(controller->m_threadContext.core, &width, &height);
memset(controller->m_frontBuffer, 0xF8, width * height * BYTES_PER_PIXEL); memset(controller->m_frontBuffer, 0xF8, width * height * BYTES_PER_PIXEL);
@ -415,6 +420,7 @@ void GameController::loadSave(const QString& path, bool temporary) {
if (!isLoaded()) { if (!isLoaded()) {
return; return;
} }
m_resetActions.append([this, path, temporary]() {
VFile* vf = VFileDevice::open(path, temporary ? O_RDONLY : O_RDWR); VFile* vf = VFileDevice::open(path, temporary ? O_RDONLY : O_RDWR);
if (!vf) { if (!vf) {
LOG(QT, ERROR) << tr("Failed to open save file: %1").arg(path); LOG(QT, ERROR) << tr("Failed to open save file: %1").arg(path);
@ -426,6 +432,8 @@ void GameController::loadSave(const QString& path, bool temporary) {
} else { } else {
m_threadContext.core->loadSave(m_threadContext.core, vf); m_threadContext.core->loadSave(m_threadContext.core, vf);
} }
});
reset();
} }
void GameController::yankPak() { void GameController::yankPak() {

View File

@ -192,6 +192,7 @@ private:
AudioProcessor* m_audioProcessor; AudioProcessor* m_audioProcessor;
QAtomicInt m_pauseAfterFrame; QAtomicInt m_pauseAfterFrame;
QList<std::function<void ()>> m_resetActions;
bool m_videoSync; bool m_videoSync;
bool m_audioSync; bool m_audioSync;

View File

@ -850,7 +850,7 @@ void Window::setupMenu(QMenuBar* menubar) {
installEventFilter(m_shortcutController); installEventFilter(m_shortcutController);
addControlledAction(fileMenu, fileMenu->addAction(tr("Load &ROM..."), this, SLOT(selectROM()), QKeySequence::Open), addControlledAction(fileMenu, fileMenu->addAction(tr("Load &ROM..."), this, SLOT(selectROM()), QKeySequence::Open),
"loadROM"); "loadROM");
QAction* loadTemporarySave = new QAction(tr("Load temporary save"), fileMenu); QAction* loadTemporarySave = new QAction(tr("Load temporary save..."), fileMenu);
connect(loadTemporarySave, &QAction::triggered, [this]() { this->selectSave(true); }); connect(loadTemporarySave, &QAction::triggered, [this]() { this->selectSave(true); });
m_gameActions.append(loadTemporarySave); m_gameActions.append(loadTemporarySave);
m_gbaActions.append(loadTemporarySave); m_gbaActions.append(loadTemporarySave);