Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pegasus frontend: Handle 'extra' based on command/launch lines #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions src/pegasus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,17 @@ QString Pegasus::fromPreservedHeader(const QString &key, const QString &suggeste
return suggested;
}

bool Pegasus::hasPreservedHeader(const QString &key)
{
for(int a = 0; a < headerPairs.length(); ++a) {
if(key == headerPairs.at(a).first) {
return true;
}
}

return false;
}

void Pegasus::removePreservedHeader(const QString &key)
{
for(int a = headerPairs.length() - 1; a >= 0; --a) {
Expand Down Expand Up @@ -280,19 +291,30 @@ void Pegasus::assembleList(QString &finalOutput, QList<GameEntry> &gameEntries)
finalOutput.append("shortname: " + fromPreservedHeader("shortname", config->platform) + "\n");
// finalOutput.append("extensions: " + fromPreservedHeader("extensions", extensions) + "\n");
if(config->frontendExtra.isEmpty()) {
finalOutput.append("command: " + fromPreservedHeader("command", "/opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ " + config->platform + " \"{file.path}\"") + "\n");
if(!hasPreservedHeader("command") && !hasPreservedHeader("launch")) {
finalOutput.append("command: " + fromPreservedHeader("command", "/opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ " + config->platform + " \"{file.path}\"") + "\n");
}
} else {
//finalOutput.append("command: " + config->frontendExtra.replace(":","") + "\n");
finalOutput.append("command: " + config->frontendExtra + "\n");
removePreservedHeader("command");
}
if(!headerPairs.isEmpty()) {
for(const auto &pair: headerPairs) {
finalOutput.append(toPegasusFormat(pair.first, pair.second) + "\n");
}
if(!headerPairs.isEmpty()) {
for(const auto &pair: headerPairs) {
if(pair.first != "command" && pair.first != "launch") {
finalOutput.append(toPegasusFormat(pair.first, pair.second) + "\n");
}
}
finalOutput.append("\n");
}
// save command/launch for last
if(hasPreservedHeader("command")) {
finalOutput.append(toPegasusFormat("command", fromPreservedHeader("command", "")) + "\n");
} else {
finalOutput.append(toPegasusFormat("launch", fromPreservedHeader("launch", "")) + "\n");
}
finalOutput.append("\n");

int dots = 0;
// Always make dotMod at least 1 or it will give "floating point exception" when modulo
int dotMod = gameEntries.length() * 0.1 + 1;
Expand Down
1 change: 1 addition & 0 deletions src/pegasus.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Pegasus : public AbstractFrontend
private:
QString makeAbsolute(const QString &filePath, const QString &inputFolder);
QString fromPreservedHeader(const QString &key, const QString &suggested);
bool hasPreservedHeader(const QString &key);
void removePreservedHeader(const QString &key);
QString toPegasusFormat(const QString &key, const QString &value);
QList<QPair<QString, QString> > headerPairs;
Expand Down