chore: rename game.rs
to the more fitting tui.rs
This commit is contained in:
parent
50b59ca303
commit
400852f7dc
3 changed files with 11 additions and 12 deletions
|
@ -1,13 +1,13 @@
|
|||
use color_eyre::Result;
|
||||
|
||||
mod game;
|
||||
mod tui;
|
||||
mod menu;
|
||||
mod util;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
color_eyre::install()?;
|
||||
let terminal = ratatui::init();
|
||||
let app_result = game::Mode::default().run(terminal);
|
||||
let app_result = tui::Mode::default().run(terminal);
|
||||
ratatui::restore();
|
||||
app_result
|
||||
}
|
||||
|
|
|
@ -7,12 +7,11 @@ use ratatui::{
|
|||
style::{Modifier, Style, Stylize, palette::tailwind::*},
|
||||
widgets::{
|
||||
Block, Borders, HighlightSpacing, List,
|
||||
ListState, Padding, StatefulWidget, Paragraph
|
||||
ListState, Padding, StatefulWidget, Paragraph, Widget
|
||||
},
|
||||
};
|
||||
use ratatui::prelude::*;
|
||||
|
||||
use crate::game;
|
||||
use crate::tui;
|
||||
|
||||
const GAME_HEADER_STYLE: Style = Style::new()
|
||||
.fg(ZINC.c100)
|
||||
|
@ -96,25 +95,25 @@ impl FromIterator<&'static str> for OptionList {
|
|||
}
|
||||
|
||||
impl OptionList {
|
||||
pub fn handle_key(mut self, key: KeyEvent) -> game::Mode {
|
||||
pub fn handle_key(mut self, key: KeyEvent) -> tui::Mode {
|
||||
match key.code {
|
||||
KeyCode::Char('q') | KeyCode::Esc => game::Mode::Exit,
|
||||
KeyCode::Char('q') | KeyCode::Esc => tui::Mode::Exit,
|
||||
KeyCode::Char('j') | KeyCode::Down => {
|
||||
self.select_next();
|
||||
game::Mode::MainMenu(self)
|
||||
tui::Mode::MainMenu(self)
|
||||
}
|
||||
KeyCode::Char('k') | KeyCode::Up => {
|
||||
self.select_previous();
|
||||
game::Mode::MainMenu(self)
|
||||
tui::Mode::MainMenu(self)
|
||||
}
|
||||
KeyCode::Char('c') => {
|
||||
if key.modifiers.contains(event::KeyModifiers::CONTROL) {
|
||||
game::Mode::Exit
|
||||
tui::Mode::Exit
|
||||
} else {
|
||||
game::Mode::MainMenu(self)
|
||||
tui::Mode::MainMenu(self)
|
||||
}
|
||||
}
|
||||
_ => game::Mode::MainMenu(self),
|
||||
_ => tui::Mode::MainMenu(self),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue