mirror of https://github.com/mgba-emu/mgba.git
Qt: Ability to temporarily load a savegame
This commit is contained in:
parent
a088ad781a
commit
c207675dfb
1
CHANGES
1
CHANGES
|
@ -10,6 +10,7 @@ Features:
|
|||
- GUI: Add fast-forward
|
||||
- Wii: 240p support
|
||||
- 3DS: Adjustable screen darkening
|
||||
- Ability to temporarily load a savegame
|
||||
Bugfixes:
|
||||
- SDL: Fix axes being mapped wrong
|
||||
- GBA Memory: Fix mirror on non-overdumped Classic NES games
|
||||
|
|
|
@ -209,7 +209,8 @@ static bool _GBACoreLoadSave(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
|
||||
}
|
||||
|
||||
|
|
|
@ -138,6 +138,11 @@ GameController::GameController(QObject* parent)
|
|||
|
||||
m_threadContext.resetCallback = [](mCoreThread* context) {
|
||||
GameController* controller = static_cast<GameController*>(context->userData);
|
||||
for (auto action : controller->m_resetActions) {
|
||||
action();
|
||||
}
|
||||
controller->m_resetActions.clear();
|
||||
|
||||
unsigned width, height;
|
||||
controller->m_threadContext.core->desiredVideoDimensions(controller->m_threadContext.core, &width, &height);
|
||||
memset(controller->m_frontBuffer, 0xF8, width * height * BYTES_PER_PIXEL);
|
||||
|
@ -415,17 +420,20 @@ void GameController::loadSave(const QString& path, bool temporary) {
|
|||
if (!isLoaded()) {
|
||||
return;
|
||||
}
|
||||
VFile* vf = VFileDevice::open(path, temporary ? O_RDONLY : O_RDWR);
|
||||
if (!vf) {
|
||||
LOG(QT, ERROR) << tr("Failed to open save file: %1").arg(path);
|
||||
return;
|
||||
}
|
||||
m_resetActions.append([this, path, temporary]() {
|
||||
VFile* vf = VFileDevice::open(path, temporary ? O_RDONLY : O_RDWR);
|
||||
if (!vf) {
|
||||
LOG(QT, ERROR) << tr("Failed to open save file: %1").arg(path);
|
||||
return;
|
||||
}
|
||||
|
||||
if (temporary) {
|
||||
m_threadContext.core->loadTemporarySave(m_threadContext.core, vf);
|
||||
} else {
|
||||
m_threadContext.core->loadSave(m_threadContext.core, vf);
|
||||
}
|
||||
if (temporary) {
|
||||
m_threadContext.core->loadTemporarySave(m_threadContext.core, vf);
|
||||
} else {
|
||||
m_threadContext.core->loadSave(m_threadContext.core, vf);
|
||||
}
|
||||
});
|
||||
reset();
|
||||
}
|
||||
|
||||
void GameController::yankPak() {
|
||||
|
|
|
@ -192,6 +192,7 @@ private:
|
|||
AudioProcessor* m_audioProcessor;
|
||||
|
||||
QAtomicInt m_pauseAfterFrame;
|
||||
QList<std::function<void ()>> m_resetActions;
|
||||
|
||||
bool m_videoSync;
|
||||
bool m_audioSync;
|
||||
|
|
|
@ -850,7 +850,7 @@ void Window::setupMenu(QMenuBar* menubar) {
|
|||
installEventFilter(m_shortcutController);
|
||||
addControlledAction(fileMenu, fileMenu->addAction(tr("Load &ROM..."), this, SLOT(selectROM()), QKeySequence::Open),
|
||||
"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); });
|
||||
m_gameActions.append(loadTemporarySave);
|
||||
m_gbaActions.append(loadTemporarySave);
|
||||
|
|
Loading…
Reference in New Issue