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;
|
use color_eyre::Result;
|
||||||
|
|
||||||
mod game;
|
mod tui;
|
||||||
mod menu;
|
mod menu;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
color_eyre::install()?;
|
color_eyre::install()?;
|
||||||
let terminal = ratatui::init();
|
let terminal = ratatui::init();
|
||||||
let app_result = game::Mode::default().run(terminal);
|
let app_result = tui::Mode::default().run(terminal);
|
||||||
ratatui::restore();
|
ratatui::restore();
|
||||||
app_result
|
app_result
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,11 @@ use ratatui::{
|
||||||
style::{Modifier, Style, Stylize, palette::tailwind::*},
|
style::{Modifier, Style, Stylize, palette::tailwind::*},
|
||||||
widgets::{
|
widgets::{
|
||||||
Block, Borders, HighlightSpacing, List,
|
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()
|
const GAME_HEADER_STYLE: Style = Style::new()
|
||||||
.fg(ZINC.c100)
|
.fg(ZINC.c100)
|
||||||
|
@ -96,25 +95,25 @@ impl FromIterator<&'static str> for OptionList {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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 {
|
match key.code {
|
||||||
KeyCode::Char('q') | KeyCode::Esc => game::Mode::Exit,
|
KeyCode::Char('q') | KeyCode::Esc => tui::Mode::Exit,
|
||||||
KeyCode::Char('j') | KeyCode::Down => {
|
KeyCode::Char('j') | KeyCode::Down => {
|
||||||
self.select_next();
|
self.select_next();
|
||||||
game::Mode::MainMenu(self)
|
tui::Mode::MainMenu(self)
|
||||||
}
|
}
|
||||||
KeyCode::Char('k') | KeyCode::Up => {
|
KeyCode::Char('k') | KeyCode::Up => {
|
||||||
self.select_previous();
|
self.select_previous();
|
||||||
game::Mode::MainMenu(self)
|
tui::Mode::MainMenu(self)
|
||||||
}
|
}
|
||||||
KeyCode::Char('c') => {
|
KeyCode::Char('c') => {
|
||||||
if key.modifiers.contains(event::KeyModifiers::CONTROL) {
|
if key.modifiers.contains(event::KeyModifiers::CONTROL) {
|
||||||
game::Mode::Exit
|
tui::Mode::Exit
|
||||||
} else {
|
} else {
|
||||||
game::Mode::MainMenu(self)
|
tui::Mode::MainMenu(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => game::Mode::MainMenu(self),
|
_ => tui::Mode::MainMenu(self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue