From b7d2cceff6a4a9ca71ae23ece8e37262b937b2ce Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Fri, 7 Oct 2022 12:05:54 +0200 Subject: [PATCH] Prepare next task --- rust/cli_player/src/ui_screens/set_boats_layout.rs | 1 + rust/cli_player/src/ui_widgets/game_map_widget.rs | 9 +++++++++ 2 files changed, 10 insertions(+) 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 eb2629c..4f8ee9a 100644 --- a/rust/cli_player/src/ui_screens/set_boats_layout.rs +++ b/rust/cli_player/src/ui_screens/set_boats_layout.rs @@ -81,6 +81,7 @@ 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_title("Now, configure your boats") .set_legend( "n next boat \n\ r rotate boat \n\n\ 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 9545292..30fcb14 100644 --- a/rust/cli_player/src/ui_widgets/game_map_widget.rs +++ b/rust/cli_player/src/ui_widgets/game_map_widget.rs @@ -18,6 +18,7 @@ pub struct GameMapWidget<'a> { rules: &'a GameRules, default_empty_character: char, colored_cells: Vec, + title: Option, legend: Option, } @@ -27,6 +28,7 @@ impl<'a> GameMapWidget<'a> { rules, default_empty_character: '.', colored_cells: vec![], + title: None, legend: None, } } @@ -41,6 +43,11 @@ impl<'a> GameMapWidget<'a> { self } + pub fn set_title(mut self, title: D) -> Self { + self.title = Some(title.to_string()); + self + } + pub fn set_legend(mut self, legend: D) -> Self { self.legend = Some(legend.to_string()); self @@ -70,6 +77,8 @@ impl<'a> Widget for GameMapWidget<'a> { let symbols = BorderType::line_symbols(BorderType::Plain); + // TODO : render title + // Paint game grid for y in 0..(self.rules.map_height + 1) { if y < self.rules.map_height {