Board layers
This commit is contained in:
+22
-14
@@ -143,21 +143,29 @@ fn run(
|
||||
continue;
|
||||
}
|
||||
let size = terminal.size()?;
|
||||
match current_input_mode(mode, ui) {
|
||||
InputMode::Board | InputMode::Frozen => {
|
||||
if let Mode::Play(game) = mode {
|
||||
handle_board_input(event, ui.log.open, size.height, game, ui);
|
||||
}
|
||||
// Each Mode only produces a subset of input modes (Editor only in Edit;
|
||||
// Board/Scroll/Frozen only in Play; Menu/Ignore in either). Match on Mode
|
||||
// first so each handler gets the right `game`/`ed` without re-checking,
|
||||
// and assert the impossible combinations away with `unreachable!`.
|
||||
let input_mode = current_input_mode(mode, ui);
|
||||
if matches!(input_mode, InputMode::Menu) {
|
||||
handle_menu_input(event, ui)
|
||||
} else if !matches!(input_mode, InputMode::Ignore) {
|
||||
// If input_mode is ignore, an animation is running and claiming no input mode — discard all events.
|
||||
match mode {
|
||||
Mode::Play(game) => match input_mode {
|
||||
InputMode::Board | InputMode::Frozen => {
|
||||
handle_board_input(event, ui.log.open, size.height, game, ui);
|
||||
}
|
||||
InputMode::Scroll => handle_scroll_input(event, game, ui),
|
||||
_ => unreachable!("Menu and Ignore handled above; Editor input mode only occurs in Edit mode"),
|
||||
},
|
||||
Mode::Edit(ed) => match input_mode {
|
||||
InputMode::Editor => handle_editor_input(event, size.width, ed, ui),
|
||||
_ => unreachable!("Menu and Ignore handled above; Board/Scroll/Frozen input modes only occur in Play mode")
|
||||
},
|
||||
}
|
||||
InputMode::Menu => handle_menu_input(event, ui),
|
||||
InputMode::Scroll => {
|
||||
if let Mode::Play(game) = mode { handle_scroll_input(event, game, ui); }
|
||||
}
|
||||
InputMode::Editor => {
|
||||
if let Mode::Edit(ed) = mode { handle_editor_input(event, size.width, ed, ui); }
|
||||
}
|
||||
// Animation running and claiming no input mode — discard all events.
|
||||
InputMode::Ignore => {}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user