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);
|
||||
}
|
||||
|
||||
void CoreController::setPath(const QString& path, const QString& base) {
|
||||
m_path = path;
|
||||
m_baseDirectory = base;
|
||||
}
|
||||
|
||||
const color_t* CoreController::drawContext() {
|
||||
if (m_hwaccel) {
|
||||
return nullptr;
|
||||
|
@ -816,6 +821,8 @@ void CoreController::loadSave(const QString& path, bool temporary) {
|
|||
}
|
||||
if (!ok) {
|
||||
vf->close(vf);
|
||||
} else {
|
||||
m_savePath = path;
|
||||
}
|
||||
});
|
||||
if (hasStarted()) {
|
||||
|
@ -823,8 +830,8 @@ void CoreController::loadSave(const QString& path, bool temporary) {
|
|||
}
|
||||
}
|
||||
|
||||
void CoreController::loadSave(VFile* vf, bool temporary) {
|
||||
m_resetActions.append([this, vf, temporary]() {
|
||||
void CoreController::loadSave(VFile* vf, bool temporary, const QString& path) {
|
||||
m_resetActions.append([this, vf, temporary, path]() {
|
||||
bool ok;
|
||||
if (temporary) {
|
||||
ok = m_threadContext.core->loadTemporarySave(m_threadContext.core, vf);
|
||||
|
@ -833,6 +840,8 @@ void CoreController::loadSave(VFile* vf, bool temporary) {
|
|||
}
|
||||
if (!ok) {
|
||||
vf->close(vf);
|
||||
} else {
|
||||
m_savePath = path;
|
||||
}
|
||||
});
|
||||
if (hasStarted()) {
|
||||
|
@ -1267,7 +1276,11 @@ void CoreController::updatePlayerSave() {
|
|||
QByteArray saveSuffixBin(saveSuffix.toUtf8());
|
||||
VFile* save = mDirectorySetOpenSuffix(&m_threadContext.core->dirs, m_threadContext.core->dirs.save, saveSuffixBin.constData(), O_CREAT | O_RDWR);
|
||||
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; }
|
||||
|
||||
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();
|
||||
QImage getPixels();
|
||||
|
||||
|
@ -162,7 +167,7 @@ public slots:
|
|||
void saveBackupState();
|
||||
|
||||
void loadSave(const QString&, bool temporary);
|
||||
void loadSave(VFile*, bool temporary);
|
||||
void loadSave(VFile*, bool temporary, const QString& path = {});
|
||||
void loadPatch(const QString&);
|
||||
void scanCard(const QString&);
|
||||
void scanCards(const QStringList&);
|
||||
|
@ -249,6 +254,10 @@ private:
|
|||
CoreController* self;
|
||||
} m_logger{};
|
||||
|
||||
QString m_path;
|
||||
QString m_baseDirectory;
|
||||
QString m_savePath;
|
||||
|
||||
bool m_patched = false;
|
||||
bool m_preload = false;
|
||||
|
||||
|
|
|
@ -122,6 +122,7 @@ CoreController* CoreManager::loadGame(VFile* vf, const QString& path, const QStr
|
|||
if (m_multiplayer) {
|
||||
cc->setMultiplayerController(m_multiplayer);
|
||||
}
|
||||
cc->setPath(path, info.dir().canonicalPath());
|
||||
emit coreLoaded(cc);
|
||||
return cc;
|
||||
}
|
||||
|
@ -171,6 +172,7 @@ CoreController* CoreManager::loadBIOS(int platform, const QString& path) {
|
|||
if (m_multiplayer) {
|
||||
cc->setMultiplayerController(m_multiplayer);
|
||||
}
|
||||
cc->setPath(path, info.dir().canonicalPath());
|
||||
emit coreLoaded(cc);
|
||||
return cc;
|
||||
}
|
||||
|
|
|
@ -62,4 +62,11 @@ ROMInfo::ROMInfo(std::shared_ptr<CoreController> controller, QWidget* parent)
|
|||
m_ui.crc->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>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
Loading…
Reference in New Issue