use serde::{Deserialize, Serialize}; use std::path::PathBuf; use std::string::String; // Config may not exist, or may be old, so it's okay if these are optional #[derive(Serialize, Deserialize, Debug)] pub struct Configuration { pub toggle_grasscutter: Option, pub game_install_path: Option, pub grasscutter_with_game: Option, pub grasscutter_path: Option, pub java_path: Option, pub close_action: Option, pub startup_launch: Option, pub last_ip: Option, pub last_port: Option, pub language: Option, pub custom_background: Option, pub cert_generated: Option, pub theme: Option, pub https_enabled: Option, pub debug_enabled: Option, pub patch_rsa: Option, pub use_internal_proxy: Option, pub wipe_login: Option, pub horny_mode: Option, pub auto_mongodb: Option, pub un_elevated: Option, pub redirect_more: Option, } pub fn config_path() -> PathBuf { let mut path = tauri::api::path::data_dir().unwrap(); path.push("cultivation"); path.push("configuration.json"); path } pub fn get_config() -> Configuration { let path = config_path(); let config = std::fs::read_to_string(path).unwrap_or("{}".to_string()); let config: Configuration = serde_json::from_str(&config).unwrap(); config }