Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
Signed-off-by: Michael X. Grey <[email protected]>
  • Loading branch information
mxgrey committed Jul 7, 2023
1 parent e5f5f0b commit fffe193
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion rmf_site_editor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ pub mod occupancy;
use occupancy::OccupancyPlugin;

mod demo_world;
mod log;
mod recency;
mod shapes;
mod log;
use log::LogHistoryPlugin;

mod main_menu;
Expand Down
25 changes: 12 additions & 13 deletions rmf_site_editor/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ impl From<Log> for LogHistoryElement {
impl fmt::Display for LogHistoryElement {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.copies > 1 {
write!(f, "({}x) {}{}", self.copies, self.log.category, self.log.message)
write!(
f,
"({}x) {}{}",
self.copies, self.log.category, self.log.message
)
} else {
write!(f, "{}{}", self.log.category, self.log.message)
}
Expand Down Expand Up @@ -170,12 +174,11 @@ impl LogHistory {
&self.log_history
}

pub fn iter(&self) -> impl Iterator<Item=&LogHistoryElement> {
self.log_history.iter()
pub fn iter(&self) -> impl Iterator<Item = &LogHistoryElement> {
self.log_history
.iter()
.rev()
.filter(
|e| self.category_filter[&e.log.category]
)
.filter(|e| self.category_filter[&e.log.category])
.take(self.display_limit)
}

Expand Down Expand Up @@ -216,7 +219,7 @@ impl LogHistory {
pub fn top(&self) -> Option<&LogHistoryElement> {
for element in self.log_history.iter().rev() {
if self.category_filter[&element.log.category] {
return Some(element)
return Some(element);
}
}

Expand Down Expand Up @@ -319,10 +322,7 @@ where
}
}

fn receive_logs(
mut log_history: ResMut<LogHistory>,
mut log_events: EventReader<Log>,
) {
fn receive_logs(mut log_history: ResMut<LogHistory>, mut log_events: EventReader<Log>) {
log_history.receive_logs();
for log in log_events.iter() {
log_history.push(log.clone());
Expand All @@ -333,8 +333,7 @@ pub struct LogHistoryPlugin;

impl Plugin for LogHistoryPlugin {
fn build(&self, app: &mut App) {
app
.add_event::<Log>()
app.add_event::<Log>()
.init_resource::<LogHistory>()
.add_system(receive_logs);
}
Expand Down
2 changes: 1 addition & 1 deletion rmf_site_editor/src/site/deletion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/

use crate::{
log::Log,
interaction::{Select, Selection},
log::Log,
site::{Category, CurrentLevel, Dependents, LevelProperties, SiteUpdateStage},
};
use bevy::{ecs::system::SystemParam, prelude::*};
Expand Down
6 changes: 5 additions & 1 deletion rmf_site_editor/src/widgets/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ impl<'a, 'w2, 's2> ConsoleWidget<'a, 'w2, 's2> {
ui.horizontal_wrapped(|ui| {
ui.spacing_mut().item_spacing.x = 10.0;
// Filter logs by category
let mut all_are_checked = self.events.display.log_history.all_categories_are_selected();
let mut all_are_checked = self
.events
.display
.log_history
.all_categories_are_selected();
let all_were_checked = all_are_checked;
ui.checkbox(&mut all_are_checked, "All");
ui.checkbox(
Expand Down
2 changes: 1 addition & 1 deletion rmf_site_editor/src/widgets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ use crate::{
interaction::{
ChangeMode, HeadlightToggle, Hover, MoveTo, PickingBlockers, Select, SpawnPreview,
},
log::LogHistory,
occupancy::CalculateGrid,
recency::ChangeRank,
site::{
AssociatedGraphs, Change, ConsiderAssociatedGraph, ConsiderLocationTag, CurrentLevel,
Delete, ExportLights, FloorVisibility, PhysicalLightToggle, SaveNavGraphs, SiteState,
ToggleLiftDoorAvailability,
},
log::LogHistory,
AppState, CreateNewWorkspace, CurrentWorkspace, LoadWorkspace, SaveWorkspace,
};
use bevy::{ecs::system::SystemParam, prelude::*};
Expand Down

0 comments on commit fffe193

Please sign in to comment.