test turn

This commit is contained in:
Rendo 2026-01-29 02:06:48 +05:00
commit 2f1b6e9152
3 changed files with 84 additions and 84 deletions

View file

@ -2,6 +2,7 @@ use bevy::prelude::*;
use crate::buttons;
use crate::card;
use crate::turns::try_confirm_turn;
const PANEL_BORDER: Color = Color::srgb_u8(36, 36, 143);
const PANEL_BACKGROUND: Color = Color::srgb_u8(0, 0, 52);
@ -55,60 +56,44 @@ fn setup_debug_menu(mut commands: Commands) {
))
.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)
},
);
commands.spawn(button(panel, "AddCard")).observe(
|_: On<buttons::ButtonPressedEvent>, mut commands: Commands| {
commands.trigger(card::AddCard)
},
);
commands.spawn(button(panel, "ClearCards")).observe(
|_: On<buttons::ButtonPressedEvent>, mut commands: Commands| {
commands.trigger(card::ClearCards)
},
);
commands.spawn(button(panel, "ConfirmTurn")).observe(
|_: On<buttons::ButtonPressedEvent>, mut commands: Commands| {
commands.run_system_cached(try_confirm_turn);
},
);
}
fn button(child_of: Entity, text: impl Into<String>) -> impl Bundle {
(
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(child_of),
children![(
Text::new(text),
TextFont {
font_size: 11.0,
..default()
},
)],
)
}