feat(genshin): allowed to launch the game without launcher.bat
file
This commit is contained in:
parent
cedb6f05b5
commit
1e75e23692
1 changed files with 25 additions and 8 deletions
|
@ -50,6 +50,13 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
let config = Config::get()?;
|
let config = Config::get()?;
|
||||||
|
|
||||||
|
let game_executable = config.patch.apply
|
||||||
|
.then_some("launcher.bat")
|
||||||
|
.unwrap_or_else(|| match config.launcher.edition {
|
||||||
|
genshin::GameEdition::Global => "GenshinImpact.exe",
|
||||||
|
genshin::GameEdition::China => "YuanShen.exe"
|
||||||
|
});
|
||||||
|
|
||||||
let game_path = config.game.path.for_edition(config.launcher.edition);
|
let game_path = config.game.path.for_edition(config.launcher.edition);
|
||||||
|
|
||||||
if !game_path.exists() {
|
if !game_path.exists() {
|
||||||
|
@ -110,15 +117,23 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
return Err(anyhow::anyhow!("Failed to update FPS unlocker config: {err}"));
|
return Err(anyhow::anyhow!("Failed to update FPS unlocker config: {err}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let bat_path = game_path.join("fps_unlocker.bat");
|
let launcher_bat = game_path.join("launcher.bat");
|
||||||
let original_bat_path = game_path.join("launcher.bat");
|
let fps_unlocker_bat = game_path.join("fps_unlocker.bat");
|
||||||
|
|
||||||
// Generate fpsunlocker.bat from launcher.bat
|
// Generate fps_unlocker.bat
|
||||||
std::fs::write(bat_path, std::fs::read_to_string(original_bat_path)?
|
if config.patch.apply {
|
||||||
|
std::fs::write(fps_unlocker_bat, std::fs::read_to_string(launcher_bat)?
|
||||||
.replace("start GenshinImpact.exe %*", &format!("start GenshinImpact.exe %*\n\nZ:\ncd \"{}\"\nstart unlocker.exe", unlocker.dir().to_string_lossy()))
|
.replace("start GenshinImpact.exe %*", &format!("start GenshinImpact.exe %*\n\nZ:\ncd \"{}\"\nstart unlocker.exe", unlocker.dir().to_string_lossy()))
|
||||||
.replace("start YuanShen.exe %*", &format!("start YuanShen.exe %*\n\nZ:\ncd \"{}\"\nstart unlocker.exe", unlocker.dir().to_string_lossy())))?;
|
.replace("start YuanShen.exe %*", &format!("start YuanShen.exe %*\n\nZ:\ncd \"{}\"\nstart unlocker.exe", unlocker.dir().to_string_lossy())))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
// 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(fps_unlocker_bat, format!("start {game_executable} %*\n\nZ:\ncd \"{}\"\nstart unlocker.exe", unlocker.dir().to_string_lossy()))?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Generate `config.ini` if environment emulation feature is presented
|
// Generate `config.ini` if environment emulation feature is presented
|
||||||
|
|
||||||
#[cfg(feature = "environment-emulation")] {
|
#[cfg(feature = "environment-emulation")] {
|
||||||
|
@ -154,9 +169,11 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
windows_command += if config.game.enhancements.fps_unlocker.enabled && cfg!(feature = "fps-unlocker") {
|
windows_command += if config.game.enhancements.fps_unlocker.enabled && cfg!(feature = "fps-unlocker") {
|
||||||
"fps_unlocker.bat"
|
"fps_unlocker.bat"
|
||||||
} else {
|
} else {
|
||||||
"launcher.bat "
|
game_executable
|
||||||
};
|
};
|
||||||
|
|
||||||
|
windows_command += " ";
|
||||||
|
|
||||||
if config.game.wine.borderless {
|
if config.game.wine.borderless {
|
||||||
windows_command += "-screen-fullscreen 0 -popupwindow ";
|
windows_command += "-screen-fullscreen 0 -popupwindow ";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue