final refactors
This commit is contained in:
+12
-1
@@ -1,7 +1,6 @@
|
||||
use ratatui::crossterm::event::{Event, KeyCode, MouseEventKind};
|
||||
use kiln_core::Direction;
|
||||
use kiln_core::game::{GameState, ScrollLine};
|
||||
use crate::resolve_choice;
|
||||
use crate::scroll_overlay::ScrollAnimState;
|
||||
use crate::ui::Ui;
|
||||
|
||||
@@ -50,6 +49,18 @@ pub(crate) fn handle_board_input(event: Event, log_open: bool, terminal_h: u16,
|
||||
false
|
||||
}
|
||||
|
||||
/// Returns the choice string for the given key character, scanning the scroll lines.
|
||||
fn resolve_choice(lines: &[ScrollLine], c: char) -> Option<String> {
|
||||
let mut letter = b'a';
|
||||
for line in lines {
|
||||
if let ScrollLine::Choice { choice, .. } = line {
|
||||
if c == letter as char { return Some(choice.clone()); }
|
||||
letter += 1;
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Handles an input event in [`InputMode::Scroll`].
|
||||
pub(crate) fn handle_scroll_input(event: Event, game: &mut GameState, ui: &mut Ui) {
|
||||
match event {
|
||||
|
||||
Reference in New Issue
Block a user