mirror of https://github.com/mgba-emu/mgba.git
Qt: Enable savestates for GB games
This commit is contained in:
parent
5ea104844d
commit
61b4d53150
|
@ -43,10 +43,13 @@ LoadSaveState::LoadSaveState(GameController* controller, QWidget* parent)
|
||||||
m_slots[7] = m_ui.state8;
|
m_slots[7] = m_ui.state8;
|
||||||
m_slots[8] = m_ui.state9;
|
m_slots[8] = m_ui.state9;
|
||||||
|
|
||||||
|
unsigned width, height;
|
||||||
|
controller->thread()->core->desiredVideoDimensions(controller->thread()->core, &width, &height);
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < NUM_SLOTS; ++i) {
|
for (i = 0; i < NUM_SLOTS; ++i) {
|
||||||
loadState(i + 1);
|
loadState(i + 1);
|
||||||
m_slots[i]->installEventFilter(this);
|
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); });
|
connect(m_slots[i], &QAbstractButton::clicked, this, [this, i]() { triggerState(i + 1); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,9 +195,11 @@ void LoadSaveState::loadState(int slot) {
|
||||||
QDateTime creation/*(QDateTime::fromMSecsSinceEpoch(state->creationUsec / 1000LL))*/; // TODO
|
QDateTime creation/*(QDateTime::fromMSecsSinceEpoch(state->creationUsec / 1000LL))*/; // TODO
|
||||||
QImage stateImage;
|
QImage stateImage;
|
||||||
|
|
||||||
|
unsigned width, height;
|
||||||
|
thread->core->desiredVideoDimensions(thread->core, &width, &height);
|
||||||
mStateExtdataItem item;
|
mStateExtdataItem item;
|
||||||
if (mStateExtdataGet(&extdata, EXTDATA_SCREENSHOT, &item) && item.size >= VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4) {
|
if (mStateExtdataGet(&extdata, EXTDATA_SCREENSHOT, &item) && item.size >= width * height * 4) {
|
||||||
stateImage = QImage((uchar*) item.data, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, QImage::Format_ARGB32).rgbSwapped();
|
stateImage = QImage((uchar*) item.data, width, height, QImage::Format_ARGB32).rgbSwapped();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stateImage.isNull()) {
|
if (!stateImage.isNull()) {
|
||||||
|
|
|
@ -37,12 +37,6 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>242</width>
|
|
||||||
<height>162</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>No Save</string>
|
<string>No Save</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -65,12 +59,6 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>242</width>
|
|
||||||
<height>162</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>No Save</string>
|
<string>No Save</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -115,12 +103,6 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>242</width>
|
|
||||||
<height>162</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>No Save</string>
|
<string>No Save</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -143,12 +125,6 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>242</width>
|
|
||||||
<height>162</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>No Save</string>
|
<string>No Save</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -171,12 +147,6 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>242</width>
|
|
||||||
<height>162</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>No Save</string>
|
<string>No Save</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -199,12 +169,6 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>242</width>
|
|
||||||
<height>162</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>No Save</string>
|
<string>No Save</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -227,12 +191,6 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>242</width>
|
|
||||||
<height>162</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>No Save</string>
|
<string>No Save</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -255,12 +213,6 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>242</width>
|
|
||||||
<height>162</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>No Save</string>
|
<string>No Save</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -283,12 +235,6 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>242</width>
|
|
||||||
<height>162</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>No Save</string>
|
<string>No Save</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -836,7 +836,6 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
connect(loadState, &QAction::triggered, [this]() { this->openStateWindow(LoadSave::LOAD); });
|
connect(loadState, &QAction::triggered, [this]() { this->openStateWindow(LoadSave::LOAD); });
|
||||||
m_gameActions.append(loadState);
|
m_gameActions.append(loadState);
|
||||||
m_nonMpActions.append(loadState);
|
m_nonMpActions.append(loadState);
|
||||||
m_gbaActions.append(loadState);
|
|
||||||
addControlledAction(fileMenu, loadState, "loadState");
|
addControlledAction(fileMenu, loadState, "loadState");
|
||||||
|
|
||||||
QAction* saveState = new QAction(tr("&Save state"), fileMenu);
|
QAction* saveState = new QAction(tr("&Save state"), fileMenu);
|
||||||
|
@ -844,7 +843,6 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
connect(saveState, &QAction::triggered, [this]() { this->openStateWindow(LoadSave::SAVE); });
|
connect(saveState, &QAction::triggered, [this]() { this->openStateWindow(LoadSave::SAVE); });
|
||||||
m_gameActions.append(saveState);
|
m_gameActions.append(saveState);
|
||||||
m_nonMpActions.append(saveState);
|
m_nonMpActions.append(saveState);
|
||||||
m_gbaActions.append(saveState);
|
|
||||||
addControlledAction(fileMenu, saveState, "saveState");
|
addControlledAction(fileMenu, saveState, "saveState");
|
||||||
|
|
||||||
QMenu* quickLoadMenu = fileMenu->addMenu(tr("Quick load"));
|
QMenu* quickLoadMenu = fileMenu->addMenu(tr("Quick load"));
|
||||||
|
@ -856,14 +854,12 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
connect(quickLoad, SIGNAL(triggered()), m_controller, SLOT(loadState()));
|
connect(quickLoad, SIGNAL(triggered()), m_controller, SLOT(loadState()));
|
||||||
m_gameActions.append(quickLoad);
|
m_gameActions.append(quickLoad);
|
||||||
m_nonMpActions.append(quickLoad);
|
m_nonMpActions.append(quickLoad);
|
||||||
m_gbaActions.append(quickLoad);
|
|
||||||
addControlledAction(quickLoadMenu, quickLoad, "quickLoad");
|
addControlledAction(quickLoadMenu, quickLoad, "quickLoad");
|
||||||
|
|
||||||
QAction* quickSave = new QAction(tr("Save recent"), quickSaveMenu);
|
QAction* quickSave = new QAction(tr("Save recent"), quickSaveMenu);
|
||||||
connect(quickSave, SIGNAL(triggered()), m_controller, SLOT(saveState()));
|
connect(quickSave, SIGNAL(triggered()), m_controller, SLOT(saveState()));
|
||||||
m_gameActions.append(quickSave);
|
m_gameActions.append(quickSave);
|
||||||
m_nonMpActions.append(quickSave);
|
m_nonMpActions.append(quickSave);
|
||||||
m_gbaActions.append(quickSave);
|
|
||||||
addControlledAction(quickSaveMenu, quickSave, "quickSave");
|
addControlledAction(quickSaveMenu, quickSave, "quickSave");
|
||||||
|
|
||||||
quickLoadMenu->addSeparator();
|
quickLoadMenu->addSeparator();
|
||||||
|
@ -874,7 +870,6 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
connect(undoLoadState, SIGNAL(triggered()), m_controller, SLOT(loadBackupState()));
|
connect(undoLoadState, SIGNAL(triggered()), m_controller, SLOT(loadBackupState()));
|
||||||
m_gameActions.append(undoLoadState);
|
m_gameActions.append(undoLoadState);
|
||||||
m_nonMpActions.append(undoLoadState);
|
m_nonMpActions.append(undoLoadState);
|
||||||
m_gbaActions.append(undoLoadState);
|
|
||||||
addControlledAction(quickLoadMenu, undoLoadState, "undoLoadState");
|
addControlledAction(quickLoadMenu, undoLoadState, "undoLoadState");
|
||||||
|
|
||||||
QAction* undoSaveState = new QAction(tr("Undo save state"), quickSaveMenu);
|
QAction* undoSaveState = new QAction(tr("Undo save state"), quickSaveMenu);
|
||||||
|
@ -882,7 +877,6 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
connect(undoSaveState, SIGNAL(triggered()), m_controller, SLOT(saveBackupState()));
|
connect(undoSaveState, SIGNAL(triggered()), m_controller, SLOT(saveBackupState()));
|
||||||
m_gameActions.append(undoSaveState);
|
m_gameActions.append(undoSaveState);
|
||||||
m_nonMpActions.append(undoSaveState);
|
m_nonMpActions.append(undoSaveState);
|
||||||
m_gbaActions.append(undoSaveState);
|
|
||||||
addControlledAction(quickSaveMenu, undoSaveState, "undoSaveState");
|
addControlledAction(quickSaveMenu, undoSaveState, "undoSaveState");
|
||||||
|
|
||||||
quickLoadMenu->addSeparator();
|
quickLoadMenu->addSeparator();
|
||||||
|
@ -895,7 +889,6 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
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);
|
||||||
m_nonMpActions.append(quickLoad);
|
m_nonMpActions.append(quickLoad);
|
||||||
m_gbaActions.append(quickLoad);
|
|
||||||
addControlledAction(quickLoadMenu, quickLoad, QString("quickLoad.%1").arg(i));
|
addControlledAction(quickLoadMenu, quickLoad, QString("quickLoad.%1").arg(i));
|
||||||
|
|
||||||
quickSave = new QAction(tr("State &%1").arg(i), quickSaveMenu);
|
quickSave = new QAction(tr("State &%1").arg(i), quickSaveMenu);
|
||||||
|
@ -903,7 +896,6 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
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);
|
||||||
m_nonMpActions.append(quickSave);
|
m_nonMpActions.append(quickSave);
|
||||||
m_gbaActions.append(quickSave);
|
|
||||||
addControlledAction(quickSaveMenu, quickSave, QString("quickSave.%1").arg(i));
|
addControlledAction(quickSaveMenu, quickSave, QString("quickSave.%1").arg(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue