Skip to content

Commit

Permalink
add: markers being shown added as configurable option
Browse files Browse the repository at this point in the history
  • Loading branch information
ActuallyHappening committed Jul 20, 2023
1 parent f940f17 commit 32983ec
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/board/cells/markers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ fn spawn_mark(
commands: &mut Commands,
(meshes, materials, ass): &mut ResSpawning,
) {

if !options.show_markers { return; }

if let Some(mark) = cached_info::get(&options.with_start(at)) {
let quad = shape::Quad::new(Vec2::new(CELL_SIZE, CELL_SIZE) * 0.7);
let mesh = meshes.add(Mesh::from(quad));
Expand Down
32 changes: 27 additions & 5 deletions src/board/ui.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::ops::DerefMut;

use super::{
automatic::{ComputationResult, ToggleAction},
cells::MarkerMarker,
Expand Down Expand Up @@ -38,7 +40,7 @@ impl Plugin for UiPlugin {

impl VizOptions {
/// Renders array of buttons for changing if numbers should be shown or not
fn render(&mut self, ui: &mut Ui) {
fn render(&mut self, ui: &mut Ui, should_show_markers: &mut bool) {
// show numbers
ui.label("Show numbers:");
ui.horizontal_wrapped(|ui| {
Expand Down Expand Up @@ -91,6 +93,26 @@ impl VizOptions {
})
.text("Visualization width"),
);

// show/hide markers
ui.label("Should show markers? ([h] to hide temporarily, this hides permanently)");
ui.horizontal_wrapped(|ui| {
let mut yes_text = RichText::new("Yes");
if *should_show_markers {
yes_text = yes_text.color(UI_ENABLED_COLOUR);
}
if ui.button(yes_text).clicked() {
*should_show_markers = true;
}

let mut no_text = RichText::new("No");
if !*should_show_markers {
no_text = no_text.color(UI_ENABLED_COLOUR);
}
if ui.button(no_text).clicked() {
*should_show_markers = false;
}
});
}

pub fn sys_viz_options_ui(
Expand All @@ -107,12 +129,12 @@ impl VizOptions {
ui.heading("Visualization options:");

let copy = *viz_options;

let prev_show_markers = to_reload.current.show_markers;

(*viz_options).render(ui);
if *viz_options != copy {
(*viz_options).render(ui, &mut to_reload.deref_mut().current.show_markers);
if *viz_options != copy || prev_show_markers != to_reload.current.show_markers {
(*to_reload).requires_updating();
trace!("Updating because of viz_options ui change detected")
trace!("Updating because of viz_options ui change detected or show_markers was mutated")
}
});
}
Expand Down

0 comments on commit 32983ec

Please sign in to comment.