Build production-ready editor authoring workflows
CI / Format, lint, test, build (push) Waiting to run
CI / Format, lint, test, build (push) Waiting to run
This commit is contained in:
1 parent
cc1fa6ea3b
commit
0553a85220
163 files changed
+34547
-1565
No files matched your search
@@ -3,13 +3,15 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy_egui::egui;
|
||||
use bevy_inspector_egui::bevy_inspector::hierarchy::SelectedEntities;
|
||||
use egui_phosphor_icons::icons;
|
||||
|
||||
use crate::history::EditorHistory;
|
||||
use crate::operators::ActiveOperator;
|
||||
use crate::scene_io::SceneIo;
|
||||
use crate::state::{EditorMode, PlayPaused};
|
||||
|
||||
use super::theme::{status_bar_frame, TEXT};
|
||||
use super::theme::{status_bar_frame, ACCENT, SELECTION, SUCCESS, TEXT, TEXT_DIM, TEXT_MUTED};
|
||||
use super::widgets::phosphor_icon;
|
||||
|
||||
pub fn status_bar_ui(
|
||||
world: &World,
|
||||
@@ -18,10 +20,10 @@ pub fn status_bar_ui(
|
||||
mode: EditorMode,
|
||||
) {
|
||||
egui::Panel::bottom("editor_status_bar")
|
||||
.exact_size(24.0)
|
||||
.exact_size(27.0)
|
||||
.frame(status_bar_frame())
|
||||
.show_inside(root_ui, |ui| {
|
||||
ui.spacing_mut().item_spacing.x = 12.0;
|
||||
ui.spacing_mut().item_spacing.x = 10.0;
|
||||
egui::containers::Sides::new()
|
||||
.shrink_left()
|
||||
.truncate()
|
||||
@@ -29,23 +31,41 @@ pub fn status_bar_ui(
|
||||
ui,
|
||||
|ui| {
|
||||
let status = primary_status_line(world);
|
||||
ui.label(
|
||||
egui::RichText::new("●")
|
||||
.color(if world.resource::<SceneIo>().dirty {
|
||||
ACCENT
|
||||
} else {
|
||||
SUCCESS
|
||||
})
|
||||
.small(),
|
||||
);
|
||||
ui.add(
|
||||
egui::Label::new(egui::RichText::new(&status).color(TEXT)).truncate(),
|
||||
egui::Label::new(egui::RichText::new(&status).color(TEXT_DIM))
|
||||
.truncate(),
|
||||
)
|
||||
.on_hover_text(status);
|
||||
},
|
||||
|ui| {
|
||||
let mode_label = match mode {
|
||||
EditorMode::Editing => "Edit".to_string(),
|
||||
let (mode_icon, mode_label, mode_color) = match mode {
|
||||
EditorMode::Editing => (icons::PENCIL_SIMPLE, "EDIT", ACCENT),
|
||||
EditorMode::Playing => {
|
||||
if world.resource::<PlayPaused>().0 {
|
||||
"Play (paused)".to_string()
|
||||
(icons::PAUSE, "PAUSED", ACCENT)
|
||||
} else {
|
||||
"Play".to_string()
|
||||
(icons::PLAY, "PLAYING", SUCCESS)
|
||||
}
|
||||
}
|
||||
};
|
||||
ui.label(egui::RichText::new(mode_label).color(TEXT));
|
||||
ui.label(phosphor_icon(mode_icon, 13.0).color(mode_color));
|
||||
ui.label(
|
||||
egui::RichText::new(mode_label)
|
||||
.color(mode_color)
|
||||
.strong()
|
||||
.small(),
|
||||
);
|
||||
|
||||
ui.separator();
|
||||
|
||||
let count = selected.len();
|
||||
let selection = match count {
|
||||
@@ -53,11 +73,15 @@ pub fn status_bar_ui(
|
||||
1 => "1 selected".to_string(),
|
||||
_ => format!("{count} selected"),
|
||||
};
|
||||
ui.label(egui::RichText::new(selection).color(TEXT));
|
||||
ui.label(egui::RichText::new(selection).color(if count == 0 {
|
||||
TEXT_MUTED
|
||||
} else {
|
||||
SELECTION
|
||||
}));
|
||||
|
||||
ui.label(
|
||||
egui::RichText::new(world.resource::<EditorHistory>().status.clone())
|
||||
.color(TEXT),
|
||||
.color(TEXT_DIM),
|
||||
);
|
||||
|
||||
if let Some(operator_label) = world.resource::<ActiveOperator>().label() {
|
||||
@@ -76,7 +100,12 @@ pub fn status_bar_ui(
|
||||
|
||||
fn scene_line(scene_io: &SceneIo) -> String {
|
||||
let dirty = if scene_io.dirty { " *" } else { "" };
|
||||
format!("Scene: {}{dirty}", scene_io.active_path_label())
|
||||
let recovery = if scene_io.recovery_snapshot.is_some() {
|
||||
" [recovery]"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
format!("Scene: {}{dirty}{recovery}", scene_io.active_path_label())
|
||||
}
|
||||
|
||||
fn primary_status_line(world: &World) -> String {
|
||||
@@ -95,5 +124,8 @@ mod tests {
|
||||
|
||||
scene_io.mark_dirty();
|
||||
assert!(scene_line(&scene_io).ends_with('*'));
|
||||
|
||||
scene_io.recovery_snapshot = Some("recovery.scn.ron".into());
|
||||
assert!(scene_line(&scene_io).ends_with("[recovery]"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user