feat: add %launch_args% to other games as well

This commit is contained in:
Observer KRypt0n_ 2023-08-17 12:32:18 +02:00
parent 0f2163d22d
commit cd76037015
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
3 changed files with 35 additions and 17 deletions

View file

@ -75,9 +75,11 @@ pub fn run() -> anyhow::Result<()> {
} }
// Prepare bash -c '<command>' // Prepare bash -c '<command>'
// %command% = %bash_command% %windows_command% %launch_args%
let mut bash_command = String::new(); let mut bash_command = String::new();
let mut windows_command = String::new(); let mut windows_command = String::new();
let mut launch_args = String::new();
if config.game.enhancements.gamemode { if config.game.enhancements.gamemode {
bash_command += "gamemoderun "; 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()); windows_command += &format!("'{}/jadeite.exe' 'Z:\\{}/BH3.exe' -- ", folders.patch.to_string_lossy(), folders.game.to_string_lossy());
if config.game.wine.borderless { 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 // https://notabug.org/Krock/dawn/src/master/TWEAKS.md
if config.game.enhancements.fsr.enabled { if config.game.enhancements.fsr.enabled {
windows_command += "-window-mode exclusive "; launch_args += "-window-mode exclusive ";
} }
// gamescope <params> -- <command to run> // gamescope <params> -- <command to run>
@ -113,9 +115,10 @@ pub fn run() -> anyhow::Result<()> {
// Bundle all windows arguments used to run the game into a single file // Bundle all windows arguments used to run the game into a single file
if features.compact_launch { 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"); windows_command = String::from("compact_launch.bat");
launch_args = String::new();
} }
// bwrap <params> -- <command to run> // bwrap <params> -- <command to run>
@ -159,12 +162,13 @@ pub fn run() -> anyhow::Result<()> {
bash_command = match &config.game.command { bash_command = match &config.game.command {
// Use user-given launch command // Use user-given launch command
Some(command) => replace_keywords(command, &folders) 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("%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 // 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"); let mut command = Command::new("bash");

View file

@ -71,9 +71,11 @@ pub fn run() -> anyhow::Result<()> {
} }
// Prepare bash -c '<command>' // Prepare bash -c '<command>'
// %command% = %bash_command% %windows_command% %launch_args%
let mut bash_command = String::new(); let mut bash_command = String::new();
let mut windows_command = String::new(); let mut windows_command = String::new();
let mut launch_args = String::new();
if config.game.enhancements.gamemode { if config.game.enhancements.gamemode {
bash_command += "gamemoderun "; bash_command += "gamemoderun ";
@ -94,12 +96,12 @@ pub fn run() -> anyhow::Result<()> {
windows_command += "PGR.exe "; windows_command += "PGR.exe ";
if config.game.wine.borderless { 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 // https://notabug.org/Krock/dawn/src/master/TWEAKS.md
if config.game.enhancements.fsr.enabled { if config.game.enhancements.fsr.enabled {
windows_command += "-window-mode exclusive "; launch_args += "-window-mode exclusive ";
} }
// gamescope <params> -- <command to run> // gamescope <params> -- <command to run>
@ -109,9 +111,10 @@ pub fn run() -> anyhow::Result<()> {
// Bundle all windows arguments used to run the game into a single file // Bundle all windows arguments used to run the game into a single file
if features.compact_launch { 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"); windows_command = String::from("compact_launch.bat");
launch_args = String::new();
} }
// bwrap <params> -- <command to run> // bwrap <params> -- <command to run>
@ -136,6 +139,12 @@ pub fn run() -> anyhow::Result<()> {
.replace(folders.game.to_str().unwrap(), sandboxed_folders.game.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()); .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}"); bash_command = format!("{bwrap} --chdir /tmp/sandbox/game -- {bash_command}");
folders = sandboxed_folders; folders = sandboxed_folders;
} }
@ -144,12 +153,13 @@ pub fn run() -> anyhow::Result<()> {
bash_command = match &config.game.command { bash_command = match &config.game.command {
// Use user-given launch command // Use user-given launch command
Some(command) => replace_keywords(command, &folders) 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("%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 // 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"); let mut command = Command::new("bash");

View file

@ -75,9 +75,11 @@ pub fn run() -> anyhow::Result<()> {
} }
// Prepare bash -c '<command>' // Prepare bash -c '<command>'
// %command% = %bash_command% %windows_command% %launch_args%
let mut bash_command = String::new(); let mut bash_command = String::new();
let mut windows_command = String::new(); let mut windows_command = String::new();
let mut launch_args = String::new();
if config.game.enhancements.gamemode { if config.game.enhancements.gamemode {
bash_command += "gamemoderun "; 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()); windows_command += &format!("'{}/jadeite.exe' 'Z:\\{}/StarRail.exe' -- ", folders.patch.to_string_lossy(), folders.game.to_string_lossy());
if config.game.wine.borderless { 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 // https://notabug.org/Krock/dawn/src/master/TWEAKS.md
if config.game.enhancements.fsr.enabled { if config.game.enhancements.fsr.enabled {
windows_command += "-window-mode exclusive "; launch_args += "-window-mode exclusive ";
} }
// gamescope <params> -- <command to run> // gamescope <params> -- <command to run>
@ -113,9 +115,10 @@ pub fn run() -> anyhow::Result<()> {
// Bundle all windows arguments used to run the game into a single file // Bundle all windows arguments used to run the game into a single file
if features.compact_launch { 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"); windows_command = String::from("compact_launch.bat");
launch_args = String::new();
} }
// bwrap <params> -- <command to run> // bwrap <params> -- <command to run>
@ -161,10 +164,11 @@ pub fn run() -> anyhow::Result<()> {
Some(command) => replace_keywords(command, &folders) Some(command) => replace_keywords(command, &folders)
.replace("%command%", &format!("{bash_command} {windows_command}")) .replace("%command%", &format!("{bash_command} {windows_command}"))
.replace("%bash_command%", &bash_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 // 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"); let mut command = Command::new("bash");