Skip to content

Commit

Permalink
Support passing launcher information to mods
Browse files Browse the repository at this point in the history
This change together with praydog/uevr-frontend#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}}", "--launch_args={{StartCommandArgs}}"
    ]
  },
  "engine": "Unreal",
  "unityBackend": null
}
```
  • Loading branch information
keton committed Jun 17, 2024
1 parent 3805280 commit cf6c289
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion backend/src/mod_loaders/runnable_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{
result::Error,
serializable_enum,
serializable_struct,
Result,
Result, providers::provider_command::ProviderCommand,
};

serializable_struct!(RunnableLoader {
Expand All @@ -38,6 +38,8 @@ serializable_enum!(RunnableParameter {
ExecutableName,
ExecutablePath,
GameJson,
StartCommand,
StartCommandArgs,
});

impl ModLoaderStatic for RunnableLoader {
Expand Down Expand Up @@ -91,6 +93,24 @@ 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(exe_path, _) => Ok(exe_path.to_string_lossy().to_string())
}
None => Ok(game.executable.path.to_string_lossy().to_string()) // fallback to path
}
});
result = replace_parameter_value(&result, RunnableParameter::StartCommandArgs, || {
match &game.start_command {
Some(provider_command) => match provider_command {
ProviderCommand::Path(_, args) => Ok(args.join(" ")),
_ => Ok(String::from("")),
}
_ => Ok(String::from("")),
}
});

result
}
Expand Down

0 comments on commit cf6c289

Please sign in to comment.