mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-02-09 13:03:09 +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 <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
#include <QStringList>
|
||||
#include <QTextStream>
|
||||
|
||||
SteamImporter::SteamImporter(QObject *parent)
|
||||
|
|
@ -122,10 +123,54 @@ Game *SteamImporter::parseAppManifest(const QString &path)
|
|||
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
|
||||
QString stateFlags = getValue(QStringLiteral("StateFlags"));
|
||||
if (stateFlags == QLatin1String("2")) {
|
||||
// Only partially installed
|
||||
if (!stateFlags.isEmpty()) {
|
||||
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);
|
||||
|
|
@ -140,8 +185,6 @@ Game *SteamImporter::parseAppManifest(const QString &path)
|
|||
}
|
||||
|
||||
// Set installation directory
|
||||
QFileInfo manifestInfo(path);
|
||||
QString gameDir = manifestInfo.absolutePath() + QStringLiteral("/common/") + installDir;
|
||||
game->setWorkingDirectory(gameDir);
|
||||
|
||||
game->setInstalled(true);
|
||||
|
|
|
|||
Loading…
Reference in a new issue