2026-01-08 20:49:19 -08:00
|
|
|
use std::time::Duration;
|
|
|
|
|
|
2026-01-09 06:54:17 -08:00
|
|
|
use bevy::{app::ScheduleRunnerPlugin, prelude::*, state::app::StatesPlugin};
|
2026-01-09 23:14:29 -08:00
|
|
|
use bevy_ratatui::RatatuiPlugins;
|
|
|
|
|
use ratatui::{text::ToSpan, widgets::Paragraph};
|
|
|
|
|
|
2026-01-11 20:10:30 -08:00
|
|
|
use jong::game::GameState;
|
|
|
|
|
use jong::game::wall::InWall;
|
|
|
|
|
|
2026-01-09 03:34:54 -08:00
|
|
|
mod console;
|
2026-01-08 20:49:19 -08:00
|
|
|
mod input;
|
2026-01-09 23:14:29 -08:00
|
|
|
mod render;
|
2026-01-08 20:49:19 -08:00
|
|
|
|
2026-01-11 20:10:30 -08:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, States, Default)]
|
|
|
|
|
enum TuiState {
|
|
|
|
|
#[default]
|
2026-01-11 22:32:30 -08:00
|
|
|
MainMenu,
|
2026-01-11 20:10:30 -08:00
|
|
|
InGame,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
|
pub struct RiichiTui {
|
|
|
|
|
// player_names: Vec<String>,
|
|
|
|
|
}
|
2026-01-07 00:51:57 -08:00
|
|
|
|
2026-01-08 20:49:19 -08:00
|
|
|
impl Plugin for RiichiTui {
|
|
|
|
|
fn build(&self, app: &mut App) {
|
|
|
|
|
app.add_plugins((
|
|
|
|
|
MinimalPlugins.set(ScheduleRunnerPlugin::run_loop(Duration::from_secs_f32(
|
2026-01-09 03:34:54 -08:00
|
|
|
1. / 60.,
|
2026-01-08 20:49:19 -08:00
|
|
|
))),
|
|
|
|
|
RatatuiPlugins {
|
|
|
|
|
// enable_kitty_protocol: todo!(),
|
|
|
|
|
// enable_mouse_capture: todo!(),
|
|
|
|
|
enable_input_forwarding: true,
|
|
|
|
|
..Default::default()
|
|
|
|
|
},
|
|
|
|
|
))
|
2026-01-09 03:34:54 -08:00
|
|
|
.add_plugins(StatesPlugin)
|
2026-01-11 20:10:30 -08:00
|
|
|
|
|
|
|
|
// setup console
|
2026-01-09 03:34:54 -08:00
|
|
|
.init_state::<console::ConsoleState>()
|
|
|
|
|
.add_systems(Update, console::toggle_console)
|
|
|
|
|
.add_systems(Update, console::draw_console.run_if(in_state(console::ConsoleState::Open)))
|
2026-01-11 20:10:30 -08:00
|
|
|
|
2026-01-09 23:14:29 -08:00
|
|
|
.init_state::<TuiState>()
|
2026-01-11 22:32:30 -08:00
|
|
|
.add_systems(Update, render::draw_mainmenu.run_if(in_state(TuiState::MainMenu)))
|
2026-01-11 20:10:30 -08:00
|
|
|
// .add_systems(Update, input::keyboard_input_system)
|
2026-01-11 22:32:30 -08:00
|
|
|
// .add_systems()
|
|
|
|
|
.add_systems(Update, render::ingame::draw_ingame.run_if(in_state(TuiState::InGame)))
|
|
|
|
|
.add_systems(Update, render::hand::render_changed_hand.run_if(in_state(GameState::Play)))
|
2026-01-09 03:34:54 -08:00
|
|
|
// semicolon stopper
|
|
|
|
|
;
|
2026-01-08 20:49:19 -08:00
|
|
|
}
|
|
|
|
|
}
|
2026-01-07 00:51:57 -08:00
|
|
|
|
2026-01-11 20:10:30 -08:00
|
|
|
// fn prompt_names() {}
|