From a22e7d8bb8f28c813a62a56c07b8d86741bc8e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Lower?= Date: Mon, 15 Jan 2024 16:53:48 +0100 Subject: [PATCH] Support passing `game.start_command` to mods This change together with https://github.com/praydog/uevr-frontend/pull/9 will allow one click 'launch to VR' from within Rai Pal. This also introduces proper division of responsibility where Rai Pal knows what to launch and UEVRInjector knows how to launch it. On top of the code change UEVR `rai-pal-manifest.json` needs to look like this: ```json { "version": "1.03", "runnable": { "path": "UEVRInjector.exe", "args": [ "--attach={{ExecutableName}}", "--delay=30", "--launch={{StartCommand}}" ] }, "engine": "Unreal", "unityBackend": null } ``` --- backend/src/mod_loaders/runnable_loader.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/src/mod_loaders/runnable_loader.rs b/backend/src/mod_loaders/runnable_loader.rs index 65e98d63..5618bcd8 100644 --- a/backend/src/mod_loaders/runnable_loader.rs +++ b/backend/src/mod_loaders/runnable_loader.rs @@ -27,7 +27,7 @@ use crate::{ result::Error, serializable_enum, serializable_struct, - Result, + Result, providers::provider_command::ProviderCommand, }; serializable_struct!(RunnableLoader { @@ -38,6 +38,7 @@ serializable_enum!(RunnableParameter { ExecutableName, ExecutablePath, GameJson, + StartCommand, }); #[async_trait] @@ -92,6 +93,15 @@ fn replace_parameters(argument: &str, game: &InstalledGame) -> String { result = replace_parameter_value(&result, RunnableParameter::GameJson, || { Ok(serde_json::to_string(&game)?) }); + result = replace_parameter_value(&result, RunnableParameter::StartCommand, || { + match &game.start_command { + Some(provider_command) => match provider_command { + ProviderCommand::String(s) => Ok(s.to_string()), + ProviderCommand::Path(_, _) => Ok(game.executable.path.to_string_lossy().replacen("\\\\\\\\?\\\\", "", 1)) // for GOG we can use .exe directly + } + None => Ok(game.executable.path.to_string_lossy().replacen("\\\\\\\\?\\\\", "", 1)) // fallback to path + } + }); result }