use geng_ui as ui;
use geng_window::Event;
use std::ops::DerefMut;
mod combined;
mod manager;
pub use combined::*;
pub use manager::*;
pub enum Transition {
Pop,
Switch(Box<dyn State>),
Push(Box<dyn State>),
}
pub trait State: 'static {
fn update(&mut self, delta_time: f64) {
#![allow(unused_variables)]
}
fn fixed_update(&mut self, delta_time: f64) {
#![allow(unused_variables)]
}
fn draw(&mut self, framebuffer: &mut ugli::Framebuffer);
fn handle_event(&mut self, event: Event) {
#![allow(unused_variables)]
}
fn transition(&mut self) -> Option<Transition> {
None
}
fn ui<'a>(&'a mut self, cx: &'a ui::Controller) -> Box<dyn ui::Widget + 'a> {
#![allow(unused_variables)]
Box::new(ui::Void)
}
}
pub struct Empty;
impl State for Empty {
fn draw(&mut self, _: &mut ugli::Framebuffer) {}
}
impl<T: State + ?Sized> State for Box<T> {
fn update(&mut self, delta_time: f64) {
<T as State>::update(self, delta_time);
}
fn fixed_update(&mut self, delta_time: f64) {
<T as State>::fixed_update(self, delta_time);
}
fn draw(&mut self, framebuffer: &mut ugli::Framebuffer) {
<T as State>::draw(self, framebuffer);
}
fn handle_event(&mut self, event: Event) {
<T as State>::handle_event(self, event);
}
fn transition(&mut self) -> Option<Transition> {
<T as State>::transition(self)
}
fn ui<'a>(&'a mut self, cx: &'a ui::Controller) -> Box<dyn ui::Widget + 'a> {
<T as State>::ui(self, cx)
}
}