shuffle
This commit is contained in:
parent
78029687d7
commit
bea146d439
9 changed files with 88 additions and 41 deletions
|
|
@ -1,13 +1,12 @@
|
|||
use tui_logger::TuiLoggerWidget;
|
||||
|
||||
use bevy_ratatui::RatatuiContext;
|
||||
|
||||
use bevy::input::keyboard::Key;
|
||||
use bevy::prelude::*;
|
||||
use bevy_ratatui::RatatuiContext;
|
||||
use tui_logger::TuiLoggerWidget;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default, States)]
|
||||
pub(crate) enum ConsoleState {
|
||||
Open,
|
||||
#[default]
|
||||
Open,
|
||||
Closed,
|
||||
}
|
||||
|
||||
|
|
@ -28,7 +27,6 @@ pub(crate) fn toggle_console(
|
|||
mut next_state: ResMut<NextState<ConsoleState>>,
|
||||
) {
|
||||
if input.just_pressed(Key::Character("`".into())) {
|
||||
trace!("toggled");
|
||||
next_state.set(!*curr_state.get());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use bevy::{app::ScheduleRunnerPlugin, input::keyboard::Key, prelude::*, state::app::StatesPlugin};
|
||||
use bevy::{app::ScheduleRunnerPlugin, prelude::*, state::app::StatesPlugin};
|
||||
use bevy_ratatui::{RatatuiContext, RatatuiPlugins};
|
||||
use jong::tiles::Tile;
|
||||
use tui_logger::TuiLoggerSmartWidget;
|
||||
|
||||
use jong::{game::wall::Wall, tiles::Tile};
|
||||
use ratatui::widgets::Paragraph;
|
||||
mod console;
|
||||
mod input;
|
||||
|
||||
|
|
@ -40,10 +39,36 @@ impl Plugin for RiichiTui {
|
|||
// InGame,
|
||||
// }
|
||||
|
||||
pub(crate) fn draw_system(mut tui_ctx: ResMut<RatatuiContext>, query: Query<&Tile>) -> Result {
|
||||
pub(crate) fn draw_system(
|
||||
// mut commands: Commands,
|
||||
wall: Option<Single<&Wall>>,
|
||||
tiles: Option<Populated<&Tile>>,
|
||||
mut tui_ctx: ResMut<RatatuiContext>,
|
||||
) -> Result {
|
||||
let title = ratatui::text::Text::raw("tiny riichi");
|
||||
let wall = if let Some(wall) = wall {
|
||||
let text = (*wall)
|
||||
.iter()
|
||||
.map(|c| {
|
||||
tiles
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.get(c)
|
||||
.map(|tile| format!("{tile:?}"))
|
||||
})
|
||||
.collect::<Result<String, _>>()?;
|
||||
|
||||
Some(Paragraph::new(text))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
tui_ctx.draw(|frame| {
|
||||
let text = ratatui::text::Text::raw("tiny riichi");
|
||||
frame.render_widget(text, frame.area());
|
||||
frame.render_widget(title, frame.area());
|
||||
|
||||
if let Some(wall) = wall {
|
||||
frame.render_widget(wall, frame.area());
|
||||
}
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue