feat(genshin): added %launch_args% command magic word

This commit is contained in:
Observer KRypt0n_ 2023-08-17 12:22:53 +02:00
parent 916d4b56e0
commit b2aa2d1fd8
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2

View file

@ -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>'
// %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 <params> -- <command to run>
@ -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 <params> -- <command to run>
@ -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");