From cd76037015899b2a319acd2e5c4e5e161d46b4c4 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Thu, 17 Aug 2023 12:32:18 +0200 Subject: [PATCH] feat: add `%launch_args%` to other games as well --- src/games/honkai/game.rs | 16 ++++++++++------ src/games/pgr/game.rs | 22 ++++++++++++++++------ src/games/star_rail/game.rs | 14 +++++++++----- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/games/honkai/game.rs b/src/games/honkai/game.rs index aee3c92..2cd26f6 100644 --- a/src/games/honkai/game.rs +++ b/src/games/honkai/game.rs @@ -75,9 +75,11 @@ pub fn run() -> anyhow::Result<()> { } // Prepare bash -c '' + // %command% = %bash_command% %windows_command% %launch_args% let mut bash_command = String::new(); let mut windows_command = String::new(); + let mut launch_args = String::new(); if config.game.enhancements.gamemode { bash_command += "gamemoderun "; @@ -98,12 +100,12 @@ pub fn run() -> anyhow::Result<()> { windows_command += &format!("'{}/jadeite.exe' 'Z:\\{}/BH3.exe' -- ", folders.patch.to_string_lossy(), folders.game.to_string_lossy()); if config.game.wine.borderless { - windows_command += "-screen-fullscreen 0 -popupwindow "; + launch_args += "-screen-fullscreen 0 -popupwindow "; } // https://notabug.org/Krock/dawn/src/master/TWEAKS.md if config.game.enhancements.fsr.enabled { - windows_command += "-window-mode exclusive "; + launch_args += "-window-mode exclusive "; } // gamescope -- @@ -113,9 +115,10 @@ pub fn run() -> anyhow::Result<()> { // Bundle all windows arguments used to run the game into a single file if features.compact_launch { - std::fs::write(folders.game.join("compact_launch.bat"), format!("start {windows_command}\nexit"))?; + std::fs::write(folders.game.join("compact_launch.bat"), format!("start {windows_command} {launch_args}\nexit"))?; windows_command = String::from("compact_launch.bat"); + launch_args = String::new(); } // bwrap -- @@ -159,12 +162,13 @@ pub fn run() -> anyhow::Result<()> { bash_command = match &config.game.command { // Use user-given launch command Some(command) => replace_keywords(command, &folders) - .replace("%command%", &format!("{bash_command} {windows_command}")) + .replace("%command%", &format!("{bash_command} {windows_command} {launch_args}")) .replace("%bash_command%", &bash_command) - .replace("%windows_command%", &windows_command), + .replace("%windows_command%", &windows_command) + .replace("%launch_args%", &launch_args), // Combine bash and windows parts of the command - None => format!("{bash_command} {windows_command}") + None => format!("{bash_command} {windows_command} {launch_args}") }; let mut command = Command::new("bash"); diff --git a/src/games/pgr/game.rs b/src/games/pgr/game.rs index 8d36568..fbf79be 100644 --- a/src/games/pgr/game.rs +++ b/src/games/pgr/game.rs @@ -71,9 +71,11 @@ pub fn run() -> anyhow::Result<()> { } // Prepare bash -c '' + // %command% = %bash_command% %windows_command% %launch_args% let mut bash_command = String::new(); let mut windows_command = String::new(); + let mut launch_args = String::new(); if config.game.enhancements.gamemode { bash_command += "gamemoderun "; @@ -94,12 +96,12 @@ pub fn run() -> anyhow::Result<()> { windows_command += "PGR.exe "; if config.game.wine.borderless { - windows_command += "-screen-fullscreen 0 -popupwindow "; + launch_args += "-screen-fullscreen 0 -popupwindow "; } // https://notabug.org/Krock/dawn/src/master/TWEAKS.md if config.game.enhancements.fsr.enabled { - windows_command += "-window-mode exclusive "; + launch_args += "-window-mode exclusive "; } // gamescope -- @@ -109,9 +111,10 @@ pub fn run() -> anyhow::Result<()> { // Bundle all windows arguments used to run the game into a single file if features.compact_launch { - std::fs::write(folders.game.join("compact_launch.bat"), format!("start {windows_command}\nexit"))?; + std::fs::write(folders.game.join("compact_launch.bat"), format!("start {windows_command} {launch_args}\nexit"))?; windows_command = String::from("compact_launch.bat"); + launch_args = String::new(); } // bwrap -- @@ -136,6 +139,12 @@ pub fn run() -> anyhow::Result<()> { .replace(folders.game.to_str().unwrap(), sandboxed_folders.game.to_str().unwrap()) .replace(folders.temp.to_str().unwrap(), sandboxed_folders.temp.to_str().unwrap()); + windows_command = windows_command + .replace(folders.wine.to_str().unwrap(), sandboxed_folders.wine.to_str().unwrap()) + .replace(folders.prefix.to_str().unwrap(), sandboxed_folders.prefix.to_str().unwrap()) + .replace(folders.game.to_str().unwrap(), sandboxed_folders.game.to_str().unwrap()) + .replace(folders.temp.to_str().unwrap(), sandboxed_folders.temp.to_str().unwrap()); + bash_command = format!("{bwrap} --chdir /tmp/sandbox/game -- {bash_command}"); folders = sandboxed_folders; } @@ -144,12 +153,13 @@ pub fn run() -> anyhow::Result<()> { bash_command = match &config.game.command { // Use user-given launch command Some(command) => replace_keywords(command, &folders) - .replace("%command%", &format!("{bash_command} {windows_command}")) + .replace("%command%", &format!("{bash_command} {windows_command} {launch_args}")) .replace("%bash_command%", &bash_command) - .replace("%windows_command%", &windows_command), + .replace("%windows_command%", &windows_command) + .replace("%launch_args%", &launch_args), // Combine bash and windows parts of the command - None => format!("{bash_command} {windows_command}") + None => format!("{bash_command} {windows_command} {launch_args}") }; let mut command = Command::new("bash"); diff --git a/src/games/star_rail/game.rs b/src/games/star_rail/game.rs index 76319ec..e8aa043 100644 --- a/src/games/star_rail/game.rs +++ b/src/games/star_rail/game.rs @@ -75,9 +75,11 @@ pub fn run() -> anyhow::Result<()> { } // Prepare bash -c '' + // %command% = %bash_command% %windows_command% %launch_args% let mut bash_command = String::new(); let mut windows_command = String::new(); + let mut launch_args = String::new(); if config.game.enhancements.gamemode { bash_command += "gamemoderun "; @@ -98,12 +100,12 @@ pub fn run() -> anyhow::Result<()> { windows_command += &format!("'{}/jadeite.exe' 'Z:\\{}/StarRail.exe' -- ", folders.patch.to_string_lossy(), folders.game.to_string_lossy()); if config.game.wine.borderless { - windows_command += "-screen-fullscreen 0 -popupwindow "; + launch_args += "-screen-fullscreen 0 -popupwindow "; } // https://notabug.org/Krock/dawn/src/master/TWEAKS.md if config.game.enhancements.fsr.enabled { - windows_command += "-window-mode exclusive "; + launch_args += "-window-mode exclusive "; } // gamescope -- @@ -113,9 +115,10 @@ pub fn run() -> anyhow::Result<()> { // Bundle all windows arguments used to run the game into a single file if features.compact_launch { - std::fs::write(folders.game.join("compact_launch.bat"), format!("start {windows_command}\nexit"))?; + std::fs::write(folders.game.join("compact_launch.bat"), format!("start {windows_command} {launch_args}\nexit"))?; windows_command = String::from("compact_launch.bat"); + launch_args = String::new(); } // bwrap -- @@ -161,10 +164,11 @@ pub fn run() -> anyhow::Result<()> { Some(command) => replace_keywords(command, &folders) .replace("%command%", &format!("{bash_command} {windows_command}")) .replace("%bash_command%", &bash_command) - .replace("%windows_command%", &windows_command), + .replace("%windows_command%", &windows_command) + .replace("%launch_args%", &launch_args), // Combine bash and windows parts of the command - None => format!("{bash_command} {windows_command}") + None => format!("{bash_command} {windows_command} {launch_args}") }; let mut command = Command::new("bash");