mirror of
https://codeberg.org/schrottkatze/mgd2-tram-championships.git
synced 2025-07-04 19:17:38 +00:00
menu system: beginnings
This commit is contained in:
parent
2e7de9f296
commit
2b18cdea38
5 changed files with 206 additions and 0 deletions
50
src/menus.rs
Normal file
50
src/menus.rs
Normal file
|
@ -0,0 +1,50 @@
|
|||
use bevy::{input::ButtonState, prelude::*};
|
||||
use lib::{ItemPosition, Menu, MenuItemType, Menus, OnPressAction};
|
||||
|
||||
mod lib;
|
||||
|
||||
#[derive(States, Debug, Clone, PartialEq, Eq, Hash)]
|
||||
enum CurrentMenu {
|
||||
NotInMenus,
|
||||
MainMenu,
|
||||
Settings,
|
||||
HighScores,
|
||||
StartGame,
|
||||
}
|
||||
pub fn todo_meow() {
|
||||
let plugin = Menus::<CurrentMenu>::new()
|
||||
.add_menu(
|
||||
CurrentMenu::MainMenu,
|
||||
Menu::new().add_items(&[
|
||||
&MenuItemType::Text(String::from("Hello, World!")),
|
||||
&(
|
||||
MenuItemType::Button(String::from("Start Game")),
|
||||
OnPressAction::SampleAction,
|
||||
),
|
||||
&(
|
||||
MenuItemType::Button(String::from("Settings")),
|
||||
OnPressAction::NavigateTo(CurrentMenu::Settings),
|
||||
),
|
||||
]),
|
||||
)
|
||||
.add_menu(
|
||||
CurrentMenu::Settings,
|
||||
Menu::new()
|
||||
.add_items(&[
|
||||
&MenuItemType::Text(String::from("Hello, World!")),
|
||||
&(
|
||||
MenuItemType::Button(String::from("Sample setting")),
|
||||
OnPressAction::SampleAction,
|
||||
),
|
||||
])
|
||||
.add_items_positioned(
|
||||
ItemPosition::SouthEast,
|
||||
&[&(
|
||||
MenuItemType::Button(String::from("Back")),
|
||||
OnPressAction::NavigateTo(CurrentMenu::MainMenu),
|
||||
)],
|
||||
),
|
||||
);
|
||||
|
||||
dbg!(plugin);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue