Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <[email protected]>
  • Loading branch information
luca-della-vedova committed Sep 12, 2024
1 parent 3496425 commit d7be917
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
12 changes: 4 additions & 8 deletions rmf_site_editor/examples/extending_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ impl FromWorld for MyMenuHandler {
// This is all it takes to register a new menu item
// We need to keep track of the entity in order to make
// sure that we can check the callback
let unique_export = world
.spawn(MenuItem::Text("My unique export".to_string()))
.id();
let unique_export = world.spawn(MenuItem::Text("My unique export".into())).id();

// Make it a child of the "File Menu"
let file_header = world.resource::<FileMenu>().get();
Expand All @@ -37,9 +35,7 @@ impl FromWorld for MyMenuHandler {
world.entity_mut(menu).push_children(&[sub_menu]);

// Finally we can create a custom action
let custom_nested_menu = world
.spawn(MenuItem::Text("My Awesome Action".to_string()))
.id();
let custom_nested_menu = world.spawn(MenuItem::Text("My Awesome Action".into())).id();
world
.entity_mut(sub_menu)
.push_children(&[custom_nested_menu]);
Expand All @@ -56,7 +52,7 @@ impl FromWorld for MyMenuHandler {
/// an event that is of the same type as the one we are supposed to
/// handle.
fn watch_unique_export_click(mut reader: EventReader<MenuEvent>, menu_handle: Res<MyMenuHandler>) {
for event in reader.iter() {
for event in reader.read() {
if event.clicked() && event.source() == menu_handle.unique_export {
println!("Doing our epic export");
}
Expand All @@ -67,7 +63,7 @@ fn watch_unique_export_click(mut reader: EventReader<MenuEvent>, menu_handle: Re
/// an event that is of the same type as the one we are supposed to
/// handle.
fn watch_submenu_click(mut reader: EventReader<MenuEvent>, menu_handle: Res<MyMenuHandler>) {
for event in reader.iter() {
for event in reader.read() {
if event.clicked() && event.source() == menu_handle.custom_nested_menu {
println!("Submenu clicked");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ impl<'a> InspectAssetSourceComponent<'a> {
// Button to load from file, disabled for wasm since there are no local files
#[cfg(not(target_arch = "wasm32"))]
if ui.button("Browse").clicked() {
// TODO(luca) change this to use FileDialogServices and be async
if let Some(file) = FileDialog::new().pick_file() {
if let Some(src) = file.to_str() {
if let (Some(default_file), true) = (self.default_file, is_relative)
Expand Down
1 change: 0 additions & 1 deletion rmf_site_editor/src/widgets/inspector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ use crate::{
interaction::Selection,
site::{Category, SiteID},
widgets::prelude::*,
AppState,
};
use bevy::{
ecs::system::{SystemParam, SystemState},
Expand Down
1 change: 1 addition & 0 deletions rmf_site_editor/src/widgets/view_lights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ impl<'w, 's> ViewLights<'w, 's> {
}
None => {
let future = AsyncComputeTaskPool::get().spawn(async move {
// TODO(luca) change this to use FileDialogServices
let file = match AsyncFileDialog::new().save_file().await {
Some(file) => file,
None => return None,
Expand Down
1 change: 1 addition & 0 deletions rmf_site_editor/src/widgets/view_nav_graphs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ impl<'w, 's> ViewNavGraphs<'w, 's> {
}
None => {
let future = AsyncComputeTaskPool::get().spawn(async move {
// TODO(luca) change this to use FileDialogServices
let file = match AsyncFileDialog::new().pick_file().await {
Some(file) => file,
None => return None,
Expand Down

0 comments on commit d7be917

Please sign in to comment.