From b1183175be321d4a0a096171267afc4ccd5ded6f Mon Sep 17 00:00:00 2001 From: GarandPLG Date: Tue, 5 May 2026 13:34:07 +0200 Subject: [PATCH] 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. --- .../skirmish_states/structures/structures_enum.rs | 15 +++++++++++++-- src/app/views/skirmish.rs | 2 +- src/app/widgets/side_panel.rs | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/app/states/skirmish_states/structures/structures_enum.rs b/src/app/states/skirmish_states/structures/structures_enum.rs index 2960571..e7c72ec 100644 --- a/src/app/states/skirmish_states/structures/structures_enum.rs +++ b/src/app/states/skirmish_states/structures/structures_enum.rs @@ -2,7 +2,10 @@ use crate::app::states::skirmish_states::{ Players, 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)] pub enum Structures { @@ -58,6 +61,14 @@ impl Structure for Structures { } fn text(&self) -> Vec> { - self.structure().text() + let owner: Players = self.structure().get_owner(); + let mut lines: Vec> = self.structure().text(); + + match owner { + Players::Unclaimed => {} + _ => lines.push(Line::from_iter(["Owner: ".gray(), owner.get_span()])), + } + + lines } } diff --git a/src/app/views/skirmish.rs b/src/app/views/skirmish.rs index 60b01b4..c3e61a4 100644 --- a/src/app/views/skirmish.rs +++ b/src/app/views/skirmish.rs @@ -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] { let constraint: [Constraint; 2] = if side_panel { - [Constraint::Percentage(80), Constraint::Percentage(20)] + [Constraint::Fill(1), Constraint::Length(39)] } else { [Constraint::Percentage(100), Constraint::Percentage(0)] }; diff --git a/src/app/widgets/side_panel.rs b/src/app/widgets/side_panel.rs index 4e5b738..f24db5f 100644 --- a/src/app/widgets/side_panel.rs +++ b/src/app/widgets/side_panel.rs @@ -53,7 +53,7 @@ impl<'a> SidePanelWidget<'a> { fn get_inner_block<'b>(&self, title: String, color: Color) -> Block<'b> { Block::default() - .borders(Borders::LEFT | Borders::TOP) + .borders(Borders::TOP) .title(block_single_title_helper(title, color)) .title_alignment(Alignment::Center) .padding(Padding::symmetric(1, 1))