mirror of https://codeberg.org/topola/topola.git
feat(topola-egui): Add checkbox to hide pathfinding scores
This commit is contained in:
parent
896deb1777
commit
6f20994dab
|
|
@ -166,6 +166,7 @@ pub struct ViewActions {
|
||||||
pub zoom_to_fit: Switch,
|
pub zoom_to_fit: Switch,
|
||||||
pub show_ratsnest: Switch,
|
pub show_ratsnest: Switch,
|
||||||
pub show_navmesh: Switch,
|
pub show_navmesh: Switch,
|
||||||
|
pub show_pathfinding_scores: Switch,
|
||||||
pub show_topo_navmesh: Switch,
|
pub show_topo_navmesh: Switch,
|
||||||
pub show_bboxes: Switch,
|
pub show_bboxes: Switch,
|
||||||
pub show_origin_destination: Switch,
|
pub show_origin_destination: Switch,
|
||||||
|
|
@ -178,6 +179,10 @@ impl ViewActions {
|
||||||
zoom_to_fit: Action::new_keyless(tr.text("tr-menu-view-zoom-to-fit")).into_switch(),
|
zoom_to_fit: Action::new_keyless(tr.text("tr-menu-view-zoom-to-fit")).into_switch(),
|
||||||
show_ratsnest: Action::new_keyless(tr.text("tr-menu-view-show-ratsnest")).into_switch(),
|
show_ratsnest: Action::new_keyless(tr.text("tr-menu-view-show-ratsnest")).into_switch(),
|
||||||
show_navmesh: Action::new_keyless(tr.text("tr-menu-view-show-navmesh")).into_switch(),
|
show_navmesh: Action::new_keyless(tr.text("tr-menu-view-show-navmesh")).into_switch(),
|
||||||
|
show_pathfinding_scores: Action::new_keyless(
|
||||||
|
tr.text("tr-menu-view-show-pathfinding-scores"),
|
||||||
|
)
|
||||||
|
.into_switch(),
|
||||||
show_topo_navmesh: Action::new_keyless(tr.text("tr-menu-view-show-topo-navmesh"))
|
show_topo_navmesh: Action::new_keyless(tr.text("tr-menu-view-show-topo-navmesh"))
|
||||||
.into_switch(),
|
.into_switch(),
|
||||||
show_bboxes: Action::new_keyless(tr.text("tr-menu-view-show-bboxes")).into_switch(),
|
show_bboxes: Action::new_keyless(tr.text("tr-menu-view-show-bboxes")).into_switch(),
|
||||||
|
|
@ -206,6 +211,8 @@ impl ViewActions {
|
||||||
ui.add_enabled_ui(have_workspace, |ui| {
|
ui.add_enabled_ui(have_workspace, |ui| {
|
||||||
self.show_ratsnest.checkbox(ui, &mut menu_bar.show_ratsnest);
|
self.show_ratsnest.checkbox(ui, &mut menu_bar.show_ratsnest);
|
||||||
self.show_navmesh.checkbox(ui, &mut menu_bar.show_navmesh);
|
self.show_navmesh.checkbox(ui, &mut menu_bar.show_navmesh);
|
||||||
|
self.show_pathfinding_scores
|
||||||
|
.checkbox(ui, &mut menu_bar.show_pathfinding_scores);
|
||||||
self.show_topo_navmesh
|
self.show_topo_navmesh
|
||||||
.checkbox(ui, &mut menu_bar.show_topo_navmesh);
|
.checkbox(ui, &mut menu_bar.show_topo_navmesh);
|
||||||
self.show_bboxes.checkbox(ui, &mut menu_bar.show_bboxes);
|
self.show_bboxes.checkbox(ui, &mut menu_bar.show_bboxes);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ pub struct MenuBar {
|
||||||
pub is_placing_via: bool,
|
pub is_placing_via: bool,
|
||||||
pub show_ratsnest: bool,
|
pub show_ratsnest: bool,
|
||||||
pub show_navmesh: bool,
|
pub show_navmesh: bool,
|
||||||
|
pub show_pathfinding_scores: bool,
|
||||||
pub show_topo_navmesh: bool,
|
pub show_topo_navmesh: bool,
|
||||||
pub show_bboxes: bool,
|
pub show_bboxes: bool,
|
||||||
pub show_origin_destination: bool,
|
pub show_origin_destination: bool,
|
||||||
|
|
@ -47,6 +48,7 @@ impl MenuBar {
|
||||||
is_placing_via: false,
|
is_placing_via: false,
|
||||||
show_ratsnest: true,
|
show_ratsnest: true,
|
||||||
show_navmesh: false,
|
show_navmesh: false,
|
||||||
|
show_pathfinding_scores: false,
|
||||||
show_topo_navmesh: false,
|
show_topo_navmesh: false,
|
||||||
show_bboxes: false,
|
show_bboxes: false,
|
||||||
show_origin_destination: false,
|
show_origin_destination: false,
|
||||||
|
|
|
||||||
|
|
@ -354,27 +354,33 @@ impl Viewport {
|
||||||
None => [0.0, 0.0].into(),
|
None => [0.0, 0.0].into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
//TODO "{astar.scores[index]} ({astar.estimate_scores[index]}) (...)"
|
if menu_bar.show_pathfinding_scores {
|
||||||
let score_text = astar
|
//TODO "{astar.scores[index]} ({astar.estimate_scores[index]}) (...)"
|
||||||
.scores()
|
let score_text = astar
|
||||||
.get(&navnode)
|
.scores()
|
||||||
.map_or_else(String::new, |s| format!("g={:.2}", s));
|
.get(&navnode)
|
||||||
let estimate_score_text = astar
|
.map_or_else(String::new, |s| {
|
||||||
.estimate_scores()
|
format!("g={:.2}", s)
|
||||||
.get(&navnode)
|
});
|
||||||
.map_or_else(String::new, |s| format!("(f={:.2})", s));
|
let estimate_score_text = astar
|
||||||
let debug_text =
|
.estimate_scores()
|
||||||
activity.navnode_debug_text(navnode).unwrap_or("");
|
.get(&navnode)
|
||||||
|
.map_or_else(String::new, |s| {
|
||||||
|
format!("(f={:.2})", s)
|
||||||
|
});
|
||||||
|
let debug_text =
|
||||||
|
activity.navnode_debug_text(navnode).unwrap_or("");
|
||||||
|
|
||||||
painter.paint_text(
|
painter.paint_text(
|
||||||
pos,
|
pos,
|
||||||
egui::Align2::LEFT_BOTTOM,
|
egui::Align2::LEFT_BOTTOM,
|
||||||
&format!(
|
&format!(
|
||||||
"{} {} {}",
|
"{} {} {}",
|
||||||
score_text, estimate_score_text, debug_text
|
score_text, estimate_score_text, debug_text
|
||||||
),
|
),
|
||||||
egui::Color32::from_rgb(255, 255, 255),
|
egui::Color32::from_rgb(255, 255, 255),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ tr-menu-view = View
|
||||||
tr-menu-view-zoom-to-fit = Zoom to Fit
|
tr-menu-view-zoom-to-fit = Zoom to Fit
|
||||||
tr-menu-view-show-ratsnest = Show Ratsnest
|
tr-menu-view-show-ratsnest = Show Ratsnest
|
||||||
tr-menu-view-show-navmesh = Show Navmesh
|
tr-menu-view-show-navmesh = Show Navmesh
|
||||||
|
tr-menu-view-show-pathfinding-scores = Show Pathfinding Scores
|
||||||
tr-menu-view-show-topo-navmesh = Show Topological Navmesh
|
tr-menu-view-show-topo-navmesh = Show Topological Navmesh
|
||||||
tr-menu-view-show-bboxes = Show BBoxes
|
tr-menu-view-show-bboxes = Show BBoxes
|
||||||
tr-menu-view-show-origin-destination = Show Origin–Destination
|
tr-menu-view-show-origin-destination = Show Origin–Destination
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue