Prepare next task

This commit is contained in:
Pierre HUBERT 2022-10-07 12:05:54 +02:00
parent aea9175b7e
commit b7d2cceff6
2 changed files with 10 additions and 0 deletions

View File

@ -81,6 +81,7 @@ fn ui<B: Backend>(f: &mut Frame<B>, model: &mut SetBotsLayoutScreen, rules: &Gam
.set_default_empty_char(' ') .set_default_empty_char(' ')
.add_colored_cells(current_boat) .add_colored_cells(current_boat)
.add_colored_cells(other_boats) .add_colored_cells(other_boats)
.set_title("Now, configure your boats")
.set_legend( .set_legend(
"n next boat \n\ "n next boat \n\
r rotate boat \n\n\ r rotate boat \n\n\

View File

@ -18,6 +18,7 @@ pub struct GameMapWidget<'a> {
rules: &'a GameRules, rules: &'a GameRules,
default_empty_character: char, default_empty_character: char,
colored_cells: Vec<ColoredCells>, colored_cells: Vec<ColoredCells>,
title: Option<String>,
legend: Option<String>, legend: Option<String>,
} }
@ -27,6 +28,7 @@ impl<'a> GameMapWidget<'a> {
rules, rules,
default_empty_character: '.', default_empty_character: '.',
colored_cells: vec![], colored_cells: vec![],
title: None,
legend: None, legend: None,
} }
} }
@ -41,6 +43,11 @@ impl<'a> GameMapWidget<'a> {
self self
} }
pub fn set_title<D: Display>(mut self, title: D) -> Self {
self.title = Some(title.to_string());
self
}
pub fn set_legend<D: Display>(mut self, legend: D) -> Self { pub fn set_legend<D: Display>(mut self, legend: D) -> Self {
self.legend = Some(legend.to_string()); self.legend = Some(legend.to_string());
self self
@ -70,6 +77,8 @@ impl<'a> Widget for GameMapWidget<'a> {
let symbols = BorderType::line_symbols(BorderType::Plain); let symbols = BorderType::line_symbols(BorderType::Plain);
// TODO : render title
// Paint game grid // Paint game grid
for y in 0..(self.rules.map_height + 1) { for y in 0..(self.rules.map_height + 1) {
if y < self.rules.map_height { if y < self.rules.map_height {