Handle screens too small for setting boats layout
This commit is contained in:
parent
b1145cc362
commit
8990badaa4
@ -14,6 +14,7 @@ use sea_battle_backend::data::*;
|
||||
|
||||
use crate::constants::*;
|
||||
use crate::ui_screens::confirm_dialog_screen::confirm;
|
||||
use crate::ui_screens::popup_screen::PopupScreen;
|
||||
use crate::ui_screens::utils::{centered_rect_size, centered_text};
|
||||
use crate::ui_screens::ScreenResult;
|
||||
use crate::ui_widgets::game_map_widget::{ColoredCells, GameMapWidget};
|
||||
@ -227,6 +228,13 @@ impl<'a> SetBoatsLayoutScreen<'a> {
|
||||
}
|
||||
|
||||
let (w, h) = game_map_widget.estimated_size();
|
||||
|
||||
if f.size().width < w || f.size().height + 3 < h {
|
||||
PopupScreen::new("Screen too small!").show_in_frame(f);
|
||||
drop(game_map_widget);
|
||||
return coordinates_mapper;
|
||||
}
|
||||
|
||||
let area = centered_rect_size(w, h, &f.size());
|
||||
f.render_widget(game_map_widget, area);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user