aboutsummaryrefslogtreecommitdiff
path: root/pixel-client/src/menu.rs
diff options
context:
space:
mode:
Diffstat (limited to 'pixel-client/src/menu.rs')
-rw-r--r--pixel-client/src/menu.rs29
1 files changed, 24 insertions, 5 deletions
diff --git a/pixel-client/src/menu.rs b/pixel-client/src/menu.rs
index 0d63d4e7..6c382331 100644
--- a/pixel-client/src/menu.rs
+++ b/pixel-client/src/menu.rs
@@ -8,7 +8,10 @@ use hurrycurry_protocol::{
TileIndex,
};
use rand::{random, seq::IndexedRandom, thread_rng};
-use sdl2::keyboard::KeyboardState;
+use sdl2::{
+ keyboard::{KeyboardState, Keycode},
+ mouse::MouseState,
+};
#[derive(Debug)]
pub struct Menu {
@@ -55,9 +58,19 @@ impl Menu {
background: Vec2::ZERO,
}
}
- pub fn tick(&mut self, dt: f32, _keyboard: &KeyboardState, _layout: &AtlasLayout) {
+ pub fn tick(
+ &mut self,
+ dt: f32,
+ keyboard: &KeyboardState,
+ mouse: &MouseState,
+ _layout: &AtlasLayout,
+ ) {
self.fade_in = (self.fade_in + dt).min(1.);
self.background += Vec2::new(2., 3.) * dt;
+ self.ui_state.update(keyboard, mouse, dt);
+ }
+ pub fn keyboard_event(&mut self, keycode: Keycode, down: bool) {
+ self.ui_state.keyboard_event(keycode, down);
}
pub fn draw(&mut self, ctx: &mut Renderer) {
ctx.set_world_view(
@@ -85,9 +98,15 @@ impl Menu {
self.map.draw(ctx);
self.ui_state.draw(ctx, |ui| {
- ui.button("Join");
- ui.button("Settings");
- ui.button("Quit");
+ if ui.button("Join") {
+ eprintln!("join button")
+ }
+ if ui.button("Settings") {
+ eprintln!("settings button")
+ }
+ if ui.button("Quit") {
+ eprintln!("quit button")
+ }
});
ctx.draw_ui(SpriteDraw::overlay(