From 5d8d9fe6205f6f589c1aa5658e5db7ed51a14511 Mon Sep 17 00:00:00 2001 From: Danny McGee Date: Wed, 4 Oct 2023 16:05:34 -0400 Subject: [PATCH] Split UI module --- studio/src/ui.rs | 65 -------------------------------------------- studio/src/ui/fps.rs | 54 ++++++++++++++++++++++++++++++++++++ studio/src/ui/mod.rs | 13 +++++++++ 3 files changed, 67 insertions(+), 65 deletions(-) delete mode 100644 studio/src/ui.rs create mode 100644 studio/src/ui/fps.rs create mode 100644 studio/src/ui/mod.rs diff --git a/studio/src/ui.rs b/studio/src/ui.rs deleted file mode 100644 index 89c20a6..0000000 --- a/studio/src/ui.rs +++ /dev/null @@ -1,65 +0,0 @@ -use bevy::{ - diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin}, - prelude::*, -}; - -pub struct UiLayerPlugin; - -impl Plugin for UiLayerPlugin { - fn build(&self, app: &mut App) { - app.add_plugins(FrameTimeDiagnosticsPlugin) - .add_systems(Startup, layout) - .add_systems(Update, update); - } -} - -#[derive(Component)] -pub struct FramerateCounter; - -fn layout(mut cmd: Commands) { - cmd.spawn(NodeBundle { - style: Style { - width: Val::Percent(100.), - height: Val::Percent(100.), - padding: UiRect::all(Val::Px(16.)), - ..default() - }, - ..default() - }) - .with_children(|parent| { - parent.spawn(( - FramerateCounter, - TextBundle::from_section( - "0 fps", - TextStyle { - color: Color::GREEN, - font_size: 14., - ..default() - }, - ) - .with_text_alignment(TextAlignment::Right) - .with_style(Style { - // TODO: This doesn't seem to have any effect - width: Val::Percent(100.), - ..default() - }), - )); - }); -} - -fn update( - time: Res