mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-06-28 09:59:41 -06:00
add functionality to import savefiles
This commit is contained in:
@ -1052,6 +1052,9 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
||||
actUndoStateLoad->setShortcut(QKeySequence(Qt::Key_F12));
|
||||
connect(actUndoStateLoad, &QAction::triggered, this, &MainWindow::onUndoStateLoad);
|
||||
|
||||
actImportSavefile = menu->addAction("Import savefile");
|
||||
connect(actImportSavefile, &QAction::triggered, this, &MainWindow::onImportSavefile);
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
actQuit = menu->addAction("Quit");
|
||||
@ -1220,6 +1223,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
||||
actLoadState[i]->setEnabled(false);
|
||||
}
|
||||
actUndoStateLoad->setEnabled(false);
|
||||
actImportSavefile->setEnabled(false);
|
||||
|
||||
actPause->setEnabled(false);
|
||||
actReset->setEnabled(false);
|
||||
@ -1618,6 +1622,41 @@ void MainWindow::onUndoStateLoad()
|
||||
OSD::AddMessage(0, "State load undone");
|
||||
}
|
||||
|
||||
void MainWindow::onImportSavefile()
|
||||
{
|
||||
if (!RunningSomething) return;
|
||||
|
||||
emuThread->emuPause();
|
||||
QString path = QFileDialog::getOpenFileName(this,
|
||||
"Select savefile",
|
||||
Config::LastROMFolder,
|
||||
"Savefiles (*.sav *.bin *.dsv);;Any file (*.*)");
|
||||
|
||||
if (!path.isEmpty())
|
||||
{
|
||||
if (QMessageBox::warning(this,
|
||||
"Emulation will be reset and data overwritten",
|
||||
"The emulation will be reset and the current savefile overwritten.",
|
||||
QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
|
||||
{
|
||||
int res = Frontend::Reset();
|
||||
if (res != Frontend::Load_OK)
|
||||
{
|
||||
QMessageBox::critical(this, "melonDS", "Reset failed\n" + loadErrorStr(res));
|
||||
}
|
||||
else
|
||||
{
|
||||
int diff = Frontend::ImportSRAM(path.toStdString().c_str());
|
||||
if (diff > 0)
|
||||
OSD::AddMessage(0, "Trimmed savefile");
|
||||
else if (diff < 0)
|
||||
OSD::AddMessage(0, "Savefile shorter than SRAM");
|
||||
}
|
||||
}
|
||||
}
|
||||
emuThread->emuUnpause();
|
||||
}
|
||||
|
||||
void MainWindow::onQuit()
|
||||
{
|
||||
QApplication::quit();
|
||||
@ -1923,6 +1962,7 @@ void MainWindow::onEmuStart()
|
||||
actPause->setChecked(false);
|
||||
actReset->setEnabled(true);
|
||||
actStop->setEnabled(true);
|
||||
actImportSavefile->setEnabled(true);
|
||||
|
||||
actSetupCheats->setEnabled(true);
|
||||
}
|
||||
@ -1937,6 +1977,7 @@ void MainWindow::onEmuStop()
|
||||
actLoadState[i]->setEnabled(false);
|
||||
}
|
||||
actUndoStateLoad->setEnabled(false);
|
||||
actImportSavefile->setEnabled(false);
|
||||
|
||||
actPause->setEnabled(false);
|
||||
actReset->setEnabled(false);
|
||||
|
Reference in New Issue
Block a user