diff --git a/CHANGELOG.md b/CHANGELOG.md index 338d3fc..207d95e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## v0.1.13: - Display window +- Various UI improvements, saving is now seperate window + ## v0.1.12: - Hotkeys for targets/disable diff --git a/src/board.rs b/src/board.rs index fd18c47..3d6e26d 100644 --- a/src/board.rs +++ b/src/board.rs @@ -48,26 +48,14 @@ pub struct CurrentOptions { /// Sets up default resources + sends initial [NewOptions] event fn setup(mut commands: Commands) { - // let mut board = BoardOptions::new(2, 3); - // board.rm((1, 2)); - // board.rm((2, 2)); - // board.rm((2, 1)); - // board.rm((3, 1)); - let board = BoardOptions::new(8, 8); + let mut default_options = CurrentOptions::from_options(Options::default()); - let options = Options { - options: board, - selected_start: None, - selected_algorithm: Algorithm::default(), - requires_updating: true, - }; - let mut current_options = CurrentOptions::from_options(options); if let Some(state) = crate::weburl::try_load_state_from_url() { info!("Loaded state from URL!"); - current_options.current.options = state.options; + default_options.current.options = state.options; } - commands.insert_resource(current_options); + commands.insert_resource(default_options); } mod top_level_types { diff --git a/src/board/ui.rs b/src/board/ui.rs index 07b149a..323e9a1 100644 --- a/src/board/ui.rs +++ b/src/board/ui.rs @@ -12,6 +12,7 @@ use crate::{ solver::algs::Computation, MainCamera, ProgramState, }; +use bevy::transform::commands; use bevy_egui::{ egui::{Color32, Pos2, RichText, Ui}, *, @@ -96,13 +97,18 @@ impl VizOptions { mut viz_options: ResMut, mut contexts: EguiContexts, mut to_reload: ResMut, + + markers: Query, With)>, + mut commands: Commands, ) { - egui::Window::new("viz_options_ui") + egui::Window::new("Visualization options") .default_pos(Pos2::new(4200., 4200.)) .show(contexts.ctx_mut(), |ui| { ui.heading("Visualization options:"); let copy = *viz_options; + + (*viz_options).render(ui); if *viz_options != copy { (*to_reload).requires_updating(); diff --git a/src/solver/algs.rs b/src/solver/algs.rs index dc9bced..851bc08 100644 --- a/src/solver/algs.rs +++ b/src/solver/algs.rs @@ -134,6 +134,8 @@ pub struct Options { pub selected_start: Option, pub selected_algorithm: Algorithm, + // ignored by hash + pub show_markers: bool, #[derivative(PartialEq = "ignore")] // must be ignored by Hash pub requires_updating: bool, @@ -147,6 +149,18 @@ impl std::hash::Hash for Options { } } +impl Default for Options { + fn default() -> Self { + Options { + options: BoardOptions::default(), + selected_start: None, + selected_algorithm: Algorithm::default(), + requires_updating: true, + show_markers: true, + } + } +} + impl Deref for Options { type Target = BoardOptions; diff --git a/src/solver/boardoptions.rs b/src/solver/boardoptions.rs index 07238f0..ff61eab 100644 --- a/src/solver/boardoptions.rs +++ b/src/solver/boardoptions.rs @@ -9,6 +9,12 @@ pub struct BoardOptions { options: Vec>, } +impl Default for BoardOptions { + fn default() -> Self { + Self::new(8, 8) + } +} + #[derive(EnumIs)] pub enum TargetRestriction { /// All cells are endable.