cargo fix
This commit is contained in:
parent
b5e670b491
commit
f465197896
8 changed files with 21 additions and 32 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
use bevy::{ecs::relationship::RelationshipSourceCollection, prelude::*};
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
game::{GameState, player::Player, wall::Wall /* wall::WallTiles */},
|
game::{GameState, player::Player, wall::Wall},
|
||||||
tile::Tile,
|
tile::Tile,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub struct DrawnTile(pub Entity);
|
||||||
|
|
||||||
pub(crate) fn sort_hands(
|
pub(crate) fn sort_hands(
|
||||||
tiles: Populated<&Tile>,
|
tiles: Populated<&Tile>,
|
||||||
mut hands: Populated<&mut Children, (Changed<Hand>, Without<Player>)>,
|
hands: Populated<&mut Children, (Changed<Hand>, Without<Player>)>,
|
||||||
) -> Result {
|
) -> Result {
|
||||||
for mut hand in hands {
|
for mut hand in hands {
|
||||||
hand.sort_unstable_by_key(|e| tiles.get(*e).unwrap().suit);
|
hand.sort_unstable_by_key(|e| tiles.get(*e).unwrap().suit);
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,13 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use strum::{EnumCount, FromRepr};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
EnumNextCycle,
|
|
||||||
game::{
|
game::{
|
||||||
hand::{DrawnTile, Hand},
|
hand::Hand,
|
||||||
player::{MainPlayer, Player},
|
player::MainPlayer,
|
||||||
round::{CurrentPlayer, TurnState, Wind},
|
round::{CurrentPlayer, TurnState, Wind},
|
||||||
wall::Wall,
|
wall::Wall,
|
||||||
},
|
},
|
||||||
tile::{self, *},
|
tile::{self},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod hand;
|
pub mod hand;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_ratatui::{RatatuiContext, event::MouseMessage};
|
use bevy_ratatui::{RatatuiContext, event::MouseMessage};
|
||||||
use ratatui::{crossterm::event::MouseEvent, layout::Position};
|
use ratatui::layout::Position;
|
||||||
|
|
||||||
use crate::tui::render::Hovered;
|
use crate::tui::render::Hovered;
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@ pub(crate) struct PickRegion {
|
||||||
pub(crate) fn input_system(
|
pub(crate) fn input_system(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut messages: MessageReader<MouseMessage>,
|
mut messages: MessageReader<MouseMessage>,
|
||||||
context: Res<RatatuiContext>,
|
_context: Res<RatatuiContext>,
|
||||||
entities: Query<(Entity, &PickRegion)>,
|
entities: Query<(Entity, &PickRegion)>,
|
||||||
hovered: Query<(Entity, &PickRegion), With<Hovered>>,
|
hovered: Query<(Entity, &PickRegion), With<Hovered>>,
|
||||||
) -> Result {
|
) -> Result {
|
||||||
|
|
@ -28,7 +28,7 @@ pub(crate) fn input_system(
|
||||||
match event.kind {
|
match event.kind {
|
||||||
ratatui::crossterm::event::MouseEventKind::Down(mouse_button) => match mouse_button {
|
ratatui::crossterm::event::MouseEventKind::Down(mouse_button) => match mouse_button {
|
||||||
ratatui::crossterm::event::MouseButton::Left => {
|
ratatui::crossterm::event::MouseButton::Left => {
|
||||||
for (entity, region) in &entities {}
|
for (_entity, _region) in &entities {}
|
||||||
}
|
}
|
||||||
// ratatui::crossterm::event::MouseButton::Right => todo!(),
|
// ratatui::crossterm::event::MouseButton::Right => todo!(),
|
||||||
// ratatui::crossterm::event::MouseButton::Middle => todo!(),
|
// ratatui::crossterm::event::MouseButton::Middle => todo!(),
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,11 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_ratatui::RatatuiContext;
|
use bevy_ratatui::RatatuiContext;
|
||||||
use bevy_ratatui::event::KeyMessage;
|
|
||||||
use ratatui::crossterm::event::KeyCode;
|
|
||||||
use ratatui::layout::Constraint;
|
use ratatui::layout::Constraint;
|
||||||
use ratatui::layout::Layout;
|
use ratatui::layout::Layout;
|
||||||
|
|
||||||
use jong::game::GameState;
|
|
||||||
|
|
||||||
use crate::tui::TuiState;
|
|
||||||
|
|
||||||
const MAINMENU_OPTIONS: [&str; 2] = ["(p)lay", "(q)uit"];
|
const MAINMENU_OPTIONS: [&str; 2] = ["(p)lay", "(q)uit"];
|
||||||
|
|
||||||
pub(crate) fn draw_mainmenu(mut tui_ctx: ResMut<RatatuiContext>) {
|
pub(crate) fn draw_mainmenu(mut tui_ctx: ResMut<RatatuiContext>) -> Result {
|
||||||
let options = MAINMENU_OPTIONS;
|
let options = MAINMENU_OPTIONS;
|
||||||
let layout = Layout::vertical(vec![Constraint::Min(1); options.len()]);
|
let layout = Layout::vertical(vec![Constraint::Min(1); options.len()]);
|
||||||
|
|
||||||
|
|
@ -20,5 +14,7 @@ pub(crate) fn draw_mainmenu(mut tui_ctx: ResMut<RatatuiContext>) {
|
||||||
for (opt, area) in options.into_iter().zip(areas.iter()) {
|
for (opt, area) in options.into_iter().zip(areas.iter()) {
|
||||||
frame.render_widget(opt, *area)
|
frame.render_widget(opt, *area)
|
||||||
}
|
}
|
||||||
});
|
})?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,10 @@ use std::time::Duration;
|
||||||
|
|
||||||
use bevy::{app::ScheduleRunnerPlugin, prelude::*, state::app::StatesPlugin};
|
use bevy::{app::ScheduleRunnerPlugin, prelude::*, state::app::StatesPlugin};
|
||||||
use bevy_ratatui::RatatuiPlugins;
|
use bevy_ratatui::RatatuiPlugins;
|
||||||
use ratatui::{text::ToSpan, widgets::Paragraph};
|
|
||||||
|
|
||||||
use jong::game::GameState;
|
use jong::game::GameState;
|
||||||
// use jong::game::wall::InWall;
|
// use jong::game::wall::InWall;
|
||||||
|
|
||||||
use crate::tui::{console::ConsoleState, menu::draw_mainmenu, render::ingame::draw_ingame};
|
|
||||||
|
|
||||||
mod console;
|
mod console;
|
||||||
mod menu;
|
mod menu;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use bevy::{platform::collections::HashMap, prelude::*};
|
use bevy::{platform::collections::HashMap, prelude::*};
|
||||||
use ratatui::widgets::Paragraph;
|
|
||||||
|
|
||||||
use jong::{
|
use jong::{
|
||||||
game::{hand::Hand, player::Player},
|
game::{hand::Hand, player::Player},
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,7 @@ use bevy_ratatui::RatatuiContext;
|
||||||
use jong::game::hand::DrawnTile;
|
use jong::game::hand::DrawnTile;
|
||||||
use jong::game::player::{MainPlayer, Player};
|
use jong::game::player::{MainPlayer, Player};
|
||||||
use jong::tile::Tile;
|
use jong::tile::Tile;
|
||||||
use rand::rand_core::block::BlockRngCore;
|
use ratatui::widgets::{Block, Borders};
|
||||||
use ratatui::style::Styled;
|
|
||||||
use ratatui::widgets::{Block, Borders, Widget};
|
|
||||||
|
|
||||||
use crate::tui::render::tile::draw_tile;
|
use crate::tui::render::tile::draw_tile;
|
||||||
use crate::tui::{
|
use crate::tui::{
|
||||||
|
|
@ -38,11 +36,11 @@ pub(crate) fn draw_ingame(
|
||||||
let horizontal_slicer_left = Layout::horizontal(constraints.iter().rev());
|
let horizontal_slicer_left = Layout::horizontal(constraints.iter().rev());
|
||||||
let vertical_slicer_top = Layout::vertical(constraints.iter().rev());
|
let vertical_slicer_top = Layout::vertical(constraints.iter().rev());
|
||||||
let [left_hand, this_hand] = horizontal_slicer_right.areas::<2>(term_area);
|
let [left_hand, this_hand] = horizontal_slicer_right.areas::<2>(term_area);
|
||||||
let [_, mut left_hand] = vertical_slicer_bottom.areas::<2>(left_hand);
|
let [_, left_hand] = vertical_slicer_bottom.areas::<2>(left_hand);
|
||||||
let [_, mut this_hand] = vertical_slicer_top.areas::<2>(this_hand);
|
let [_, mut this_hand] = vertical_slicer_top.areas::<2>(this_hand);
|
||||||
let [cross_hand, right_hand] = horizontal_slicer_left.areas::<2>(term_area);
|
let [cross_hand, right_hand] = horizontal_slicer_left.areas::<2>(term_area);
|
||||||
let [mut right_hand, _] = vertical_slicer_top.areas::<2>(right_hand);
|
let [right_hand, _] = vertical_slicer_top.areas::<2>(right_hand);
|
||||||
let [mut cross_hand, _] = vertical_slicer_bottom.areas::<2>(cross_hand);
|
let [cross_hand, _] = vertical_slicer_bottom.areas::<2>(cross_hand);
|
||||||
|
|
||||||
let margin = Margin::new(
|
let margin = Margin::new(
|
||||||
(left_hand.width + right_hand.width) / 2,
|
(left_hand.width + right_hand.width) / 2,
|
||||||
|
|
@ -53,7 +51,7 @@ pub(crate) fn draw_ingame(
|
||||||
let cross_pond =
|
let cross_pond =
|
||||||
Layout::vertical([Constraint::Fill(1), Constraint::Max(1), Constraint::Fill(1)]);
|
Layout::vertical([Constraint::Fill(1), Constraint::Max(1), Constraint::Fill(1)]);
|
||||||
let [mut left_pond, center, mut right_pond] = all_pond.areas::<3>(pond_area);
|
let [mut left_pond, center, mut right_pond] = all_pond.areas::<3>(pond_area);
|
||||||
let [cross_pond, compass, this_pond] = cross_pond.areas::<3>(center);
|
let [cross_pond, _compass, this_pond] = cross_pond.areas::<3>(center);
|
||||||
// let shift = left_pond.height - cross_pond.height;
|
// let shift = left_pond.height - cross_pond.height;
|
||||||
left_pond.height = cross_pond.height;
|
left_pond.height = cross_pond.height;
|
||||||
left_pond.y += cross_pond.height / 2;
|
left_pond.y += cross_pond.height / 2;
|
||||||
|
|
@ -79,14 +77,14 @@ pub(crate) fn draw_ingame(
|
||||||
])
|
])
|
||||||
.flex(Flex::SpaceBetween);
|
.flex(Flex::SpaceBetween);
|
||||||
let this_clamped = this_hand.height.abs_diff(5);
|
let this_clamped = this_hand.height.abs_diff(5);
|
||||||
if let Some(val) = this_hand.height.checked_sub(this_clamped) {
|
if let Some(_val) = this_hand.height.checked_sub(this_clamped) {
|
||||||
this_hand.height = 4
|
this_hand.height = 4
|
||||||
} else {
|
} else {
|
||||||
// FIXME show error
|
// FIXME show error
|
||||||
panic!("terminal too small!");
|
panic!("terminal too small!");
|
||||||
}
|
}
|
||||||
this_hand.y += this_clamped + 1;
|
this_hand.y += this_clamped + 1;
|
||||||
let [this_hand, mut this_drawn, this_meld] = hand_area_layout.areas::<3>(this_hand);
|
let [this_hand, mut this_drawn, _this_meld] = hand_area_layout.areas::<3>(this_hand);
|
||||||
|
|
||||||
// this_hand
|
// this_hand
|
||||||
let mut constraints = vec![Constraint::Max(5); hand.len()];
|
let mut constraints = vec![Constraint::Max(5); hand.len()];
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use jong::tile::Tile;
|
||||||
pub(crate) struct RenderedTile(pub(crate) Paragraph<'static>);
|
pub(crate) struct RenderedTile(pub(crate) Paragraph<'static>);
|
||||||
|
|
||||||
pub(crate) fn draw_tile(tile: &Tile) -> Paragraph<'static> {
|
pub(crate) fn draw_tile(tile: &Tile) -> Paragraph<'static> {
|
||||||
use ratatui::prelude::*;
|
|
||||||
|
|
||||||
let block = ratatui::widgets::Block::bordered();
|
let block = ratatui::widgets::Block::bordered();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue