diff --git a/rust/cli_player/src/ui_screens/set_boats_layout.rs b/rust/cli_player/src/ui_screens/set_boats_layout.rs index d8d91d1..eb2629c 100644 --- a/rust/cli_player/src/ui_screens/set_boats_layout.rs +++ b/rust/cli_player/src/ui_screens/set_boats_layout.rs @@ -81,7 +81,12 @@ fn ui(f: &mut Frame, model: &mut SetBotsLayoutScreen, rules: &Gam .set_default_empty_char(' ') .add_colored_cells(current_boat) .add_colored_cells(other_boats) - .set_legend("n next boat \nr rotate boat \n\n↓ ↑ → ← move boat \n\nEnter confirm layout"); + .set_legend( + "n next boat \n\ + r rotate boat \n\n\ + ← ↓↑ → move boat \n\n\ + Enter confirm layout", + ); let (w, h) = game_map_widget.estimated_size(); let area = centered_rect_size(w, h, &f.size()); diff --git a/rust/cli_player/src/ui_widgets/game_map_widget.rs b/rust/cli_player/src/ui_widgets/game_map_widget.rs index 6bffbc2..9545292 100644 --- a/rust/cli_player/src/ui_widgets/game_map_widget.rs +++ b/rust/cli_player/src/ui_widgets/game_map_widget.rs @@ -1,11 +1,14 @@ -use crate::ui_screens::utils::centered_rect_size; -use sea_battle_backend::data::{Coordinates, GameRules, PlayConfiguration}; use std::fmt::Display; + use tui::buffer::Buffer; use tui::layout::Rect; use tui::style::{Color, Style}; use tui::widgets::{BorderType, Widget}; +use sea_battle_backend::data::{Coordinates, GameRules, PlayConfiguration}; + +use crate::ui_screens::utils::centered_rect_size; + pub struct ColoredCells { pub color: Color, pub cells: Vec, @@ -69,9 +72,23 @@ impl<'a> Widget for GameMapWidget<'a> { // Paint game grid for y in 0..(self.rules.map_height + 1) { + if y < self.rules.map_height { + buf.get_mut(area.x, area.y + 2 + (y as u16 * 2)) + .set_char(alphabet.chars().nth(y).unwrap()); + } + for x in 0..(self.rules.map_width + 1) { - let o_x = area.x + (x as u16 * 2); - let o_y = area.y + (y as u16 * 2); + if x < self.rules.map_width { + buf.set_string( + area.x + 2 + (x as u16 * 2) - (x as u16) / 10, + area.y, + x.to_string(), + Style::default(), + ); + } + + let o_x = 1 + area.x + (x as u16 * 2); + let o_y = 1 + area.y + (y as u16 * 2); buf.get_mut(o_x, o_y).set_symbol(match (x, y) { (0, 0) => symbols.top_left,