use crate::prelude::*; /// Menu Plugin; empty struct for Plugin impl pub(crate) struct MenuPlugin; impl Plugin for MenuPlugin { fn build(&self, app: &mut App) { app.init_state::(); app.add_systems(Startup, init_menu_ui); app.add_systems( Update, manage_visibility::.run_if(state_changed::), ); app.add_systems( Update, button_state_action::.run_if(any_component_changed::), ); } } /// State tracking if the menu is open or closed #[derive(States, Debug, Clone, PartialEq, Eq, Hash, Default, Component)] pub(crate) enum MenuState { #[default] Open, Closed, } /// Initialize menu UI nodes at startup fn init_menu_ui(mut commands: Commands) { commands .spawn((MenuState::Open, GameChoice::None, Pickable::IGNORE)) .add(UiContainer) .with_children(|parent| { parent.spawn_empty().add(UiTitle { text: "Game Jam Casino", ..default() }); parent .spawn(SetState(GameChoice::Dice)) .add(UiButton { label: "Dice" }); }); }