progress checkin

main
Jordan Orelli 1 year ago
parent 9de30b29cb
commit a46ab65b3a

344
Cargo.lock generated

@ -200,6 +200,25 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "arboard"
version = "3.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac57f2b058a76363e357c056e4f74f1945bf734d37b8b3ef49066c4787dde0fc"
dependencies = [
"clipboard-win",
"core-graphics",
"image",
"log",
"objc",
"objc-foundation",
"objc_id",
"parking_lot",
"thiserror",
"winapi",
"x11rb",
]
[[package]] [[package]]
name = "arrayvec" name = "arrayvec"
version = "0.7.4" version = "0.7.4"
@ -255,6 +274,12 @@ version = "4.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae"
[[package]]
name = "atomic_refcell"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "112ef6b3f6cb3cb6fc5b6b494ef7a848492cff1ab0ef4de10b0f7d572861c905"
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.1.0" version = "1.1.0"
@ -297,6 +322,45 @@ dependencies = [
"bevy_internal", "bevy_internal",
] ]
[[package]]
name = "bevy-inspector-egui"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd2523be5ae7d482e5435dc75509b80a320989175768fb4b711603b9d2ab8fff"
dependencies = [
"bevy-inspector-egui-derive",
"bevy_app",
"bevy_asset",
"bevy_core",
"bevy_core_pipeline",
"bevy_ecs",
"bevy_egui",
"bevy_hierarchy",
"bevy_log",
"bevy_math",
"bevy_pbr",
"bevy_reflect",
"bevy_render",
"bevy_utils",
"bevy_window",
"egui",
"image",
"once_cell",
"pretty-type-name",
"smallvec",
]
[[package]]
name = "bevy-inspector-egui-derive"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0edba455601861b8e8b76128ae5d46dd968114edde60f0ac3d2c21535a947548"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.37",
]
[[package]] [[package]]
name = "bevy_a11y" name = "bevy_a11y"
version = "0.11.2" version = "0.11.2"
@ -488,6 +552,19 @@ dependencies = [
"syn 2.0.37", "syn 2.0.37",
] ]
[[package]]
name = "bevy_egui"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a73a93a8cf6b8c744281d1b88f5b0fa278d608e909af9bbf4eb491a7cb1ad2c"
dependencies = [
"arboard",
"bevy",
"egui",
"thread_local",
"webbrowser",
]
[[package]] [[package]]
name = "bevy_encase_derive" name = "bevy_encase_derive"
version = "0.11.2" version = "0.11.2"
@ -1176,6 +1253,17 @@ dependencies = [
"libloading 0.7.4", "libloading 0.7.4",
] ]
[[package]]
name = "clipboard-win"
version = "4.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362"
dependencies = [
"error-code",
"str-buf",
"winapi",
]
[[package]] [[package]]
name = "codespan-reporting" name = "codespan-reporting"
version = "0.11.1" version = "0.11.1"
@ -1402,6 +1490,35 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
[[package]]
name = "ecolor"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e479a7fa3f23d4e794f8b2f8b3568dd4e47886ad1b12c9c095e141cb591eb63"
dependencies = [
"bytemuck",
]
[[package]]
name = "egui"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3aef8ec3ae1b772f340170c65bf27d5b8c28f543a0116c844d2ac08d01123e7"
dependencies = [
"ahash 0.8.3",
"epaint",
"nohash-hasher",
]
[[package]]
name = "emath"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3857d743a6e0741cdd60b622a74c7a36ea75f5f8f11b793b41d905d2c9721a4b"
dependencies = [
"bytemuck",
]
[[package]] [[package]]
name = "encase" name = "encase"
version = "0.6.1" version = "0.6.1"
@ -1434,6 +1551,22 @@ dependencies = [
"syn 2.0.37", "syn 2.0.37",
] ]
[[package]]
name = "epaint"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09333964d4d57f40a85338ba3ca5ed4716070ab184dcfed966b35491c5c64f3b"
dependencies = [
"ab_glyph",
"ahash 0.8.3",
"atomic_refcell",
"bytemuck",
"ecolor",
"emath",
"nohash-hasher",
"parking_lot",
]
[[package]] [[package]]
name = "equivalent" name = "equivalent"
version = "1.0.1" version = "1.0.1"
@ -1449,6 +1582,16 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "error-code"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21"
dependencies = [
"libc",
"str-buf",
]
[[package]] [[package]]
name = "euclid" name = "euclid"
version = "0.22.9" version = "0.22.9"
@ -1531,6 +1674,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "form_urlencoded"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652"
dependencies = [
"percent-encoding",
]
[[package]] [[package]]
name = "fsevent-sys" name = "fsevent-sys"
version = "4.1.0" version = "4.1.0"
@ -1567,6 +1719,16 @@ dependencies = [
"waker-fn", "waker-fn",
] ]
[[package]]
name = "gethostname"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e"
dependencies = [
"libc",
"winapi",
]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.10" version = "0.2.10"
@ -1812,6 +1974,25 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
[[package]]
name = "home"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "idna"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c"
dependencies = [
"unicode-bidi",
"unicode-normalization",
]
[[package]] [[package]]
name = "image" name = "image"
version = "0.24.7" version = "0.24.7"
@ -1824,6 +2005,7 @@ dependencies = [
"num-rational", "num-rational",
"num-traits", "num-traits",
"png", "png",
"tiff",
] ]
[[package]] [[package]]
@ -1928,6 +2110,22 @@ dependencies = [
"walkdir", "walkdir",
] ]
[[package]]
name = "jni"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97"
dependencies = [
"cesu8",
"cfg-if",
"combine",
"jni-sys",
"log",
"thiserror",
"walkdir",
"windows-sys 0.45.0",
]
[[package]] [[package]]
name = "jni-sys" name = "jni-sys"
version = "0.3.0" version = "0.3.0"
@ -1943,6 +2141,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "jpeg-decoder"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e"
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.64" version = "0.3.64"
@ -2100,6 +2304,15 @@ version = "2.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
[[package]]
name = "memoffset"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "metal" name = "metal"
version = "0.24.0" version = "0.24.0"
@ -2221,6 +2434,7 @@ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"cfg-if", "cfg-if",
"libc", "libc",
"memoffset",
] ]
[[package]] [[package]]
@ -2234,6 +2448,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "nohash-hasher"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
[[package]] [[package]]
name = "nom" name = "nom"
version = "7.1.3" version = "7.1.3"
@ -2375,6 +2595,17 @@ dependencies = [
"objc_exception", "objc_exception",
] ]
[[package]]
name = "objc-foundation"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
dependencies = [
"block",
"objc",
"objc_id",
]
[[package]] [[package]]
name = "objc-sys" name = "objc-sys"
version = "0.2.0-beta.2" version = "0.2.0-beta.2"
@ -2410,6 +2641,15 @@ dependencies = [
"cc", "cc",
] ]
[[package]]
name = "objc_id"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b"
dependencies = [
"objc",
]
[[package]] [[package]]
name = "object" name = "object"
version = "0.32.1" version = "0.32.1"
@ -2572,6 +2812,12 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "pretty-type-name"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0f73cdaf19b52e6143685c3606206e114a4dfa969d6b14ec3894c88eb38bd4b"
[[package]] [[package]]
name = "proc-macro-crate" name = "proc-macro-crate"
version = "1.3.1" version = "1.3.1"
@ -2716,6 +2962,7 @@ name = "rps"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bevy", "bevy",
"bevy-inspector-egui",
"tracing", "tracing",
] ]
@ -2867,6 +3114,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "str-buf"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0"
[[package]] [[package]]
name = "svg_fmt" name = "svg_fmt"
version = "0.4.1" version = "0.4.1"
@ -2980,6 +3233,17 @@ dependencies = [
"once_cell", "once_cell",
] ]
[[package]]
name = "tiff"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d172b0f4d3fba17ba89811858b9d3d97f928aece846475bbda076ca46736211"
dependencies = [
"flate2",
"jpeg-decoder",
"weezl",
]
[[package]] [[package]]
name = "tinyvec" name = "tinyvec"
version = "1.6.0" version = "1.6.0"
@ -3101,12 +3365,27 @@ dependencies = [
"static_assertions", "static_assertions",
] ]
[[package]]
name = "unicode-bidi"
version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.12" version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-normalization"
version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
dependencies = [
"tinyvec",
]
[[package]] [[package]]
name = "unicode-width" name = "unicode-width"
version = "0.1.11" version = "0.1.11"
@ -3119,6 +3398,17 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]]
name = "url"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5"
dependencies = [
"form_urlencoded",
"idna",
"percent-encoding",
]
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "1.4.1" version = "1.4.1"
@ -3256,6 +3546,29 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "webbrowser"
version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2c79b77f525a2d670cb40619d7d9c673d09e0666f72c591ebd7861f84a87e57"
dependencies = [
"core-foundation",
"home",
"jni 0.21.1",
"log",
"ndk-context",
"objc",
"raw-window-handle",
"url",
"web-sys",
]
[[package]]
name = "weezl"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
[[package]] [[package]]
name = "wgpu" name = "wgpu"
version = "0.16.3" version = "0.16.3"
@ -3387,6 +3700,15 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "winapi-wsapoll"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44c17110f57155602a80dca10be03852116403c9ff3cd25b079d666f2aa3df6e"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "winapi-x86_64-pc-windows-gnu" name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
@ -3645,6 +3967,28 @@ dependencies = [
"pkg-config", "pkg-config",
] ]
[[package]]
name = "x11rb"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507"
dependencies = [
"gethostname",
"nix 0.24.3",
"winapi",
"winapi-wsapoll",
"x11rb-protocol",
]
[[package]]
name = "x11rb-protocol"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56b245751c0ac9db0e006dc812031482784e434630205a93c73cfefcaabeac67"
dependencies = [
"nix 0.24.3",
]
[[package]] [[package]]
name = "xi-unicode" name = "xi-unicode"
version = "0.3.0" version = "0.3.0"

@ -16,4 +16,5 @@ edition = "2021"
[dependencies] [dependencies]
bevy = { version = "0.11.2", features = [ ] } bevy = { version = "0.11.2", features = [ ] }
bevy-inspector-egui = "0.19.0"
tracing = "0.1.37" tracing = "0.1.37"

@ -5,8 +5,11 @@ mod start_menu;
use bevy::prelude::*; use bevy::prelude::*;
use bevy_inspector_egui::quick::WorldInspectorPlugin;
fn main() { fn main() {
App::new() App::new()
.add_plugins((DefaultPlugins, game::Game::default())) .add_plugins((DefaultPlugins, game::Game::default()))
.add_plugins(WorldInspectorPlugin::new())
.run(); .run();
} }

@ -1,24 +1,56 @@
use crate::events; use crate::events;
use bevy::ecs::system::EntityCommand;
use bevy::prelude::*; use bevy::prelude::*;
use bevy::text::DEFAULT_FONT_HANDLE;
pub struct Play {} pub struct Play {}
fn action_button() -> ButtonBundle { struct ActionButton {
text: String,
}
impl EntityCommand for ActionButton {
fn apply(self, id: Entity, world: &mut World) {
let style = TextStyle {
font: DEFAULT_FONT_HANDLE.typed(),
font_size: 24.0,
color: Color::WHITE,
};
let button = world
.spawn((
Name::new("action button"),
ButtonBundle { ButtonBundle {
style: Style { style: Style {
align_items: AlignItems::Center, align_items: AlignItems::Center,
width: Val::Percent(100.0), width: Val::Percent(100.0),
height: Val::Percent(100.0), height: Val::Percent(100.0),
border: UiRect::all(Val::Px(2.0)),
..default() ..default()
}, },
border_color: Color::RED.into(),
background_color: Color::GRAY.into(), background_color: Color::GRAY.into(),
..default() ..default()
},
// TextBundle::from_section("Cool", style),
))
.set_parent(id)
.id();
world
.spawn((
Name::new("fart"),
TextBundle::from_section(self.text, style),
))
.set_parent(button);
} }
} }
fn handle_play(mut events: EventReader<events::Play>, mut commands: Commands) { fn handle_play(mut events: EventReader<events::Play>, mut commands: Commands) {
for _ in events.iter() { for _ in events.iter() {
let mut bg = commands.spawn(NodeBundle { let mut bg = commands.spawn((
Name::new("UI Container"),
NodeBundle {
style: Style { style: Style {
display: Display::Flex, display: Display::Flex,
flex_direction: FlexDirection::Column, flex_direction: FlexDirection::Column,
@ -26,13 +58,16 @@ fn handle_play(mut events: EventReader<events::Play>, mut commands: Commands) {
width: Val::Percent(100.0), width: Val::Percent(100.0),
..default() ..default()
}, },
border_color: Color::RED.into(),
background_color: Color::GRAY.into(), background_color: Color::GRAY.into(),
..default() ..default()
}); },
));
bg.with_children(|bg| { bg.with_children(|bg| {
// header bg.spawn((
bg.spawn(NodeBundle { Name::new("Header"),
NodeBundle {
style: Style { style: Style {
display: Display::Flex, display: Display::Flex,
height: Val::Percent(10.0), height: Val::Percent(10.0),
@ -46,10 +81,12 @@ fn handle_play(mut events: EventReader<events::Play>, mut commands: Commands) {
border_color: Color::BLACK.into(), border_color: Color::BLACK.into(),
background_color: Color::GRAY.into(), background_color: Color::GRAY.into(),
..default() ..default()
}); },
));
// main play area bg.spawn((
bg.spawn(NodeBundle { Name::new("Play"),
NodeBundle {
style: Style { style: Style {
display: Display::Flex, display: Display::Flex,
height: Val::Percent(50.0), height: Val::Percent(50.0),
@ -63,10 +100,13 @@ fn handle_play(mut events: EventReader<events::Play>, mut commands: Commands) {
background_color: Color::GRAY.into(), background_color: Color::GRAY.into(),
border_color: Color::BLACK.into(), border_color: Color::BLACK.into(),
..default() ..default()
}); },
));
// Action controls // Action controls
let mut control_row = bg.spawn(NodeBundle { let mut control_row = bg.spawn((
Name::new("Controls"),
NodeBundle {
style: Style { style: Style {
flex_direction: FlexDirection::Row, flex_direction: FlexDirection::Row,
display: Display::Flex, display: Display::Flex,
@ -76,44 +116,17 @@ fn handle_play(mut events: EventReader<events::Play>, mut commands: Commands) {
}, },
background_color: Color::GRAY.into(), background_color: Color::GRAY.into(),
..default() ..default()
});
control_row.with_children(|controls| {
controls.spawn(NodeBundle {
style: Style {
display: Display::Flex,
height: Val::Percent(100.0),
width: Val::Percent(100.0),
border: UiRect::all(Val::Px(8.0)),
..default()
},
border_color: Color::RED.into(),
background_color: Color::GRAY.into(),
..default()
});
controls.spawn(NodeBundle {
style: Style {
display: Display::Flex,
height: Val::Percent(100.0),
width: Val::Percent(100.0),
border: UiRect::all(Val::Px(8.0)),
..default()
}, },
border_color: Color::RED.into(), ));
background_color: Color::GRAY.into(),
..default() control_row.add(ActionButton {
text: "Rock".into(),
}); });
controls.spawn(NodeBundle { control_row.add(ActionButton {
style: Style { text: "Paper".into(),
display: Display::Flex,
height: Val::Percent(100.0),
width: Val::Percent(100.0),
border: UiRect::all(Val::Px(8.0)),
..default()
},
border_color: Color::RED.into(),
background_color: Color::GRAY.into(),
..default()
}); });
control_row.add(ActionButton {
text: "Scissors".into(),
}); });
}); });
} }

@ -24,7 +24,7 @@ struct QuitButton;
#[derive(Component)] #[derive(Component)]
pub(crate) struct PlayButton; pub(crate) struct PlayButton;
fn title_text() -> TextBundle { fn title_text() -> impl Bundle {
let style = TextStyle { let style = TextStyle {
font: DEFAULT_FONT_HANDLE.typed(), font: DEFAULT_FONT_HANDLE.typed(),
font_size: 32.0, font_size: 32.0,
@ -33,7 +33,7 @@ fn title_text() -> TextBundle {
TextBundle::from_section("Rock, Paper, Scissors", style) TextBundle::from_section("Rock, Paper, Scissors", style)
} }
fn thicc_button() -> ButtonBundle { fn thicc_button() -> impl Bundle {
ButtonBundle { ButtonBundle {
style: Style { style: Style {
flex_direction: FlexDirection::Column, flex_direction: FlexDirection::Column,
@ -103,17 +103,20 @@ fn click_quit(
} }
} }
fn vertical_spacer(height: f32) -> NodeBundle { fn vertical_spacer(height: f32) -> impl Bundle {
(
Name::new("spacer"),
NodeBundle { NodeBundle {
style: Style { style: Style {
min_height: Val::Px(height), min_height: Val::Px(height),
..default() ..default()
}, },
..default() ..default()
} },
)
} }
fn column() -> NodeBundle { fn column() -> impl Bundle {
NodeBundle { NodeBundle {
style: Style { style: Style {
display: Display::Flex, display: Display::Flex,
@ -127,11 +130,11 @@ fn column() -> NodeBundle {
} }
} }
struct AddChildLabel { struct Label {
text: String, text: String,
} }
impl EntityCommand for AddChildLabel { impl EntityCommand for Label {
fn apply(self, id: Entity, world: &mut World) { fn apply(self, id: Entity, world: &mut World) {
let style = TextStyle { let style = TextStyle {
font: DEFAULT_FONT_HANDLE.typed(), font: DEFAULT_FONT_HANDLE.typed(),
@ -160,12 +163,15 @@ fn setup(mut commands: Commands) {
let green = Color::rgb(0.2, 0.8, 0.2); let green = Color::rgb(0.2, 0.8, 0.2);
commands.spawn(Camera2dBundle::default()); commands.spawn(Camera2dBundle::default());
commands.spawn((MainMenu, column())).with_children(|menu| { commands
.spawn((Name::new("Start Menu"), MainMenu, column()))
.with_children(|menu| {
menu.spawn(vertical_spacer(80.0)); menu.spawn(vertical_spacer(80.0));
menu.spawn((Title, title_text())); menu.spawn((Name::new("Title Text"), Title, title_text()));
menu.spawn(vertical_spacer(32.0)); menu.spawn(vertical_spacer(32.0));
menu.spawn(( menu.spawn((
Name::new("Play Button"),
PlayButton, PlayButton,
thicc_button(), thicc_button(),
HoverColor { HoverColor {
@ -173,13 +179,14 @@ fn setup(mut commands: Commands) {
off: red, off: red,
}, },
)) ))
.add(AddChildLabel { .add(Label {
text: String::from("Play"), text: String::from("Play"),
}); });
menu.spawn(vertical_spacer(32.0)); menu.spawn(vertical_spacer(32.0));
menu.spawn(( menu.spawn((
Name::new("Quit Button"),
QuitButton, QuitButton,
thicc_button(), thicc_button(),
HoverColor { HoverColor {
@ -187,7 +194,7 @@ fn setup(mut commands: Commands) {
off: red, off: red,
}, },
)) ))
.add(AddChildLabel { .add(Label {
text: String::from("Quit"), text: String::from("Quit"),
}); });
}); });

Loading…
Cancel
Save