diff --git a/src/main.rs b/src/main.rs index 55de9a9..2cf466b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,8 @@ fn main() { })) .add_plugins(EguiPlugin::default()) .add_plugins(WorldInspectorPlugin::new()) + .init_resource::() + .register_type::() .add_systems( Startup, (setup, assets::load_assets, widgets::spawn_cutter_machine_ui), diff --git a/src/resources.rs b/src/resources.rs index bbadbb1..f7cfa57 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -3,32 +3,31 @@ use bevy::{color::palettes::css::*, prelude::*}; #[derive(Debug, Reflect, Resource)] +#[reflect(Resource)] pub struct UiTheme { // TODO: Panes // Colors for the "Big Red Buttons" (the main actions of the machines) // normal - brb_bg: Color, - brb_border: Color, + pub brb_bg: Color, + pub brb_border: Color, // hover - brb_hover_bg: Color, - brb_hover_border: Color, + pub brb_hover_bg: Color, + pub brb_hover_border: Color, // pressed - brb_pressed_bg: Color, - brb_pressed_border: Color, - + pub brb_pressed_bg: Color, + pub brb_pressed_border: Color, } impl FromWorld for UiTheme { fn from_world(world: &mut World) -> Self { Self { - brb_bg: RED.into(), - brb_border: DARK_RED.into(), - brb_hover_bg: PINK.into(), - brb_hover_border: RED.into(), - brb_pressed_bg: GREEN.into(), - brb_pressed_border: DARK_GREEN.into(), + brb_bg: RED.into(), + brb_border: DARK_RED.into(), + brb_hover_bg: PINK.into(), + brb_hover_border: RED.into(), + brb_pressed_bg: GREEN.into(), + brb_pressed_border: DARK_GREEN.into(), } } } - diff --git a/src/widgets.rs b/src/widgets.rs index d8ff126..fd08390 100644 --- a/src/widgets.rs +++ b/src/widgets.rs @@ -6,6 +6,8 @@ use bevy::{ ui::Val::*, }; +use crate::resources::UiTheme; + pub fn spawn_cutter_machine_ui(mut commands: Commands) { commands .spawn((machine_ui_base("Cutting Machine"),)) @@ -131,44 +133,47 @@ fn button_hover_start( // Get button background and border colors so we can change them. // Filter for *changed* interactions, and only entities with a [`Button`] mut button_colors: Query<(&mut BackgroundColor, &mut BorderColor), With