From b2aa2d1fd8d1937e1e639de92378fc02bde320bd Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Thu, 17 Aug 2023 12:22:53 +0200 Subject: [PATCH] feat(genshin): added `%launch_args%` command magic word --- src/games/genshin/game.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/games/genshin/game.rs b/src/games/genshin/game.rs index 111750d..f18cf15 100644 --- a/src/games/genshin/game.rs +++ b/src/games/genshin/game.rs @@ -115,7 +115,6 @@ pub fn run() -> anyhow::Result<()> { return Err(anyhow::anyhow!("Failed to update FPS unlocker config: {err}")); } - // If patch applying is disabled, then game_executable is either GenshinImpact.exe or YuanShen.exe // so we don't need to check it here std::fs::write(game_path.join("fps_unlocker.bat"), format!("start {game_executable} %*\n\nZ:\ncd \"{}\"\nstart unlocker.exe", unlocker.dir().to_string_lossy()))?; @@ -133,9 +132,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 "; @@ -162,12 +163,12 @@ pub fn run() -> anyhow::Result<()> { windows_command += " "; 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 -- @@ -177,9 +178,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 -- @@ -212,12 +214,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");