hover effect, layout hands and ponds

This commit is contained in:
Tao Tien 2026-01-13 04:11:09 -08:00
parent 4112edbf2a
commit 8a8a702a08
6 changed files with 163 additions and 20 deletions

81
src/tui/input/keyboard.rs Normal file
View file

@ -0,0 +1,81 @@
use bevy::prelude::*;
use bevy_ratatui::crossterm::event::KeyCode;
use bevy_ratatui::event::KeyMessage;
use jong::game::GameState;
use crate::tui::{TuiState, console::ConsoleState};
// TODO change this to handle console open request, esc for menu, etc, then
// route other messages to other systems
#[allow(clippy::too_many_arguments)]
pub(crate) fn input_system(
mut messages: MessageReader<KeyMessage>,
curr_tuistate: Res<State<TuiState>>,
curr_consolestate: Res<State<ConsoleState>>,
curr_gamestate: Res<State<GameState>>,
mut next_tuistate: ResMut<NextState<TuiState>>,
mut next_consolestate: ResMut<NextState<ConsoleState>>,
mut next_gamestate: ResMut<NextState<GameState>>,
mut exit: MessageWriter<AppExit>,
) {
let (ts, cs, gs) = (
curr_tuistate.get(),
curr_consolestate.get(),
curr_gamestate.get(),
);
for message in messages.read() {
if let KeyCode::Char('`') = message.code {
next_consolestate.set(!*curr_consolestate.get());
continue;
}
if *cs == ConsoleState::Open {
let mut passthrough = false;
match message.code {
KeyCode::Up => todo!(),
KeyCode::Down => todo!(),
KeyCode::Home => todo!(),
KeyCode::End => todo!(),
KeyCode::PageUp => todo!(),
KeyCode::PageDown => todo!(),
KeyCode::Esc => next_consolestate.set(ConsoleState::Closed),
_ => passthrough = true,
}
if !passthrough {
continue;
}
}
match ts {
TuiState::MainMenu => match message.code {
KeyCode::Char('p') => {
next_tuistate.set(TuiState::InGame);
next_gamestate.set(GameState::Setup);
}
KeyCode::Char('q') => {
exit.write_default();
}
_ => {}
},
TuiState::InGame => match gs {
GameState::Setup => match message.code {
_ => {}
},
GameState::Play => match message.code {
KeyCode::Char('q') => {
exit.write_default();
}
_ => {}
},
_ => todo!(),
_ => unreachable!("TuiState::InGame but GameState invalid"),
},
}
}
}