Menu-Panel
This commit is contained in:
+27
-8
@@ -150,6 +150,8 @@ struct App {
|
||||
last: Option<Instant>,
|
||||
/// Letzte Mausposition in Fenster-Pixeln (für den UI-Cursor).
|
||||
cursor_win: [f32; 2],
|
||||
/// Linksklick steht aus, wird im nächsten redraw gegen das UI aufgelöst.
|
||||
pending_click: bool,
|
||||
/// CPU-seitige Welt-Geometrie + Texturen, in `resumed` einmal auf die
|
||||
/// GPU geladen.
|
||||
mesh: Mesh,
|
||||
@@ -177,6 +179,7 @@ impl App {
|
||||
input: Input::default(),
|
||||
last: None,
|
||||
cursor_win: [0.0, 0.0],
|
||||
pending_click: false,
|
||||
mesh,
|
||||
images,
|
||||
ui_textures,
|
||||
@@ -255,9 +258,10 @@ impl ApplicationHandler for App {
|
||||
self.cursor_win = [position.x as f32, position.y as f32];
|
||||
}
|
||||
WindowEvent::MouseInput { state: ElementState::Pressed, button: MouseButton::Left, .. } => {
|
||||
// Nur im freien Modus greift der Klick die Maus (Flycam). Im
|
||||
// UI-/Dialog-Modus bleibt die Maus frei (für Klicks aufs UI).
|
||||
if matches!(self.session.mode, Mode::Free) { self.set_grab(true); }
|
||||
// Klick nur vormerken; der nächste redraw entscheidet (mit der
|
||||
// frisch berechneten Hover-Aktion) zwischen UI-Klick und
|
||||
// Flycam-Greifen.
|
||||
self.pending_click = true;
|
||||
}
|
||||
WindowEvent::KeyboardInput { event: key, .. } => self.on_key(event_loop, key),
|
||||
WindowEvent::Resized(size) => {
|
||||
@@ -265,7 +269,7 @@ impl ApplicationHandler for App {
|
||||
gpu.resize(size.width, size.height);
|
||||
}
|
||||
}
|
||||
WindowEvent::RedrawRequested => self.redraw(),
|
||||
WindowEvent::RedrawRequested => self.redraw(event_loop),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -293,7 +297,7 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
fn redraw(&mut self) {
|
||||
fn redraw(&mut self, event_loop: &ActiveEventLoop) {
|
||||
// dt messen; im Dialog Kamera und Sim anhalten → Welt pausiert,
|
||||
// während die Konsole den Dialog treibt.
|
||||
let now = Instant::now();
|
||||
@@ -323,11 +327,26 @@ impl App {
|
||||
.unwrap_or([0.0, 0.0]),
|
||||
grabbed: self.input.grabbed,
|
||||
};
|
||||
// Overlay state-driven bauen (Stage 3: Demo-Panel + Cursor).
|
||||
let overlay = ui::layout(
|
||||
// Overlay state-driven bauen; Hover-Aktion kommt aus der Maus-Position.
|
||||
let screen = ui::layout(
|
||||
[gpu::INTERNAL_W as f32, gpu::INTERNAL_H as f32], &self.fonts, &cursor,
|
||||
);
|
||||
if let Some(gpu) = &mut self.gpu { gpu.frame(&view, &overlay); }
|
||||
|
||||
// Vorgemerkten Klick auflösen: über einem Klickziel → dessen Aktion
|
||||
// durch denselben exec-Trichter wie die Konsole; sonst im Free-Modus
|
||||
// die Maus für die Flycam greifen.
|
||||
if self.pending_click {
|
||||
self.pending_click = false;
|
||||
if let Some(action) = screen.hover_action.clone() {
|
||||
let r = self.session.exec(&action);
|
||||
for out in r.output { println!("{out}"); }
|
||||
if r.quit { event_loop.exit(); }
|
||||
} else if matches!(self.session.mode, Mode::Free) && !self.input.grabbed {
|
||||
self.set_grab(true);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(gpu) = &mut self.gpu { gpu.frame(&view, &screen.ui); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user