#![feature(async_closure)] use std::time::Duration; use xmpd_manifest::{store::JsonStore, Manifest}; #[macro_use] mod macros; mod main_window; mod windows; mod components; mod data; mod utils; const W_NAME: &str = "xmpd v2.0.0a"; type Result = anyhow::Result; pub fn start() -> Result<()> { xmpd_cache::Cache::get()?.init()?; let options = eframe::NativeOptions::default(); let mut state = GuiState::new()?; let res = eframe::run_simple_native(W_NAME, options, move |ctx, _frame| { egui_extras::install_image_loaders(ctx); state.windows.clone().draw_all(ctx, &mut state); handle_error_ui!(main_window::draw(ctx, &mut state)); ctx.request_repaint_after(Duration::from_millis(500)); }); if let Err(e) = res { // dumb err value by eframe anyhow::bail!(e.to_string()); } Ok(()) } pub struct GuiState { pub manifest: Manifest, pub windows: windows::Windows, } impl GuiState { pub fn new() -> Result { Ok(Self { manifest: Manifest::new(&xmpd_cliargs::CLIARGS.manifest_path())?, windows: windows::Windows::new(), }) } }