Display structure owner and adjust UI layouts

Add owner line to structure text, using gray label and owner span.
Switch side panel layout to Fill/Length and remove left border from side
panel widget.
Import Stylize for colored text rendering.
This commit is contained in:
2026-05-05 13:34:07 +02:00
parent 55a260755c
commit b1183175be
3 changed files with 15 additions and 4 deletions
@@ -2,7 +2,10 @@ use crate::app::states::skirmish_states::{
Players, Players,
structures::{BaseBuilding, Ore, Stone, Structure, Tunnel}, structures::{BaseBuilding, Ore, Stone, Structure, Tunnel},
}; };
use ratatui::{style::Color, text::Line}; use ratatui::{
style::{Color, Stylize},
text::Line,
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Structures { pub enum Structures {
@@ -58,6 +61,14 @@ impl Structure for Structures {
} }
fn text(&self) -> Vec<Line<'_>> { fn text(&self) -> Vec<Line<'_>> {
self.structure().text() let owner: Players = self.structure().get_owner();
let mut lines: Vec<Line<'_>> = self.structure().text();
match owner {
Players::Unclaimed => {}
_ => lines.push(Line::from_iter(["Owner: ".gray(), owner.get_span()])),
}
lines
} }
} }
+1 -1
View File
@@ -47,7 +47,7 @@ pub fn skirmish_layout(area: Rect) -> [Rect; 3] {
pub fn skirmish_main_area_layout(area: Rect, side_panel: bool) -> [Rect; 2] { pub fn skirmish_main_area_layout(area: Rect, side_panel: bool) -> [Rect; 2] {
let constraint: [Constraint; 2] = if side_panel { let constraint: [Constraint; 2] = if side_panel {
[Constraint::Percentage(80), Constraint::Percentage(20)] [Constraint::Fill(1), Constraint::Length(39)]
} else { } else {
[Constraint::Percentage(100), Constraint::Percentage(0)] [Constraint::Percentage(100), Constraint::Percentage(0)]
}; };
+1 -1
View File
@@ -53,7 +53,7 @@ impl<'a> SidePanelWidget<'a> {
fn get_inner_block<'b>(&self, title: String, color: Color) -> Block<'b> { fn get_inner_block<'b>(&self, title: String, color: Color) -> Block<'b> {
Block::default() Block::default()
.borders(Borders::LEFT | Borders::TOP) .borders(Borders::TOP)
.title(block_single_title_helper(title, color)) .title(block_single_title_helper(title, color))
.title_alignment(Alignment::Center) .title_alignment(Alignment::Center)
.padding(Padding::symmetric(1, 1)) .padding(Padding::symmetric(1, 1))