reorder stuff for tui main menu
This commit is contained in:
parent
3417384b86
commit
130bb38725
4 changed files with 60 additions and 34 deletions
|
|
@ -13,8 +13,8 @@ mod render;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, States, Default)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, States, Default)]
|
||||||
enum TuiState {
|
enum TuiState {
|
||||||
MainMenu,
|
|
||||||
#[default]
|
#[default]
|
||||||
|
MainMenu,
|
||||||
InGame,
|
InGame,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,9 +44,11 @@ impl Plugin for RiichiTui {
|
||||||
.add_systems(Update, console::draw_console.run_if(in_state(console::ConsoleState::Open)))
|
.add_systems(Update, console::draw_console.run_if(in_state(console::ConsoleState::Open)))
|
||||||
|
|
||||||
.init_state::<TuiState>()
|
.init_state::<TuiState>()
|
||||||
|
.add_systems(Update, render::draw_mainmenu.run_if(in_state(TuiState::MainMenu)))
|
||||||
// .add_systems(Update, input::keyboard_input_system)
|
// .add_systems(Update, input::keyboard_input_system)
|
||||||
.add_systems(Update, render::draw_ingame.run_if(in_state(TuiState::InGame)))
|
// .add_systems()
|
||||||
.add_systems(Update,render::render_changed_hand.run_if(in_state(GameState::Play)))
|
.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)))
|
||||||
// semicolon stopper
|
// semicolon stopper
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
26
src/tui/render/hand.rs
Normal file
26
src/tui/render/hand.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
use bevy::prelude::*;
|
||||||
|
use ratatui::widgets::Paragraph;
|
||||||
|
|
||||||
|
use jong::game::player::HandTiles;
|
||||||
|
use jong::tiles::Tile;
|
||||||
|
|
||||||
|
use crate::tui::render::tiles;
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
pub(crate) struct RenderedHand<'a>(pub(crate) Vec<Paragraph<'a>>);
|
||||||
|
|
||||||
|
pub(crate) fn render_changed_hand(
|
||||||
|
hand: Single<&HandTiles, Changed<HandTiles>>,
|
||||||
|
// hand_tiles: Query<&HandTiles, With<Hand>>,
|
||||||
|
tiles: Query<&Tile>,
|
||||||
|
mut target: Single<&'static mut RenderedHand>,
|
||||||
|
) -> Result {
|
||||||
|
let hand_tiles = hand
|
||||||
|
.iter()
|
||||||
|
.map(|inhand| -> Result<_> { Ok(tiles.get(inhand).map(tiles::draw_tile)?) })
|
||||||
|
.collect::<Result<Vec<_>>>()?;
|
||||||
|
|
||||||
|
target.0 = hand_tiles;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
@ -1,42 +1,13 @@
|
||||||
use bevy::ecs::system::SystemParam;
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_ratatui::RatatuiContext;
|
use bevy_ratatui::RatatuiContext;
|
||||||
use ratatui::widgets::Paragraph;
|
|
||||||
|
|
||||||
use jong::{
|
use crate::tui::render::hand;
|
||||||
game::{
|
|
||||||
player::{Hand, HandTiles},
|
|
||||||
wall::{Wall, WallTiles},
|
|
||||||
},
|
|
||||||
tiles::Tile,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod tiles;
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub(crate) struct RenderedHand<'a>(Vec<Paragraph<'a>>);
|
|
||||||
|
|
||||||
pub(crate) fn render_changed_hand(
|
|
||||||
hand: Single<&HandTiles, Changed<HandTiles>>,
|
|
||||||
// hand_tiles: Query<&HandTiles, With<Hand>>,
|
|
||||||
tiles: Query<&Tile>,
|
|
||||||
mut target: Single<&'static mut RenderedHand>,
|
|
||||||
) -> Result {
|
|
||||||
let hand_tiles = hand
|
|
||||||
.iter()
|
|
||||||
.map(|inhand| -> Result<_> { Ok(tiles.get(inhand).map(tiles::draw_tile)?) })
|
|
||||||
.collect::<Result<Vec<_>>>()?;
|
|
||||||
|
|
||||||
target.0 = hand_tiles;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn draw_ingame(
|
pub(crate) fn draw_ingame(
|
||||||
// tiles: Query<&Tile>,
|
// tiles: Query<&Tile>,
|
||||||
// wall_tiles: Option<Single<&WallTiles, With<Wall>>>,
|
// wall_tiles: Option<Single<&WallTiles, With<Wall>>>,
|
||||||
// hand_tiles: Query<&HandTiles, With<Hand>>,
|
// hand_tiles: Query<&HandTiles, With<Hand>>,
|
||||||
rendered_hand: Single<&'static RenderedHand>,
|
rendered_hand: Single<&'static hand::RenderedHand>,
|
||||||
mut tui_ctx: ResMut<RatatuiContext>,
|
mut tui_ctx: ResMut<RatatuiContext>,
|
||||||
) -> Result {
|
) -> Result {
|
||||||
use ratatui::layout::Flex;
|
use ratatui::layout::Flex;
|
||||||
27
src/tui/render/mod.rs
Normal file
27
src/tui/render/mod.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
use bevy::ecs::system::SystemParam;
|
||||||
|
use bevy::prelude::*;
|
||||||
|
use bevy_ratatui::RatatuiContext;
|
||||||
|
use ratatui::widgets::Paragraph;
|
||||||
|
|
||||||
|
use jong::{
|
||||||
|
game::{
|
||||||
|
GameState,
|
||||||
|
player::Hand,
|
||||||
|
wall::{Wall, WallTiles},
|
||||||
|
},
|
||||||
|
tiles::Tile,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::tui::TuiState;
|
||||||
|
|
||||||
|
pub(crate) mod hand;
|
||||||
|
pub(crate) mod ingame;
|
||||||
|
mod tiles;
|
||||||
|
|
||||||
|
pub(crate) fn draw_mainmenu(
|
||||||
|
mut tui_ctx: ResMut<RatatuiContext>,
|
||||||
|
mut tui_state: ResMut<NextState<TuiState>>,
|
||||||
|
mut game_state: ResMut<NextState<GameState>>,
|
||||||
|
) {
|
||||||
|
tui_ctx.draw(|frame| {});
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue