1
0
Fork 0

removed unnecessary command args

This commit is contained in:
Kim, Jimin 2022-01-27 16:08:27 +09:00
parent cb77b67e8e
commit bbe2bdf72d
4 changed files with 21 additions and 20 deletions

View file

@ -3,10 +3,17 @@ use tauri::Window;
use super::{InstallErr, InstallResult};
use crate::commands::install::{emit, InstallSteps};
pub async fn launch_game_once(window: &Window) -> Result<InstallResult, InstallErr> {
pub async fn launch_game_once(
window: &Window,
was_game_launched: bool,
) -> Result<InstallResult, InstallErr> {
println!();
println!("Launch Game once");
if was_game_launched {
return Ok(InstallResult::Skip);
}
emit(&window, InstallSteps::LaunchGame);
return Ok(InstallResult::LaunchGame); // stop install
}

View file

@ -52,7 +52,12 @@ fn is_already_set() -> bool {
match fs::read_to_string(localconfig_path) {
Ok(content) => {
return content.contains("./run_bepinex.sh %command%");
// todo: improve logic
// 1. find line only containing "750470"
// 2. find next closest line only containing "}"
// 3. check if section contains "./run_bepinex.sh %command%"
return content.contains("./run_bepinex.sh %command%") && content.contains("750470");
}
Err(err) => {

View file

@ -70,13 +70,11 @@ struct InstallPayload(i64);
///
/// * `window` - standard tauri argument. See [docs](https://tauri.studio/docs/guides/command#accessing-the-window-in-commands) for more info.
/// * `game_path` - absolute path to the game folder/directory.
/// * `is_launch_option_set` - whether if the steam launch option for the game is set or not.
/// * `was_game_launched` - whether if the game was launched once after installing BepInEx to generate the plugins folder.
#[tauri::command]
pub async fn install(
window: Window,
game_path: String,
is_launch_option_set: bool,
was_game_launched: bool,
) -> Result<InstallResult, InstallErr> {
println!("install command called");
@ -118,29 +116,25 @@ pub async fn install(
// Install BepInEx
//
if !is_launch_option_set {
match install_bepinex::install_bepinex(&window, game_path).await {
Ok(()) => {}
Err(err) => return Err(err),
}
match install_bepinex::install_bepinex(&window, game_path).await {
Ok(()) => {}
Err(err) => return Err(err),
}
//
// Setup steam launch option if OS is linux or macOS
//
if !was_game_launched {
match launch_options::unix_launch_option_setup(&window).await {
Ok(_) => {}
Err(err) => return Err(err),
}
match launch_options::unix_launch_option_setup(&window).await {
Ok(_) => {}
Err(err) => return Err(err),
}
//
// Run the game once to generate the plugins directory
//
match launch_game::launch_game_once(&window).await {
match launch_game::launch_game_once(&window, was_game_launched).await {
Ok(res) => {
if res != InstallResult::Skip {
return Ok(res);

View file

@ -20,7 +20,6 @@
interface Args {
gamePath: string
isLaunchOptionSet: boolean
wasGameLaunched: boolean
}
@ -92,7 +91,6 @@
function install() {
_install({
gamePath: _gamePath,
isLaunchOptionSet: false,
wasGameLaunched: false,
})
}
@ -105,7 +103,6 @@
_gamePath = value as string
_install({
gamePath: _gamePath,
isLaunchOptionSet: false,
wasGameLaunched: false,
})
})
@ -117,7 +114,6 @@
function setSteamLaunchOptionAndInstall() {
_install({
gamePath: _gamePath,
isLaunchOptionSet: true,
wasGameLaunched: false,
})
}
@ -128,7 +124,6 @@
function launchGameAndInstall() {
_install({
gamePath: _gamePath,
isLaunchOptionSet: true,
wasGameLaunched: true,
})
}