mirror of https://github.com/mgba-emu/mgba.git
Qt: Plumb through some path info into the CoreController
This commit is contained in:
parent
c0507b8a71
commit
4b38883b6a
|
@ -231,6 +231,11 @@ CoreController::~CoreController() {
|
||||||
m_threadContext.core->deinit(m_threadContext.core);
|
m_threadContext.core->deinit(m_threadContext.core);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CoreController::setPath(const QString& path, const QString& base) {
|
||||||
|
m_path = path;
|
||||||
|
m_baseDirectory = base;
|
||||||
|
}
|
||||||
|
|
||||||
const color_t* CoreController::drawContext() {
|
const color_t* CoreController::drawContext() {
|
||||||
if (m_hwaccel) {
|
if (m_hwaccel) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -816,6 +821,8 @@ void CoreController::loadSave(const QString& path, bool temporary) {
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
vf->close(vf);
|
vf->close(vf);
|
||||||
|
} else {
|
||||||
|
m_savePath = path;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (hasStarted()) {
|
if (hasStarted()) {
|
||||||
|
@ -823,8 +830,8 @@ void CoreController::loadSave(const QString& path, bool temporary) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreController::loadSave(VFile* vf, bool temporary) {
|
void CoreController::loadSave(VFile* vf, bool temporary, const QString& path) {
|
||||||
m_resetActions.append([this, vf, temporary]() {
|
m_resetActions.append([this, vf, temporary, path]() {
|
||||||
bool ok;
|
bool ok;
|
||||||
if (temporary) {
|
if (temporary) {
|
||||||
ok = m_threadContext.core->loadTemporarySave(m_threadContext.core, vf);
|
ok = m_threadContext.core->loadTemporarySave(m_threadContext.core, vf);
|
||||||
|
@ -833,6 +840,8 @@ void CoreController::loadSave(VFile* vf, bool temporary) {
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
vf->close(vf);
|
vf->close(vf);
|
||||||
|
} else {
|
||||||
|
m_savePath = path;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (hasStarted()) {
|
if (hasStarted()) {
|
||||||
|
@ -1267,7 +1276,11 @@ void CoreController::updatePlayerSave() {
|
||||||
QByteArray saveSuffixBin(saveSuffix.toUtf8());
|
QByteArray saveSuffixBin(saveSuffix.toUtf8());
|
||||||
VFile* save = mDirectorySetOpenSuffix(&m_threadContext.core->dirs, m_threadContext.core->dirs.save, saveSuffixBin.constData(), O_CREAT | O_RDWR);
|
VFile* save = mDirectorySetOpenSuffix(&m_threadContext.core->dirs, m_threadContext.core->dirs.save, saveSuffixBin.constData(), O_CREAT | O_RDWR);
|
||||||
if (save) {
|
if (save) {
|
||||||
m_threadContext.core->loadSave(m_threadContext.core, save);
|
if (!m_threadContext.core->loadSave(m_threadContext.core, save)) {
|
||||||
|
save->close(save);
|
||||||
|
} else {
|
||||||
|
m_savePath = QString::fromUtf8(m_threadContext.core->dirs.baseName) + saveSuffix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,11 @@ public:
|
||||||
|
|
||||||
mCoreThread* thread() { return &m_threadContext; }
|
mCoreThread* thread() { return &m_threadContext; }
|
||||||
|
|
||||||
|
void setPath(const QString& path, const QString& base = {});
|
||||||
|
QString path() const { return m_path; }
|
||||||
|
QString baseDirectory() const { return m_baseDirectory; }
|
||||||
|
QString savePath() const { return m_savePath; }
|
||||||
|
|
||||||
const color_t* drawContext();
|
const color_t* drawContext();
|
||||||
QImage getPixels();
|
QImage getPixels();
|
||||||
|
|
||||||
|
@ -162,7 +167,7 @@ public slots:
|
||||||
void saveBackupState();
|
void saveBackupState();
|
||||||
|
|
||||||
void loadSave(const QString&, bool temporary);
|
void loadSave(const QString&, bool temporary);
|
||||||
void loadSave(VFile*, bool temporary);
|
void loadSave(VFile*, bool temporary, const QString& path = {});
|
||||||
void loadPatch(const QString&);
|
void loadPatch(const QString&);
|
||||||
void scanCard(const QString&);
|
void scanCard(const QString&);
|
||||||
void scanCards(const QStringList&);
|
void scanCards(const QStringList&);
|
||||||
|
@ -249,6 +254,10 @@ private:
|
||||||
CoreController* self;
|
CoreController* self;
|
||||||
} m_logger{};
|
} m_logger{};
|
||||||
|
|
||||||
|
QString m_path;
|
||||||
|
QString m_baseDirectory;
|
||||||
|
QString m_savePath;
|
||||||
|
|
||||||
bool m_patched = false;
|
bool m_patched = false;
|
||||||
bool m_preload = false;
|
bool m_preload = false;
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,7 @@ CoreController* CoreManager::loadGame(VFile* vf, const QString& path, const QStr
|
||||||
if (m_multiplayer) {
|
if (m_multiplayer) {
|
||||||
cc->setMultiplayerController(m_multiplayer);
|
cc->setMultiplayerController(m_multiplayer);
|
||||||
}
|
}
|
||||||
|
cc->setPath(path, info.dir().canonicalPath());
|
||||||
emit coreLoaded(cc);
|
emit coreLoaded(cc);
|
||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
|
@ -171,6 +172,7 @@ CoreController* CoreManager::loadBIOS(int platform, const QString& path) {
|
||||||
if (m_multiplayer) {
|
if (m_multiplayer) {
|
||||||
cc->setMultiplayerController(m_multiplayer);
|
cc->setMultiplayerController(m_multiplayer);
|
||||||
}
|
}
|
||||||
|
cc->setPath(path, info.dir().canonicalPath());
|
||||||
emit coreLoaded(cc);
|
emit coreLoaded(cc);
|
||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,4 +62,11 @@ ROMInfo::ROMInfo(std::shared_ptr<CoreController> controller, QWidget* parent)
|
||||||
m_ui.crc->setText(tr("(unknown)"));
|
m_ui.crc->setText(tr("(unknown)"));
|
||||||
m_ui.name->setText(tr("(unknown)"));
|
m_ui.name->setText(tr("(unknown)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString savePath = controller->savePath();
|
||||||
|
if (!savePath.isEmpty()) {
|
||||||
|
m_ui.savefile->setText(savePath);
|
||||||
|
} else {
|
||||||
|
m_ui.savefile->setText(tr("(unknown)"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,20 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save file:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QLabel" name="savefile">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">{SAVEFILE}</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
Loading…
Reference in New Issue