Skip to content

Commit

Permalink
Fixed launching Steam games through LaunchBox
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Oct 4, 2021
1 parent 73938a4 commit fff1a5b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/backend/providers/launchbox/LaunchBoxGamelistXml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -66,10 +65,9 @@ enum class AppField : unsigned char {
void apply_game_fields(
const HashMap<GameField, QString>& fields,
model::Game& game,
const HashMap<QString, Emulator>& emulators)
const HashMap<QString, Emulator>& emulators,
const QString& steam_call)
{
const QString steam_call(providers::find_steam_call());

QString emu_id;
QString emu_params;
QString emu_platform_name;
Expand Down Expand Up @@ -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)));
Expand Down Expand Up @@ -368,6 +366,7 @@ HashMap<AppField, QString> GamelistXml::read_app_node(QXmlStreamReader& xml) con
std::vector<model::Game*> GamelistXml::find_games_for(
const Platform& platform,
const HashMap<QString, Emulator>& 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
Expand Down Expand Up @@ -441,7 +440,7 @@ std::vector<model::Game*> 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;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/providers/launchbox/LaunchBoxGamelistXml.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GamelistXml {
public:
explicit GamelistXml(QString, QDir);

std::vector<model::Game*> find_games_for(const Platform&, const HashMap<QString, Emulator>&, SearchContext&) const;
std::vector<model::Game*> find_games_for(const Platform&, const HashMap<QString, Emulator>&, const QString&, SearchContext&) const;

private:
const QString m_log_tag;
Expand Down
5 changes: 4 additions & 1 deletion src/backend/providers/launchbox/LaunchBoxProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -64,6 +65,8 @@ Provider& LaunchboxProvider::run(providers::SearchContext& sctx)
return *this;
}

const QString steam_call = providers::find_steam_call();

const HashMap<QString, Emulator> emulators = EmulatorsXml(display_name(), lb_dir).find();
// NOTE: It's okay to not have any emulators

Expand All @@ -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<model::Game*> games = metahelper.find_games_for(platform, emulators, sctx);
const std::vector<model::Game*> games = metahelper.find_games_for(platform, emulators, steam_call, sctx);
progress += progress_step;
emit progressChanged(progress);

Expand Down

0 comments on commit fff1a5b

Please sign in to comment.