67 lines
2.2 KiB
Rust
67 lines
2.2 KiB
Rust
//! Fixed bottom status strip.
|
|
|
|
use bevy::prelude::*;
|
|
use bevy_egui::egui;
|
|
use bevy_inspector_egui::bevy_inspector::hierarchy::SelectedEntities;
|
|
|
|
use crate::history::EditorHistory;
|
|
use crate::scene_io::SceneIo;
|
|
use crate::state::{EditorMode, PlayPaused};
|
|
|
|
use super::theme::{status_bar_frame, TEXT};
|
|
|
|
pub fn status_bar_ui(
|
|
world: &World,
|
|
ctx: &egui::Context,
|
|
selected: &SelectedEntities,
|
|
mode: EditorMode,
|
|
) {
|
|
egui::TopBottomPanel::bottom("editor_status_bar")
|
|
.exact_height(24.0)
|
|
.frame(status_bar_frame())
|
|
.show(ctx, |ui| {
|
|
ui.horizontal_centered(|ui| {
|
|
ui.spacing_mut().item_spacing.x = 16.0;
|
|
ui.label(egui::RichText::new(scene_line(world)).color(TEXT));
|
|
|
|
let mode_label = match mode {
|
|
EditorMode::Editing => "Edit".to_string(),
|
|
EditorMode::Playing => {
|
|
if world.resource::<PlayPaused>().0 {
|
|
"Play (paused)".to_string()
|
|
} else {
|
|
"Play".to_string()
|
|
}
|
|
}
|
|
};
|
|
ui.label(egui::RichText::new(mode_label).color(TEXT));
|
|
|
|
let count = selected.len();
|
|
let sel = if count == 0 {
|
|
"None".to_string()
|
|
} else if count == 1 {
|
|
"1 selected".to_string()
|
|
} else {
|
|
format!("{count} selected")
|
|
};
|
|
ui.label(egui::RichText::new(sel).color(TEXT));
|
|
|
|
ui.label(
|
|
egui::RichText::new(world.resource::<EditorHistory>().status.clone())
|
|
.color(TEXT),
|
|
);
|
|
|
|
#[cfg(feature = "hot-reload")]
|
|
if let Some(hot) = world.get_resource::<crate::hot_reload::HotReloadState>() {
|
|
ui.label(egui::RichText::new(hot.label.clone()).color(TEXT));
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
fn scene_line(world: &World) -> String {
|
|
let scene_io = world.resource::<SceneIo>();
|
|
let dirty = if scene_io.dirty { " *" } else { "" };
|
|
format!("Scene: {}{dirty}", scene_io.active_path_label())
|
|
}
|