This commit is contained in:
1 parent
d847706b8f
commit
4dc22cd3b6
5 files changed
+213
-3
No files matched your search
@@ -7,6 +7,7 @@ use bevy::prelude::*;
|
||||
use bevy_egui::egui;
|
||||
use egui_phosphor_icons::{icons, Icon};
|
||||
use shared::{
|
||||
brush_math::{validate_brush, BrushDiagnosticSeverity},
|
||||
inspector_component_active, AuthoringLightKind, AuthoringRigidBody, BrushDesc, BrushKind,
|
||||
ColliderDesc, ColliderShapeDesc, ColorDesc, ComponentInstanceId, EditorAssetRef,
|
||||
InspectorOrder, LevelObject, LightDesc, MaterialDesc, MaterialParameter,
|
||||
@@ -2441,6 +2442,7 @@ fn brush_editor_ui(world: &mut World, ui: &mut egui::Ui, entity: Entity) {
|
||||
changed |= ui.checkbox(&mut brush.receive_shadows, "Receive").changed();
|
||||
});
|
||||
});
|
||||
brush_validation_ui(ui, &brush);
|
||||
changed |= selected_brush_face_controls(world, ui, entity, &mut brush);
|
||||
if ui.button("Reset Cube Brush").clicked() {
|
||||
reset_cube = true;
|
||||
@@ -2457,6 +2459,60 @@ fn brush_editor_ui(world: &mut World, ui: &mut egui::Ui, entity: Entity) {
|
||||
}
|
||||
}
|
||||
|
||||
fn brush_validation_ui(ui: &mut egui::Ui, brush: &BrushDesc) {
|
||||
let report = validate_brush(brush);
|
||||
if report.diagnostics.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
ui.add_space(6.0);
|
||||
egui::Frame::new()
|
||||
.fill(egui::Color32::from_rgb(31, 32, 36))
|
||||
.stroke(egui::Stroke::new(1.0, BORDER))
|
||||
.inner_margin(egui::Margin::symmetric(8, 6))
|
||||
.show(ui, |ui| {
|
||||
let has_errors = !report.is_valid();
|
||||
let title_color = if has_errors {
|
||||
egui::Color32::from_rgb(255, 137, 129)
|
||||
} else {
|
||||
egui::Color32::from_rgb(255, 190, 110)
|
||||
};
|
||||
ui.horizontal(|ui| {
|
||||
let icon = if has_errors {
|
||||
icons::WARNING
|
||||
} else {
|
||||
icons::INFO
|
||||
};
|
||||
ui.label(phosphor_icon(icon, 14.0).color(title_color));
|
||||
ui.label(
|
||||
egui::RichText::new(if has_errors {
|
||||
"Brush geometry needs repair"
|
||||
} else {
|
||||
"Brush diagnostics"
|
||||
})
|
||||
.color(title_color),
|
||||
);
|
||||
});
|
||||
for diagnostic in report.diagnostics.iter().take(4) {
|
||||
let color = match diagnostic.severity {
|
||||
BrushDiagnosticSeverity::Error => egui::Color32::from_rgb(255, 137, 129),
|
||||
BrushDiagnosticSeverity::Warning => egui::Color32::from_rgb(255, 190, 110),
|
||||
};
|
||||
let face = diagnostic
|
||||
.face
|
||||
.as_ref()
|
||||
.filter(|face| !face.is_empty())
|
||||
.map(|face| format!("{}: ", face.0))
|
||||
.unwrap_or_default();
|
||||
ui.label(egui::RichText::new(format!("{face}{}", diagnostic.message)).color(color));
|
||||
}
|
||||
let hidden_count = report.diagnostics.len().saturating_sub(4);
|
||||
if hidden_count > 0 {
|
||||
ui.label(egui::RichText::new(format!("+{hidden_count} more")).color(TEXT_MUTED));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn selected_brush_face_controls(
|
||||
world: &World,
|
||||
ui: &mut egui::Ui,
|
||||
|
||||
Reference in new issue
Block a user