Skip to content

Commit

Permalink
Support passing game.start_command 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}}"
    ]
  },
  "engine": "Unreal",
  "unityBackend": null
}
```
  • Loading branch information
keton committed Jan 15, 2024
1 parent 40553b3 commit 02f5085
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 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,7 @@ serializable_enum!(RunnableParameter {
ExecutableName,
ExecutablePath,
GameJson,
StartCommand,
});

#[async_trait]
Expand Down Expand Up @@ -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(_, _) => Err(Error::AppInfoNotFound(String::from("Provider command not found")))
}
None => Err(Error::AppInfoNotFound(String::from("Provider command not found")))
}
});

result
}
Expand Down

0 comments on commit 02f5085

Please sign in to comment.