removed unnecessary command args
This commit is contained in:
parent
cb77b67e8e
commit
bbe2bdf72d
4 changed files with 21 additions and 20 deletions
|
@ -3,10 +3,17 @@ use tauri::Window;
|
||||||
use super::{InstallErr, InstallResult};
|
use super::{InstallErr, InstallResult};
|
||||||
use crate::commands::install::{emit, InstallSteps};
|
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!();
|
||||||
println!("Launch Game once");
|
println!("Launch Game once");
|
||||||
|
|
||||||
|
if was_game_launched {
|
||||||
|
return Ok(InstallResult::Skip);
|
||||||
|
}
|
||||||
|
|
||||||
emit(&window, InstallSteps::LaunchGame);
|
emit(&window, InstallSteps::LaunchGame);
|
||||||
return Ok(InstallResult::LaunchGame); // stop install
|
return Ok(InstallResult::LaunchGame); // stop install
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,12 @@ fn is_already_set() -> bool {
|
||||||
|
|
||||||
match fs::read_to_string(localconfig_path) {
|
match fs::read_to_string(localconfig_path) {
|
||||||
Ok(content) => {
|
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) => {
|
Err(err) => {
|
||||||
|
|
|
@ -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.
|
/// * `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.
|
/// * `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.
|
/// * `was_game_launched` - whether if the game was launched once after installing BepInEx to generate the plugins folder.
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn install(
|
pub async fn install(
|
||||||
window: Window,
|
window: Window,
|
||||||
game_path: String,
|
game_path: String,
|
||||||
is_launch_option_set: bool,
|
|
||||||
was_game_launched: bool,
|
was_game_launched: bool,
|
||||||
) -> Result<InstallResult, InstallErr> {
|
) -> Result<InstallResult, InstallErr> {
|
||||||
println!("install command called");
|
println!("install command called");
|
||||||
|
@ -118,29 +116,25 @@ pub async fn install(
|
||||||
// Install BepInEx
|
// Install BepInEx
|
||||||
//
|
//
|
||||||
|
|
||||||
if !is_launch_option_set {
|
match install_bepinex::install_bepinex(&window, game_path).await {
|
||||||
match install_bepinex::install_bepinex(&window, game_path).await {
|
Ok(()) => {}
|
||||||
Ok(()) => {}
|
Err(err) => return Err(err),
|
||||||
Err(err) => return Err(err),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Setup steam launch option if OS is linux or macOS
|
// Setup steam launch option if OS is linux or macOS
|
||||||
//
|
//
|
||||||
|
|
||||||
if !was_game_launched {
|
match launch_options::unix_launch_option_setup(&window).await {
|
||||||
match launch_options::unix_launch_option_setup(&window).await {
|
Ok(_) => {}
|
||||||
Ok(_) => {}
|
Err(err) => return Err(err),
|
||||||
Err(err) => return Err(err),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Run the game once to generate the plugins directory
|
// 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) => {
|
Ok(res) => {
|
||||||
if res != InstallResult::Skip {
|
if res != InstallResult::Skip {
|
||||||
return Ok(res);
|
return Ok(res);
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
interface Args {
|
interface Args {
|
||||||
gamePath: string
|
gamePath: string
|
||||||
isLaunchOptionSet: boolean
|
|
||||||
wasGameLaunched: boolean
|
wasGameLaunched: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +91,6 @@
|
||||||
function install() {
|
function install() {
|
||||||
_install({
|
_install({
|
||||||
gamePath: _gamePath,
|
gamePath: _gamePath,
|
||||||
isLaunchOptionSet: false,
|
|
||||||
wasGameLaunched: false,
|
wasGameLaunched: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -105,7 +103,6 @@
|
||||||
_gamePath = value as string
|
_gamePath = value as string
|
||||||
_install({
|
_install({
|
||||||
gamePath: _gamePath,
|
gamePath: _gamePath,
|
||||||
isLaunchOptionSet: false,
|
|
||||||
wasGameLaunched: false,
|
wasGameLaunched: false,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -117,7 +114,6 @@
|
||||||
function setSteamLaunchOptionAndInstall() {
|
function setSteamLaunchOptionAndInstall() {
|
||||||
_install({
|
_install({
|
||||||
gamePath: _gamePath,
|
gamePath: _gamePath,
|
||||||
isLaunchOptionSet: true,
|
|
||||||
wasGameLaunched: false,
|
wasGameLaunched: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -128,7 +124,6 @@
|
||||||
function launchGameAndInstall() {
|
function launchGameAndInstall() {
|
||||||
_install({
|
_install({
|
||||||
gamePath: _gamePath,
|
gamePath: _gamePath,
|
||||||
isLaunchOptionSet: true,
|
|
||||||
wasGameLaunched: true,
|
wasGameLaunched: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue