cargo fix
This commit is contained in:
parent
b5e670b491
commit
f465197896
8 changed files with 21 additions and 32 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy_ratatui::{RatatuiContext, event::MouseMessage};
|
||||
use ratatui::{crossterm::event::MouseEvent, layout::Position};
|
||||
use ratatui::layout::Position;
|
||||
|
||||
use crate::tui::render::Hovered;
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ pub(crate) struct PickRegion {
|
|||
pub(crate) fn input_system(
|
||||
mut commands: Commands,
|
||||
mut messages: MessageReader<MouseMessage>,
|
||||
context: Res<RatatuiContext>,
|
||||
_context: Res<RatatuiContext>,
|
||||
entities: Query<(Entity, &PickRegion)>,
|
||||
hovered: Query<(Entity, &PickRegion), With<Hovered>>,
|
||||
) -> Result {
|
||||
|
|
@ -28,7 +28,7 @@ pub(crate) fn input_system(
|
|||
match event.kind {
|
||||
ratatui::crossterm::event::MouseEventKind::Down(mouse_button) => match mouse_button {
|
||||
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::Middle => todo!(),
|
||||
|
|
|
|||
|
|
@ -1,17 +1,11 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy_ratatui::RatatuiContext;
|
||||
use bevy_ratatui::event::KeyMessage;
|
||||
use ratatui::crossterm::event::KeyCode;
|
||||
use ratatui::layout::Constraint;
|
||||
use ratatui::layout::Layout;
|
||||
|
||||
use jong::game::GameState;
|
||||
|
||||
use crate::tui::TuiState;
|
||||
|
||||
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 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()) {
|
||||
frame.render_widget(opt, *area)
|
||||
}
|
||||
});
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,10 @@ use std::time::Duration;
|
|||
|
||||
use bevy::{app::ScheduleRunnerPlugin, prelude::*, state::app::StatesPlugin};
|
||||
use bevy_ratatui::RatatuiPlugins;
|
||||
use ratatui::{text::ToSpan, widgets::Paragraph};
|
||||
|
||||
use jong::game::GameState;
|
||||
// use jong::game::wall::InWall;
|
||||
|
||||
use crate::tui::{console::ConsoleState, menu::draw_mainmenu, render::ingame::draw_ingame};
|
||||
|
||||
mod console;
|
||||
mod menu;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use bevy::{platform::collections::HashMap, prelude::*};
|
||||
use ratatui::widgets::Paragraph;
|
||||
|
||||
use jong::{
|
||||
game::{hand::Hand, player::Player},
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@ use bevy_ratatui::RatatuiContext;
|
|||
use jong::game::hand::DrawnTile;
|
||||
use jong::game::player::{MainPlayer, Player};
|
||||
use jong::tile::Tile;
|
||||
use rand::rand_core::block::BlockRngCore;
|
||||
use ratatui::style::Styled;
|
||||
use ratatui::widgets::{Block, Borders, Widget};
|
||||
use ratatui::widgets::{Block, Borders};
|
||||
|
||||
use crate::tui::render::tile::draw_tile;
|
||||
use crate::tui::{
|
||||
|
|
@ -38,11 +36,11 @@ pub(crate) fn draw_ingame(
|
|||
let horizontal_slicer_left = Layout::horizontal(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 [_, 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 [cross_hand, right_hand] = horizontal_slicer_left.areas::<2>(term_area);
|
||||
let [mut right_hand, _] = vertical_slicer_top.areas::<2>(right_hand);
|
||||
let [mut cross_hand, _] = vertical_slicer_bottom.areas::<2>(cross_hand);
|
||||
let [right_hand, _] = vertical_slicer_top.areas::<2>(right_hand);
|
||||
let [cross_hand, _] = vertical_slicer_bottom.areas::<2>(cross_hand);
|
||||
|
||||
let margin = Margin::new(
|
||||
(left_hand.width + right_hand.width) / 2,
|
||||
|
|
@ -53,7 +51,7 @@ pub(crate) fn draw_ingame(
|
|||
let cross_pond =
|
||||
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 [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;
|
||||
left_pond.height = cross_pond.height;
|
||||
left_pond.y += cross_pond.height / 2;
|
||||
|
|
@ -79,14 +77,14 @@ pub(crate) fn draw_ingame(
|
|||
])
|
||||
.flex(Flex::SpaceBetween);
|
||||
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
|
||||
} else {
|
||||
// FIXME show error
|
||||
panic!("terminal too small!");
|
||||
}
|
||||
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
|
||||
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) fn draw_tile(tile: &Tile) -> Paragraph<'static> {
|
||||
use ratatui::prelude::*;
|
||||
|
||||
|
||||
let block = ratatui::widgets::Block::bordered();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue