Skip to content

Commit

Permalink
Scummvm: Changes to generate a ROM folder.svm/ as <game/> launche…
Browse files Browse the repository at this point in the history
…r instead of folder.
  • Loading branch information
Gemba committed Feb 18, 2024
1 parent 6ee541a commit 84e285b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION="3.10.0"
VERSION="3.10.1"
43 changes: 42 additions & 1 deletion src/emulationstation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ void EmulationStation::assembleList(QString &finalOutput,
.replace(".zip", ".daphne");
continue;
}
if (config->platform == "scummvm") {
// entry.path is file folder on fs with valid extension -> keep as
// game entry
// RetroPie/roms/scummvm/blarf.svm/ -> as <game/>
QFileInfo entryInfo(entry.path);
if (entryInfo.isDir() &&
extensions.contains("*." % entryInfo.suffix().toLower())) {
qDebug()
<< entry.path
<< "marked as <game/> albeit being a filesystem folder";
continue;
}
}
QFileInfo entryInfo(entry.path);
// always use canonical file path to ROM
entry.path = entryInfo.canonicalFilePath();
Expand Down Expand Up @@ -229,7 +242,13 @@ void EmulationStation::addFolder(QString &base, QString sub,
bool found = false;
QString absPath = base % "/" % sub;

// RetroPie/roms/scummvm/blarf.svm/blarf.svm -> leaf (fs-file) is <game/>
// and RetroPie/roms/scummvm/blarf.svm/blarf.svm -> parent fs-folder also
// <game/> RetroPie/roms/scummvm/blarf.svm/yadda/blarf.svm -> yadda as
// <folder/>, blarf.svm (fs-file and fs-folder) both as <game/>

for (auto &entry : added) {
// check the to-be-added folder entries
if (entry.path == absPath) {
found = true;
break;
Expand All @@ -238,14 +257,15 @@ void EmulationStation::addFolder(QString &base, QString sub,

if (!found) {
for (auto &entry : gameEntries) {
// check in existing folder entries
if (entry.isFolder && entry.path == absPath) {
found = true;
break;
}
}
}

if (!found) {
if (!found && !isGameLauncher(sub)) {
GameEntry fe;
fe.path = absPath;
fe.title = sub.mid(sub.lastIndexOf('/') + 1, sub.length());
Expand All @@ -262,6 +282,27 @@ void EmulationStation::addFolder(QString &base, QString sub,
}
}

bool EmulationStation::isGameLauncher(QString &sub) {
bool folderIsGameLauncher = false;
if (config->platform == "scummvm") {
QString extensions = Platform::get().getFormats(
config->platform, config->extensions, config->addExtensions);
QStringList exts = extensions.split(" ");
for (auto ext : exts) {
QRegExp re(ext);
re.setPatternSyntax(QRegExp::Wildcard);
if (re.exactMatch(sub.toLower())) {
qDebug() << "Match: " << sub;
// do not add if .svm or other extension is used in
// fs-folder
folderIsGameLauncher = true;
break;
}
}
}
return folderIsGameLauncher;
}

QString EmulationStation::createXml(GameEntry &entry) {
QStringList l;
bool addEmptyElem = !entry.isFolder;
Expand Down
1 change: 1 addition & 0 deletions src/emulationstation.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class EmulationStation : public AbstractFrontend {
QString createXml(GameEntry &entry);
QString elem(QString elem, QString &data, bool addEmptyElem,
bool isPath = false);
bool isGameLauncher(QString &sub);
};

#endif // EMULATIONSTATION_H
8 changes: 7 additions & 1 deletion src/skyscraper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,16 @@ void Skyscraper::run() {
}
cache->readPriorities();

QDir::Filters filter = QDir::Files;
// special case scummvm: user do use .svm in folder name to work around the
// limitation of the ScummVM / lr-scummvm launch integration in ES/RetroPie
if (config.platform == "scummvm") {
filter |= QDir::Dirs;
}
QDir inputDir(config.inputFolder,
Platform::get().getFormats(config.platform, config.extensions,
config.addExtensions),
QDir::Name, QDir::Files);
QDir::Name, filter);
if (!inputDir.exists()) {
printf("Input folder '\033[1;32m%s\033[0m' doesn't exist or can't be "
"seen by current user. Please check path and permissions.\n",
Expand Down

0 comments on commit 84e285b

Please sign in to comment.