mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-02-09 21:13:08 +00:00
Import: Filter non-game Steam entries
Ignore Steam runtime/redistributable entries and other non-game content. Also skip manifests that are not fully installed and ensure the install folder exists before importing.
This commit is contained in:
parent
24b9ee6491
commit
05abbf329b
1 changed files with 47 additions and 4 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
#include <QStringList>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
SteamImporter::SteamImporter(QObject *parent)
|
SteamImporter::SteamImporter(QObject *parent)
|
||||||
|
|
@ -122,10 +123,54 @@ Game *SteamImporter::parseAppManifest(const QString &path)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto isNonGameEntry = [](const QString &title, const QString &dir) {
|
||||||
|
auto normalize = [](QString s) {
|
||||||
|
s = s.toLower();
|
||||||
|
s.remove(QLatin1Char(' '));
|
||||||
|
s.remove(QLatin1Char('_'));
|
||||||
|
s.remove(QLatin1Char('-'));
|
||||||
|
return s;
|
||||||
|
};
|
||||||
|
|
||||||
|
const QString t = normalize(title);
|
||||||
|
const QString d = normalize(dir);
|
||||||
|
static const QStringList patterns = {
|
||||||
|
QStringLiteral("steamlinuxruntime"),
|
||||||
|
QStringLiteral("steamworkscommonredistributables"),
|
||||||
|
QStringLiteral("steamworkssdkredist"),
|
||||||
|
QStringLiteral("shaderprecaching"),
|
||||||
|
QStringLiteral("proton"),
|
||||||
|
QStringLiteral("steamvr"),
|
||||||
|
};
|
||||||
|
for (const QString &p : patterns) {
|
||||||
|
if (t.contains(p) || d.contains(p)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isNonGameEntry(name, installDir)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Skip tools and other non-game content
|
// Skip tools and other non-game content
|
||||||
QString stateFlags = getValue(QStringLiteral("StateFlags"));
|
QString stateFlags = getValue(QStringLiteral("StateFlags"));
|
||||||
if (stateFlags == QLatin1String("2")) {
|
if (!stateFlags.isEmpty()) {
|
||||||
// Only partially installed
|
bool ok = false;
|
||||||
|
const int flags = stateFlags.toInt(&ok);
|
||||||
|
if (ok) {
|
||||||
|
constexpr int InstalledFlag = 4;
|
||||||
|
if ((flags & InstalledFlag) == 0) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QFileInfo manifestInfo(path);
|
||||||
|
const QString gameDir = manifestInfo.absolutePath() + QStringLiteral("/common/") + installDir;
|
||||||
|
if (!QDir(gameDir).exists()) {
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game *game = new Game(QStringLiteral("steam-%1").arg(appId), name);
|
Game *game = new Game(QStringLiteral("steam-%1").arg(appId), name);
|
||||||
|
|
@ -140,8 +185,6 @@ Game *SteamImporter::parseAppManifest(const QString &path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set installation directory
|
// Set installation directory
|
||||||
QFileInfo manifestInfo(path);
|
|
||||||
QString gameDir = manifestInfo.absolutePath() + QStringLiteral("/common/") + installDir;
|
|
||||||
game->setWorkingDirectory(gameDir);
|
game->setWorkingDirectory(gameDir);
|
||||||
|
|
||||||
game->setInstalled(true);
|
game->setInstalled(true);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue