This commit is contained in:
Rendo 2026-01-25 04:42:32 +05:00
commit badc59c239
2 changed files with 143 additions and 36 deletions

View file

@ -1,7 +1,111 @@
use bevy::prelude::*;
use crate::buttons;
use crate::card;
const PANEL_BORDER: Color = Color::srgb_u8(36, 36, 143);
const PANEL_BACKGROUND: Color = Color::srgb_u8(0, 0, 52);
const BUTTON_BORDER: Color = Color::srgb_u8(61, 68, 12);
const BUTTON_BACKGROUND: Color = Color::srgb_u8(35, 51, 38);
pub struct DevToolsPlugin;
impl Plugin for DevToolsPlugin {
fn build(&self, app: &mut App) {}
fn build(&self, app: &mut App) {
app.add_systems(Startup, setup_debug_menu);
}
}
fn setup_debug_menu(mut commands: Commands) {
let root = commands
.spawn(Node {
width: percent(100.),
height: percent(100.),
align_items: AlignItems::Start,
justify_content: JustifyContent::End,
..default()
})
.id();
let panel = commands
.spawn((
Node {
display: Display::Flex,
position_type: PositionType::Relative,
min_width: px(128),
min_height: px(32),
border: UiRect {
left: px(4.),
right: px(4.),
top: px(10.),
bottom: px(4.),
},
margin: UiRect::all(px(10)),
padding: UiRect::all(px(3)),
justify_items: JustifyItems::Start,
align_items: AlignItems::Center,
flex_direction: FlexDirection::Column,
..default()
},
BorderColor::all(PANEL_BORDER),
BackgroundColor(PANEL_BACKGROUND),
ChildOf(root),
))
.id();
commands
.spawn((
Button,
Node {
min_height: px(32),
width: percent(100.),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
margin: UiRect::all(px(4)),
border: UiRect::all(px(3)),
..default()
},
BorderColor::all(BUTTON_BORDER),
BackgroundColor(BUTTON_BACKGROUND),
ChildOf(panel),
children![(
Text::new("Add card"),
TextFont {
font_size: 11.0,
..default()
},
)],
))
.observe(
|_: On<buttons::ButtonPressedEvent>, mut commands: Commands| {
commands.trigger(card::AddCard)
},
);
commands
.spawn((
Button,
Node {
min_height: px(32),
width: percent(100.),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
margin: UiRect::all(px(4)),
border: UiRect::all(px(3)),
..default()
},
BorderColor::all(BUTTON_BORDER),
BackgroundColor(BUTTON_BACKGROUND),
ChildOf(panel),
children![(
Text::new("Clear cards"),
TextFont {
font_size: 11.0,
..default()
},
)],
))
.observe(
|_: On<buttons::ButtonPressedEvent>, mut commands: Commands| {
commands.trigger(card::ClearCards)
},
);
}