diff options
| -rw-r--r-- | ozone-cli/src/cli.rs | 8 | ||||
| -rw-r--r-- | ozone-cli/src/main.rs | 8 | ||||
| -rw-r--r-- | ozone/src/launcher.rs | 7 |
3 files changed, 15 insertions, 8 deletions
diff --git a/ozone-cli/src/cli.rs b/ozone-cli/src/cli.rs index 8ed2f33..f94a912 100644 --- a/ozone-cli/src/cli.rs +++ b/ozone-cli/src/cli.rs @@ -211,6 +211,12 @@ pub struct AccountArgs { pub command: AccountCommand
}
+#[derive(Args, Debug)]
+pub struct LaunchArgs {
+ #[arg(long)]
+ pub demo: bool
+}
+
#[derive(Subcommand, Debug)]
pub enum RootCommand {
/// Manages instances.
@@ -224,7 +230,7 @@ pub enum RootCommand { Account(AccountArgs),
/// Launches the selected instance with the selected account.
- Launch
+ Launch(LaunchArgs)
}
#[derive(Parser, Debug)]
diff --git a/ozone-cli/src/main.rs b/ozone-cli/src/main.rs index 03f249a..f346d8d 100644 --- a/ozone-cli/src/main.rs +++ b/ozone-cli/src/main.rs @@ -418,7 +418,7 @@ async fn main_inner(cli: Cli) -> Result<ExitCode, Box<dyn Error>> { } } } - RootCommand::Launch => { + RootCommand::Launch(args) => { let Some(selection) = settings.selected_instance else { eprintln!("No instance selected."); return Ok(ExitCode::FAILURE); @@ -435,7 +435,7 @@ async fn main_inner(cli: Cli) -> Result<ExitCode, Box<dyn Error>> { eprintln!("No account selected."); return Ok(ExitCode::FAILURE); }; - + if let Account::MSA(msa_acct) = account { let client = MsaAccount::create_client(); @@ -456,7 +456,7 @@ async fn main_inner(cli: Cli) -> Result<ExitCode, Box<dyn Error>> { accounts.save(&accounts_path).await?; } - + let Some((_, account)) = accounts.get_selected_account() else { eprintln!("No account selected."); return Ok(ExitCode::FAILURE); @@ -465,7 +465,7 @@ async fn main_inner(cli: Cli) -> Result<ExitCode, Box<dyn Error>> { println!("Preparing the game files..."); let launcher = Launcher::new(&home, !cli.offline).await?; - let launch = launcher.prepare_launch(inst, Settings::get_instance_path(selection), settings.client_id, account, false).await.map_err(|e| { + let launch = launcher.prepare_launch(inst, Settings::get_instance_path(selection), settings.client_id, account, args.demo).await.map_err(|e| { error!("error launching: {e}"); e })?; diff --git a/ozone/src/launcher.rs b/ozone/src/launcher.rs index f724e46..84a7e5d 100644 --- a/ozone/src/launcher.rs +++ b/ozone/src/launcher.rs @@ -230,7 +230,8 @@ pub struct Launch { #[derive(Clone, Copy)] struct LaunchFeatureMatcher<'l> { instance: &'l Instance, - account: &'l Account + account: &'l Account, + force_demo: bool } impl<'a> FeatureMatcher<'a> for LaunchFeatureMatcher<'_> { @@ -238,7 +239,7 @@ impl<'a> FeatureMatcher<'a> for LaunchFeatureMatcher<'_> { match feature { "has_custom_resolution" => self.instance.resolution.is_some(), "__ozone_win10_hack" => false, // todo - "is_demo_user" => self.account.is_demo(), + "is_demo_user" => self.force_demo || self.account.is_demo(), _ => false } } @@ -328,7 +329,7 @@ impl Launcher { */ pub async fn prepare_launch(&self, instance: &Instance, inst_home: impl AsRef<Path>, client_id: Uuid, account: &Account, force_demo: bool) -> Result<Launch, LaunchError> { let start = Instant::now(); - let feature_matcher = LaunchFeatureMatcher { instance, account }; + let feature_matcher = LaunchFeatureMatcher { instance, account, force_demo }; let version_id = &instance.game_version; let version_id = self.versions.get_instance_version_id(version_id); |
