Upgrade to Bevy 0.19 and harden editor workflows
CI / Format, lint, test, build (push) Has been cancelled
CI / Format, lint, test, build (push) Has been cancelled
This commit is contained in:
1 parent
3f85d25cc7
commit
b5e561904c
204 files changed
+6972
-29907
No files matched your search
@@ -13,59 +13,87 @@ use super::theme::{status_bar_frame, TEXT};
|
||||
|
||||
pub fn status_bar_ui(
|
||||
world: &World,
|
||||
ctx: &egui::Context,
|
||||
root_ui: &mut egui::Ui,
|
||||
selected: &SelectedEntities,
|
||||
mode: EditorMode,
|
||||
) {
|
||||
egui::TopBottomPanel::bottom("editor_status_bar")
|
||||
.exact_height(24.0)
|
||||
egui::Panel::bottom("editor_status_bar")
|
||||
.exact_size(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));
|
||||
.show_inside(root_ui, |ui| {
|
||||
ui.spacing_mut().item_spacing.x = 12.0;
|
||||
egui::containers::Sides::new()
|
||||
.shrink_left()
|
||||
.truncate()
|
||||
.show(
|
||||
ui,
|
||||
|ui| {
|
||||
let status = primary_status_line(world);
|
||||
ui.add(
|
||||
egui::Label::new(egui::RichText::new(&status).color(TEXT)).truncate(),
|
||||
)
|
||||
.on_hover_text(status);
|
||||
},
|
||||
|ui| {
|
||||
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 mode_label = match mode {
|
||||
EditorMode::Editing => "Edit".to_string(),
|
||||
EditorMode::Playing => {
|
||||
if world.resource::<PlayPaused>().0 {
|
||||
"Play (paused)".to_string()
|
||||
} else {
|
||||
"Play".to_string()
|
||||
let count = selected.len();
|
||||
let selection = match count {
|
||||
0 => "None".to_string(),
|
||||
1 => "1 selected".to_string(),
|
||||
_ => format!("{count} selected"),
|
||||
};
|
||||
ui.label(egui::RichText::new(selection).color(TEXT));
|
||||
|
||||
ui.label(
|
||||
egui::RichText::new(world.resource::<EditorHistory>().status.clone())
|
||||
.color(TEXT),
|
||||
);
|
||||
|
||||
if let Some(operator_label) = world.resource::<ActiveOperator>().label() {
|
||||
ui.label(egui::RichText::new(operator_label).color(TEXT));
|
||||
}
|
||||
}
|
||||
};
|
||||
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));
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if let Some(operator_label) = world.resource::<ActiveOperator>().label() {
|
||||
ui.label(egui::RichText::new(operator_label).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>();
|
||||
fn scene_line(scene_io: &SceneIo) -> String {
|
||||
let dirty = if scene_io.dirty { " *" } else { "" };
|
||||
format!("Scene: {}{dirty}", scene_io.active_path_label())
|
||||
}
|
||||
|
||||
fn primary_status_line(world: &World) -> String {
|
||||
let scene_io = world.resource::<SceneIo>();
|
||||
format!("{} | {}", scene_io.status, scene_line(scene_io))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn scene_line_marks_unsaved_changes() {
|
||||
let mut scene_io = SceneIo::default();
|
||||
assert!(!scene_line(&scene_io).ends_with('*'));
|
||||
|
||||
scene_io.mark_dirty();
|
||||
assert!(scene_line(&scene_io).ends_with('*'));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user