From fff1a5b2390aaa195d644b651e54c27c2a9b8a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Mustoha?= Date: Mon, 4 Oct 2021 21:25:59 +0200 Subject: [PATCH] Fixed launching Steam games through LaunchBox --- .../providers/launchbox/LaunchBoxGamelistXml.cpp | 11 +++++------ .../providers/launchbox/LaunchBoxGamelistXml.h | 2 +- src/backend/providers/launchbox/LaunchBoxProvider.cpp | 5 ++++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/backend/providers/launchbox/LaunchBoxGamelistXml.cpp b/src/backend/providers/launchbox/LaunchBoxGamelistXml.cpp index 850a57882..2b8000af1 100644 --- a/src/backend/providers/launchbox/LaunchBoxGamelistXml.cpp +++ b/src/backend/providers/launchbox/LaunchBoxGamelistXml.cpp @@ -23,7 +23,6 @@ #include "model/gaming/Collection.h" #include "model/gaming/Game.h" #include "model/gaming/GameFile.h" -#include "providers/ProviderUtils.h" #include "providers/SearchContext.h" #include "providers/launchbox/LaunchBoxXml.h" #include "utils/PathTools.h" @@ -66,10 +65,9 @@ enum class AppField : unsigned char { void apply_game_fields( const HashMap& fields, model::Game& game, - const HashMap& emulators) + const HashMap& emulators, + const QString& steam_call) { - const QString steam_call(providers::find_steam_call()); - QString emu_id; QString emu_params; QString emu_platform_name; @@ -145,7 +143,7 @@ void apply_game_fields( if (emu_id.isEmpty()) { if (source == QLatin1String("Steam")) { - game.setLaunchCmd(steam_call % path); + game.setLaunchCmd(steam_call % QChar(' ') % path); } else { game.setLaunchCmd(QStringLiteral("{file.path}")); game.setLaunchWorkdir(::clean_abs_dir(QFileInfo(path))); @@ -368,6 +366,7 @@ HashMap GamelistXml::read_app_node(QXmlStreamReader& xml) con std::vector GamelistXml::find_games_for( const Platform& platform, const HashMap& emulators, + const QString& steam_call, SearchContext& sctx) const { const QString xml_rel_path = QStringLiteral("Data/Platforms/%1.xml").arg(platform.name); // TODO: Qt 5.14+ QLatin1String @@ -441,7 +440,7 @@ std::vector GamelistXml::find_games_for( } Q_ASSERT(game_ptr); - apply_game_fields(fields, *game_ptr, emulators); + apply_game_fields(fields, *game_ptr, emulators, steam_call); gameid_map.emplace(fields.at(GameField::ID), game_ptr); sctx.game_add_to(*game_ptr, collection); continue; diff --git a/src/backend/providers/launchbox/LaunchBoxGamelistXml.h b/src/backend/providers/launchbox/LaunchBoxGamelistXml.h index 0b0aadb01..3fcfd4a0b 100644 --- a/src/backend/providers/launchbox/LaunchBoxGamelistXml.h +++ b/src/backend/providers/launchbox/LaunchBoxGamelistXml.h @@ -41,7 +41,7 @@ class GamelistXml { public: explicit GamelistXml(QString, QDir); - std::vector find_games_for(const Platform&, const HashMap&, SearchContext&) const; + std::vector find_games_for(const Platform&, const HashMap&, const QString&, SearchContext&) const; private: const QString m_log_tag; diff --git a/src/backend/providers/launchbox/LaunchBoxProvider.cpp b/src/backend/providers/launchbox/LaunchBoxProvider.cpp index 5e6da4386..6bda3769f 100644 --- a/src/backend/providers/launchbox/LaunchBoxProvider.cpp +++ b/src/backend/providers/launchbox/LaunchBoxProvider.cpp @@ -19,6 +19,7 @@ #include "Log.h" #include "Paths.h" +#include "providers/ProviderUtils.h" #include "providers/launchbox/LaunchBoxAssets.h" #include "providers/launchbox/LaunchBoxEmulatorsXml.h" #include "providers/launchbox/LaunchBoxGamelistXml.h" @@ -64,6 +65,8 @@ Provider& LaunchboxProvider::run(providers::SearchContext& sctx) return *this; } + const QString steam_call = providers::find_steam_call(); + const HashMap emulators = EmulatorsXml(display_name(), lb_dir).find(); // NOTE: It's okay to not have any emulators @@ -73,7 +76,7 @@ Provider& LaunchboxProvider::run(providers::SearchContext& sctx) const GamelistXml metahelper(display_name(), lb_dir); const Assets assethelper(display_name(), lb_dir_path); for (const Platform& platform : platforms) { - const std::vector games = metahelper.find_games_for(platform, emulators, sctx); + const std::vector games = metahelper.find_games_for(platform, emulators, steam_call, sctx); progress += progress_step; emit progressChanged(progress);