moved get game path logic to separate function
This commit is contained in:
parent
b521039687
commit
5e5a9869c1
1 changed files with 24 additions and 14 deletions
|
@ -48,21 +48,10 @@ pub async fn install(window: Window, game_path: String) -> i64 {
|
||||||
// get game path
|
// get game path
|
||||||
//
|
//
|
||||||
|
|
||||||
let game_path = if game_path.is_empty() {
|
let game_path = match get_game_path(game_path) {
|
||||||
// if game_path argument is empty, get the default path
|
Ok(game_path) => game_path,
|
||||||
|
|
||||||
let default_game_path = util::get_default_game_path();
|
Err(err) => return err as i64,
|
||||||
if default_game_path.is_none() {
|
|
||||||
// failed to find game install location.
|
|
||||||
// Prompt user to manually choose the game location.
|
|
||||||
return InstallResult::FailedToGetGamePath as i64;
|
|
||||||
}
|
|
||||||
default_game_path.unwrap()
|
|
||||||
} else {
|
|
||||||
// otherwise, use the passed value
|
|
||||||
|
|
||||||
// todo: check if game path is valid
|
|
||||||
game_path
|
|
||||||
};
|
};
|
||||||
let game_path = game_path.as_str();
|
let game_path = game_path.as_str();
|
||||||
|
|
||||||
|
@ -100,6 +89,27 @@ pub async fn install(window: Window, game_path: String) -> i64 {
|
||||||
return InstallResult::NoErr as i64;
|
return InstallResult::NoErr as i64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_game_path(game_path: String) -> Result<String, InstallResult> {
|
||||||
|
let game_path = if game_path.is_empty() {
|
||||||
|
// if game_path argument is empty, get the default path
|
||||||
|
|
||||||
|
let default_game_path = util::get_default_game_path();
|
||||||
|
if default_game_path.is_none() {
|
||||||
|
// failed to find game install location.
|
||||||
|
// Prompt user to manually choose the game location.
|
||||||
|
return Err(InstallResult::FailedToGetGamePath);
|
||||||
|
}
|
||||||
|
default_game_path.unwrap()
|
||||||
|
} else {
|
||||||
|
// otherwise, use the passed value
|
||||||
|
|
||||||
|
// todo: check if game path is valid
|
||||||
|
game_path
|
||||||
|
};
|
||||||
|
|
||||||
|
return Ok(game_path);
|
||||||
|
}
|
||||||
|
|
||||||
async fn install_bepinex(window: &Window, game_path: &str) -> Result<(), InstallResult> {
|
async fn install_bepinex(window: &Window, game_path: &str) -> Result<(), InstallResult> {
|
||||||
println!("Installing BepInEx");
|
println!("Installing BepInEx");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue