wip: refactor pt.5, no translate

This commit is contained in:
🪞👃🪞 2024-11-10 01:34:17 +01:00
parent 8c37c95cc6
commit 5df08409e5
19 changed files with 389 additions and 457 deletions

View file

@ -12,8 +12,16 @@ pub fn delegate <B, C: Command<S>, S> (
Ok(cmd.execute(state)?.map(|x|wrap(x)))
}
pub trait InputToCommand<E: Engine, S>: Sized {
pub trait InputToCommand<E: Engine, S>: Command<S> + Sized {
fn input_to_command (state: &S, input: &E::Input) -> Option<Self>;
fn execute_with_state (state: &mut S, input: &E::Input) -> Perhaps<bool> {
Ok(if let Some(command) = Self::input_to_command(state, input) {
let _undo = command.execute(state)?;
Some(true)
} else {
None
})
}
}
pub struct MenuBar<E: Engine, S, C: Command<S>> {
pub menus: Vec<Menu<E, S, C>>,