all repos — mgba @ 61b4d53150ff03b6307ed00db761f2567a695f4b

mGBA Game Boy Advance Emulator

Qt: Enable savestates for GB games
Jeffrey Pfau jeffrey@endrift.com
Mon, 30 May 2016 23:24:39 -0700
commit

61b4d53150ff03b6307ed00db761f2567a695f4b

parent

5ea104844d58095e3dc002d93074d3302976cae6

3 files changed, 7 insertions(+), 64 deletions(-)

jump to
M src/platform/qt/LoadSaveState.cppsrc/platform/qt/LoadSaveState.cpp

@@ -43,10 +43,13 @@ m_slots[6] = m_ui.state7;

m_slots[7] = m_ui.state8; m_slots[8] = m_ui.state9; + unsigned width, height; + controller->thread()->core->desiredVideoDimensions(controller->thread()->core, &width, &height); int i; for (i = 0; i < NUM_SLOTS; ++i) { loadState(i + 1); m_slots[i]->installEventFilter(this); + m_slots[i]->setMaximumSize(width + 2, height + 2); connect(m_slots[i], &QAbstractButton::clicked, this, [this, i]() { triggerState(i + 1); }); }

@@ -192,9 +195,11 @@

QDateTime creation/*(QDateTime::fromMSecsSinceEpoch(state->creationUsec / 1000LL))*/; // TODO QImage stateImage; + unsigned width, height; + thread->core->desiredVideoDimensions(thread->core, &width, &height); mStateExtdataItem item; - if (mStateExtdataGet(&extdata, EXTDATA_SCREENSHOT, &item) && item.size >= VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4) { - stateImage = QImage((uchar*) item.data, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, QImage::Format_ARGB32).rgbSwapped(); + if (mStateExtdataGet(&extdata, EXTDATA_SCREENSHOT, &item) && item.size >= width * height * 4) { + stateImage = QImage((uchar*) item.data, width, height, QImage::Format_ARGB32).rgbSwapped(); } if (!stateImage.isNull()) {
M src/platform/qt/LoadSaveState.uisrc/platform/qt/LoadSaveState.ui

@@ -37,12 +37,6 @@ <horstretch>0</horstretch>

<verstretch>0</verstretch> </sizepolicy> </property> - <property name="maximumSize"> - <size> - <width>242</width> - <height>162</height> - </size> - </property> <property name="text"> <string>No Save</string> </property>

@@ -64,12 +58,6 @@ <sizepolicy hsizetype="Maximum" vsizetype="Maximum">

<horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>242</width> - <height>162</height> - </size> </property> <property name="text"> <string>No Save</string>

@@ -115,12 +103,6 @@ <horstretch>0</horstretch>

<verstretch>0</verstretch> </sizepolicy> </property> - <property name="maximumSize"> - <size> - <width>242</width> - <height>162</height> - </size> - </property> <property name="text"> <string>No Save</string> </property>

@@ -143,12 +125,6 @@ <horstretch>0</horstretch>

<verstretch>0</verstretch> </sizepolicy> </property> - <property name="maximumSize"> - <size> - <width>242</width> - <height>162</height> - </size> - </property> <property name="text"> <string>No Save</string> </property>

@@ -171,12 +147,6 @@ <horstretch>0</horstretch>

<verstretch>0</verstretch> </sizepolicy> </property> - <property name="maximumSize"> - <size> - <width>242</width> - <height>162</height> - </size> - </property> <property name="text"> <string>No Save</string> </property>

@@ -199,12 +169,6 @@ <horstretch>0</horstretch>

<verstretch>0</verstretch> </sizepolicy> </property> - <property name="maximumSize"> - <size> - <width>242</width> - <height>162</height> - </size> - </property> <property name="text"> <string>No Save</string> </property>

@@ -227,12 +191,6 @@ <horstretch>0</horstretch>

<verstretch>0</verstretch> </sizepolicy> </property> - <property name="maximumSize"> - <size> - <width>242</width> - <height>162</height> - </size> - </property> <property name="text"> <string>No Save</string> </property>

@@ -254,12 +212,6 @@ <sizepolicy hsizetype="Maximum" vsizetype="Maximum">

<horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>242</width> - <height>162</height> - </size> </property> <property name="text"> <string>No Save</string>

@@ -282,12 +234,6 @@ <sizepolicy hsizetype="Maximum" vsizetype="Maximum">

<horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>242</width> - <height>162</height> - </size> </property> <property name="text"> <string>No Save</string>
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -836,7 +836,6 @@ loadState->setShortcut(tr("F10"));

connect(loadState, &QAction::triggered, [this]() { this->openStateWindow(LoadSave::LOAD); }); m_gameActions.append(loadState); m_nonMpActions.append(loadState); - m_gbaActions.append(loadState); addControlledAction(fileMenu, loadState, "loadState"); QAction* saveState = new QAction(tr("&Save state"), fileMenu);

@@ -844,7 +843,6 @@ saveState->setShortcut(tr("Shift+F10"));

connect(saveState, &QAction::triggered, [this]() { this->openStateWindow(LoadSave::SAVE); }); m_gameActions.append(saveState); m_nonMpActions.append(saveState); - m_gbaActions.append(saveState); addControlledAction(fileMenu, saveState, "saveState"); QMenu* quickLoadMenu = fileMenu->addMenu(tr("Quick load"));

@@ -856,14 +854,12 @@ QAction* quickLoad = new QAction(tr("Load recent"), quickLoadMenu);

connect(quickLoad, SIGNAL(triggered()), m_controller, SLOT(loadState())); m_gameActions.append(quickLoad); m_nonMpActions.append(quickLoad); - m_gbaActions.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); m_nonMpActions.append(quickSave); - m_gbaActions.append(quickSave); addControlledAction(quickSaveMenu, quickSave, "quickSave"); quickLoadMenu->addSeparator();

@@ -874,7 +870,6 @@ undoLoadState->setShortcut(tr("F11"));

connect(undoLoadState, SIGNAL(triggered()), m_controller, SLOT(loadBackupState())); m_gameActions.append(undoLoadState); m_nonMpActions.append(undoLoadState); - m_gbaActions.append(undoLoadState); addControlledAction(quickLoadMenu, undoLoadState, "undoLoadState"); QAction* undoSaveState = new QAction(tr("Undo save state"), quickSaveMenu);

@@ -882,7 +877,6 @@ undoSaveState->setShortcut(tr("Shift+F11"));

connect(undoSaveState, SIGNAL(triggered()), m_controller, SLOT(saveBackupState())); m_gameActions.append(undoSaveState); m_nonMpActions.append(undoSaveState); - m_gbaActions.append(undoSaveState); addControlledAction(quickSaveMenu, undoSaveState, "undoSaveState"); quickLoadMenu->addSeparator();

@@ -895,7 +889,6 @@ quickLoad->setShortcut(tr("F%1").arg(i));

connect(quickLoad, &QAction::triggered, [this, i]() { m_controller->loadState(i); }); m_gameActions.append(quickLoad); m_nonMpActions.append(quickLoad); - m_gbaActions.append(quickLoad); addControlledAction(quickLoadMenu, quickLoad, QString("quickLoad.%1").arg(i)); quickSave = new QAction(tr("State &%1").arg(i), quickSaveMenu);

@@ -903,7 +896,6 @@ quickSave->setShortcut(tr("Shift+F%1").arg(i));

connect(quickSave, &QAction::triggered, [this, i]() { m_controller->saveState(i); }); m_gameActions.append(quickSave); m_nonMpActions.append(quickSave); - m_gbaActions.append(quickSave); addControlledAction(quickSaveMenu, quickSave, QString("quickSave.%1").arg(i)); }