use std::sync::Arc; use winit::window::Window; use crate::{ args::Game, chooser::Chooser, dpi::{PhysicalPoint, PhysicalSize, ScaleFactor}, draw_commands::DrawCommand, input::{Key, ModifiersState, MouseButton}, installer::Installer, pob::PathOfBuilding, }; pub enum StageEvent { KeyDown { key: Key }, KeyUp { key: Key }, CharacterInput { ch: char }, ModifiersChanged { state: ModifiersState }, MouseDown { button: MouseButton }, MouseUp { button: MouseButton }, MouseWheel { delta: f32 }, MouseMoved { pos: PhysicalPoint }, Exit, Resized(PhysicalSize), ScaleFactorChanged(f64), FocusChanged(bool), HoverChanged(bool), } pub enum StageTransition { StartGame(Game), ToMain, ToShutdown, } pub struct StageFrameOutput { pub draw_commands: Vec, pub can_elide: bool, pub request_redraw: bool, pub scale_factor: ScaleFactor, } pub enum ActiveStage { Chooser(Box), Startup(Installer), Main(PathOfBuilding), } impl ActiveStage { pub fn update(&mut self) -> anyhow::Result> { match self { Self::Chooser(s) => s.update(), Self::Startup(s) => s.update(), Self::Main(s) => s.update(), } } pub fn frame(&mut self) -> anyhow::Result { match self { Self::Chooser(s) => s.frame(), Self::Startup(s) => s.frame(), Self::Main(s) => s.frame(), } } pub fn handle_event(&mut self, event: StageEvent) -> anyhow::Result> { match self { Self::Chooser(s) => s.handle_event(event), Self::Startup(s) => s.handle_event(event), Self::Main(s) => s.handle_event(event), } } pub fn set_window(&mut self, window: Arc) { match self { Self::Chooser(s) => s.set_window(window), Self::Startup(s) => s.set_window(window), Self::Main(s) => s.set_window(window), } } pub fn can_exit(&mut self) -> bool { match self { Self::Chooser(_) => true, Self::Startup(_) => true, Self::Main(s) => s.can_exit(), } } pub fn clear_pressed(&mut self) { match self { Self::Chooser(s) => s.clear_pressed(), Self::Startup(_) => {} Self::Main(s) => s.clear_pressed(), } } }