mirror of https://github.com/mgba-emu/mgba.git
Qt: ROM replacing
This commit is contained in:
parent
635fae7d05
commit
83dfbe6123
|
@ -282,17 +282,7 @@ void GameController::openGame(bool biosOnly) {
|
|||
m_threadContext.gameDir = VDirOpen(m_threadContext.fname);
|
||||
m_threadContext.stateDir = m_threadContext.gameDir;
|
||||
} else {
|
||||
m_threadContext.rom = VFileOpen(m_threadContext.fname, O_RDONLY);
|
||||
#if USE_LIBZIP
|
||||
if (!m_threadContext.gameDir) {
|
||||
m_threadContext.gameDir = VDirOpenZip(m_threadContext.fname, 0);
|
||||
}
|
||||
#endif
|
||||
#if USE_LZMA
|
||||
if (!m_threadContext.gameDir) {
|
||||
m_threadContext.gameDir = VDirOpen7z(m_threadContext.fname, 0);
|
||||
}
|
||||
#endif
|
||||
GBAThreadLoadROM(&m_threadContext, m_threadContext.fname);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -334,6 +324,19 @@ void GameController::yankPak() {
|
|||
threadContinue();
|
||||
}
|
||||
|
||||
|
||||
void GameController::replaceGame(const QString& path) {
|
||||
if (!m_gameOpen) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_fname = path;
|
||||
threadInterrupt();
|
||||
m_threadContext.fname = strdup(m_fname.toLocal8Bit().constData());
|
||||
GBAThreadReplaceROM(&m_threadContext, m_threadContext.fname);
|
||||
threadContinue();
|
||||
}
|
||||
|
||||
void GameController::loadPatch(const QString& path) {
|
||||
if (m_gameOpen) {
|
||||
closeGame();
|
||||
|
|
|
@ -98,6 +98,7 @@ public slots:
|
|||
void loadGame(const QString& path, bool dirmode = false);
|
||||
void loadBIOS(const QString& path);
|
||||
void yankPak();
|
||||
void replaceGame(const QString& path);
|
||||
void setSkipBIOS(bool);
|
||||
void setUseBIOS(bool);
|
||||
void loadPatch(const QString& path);
|
||||
|
|
|
@ -230,6 +230,24 @@ void Window::selectROM() {
|
|||
}
|
||||
}
|
||||
|
||||
void Window::replaceROM() {
|
||||
QStringList formats{
|
||||
"*.gba",
|
||||
#ifdef USE_LIBZIP
|
||||
"*.zip",
|
||||
#endif
|
||||
#ifdef USE_LZMA
|
||||
"*.7z",
|
||||
#endif
|
||||
"*.rom",
|
||||
"*.bin"};
|
||||
QString filter = tr("Game Boy Advance ROMs (%1)").arg(formats.join(QChar(' ')));
|
||||
QString filename = GBAApp::app()->getOpenFileName(this, tr("Select ROM"), filter);
|
||||
if (!filename.isEmpty()) {
|
||||
m_controller->replaceGame(filename);
|
||||
}
|
||||
}
|
||||
|
||||
void Window::selectBIOS() {
|
||||
QString filename = GBAApp::app()->getOpenFileName(this, tr("Select BIOS"));
|
||||
if (!filename.isEmpty()) {
|
||||
|
@ -615,6 +633,8 @@ void Window::setupMenu(QMenuBar* menubar) {
|
|||
addControlledAction(fileMenu, fileMenu->addAction(tr("Load &patch..."), this, SLOT(selectPatch())), "loadPatch");
|
||||
addControlledAction(fileMenu, fileMenu->addAction(tr("Boot BIOS"), m_controller, SLOT(bootBIOS())), "bootBIOS");
|
||||
|
||||
addControlledAction(fileMenu, fileMenu->addAction(tr("Replace ROM..."), this, SLOT(replaceROM())), "replaceROM");
|
||||
|
||||
m_mruMenu = fileMenu->addMenu(tr("Recent"));
|
||||
|
||||
fileMenu->addSeparator();
|
||||
|
|
|
@ -65,6 +65,8 @@ public slots:
|
|||
void loadConfig();
|
||||
void saveConfig();
|
||||
|
||||
void replaceROM();
|
||||
|
||||
void importSharkport();
|
||||
void exportSharkport();
|
||||
|
||||
|
|
Loading…
Reference in New Issue