diff --git a/Cargo.lock b/Cargo.lock index 365c387..26753cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3283,7 +3283,6 @@ dependencies = [ name = "shadplay" version = "0.0.1" dependencies = [ - "anyhow", "bevy", "bevy_egui", "bevy_panorbit_camera", diff --git a/Cargo.toml b/Cargo.toml index 597c929..81cda4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ default = ["ui"] ui = [] [dependencies] -anyhow = "1.0.75" bevy = { version = "0.11.3", features = [ "filesystem_watcher", "dynamic_linking", diff --git a/src/main.rs b/src/main.rs index 1fe2d1f..9ff3da1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,9 +11,17 @@ use bevy::{ use shadplay::{plugin::ShadPlayPlugin, system::config::UserConfig, utils::AppState}; -fn main() -> anyhow::Result<()> { +fn main() { + let path = UserConfig::get_config_path(); // Get UserConfig for the Shadplay window dimensions, decorations toggle etc. - let user_config = UserConfig::load_from_toml(UserConfig::get_config_path())?; + let user_config = match UserConfig::load_from_toml(&path) { + Ok(config) => config, + Err(_) => { + let default_config = UserConfig::default(); + let _ = default_config.save_to_toml(path); + default_config + } + }; let user_cfg_window = user_config.create_window_settings(); let mut app = App::new(); @@ -44,6 +52,4 @@ fn main() -> anyhow::Result<()> { ); shadplay.run(); - - Ok(()) }