feat(honkai): updated game launching script
This commit is contained in:
parent
6662d6516d
commit
9edbca8db8
2 changed files with 17 additions and 2 deletions
|
@ -24,6 +24,7 @@ struct Folders {
|
|||
pub wine: PathBuf,
|
||||
pub prefix: PathBuf,
|
||||
pub game: PathBuf,
|
||||
pub patch: PathBuf,
|
||||
pub temp: PathBuf
|
||||
}
|
||||
|
||||
|
@ -34,6 +35,7 @@ fn replace_keywords(command: impl ToString, folders: &Folders) -> String {
|
|||
.replace("%temp%", folders.game.to_str().unwrap())
|
||||
.replace("%launcher%", &consts::launcher_dir().unwrap().to_string_lossy())
|
||||
.replace("%game%", folders.temp.to_str().unwrap())
|
||||
.replace("%patch%", folders.patch.to_str().unwrap())
|
||||
}
|
||||
|
||||
/// Try to run the game
|
||||
|
@ -59,6 +61,7 @@ pub fn run() -> anyhow::Result<()> {
|
|||
wine: config.game.wine.builds.join(&wine.name),
|
||||
prefix: config.game.wine.prefix.clone(),
|
||||
game: config.game.path.clone(),
|
||||
patch: config.patch.path.clone(),
|
||||
temp: config.launcher.temp.clone().unwrap_or(std::env::temp_dir())
|
||||
};
|
||||
|
||||
|
@ -91,7 +94,7 @@ pub fn run() -> anyhow::Result<()> {
|
|||
windows_command += " ";
|
||||
}
|
||||
|
||||
windows_command += "launch.bat ";
|
||||
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 ";
|
||||
|
@ -123,10 +126,13 @@ pub fn run() -> anyhow::Result<()> {
|
|||
folders.game.to_str().unwrap()
|
||||
);
|
||||
|
||||
let bwrap = format!("{bwrap} --bind '{}' /tmp/sandbox/patch", folders.patch.to_string_lossy());
|
||||
|
||||
let sandboxed_folders = Folders {
|
||||
wine: PathBuf::from("/tmp/sandbox/wine"),
|
||||
prefix: PathBuf::from("/tmp/sandbox/prefix"),
|
||||
game: PathBuf::from("/tmp/sandbox/game"),
|
||||
patch: PathBuf::from("/tmp/sandbox/patch"),
|
||||
temp: PathBuf::from("/tmp")
|
||||
};
|
||||
|
||||
|
@ -134,6 +140,14 @@ pub fn run() -> anyhow::Result<()> {
|
|||
.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.patch.to_str().unwrap(), sandboxed_folders.patch.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.patch.to_str().unwrap(), sandboxed_folders.patch.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}");
|
||||
|
|
|
@ -222,7 +222,8 @@ pub fn run() -> anyhow::Result<()> {
|
|||
|
||||
// We use real current dir here because sandboxed one
|
||||
// obviously doesn't exist
|
||||
command.current_dir(game_path).spawn()?.wait_with_output()?;
|
||||
command.current_dir(game_path)
|
||||
.spawn()?.wait_with_output()?;
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
let rpc = if config.launcher.discord_rpc.enabled {
|
||||
|
|
Loading…
Reference in a new issue