2025-04-19 23:10:11 -04:00
|
|
|
use serde::Deserialize;
|
|
|
|
|
2025-04-20 11:43:19 -04:00
|
|
|
#[derive(Deserialize, Default)]
|
2025-04-19 23:10:11 -04:00
|
|
|
pub struct Config {
|
2025-04-20 11:43:19 -04:00
|
|
|
pub launcher_url: Option<String>,
|
|
|
|
pub winhttp_proxy: Option<String>,
|
2025-04-22 15:45:08 -04:00
|
|
|
#[serde(default = "Config::default_disable_webview2_install")]
|
|
|
|
pub disable_webview2_install: bool,
|
|
|
|
#[serde(default = "Config::default_disable_boot_version_check")]
|
|
|
|
pub disable_boot_version_check: bool,
|
2025-05-03 15:13:23 -04:00
|
|
|
#[serde(default = "Config::default_force_http")]
|
|
|
|
pub force_http: bool,
|
|
|
|
pub game_patch_server: Option<String>,
|
2025-04-22 15:45:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Config {
|
|
|
|
fn default_disable_webview2_install() -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
fn default_disable_boot_version_check() -> bool {
|
|
|
|
false
|
|
|
|
}
|
2025-05-03 15:13:23 -04:00
|
|
|
|
|
|
|
fn default_force_http() -> bool {
|
|
|
|
false
|
|
|
|
}
|
2025-04-19 23:10:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_config() -> Config {
|
|
|
|
std::env::current_exe()
|
|
|
|
.ok()
|
|
|
|
.and_then(|p| std::fs::read_to_string(p.join("../launchertweaks.toml")).ok())
|
|
|
|
.and_then(|s| toml::from_str::<Config>(&s).ok())
|
|
|
|
.unwrap_or_default()
|
|
|
|
}
|