From e1fee118d690f28eae1fa85a90c542e4ea110c6f Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Fri, 19 Dec 2025 17:57:32 +0100 Subject: [PATCH] ask to delete old setup on cli --- babylonia-terminal-cli/src/game.rs | 24 +++++++++++++++++++++++ babylonia-terminal-sdk/src/game_config.rs | 2 ++ babylonia-terminal-sdk/src/utils/mod.rs | 15 ++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/babylonia-terminal-cli/src/game.rs b/babylonia-terminal-cli/src/game.rs index eda23d4..9863354 100644 --- a/babylonia-terminal-cli/src/game.rs +++ b/babylonia-terminal-cli/src/game.rs @@ -24,6 +24,30 @@ pub async fn run( let mut wine_component: Option = None; let mut wine: Option = None; + // Deleting old setup + if None == GameConfig::get_config().await.launcher_version { + info!("You seem to have the old setup to play the game."); + info!("do you want to delete it to setup the new one ? (y/n) (default - yes): "); + + let input = BufReader::new(tokio::io::stdin()) + .lines() + .next_line() + .await + .unwrap(); + + if None == input + || Some("".to_string()) == input + || Some("y".to_string()) == input + || Some("yes".to_string()) == input + { + info!("Deleting old setup..."); + babylonia_terminal_sdk::utils::remove_setup().await; + info!("done!"); + } else { + info!("Keeping old setup..."); + } + } + loop { let state_result = GameState::get_current_state().await; if let Err(error) = state_result { diff --git a/babylonia-terminal-sdk/src/game_config.rs b/babylonia-terminal-sdk/src/game_config.rs index 0b39c8e..b0feded 100644 --- a/babylonia-terminal-sdk/src/game_config.rs +++ b/babylonia-terminal-sdk/src/game_config.rs @@ -18,6 +18,7 @@ pub struct GameConfig { pub is_game_installed: bool, pub is_game_patched: bool, pub launch_options: Option, + pub launcher_version: Option, } impl GameConfig { @@ -100,6 +101,7 @@ impl Default for GameConfig { is_game_installed: false, is_game_patched: false, launch_options: None, + launcher_version: Some(env!("CARGO_PKG_VERSION").to_string()), } } } diff --git a/babylonia-terminal-sdk/src/utils/mod.rs b/babylonia-terminal-sdk/src/utils/mod.rs index 3d41723..ca66b68 100644 --- a/babylonia-terminal-sdk/src/utils/mod.rs +++ b/babylonia-terminal-sdk/src/utils/mod.rs @@ -1,3 +1,10 @@ +use std::io; + +use log::debug; +use tokio::fs::remove_dir_all; + +use crate::game_config::GameConfig; + pub mod github_requester; pub mod kuro_prod_api; @@ -8,3 +15,11 @@ pub fn get_game_name() -> String { pub fn get_game_name_with_executable() -> String { format!("{}.exe", get_game_name()) } + +pub async fn remove_setup() -> io::Result<()> { + let config_dir = GameConfig::get_config_directory().await; + + debug!("Current setup directory : {:?}", config_dir); + + remove_dir_all(config_dir).await +}