diff options
author | metamuffin <metamuffin@disroot.org> | 2025-01-17 23:32:27 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-01-17 23:32:27 +0100 |
commit | f5ffcaf01b91daf0019dd6534b035398fa51f2f0 (patch) | |
tree | ef271596fee967ded3c7c1668033bba97823afbd /client/src/state.rs | |
parent | 1ca762dedcdd6c87086560dd56ab3566b08243d0 (diff) | |
download | weareserver-f5ffcaf01b91daf0019dd6534b035398fa51f2f0.tar weareserver-f5ffcaf01b91daf0019dd6534b035398fa51f2f0.tar.bz2 weareserver-f5ffcaf01b91daf0019dd6534b035398fa51f2f0.tar.zst |
fix ui unprojection
Diffstat (limited to 'client/src/state.rs')
-rw-r--r-- | client/src/state.rs | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/client/src/state.rs b/client/src/state.rs index 560c8bd..60be957 100644 --- a/client/src/state.rs +++ b/client/src/state.rs @@ -16,6 +16,7 @@ */ use crate::{ audio::Audio, camera::Camera, download::Downloader, network::Network, renderer::Renderer, + ui::UiEvent, }; use anyhow::{Context, Result}; use glam::{Vec2, Vec3}; @@ -49,7 +50,7 @@ pub struct InputState { pub move_dir: Vec3, pub mouse_acc: Vec2, pub cursor_pos: Vec2, - pub egui_events: Vec<egui::Event>, + pub ui_events: Vec<UiEvent>, } impl<'a> State<'a> { @@ -68,7 +69,7 @@ impl<'a> State<'a> { move_dir: Vec3::ZERO, mouse_acc: Vec2::ZERO, cursor_pos: Vec2::ZERO, - egui_events: Vec::new(), + ui_events: Vec::new(), }, prefab_index_res: None, prefab_index_res_loaded: None, @@ -80,7 +81,7 @@ impl<'a> State<'a> { pub fn draw(&mut self) { if let Err(e) = self .renderer - .draw(&self.tree, &self.camera, &self.input_state) + .draw(&self.tree, &self.camera, &mut self.input_state) { warn!("draw failed: {e:?}"); } @@ -91,20 +92,8 @@ impl<'a> State<'a> { } pub fn click(&mut self, button: MouseButton, down: bool) { self.input_state - .egui_events - .push(egui::Event::PointerButton { - pos: egui::Pos2::new(self.input_state.cursor_pos.x, self.input_state.cursor_pos.y), - button: match button { - MouseButton::Left => egui::PointerButton::Primary, - MouseButton::Right => egui::PointerButton::Secondary, - MouseButton::Middle => egui::PointerButton::Middle, - MouseButton::Back => egui::PointerButton::Extra1, - MouseButton::Forward => egui::PointerButton::Extra2, - MouseButton::Other(_) => egui::PointerButton::Extra1, - }, - pressed: down, - modifiers: egui::Modifiers::default(), - }); + .ui_events + .push(UiEvent::Click(self.input_state.cursor_pos, button, down)); if !down || button != MouseButton::Right { return; @@ -196,7 +185,6 @@ impl<'a> State<'a> { } } - self.input_state.egui_events.clear(); Ok(()) } } |