generated from GarandPLG/rust-flake-template
Replace named Ratatui colors with RGB values
Update docs, increase test count to 107, adjust flake.lock, and modify rendering logic to use explicit Color::Rgb throughout the codebase.
This commit is contained in:
1 parent
b1f548e3d3
commit
851d3410dd
28 files changed
+282
-152
No files matched your search
@@ -14,7 +14,8 @@ pub fn block_title_helper(
|
||||
) -> Line<'static> {
|
||||
let mut line: Line<'static> = Line::default();
|
||||
|
||||
line.spans.push(Span::from("[ ").gray());
|
||||
line.spans
|
||||
.push(Span::from("[ ").fg(Color::Rgb(192, 192, 192)));
|
||||
|
||||
for (i, (text, color)) in texts.iter().enumerate() {
|
||||
let span: Span<'_> = Span::styled(text.clone(), Style::new().fg(*color));
|
||||
@@ -22,12 +23,14 @@ pub fn block_title_helper(
|
||||
|
||||
if let Some(sep) = separator {
|
||||
if i + 1 < texts.len() {
|
||||
line.spans.push(Span::from(sep).gray());
|
||||
line.spans
|
||||
.push(Span::from(sep).fg(Color::Rgb(192, 192, 192)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
line.spans.push(Span::from(" ]").gray());
|
||||
line.spans
|
||||
.push(Span::from(" ]").fg(Color::Rgb(192, 192, 192)));
|
||||
|
||||
line
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ impl Players {
|
||||
|
||||
pub fn get_color(&self) -> Color {
|
||||
match self {
|
||||
Self::Player => Color::LightBlue,
|
||||
Self::Enemy => Color::LightRed,
|
||||
Self::Unclaimed => Color::White,
|
||||
Self::Player => Color::Rgb(0, 0, 255),
|
||||
Self::Enemy => Color::Rgb(255, 0, 0),
|
||||
Self::Unclaimed => Color::Rgb(255, 255, 255),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,9 +91,9 @@ impl Structure for BaseBuilding {
|
||||
|
||||
fn get_color(&self) -> Color {
|
||||
match self.owner {
|
||||
Players::Player => Color::LightBlue,
|
||||
Players::Enemy => Color::LightRed,
|
||||
Players::Unclaimed => Color::LightGreen,
|
||||
Players::Player => Color::Rgb(0, 0, 255),
|
||||
Players::Enemy => Color::Rgb(255, 0, 0),
|
||||
Players::Unclaimed => Color::Rgb(0, 255, 0),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ impl Structure for CollapsedTunnel {
|
||||
'#'
|
||||
}
|
||||
fn get_color(&self) -> Color {
|
||||
Color::DarkGray
|
||||
Color::Rgb(128, 128, 128)
|
||||
}
|
||||
fn get_level(&self) -> char {
|
||||
' '
|
||||
|
||||
@@ -87,9 +87,11 @@ impl Structure for Mine {
|
||||
fn text(&self) -> Vec<Line<'_>> {
|
||||
let mut lines: Vec<Line<'_>> = self.base_text();
|
||||
lines.push(Line::from_iter([
|
||||
"Ore: ".gray(),
|
||||
self.get_ore_amount().to_string().cyan(),
|
||||
format!("/{}", self.ore.get_max_ore_amount()).gray(),
|
||||
"Ore: ".fg(Color::Rgb(192, 192, 192)),
|
||||
self.get_ore_amount()
|
||||
.to_string()
|
||||
.fg(Color::Rgb(0, 128, 128)),
|
||||
format!("/{}", self.ore.get_max_ore_amount()).fg(Color::Rgb(192, 192, 192)),
|
||||
]));
|
||||
lines
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ impl Structure for Ore {
|
||||
match self.owner {
|
||||
Players::Player => self.owner.get_color(),
|
||||
Players::Enemy => self.owner.get_color(),
|
||||
Players::Unclaimed => Color::Indexed(217),
|
||||
Players::Unclaimed => Color::Rgb(255, 175, 175),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,10 +89,14 @@ impl Structure for Ore {
|
||||
let mut lines: Vec<Line<'_>> = Structure::base_text(self);
|
||||
|
||||
lines.push(Line::from_iter([
|
||||
"Ore: ".gray(),
|
||||
self.get_ore_amount().to_string().cyan(),
|
||||
"/".gray(),
|
||||
self.get_max_ore_amount().to_string().cyan(),
|
||||
"Ore: ".fg(Color::Rgb(192, 192, 192)),
|
||||
self.get_ore_amount()
|
||||
.to_string()
|
||||
.fg(Color::Rgb(0, 128, 128)),
|
||||
"/".fg(Color::Rgb(192, 192, 192)),
|
||||
self.get_max_ore_amount()
|
||||
.to_string()
|
||||
.fg(Color::Rgb(0, 128, 128)),
|
||||
]));
|
||||
|
||||
lines
|
||||
|
||||
@@ -26,7 +26,7 @@ impl Structure for Stone {
|
||||
}
|
||||
|
||||
fn get_color(&self) -> Color {
|
||||
Color::White
|
||||
Color::Rgb(255, 255, 255)
|
||||
}
|
||||
|
||||
fn get_level(&self) -> char {
|
||||
|
||||
@@ -30,21 +30,25 @@ pub trait Structure {
|
||||
|
||||
let mut lines: Vec<Line<'_>> = vec![
|
||||
Line::from_iter([
|
||||
"Durability: ".gray(),
|
||||
durability.to_string().cyan(),
|
||||
"/".gray(),
|
||||
max_durability.to_string().cyan(),
|
||||
" ( ".gray(),
|
||||
durability_percent.to_string().cyan(),
|
||||
"% )".gray(),
|
||||
"Durability: ".fg(Color::Rgb(192, 192, 192)),
|
||||
durability.to_string().fg(Color::Rgb(0, 128, 128)),
|
||||
"/".fg(Color::Rgb(192, 192, 192)),
|
||||
max_durability.to_string().fg(Color::Rgb(0, 128, 128)),
|
||||
" ( ".fg(Color::Rgb(192, 192, 192)),
|
||||
durability_percent.to_string().fg(Color::Rgb(0, 128, 128)),
|
||||
"% )".fg(Color::Rgb(192, 192, 192)),
|
||||
]),
|
||||
Line::from_iter([
|
||||
"Stress: ".fg(Color::Rgb(192, 192, 192)),
|
||||
stress.to_string().fg(Color::Rgb(0, 128, 128)),
|
||||
"%".fg(Color::Rgb(192, 192, 192)),
|
||||
]),
|
||||
Line::from_iter(["Stress: ".gray(), stress.to_string().cyan(), "%".gray()]),
|
||||
];
|
||||
|
||||
if level != ' ' {
|
||||
lines.push(Line::from_iter([
|
||||
"Level: ".gray(),
|
||||
level.to_string().cyan(),
|
||||
"Level: ".fg(Color::Rgb(192, 192, 192)),
|
||||
level.to_string().fg(Color::Rgb(0, 128, 128)),
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ impl Structure for Structures {
|
||||
let mut lines: Vec<Line<'_>> = self.s().text();
|
||||
|
||||
lines.push(Line::from_iter([
|
||||
"Owner: ".gray(),
|
||||
"Owner: ".fg(Color::Rgb(192, 192, 192)),
|
||||
self.s().get_owner().get_span(),
|
||||
]));
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ impl Structure for Tunnel {
|
||||
},
|
||||
self.support_progress().unwrap_or(0)
|
||||
))
|
||||
.cyan(),
|
||||
.fg(Color::Rgb(0, 128, 128)),
|
||||
);
|
||||
}
|
||||
lines
|
||||
@@ -111,7 +111,7 @@ impl Structure for Tunnel {
|
||||
}
|
||||
|
||||
fn get_color(&self) -> Color {
|
||||
Color::Gray
|
||||
Color::Rgb(192, 192, 192)
|
||||
}
|
||||
|
||||
fn get_level(&self) -> char {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use ratatui::{style::Stylize, text::Line};
|
||||
use ratatui::{
|
||||
style::{Color, Stylize},
|
||||
text::Line,
|
||||
};
|
||||
|
||||
use crate::app::states::skirmish_states::{
|
||||
Players, Resources,
|
||||
@@ -107,19 +110,21 @@ impl Unit for MinerUnit {
|
||||
.flat_map(|(i, task): (usize, &Tasks)| -> [Line<'_>; 2] {
|
||||
[
|
||||
Line::from_iter([
|
||||
format!("{}. ", i + 1).gray(),
|
||||
task.get_icon().gray(),
|
||||
" ".gray(),
|
||||
self.display_coords(task.get_path_front_coords()).green(),
|
||||
" -> ".gray(),
|
||||
self.display_coords(task.get_path_back_coords()).yellow(),
|
||||
format!("{}. ", i + 1).fg(Color::Rgb(192, 192, 192)),
|
||||
task.get_icon().fg(Color::Rgb(192, 192, 192)),
|
||||
" ".fg(Color::Rgb(192, 192, 192)),
|
||||
self.display_coords(task.get_path_front_coords())
|
||||
.fg(Color::Rgb(0, 128, 0)),
|
||||
" -> ".fg(Color::Rgb(192, 192, 192)),
|
||||
self.display_coords(task.get_path_back_coords())
|
||||
.fg(Color::Rgb(128, 128, 0)),
|
||||
]),
|
||||
Line::from(format!(
|
||||
" Step: {}% | Total: {}%",
|
||||
task.get_progress() as u16,
|
||||
task.get_total_progress() as u16,
|
||||
))
|
||||
.cyan(),
|
||||
.fg(Color::Rgb(0, 128, 128)),
|
||||
]
|
||||
})
|
||||
.collect::<Vec<Line<'_>>>(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::app::states::skirmish_states::{Players, tasks::Tasks};
|
||||
use ratatui::{
|
||||
style::Stylize,
|
||||
style::{Color, Stylize},
|
||||
text::{Line, Span},
|
||||
};
|
||||
use std::collections::VecDeque;
|
||||
@@ -51,31 +51,31 @@ pub trait Unit {
|
||||
let tasks: Vec<Line<'_>> = self.get_tasks_formatted();
|
||||
|
||||
let mut lines: Vec<Line<'_>> = Vec::from([
|
||||
Line::from_iter(["Owner: ".gray(), owner]),
|
||||
Line::from_iter(["Owner: ".fg(Color::Rgb(192, 192, 192)), owner]),
|
||||
Line::from_iter([
|
||||
"HP: ".gray(),
|
||||
hp.green(),
|
||||
"/".gray(),
|
||||
max_hp.green(),
|
||||
" ( ".gray(),
|
||||
hp_percent.green(),
|
||||
"% )".gray(),
|
||||
"HP: ".fg(Color::Rgb(192, 192, 192)),
|
||||
hp.fg(Color::Rgb(0, 128, 0)),
|
||||
"/".fg(Color::Rgb(192, 192, 192)),
|
||||
max_hp.fg(Color::Rgb(0, 128, 0)),
|
||||
" ( ".fg(Color::Rgb(192, 192, 192)),
|
||||
hp_percent.fg(Color::Rgb(0, 128, 0)),
|
||||
"% )".fg(Color::Rgb(192, 192, 192)),
|
||||
]),
|
||||
]);
|
||||
|
||||
if can_dig {
|
||||
lines.push(Line::from_iter([
|
||||
"Digging power: ".gray(),
|
||||
digging_power.green(),
|
||||
"Digging power: ".fg(Color::Rgb(192, 192, 192)),
|
||||
digging_power.fg(Color::Rgb(0, 128, 0)),
|
||||
]));
|
||||
}
|
||||
|
||||
if self.get_can_build() {
|
||||
lines.push(Line::from("Can build: Yes").green());
|
||||
lines.push(Line::from("Can build: Yes").fg(Color::Rgb(0, 128, 0)));
|
||||
}
|
||||
|
||||
if !have_any_tasks {
|
||||
lines.push(Line::from("Tasks Queue: ".gray()));
|
||||
lines.push(Line::from("Tasks Queue: ".fg(Color::Rgb(192, 192, 192))));
|
||||
for task in tasks {
|
||||
lines.push(task);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::app::{
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::{Alignment, Constraint, Layout, Rect},
|
||||
style::Stylize,
|
||||
style::{Color, Stylize},
|
||||
widgets::{Block, Borders, Paragraph, Widget},
|
||||
};
|
||||
|
||||
@@ -25,10 +25,10 @@ pub fn default_view(area: Rect, buf: &mut Buffer) {
|
||||
{
|
||||
Paragraph::new("Work in progress")
|
||||
.alignment(Alignment::Center)
|
||||
.yellow()
|
||||
.fg(Color::Rgb(128, 128, 0))
|
||||
.block(
|
||||
Block::new()
|
||||
.gray()
|
||||
.fg(Color::Rgb(192, 192, 192))
|
||||
.borders(Borders::LEFT | Borders::TOP | Borders::RIGHT),
|
||||
)
|
||||
.render(main_area, buf);
|
||||
|
||||
@@ -8,7 +8,7 @@ use clap::ValueEnum;
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::{Alignment, Constraint, Layout, Rect},
|
||||
style::Stylize,
|
||||
style::{Color, Stylize},
|
||||
text::Line,
|
||||
widgets::{Block, Borders, Paragraph, Widget},
|
||||
};
|
||||
@@ -62,8 +62,12 @@ pub fn main_menu_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
|
||||
Paragraph::new(title_text)
|
||||
.alignment(Alignment::Center)
|
||||
.yellow()
|
||||
.block(Block::new().gray().borders(Borders::LEFT | Borders::RIGHT))
|
||||
.fg(Color::Rgb(128, 128, 0))
|
||||
.block(
|
||||
Block::new()
|
||||
.fg(Color::Rgb(192, 192, 192))
|
||||
.borders(Borders::LEFT | Borders::RIGHT),
|
||||
)
|
||||
.render(title_area, buf);
|
||||
}
|
||||
|
||||
@@ -78,9 +82,13 @@ pub fn main_menu_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
let view_string: String = main_menu_option_helper(format!("{:?}", view));
|
||||
|
||||
let styled: Line<'_> = if states.main_menu.selected_view == i {
|
||||
Line::from_iter(["> ".cyan(), view_string.yellow()]).yellow()
|
||||
Line::from_iter([
|
||||
"> ".fg(Color::Rgb(0, 128, 128)),
|
||||
view_string.fg(Color::Rgb(128, 128, 0)),
|
||||
])
|
||||
.fg(Color::Rgb(128, 128, 0))
|
||||
} else {
|
||||
Line::from(format!(" {view_string}")).white()
|
||||
Line::from(format!(" {view_string}")).fg(Color::Rgb(255, 255, 255))
|
||||
};
|
||||
|
||||
styled
|
||||
@@ -89,8 +97,12 @@ pub fn main_menu_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
|
||||
Paragraph::new(lines)
|
||||
.alignment(Alignment::Center)
|
||||
.green()
|
||||
.block(Block::new().gray().borders(Borders::LEFT | Borders::RIGHT))
|
||||
.fg(Color::Rgb(0, 128, 0))
|
||||
.block(
|
||||
Block::new()
|
||||
.fg(Color::Rgb(192, 192, 192))
|
||||
.borders(Borders::LEFT | Borders::RIGHT),
|
||||
)
|
||||
.render(options_area, buf);
|
||||
}
|
||||
|
||||
|
||||
+58
-48
@@ -49,7 +49,7 @@ pub fn skirmish_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
|
||||
{
|
||||
let lines: Vec<Line<'_>> = Vec::from_iter([
|
||||
Line::raw("War in Tunnels").yellow(),
|
||||
Line::raw("War in Tunnels").fg(Color::Rgb(128, 128, 0)),
|
||||
Line::from_iter([
|
||||
format!(
|
||||
"Wood: {} (+{}/{}s) | ",
|
||||
@@ -72,7 +72,7 @@ pub fn skirmish_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
.alignment(Alignment::Left)
|
||||
.block(
|
||||
Block::new()
|
||||
.gray()
|
||||
.fg(Color::Rgb(192, 192, 192))
|
||||
.padding(Padding {
|
||||
left: 1,
|
||||
right: 1,
|
||||
@@ -86,11 +86,11 @@ pub fn skirmish_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
|
||||
{
|
||||
let main_block: Block = Block::new()
|
||||
.gray()
|
||||
.fg(Color::Rgb(192, 192, 192))
|
||||
.title(block_title_helper(
|
||||
&[
|
||||
("Skirmish".to_string(), Color::Magenta),
|
||||
("Map".to_string(), Color::Green),
|
||||
("Skirmish".to_string(), Color::Rgb(128, 0, 128)),
|
||||
("Map".to_string(), Color::Rgb(0, 128, 0)),
|
||||
],
|
||||
Some(" - "),
|
||||
))
|
||||
@@ -121,24 +121,24 @@ pub fn skirmish_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
|
||||
if states.skirmish.task_view {
|
||||
let mut lines: Vec<Line<'_>> = vec![
|
||||
Line::from("Enter: draw route").green(),
|
||||
Line::from("Enter: draw route").fg(Color::Rgb(0, 128, 0)),
|
||||
Line::from(format!(
|
||||
"Auto supports: {}",
|
||||
if board.auto_supports { "ON" } else { "OFF" }
|
||||
))
|
||||
.cyan(),
|
||||
Line::from("a: toggle auto supports").yellow(),
|
||||
Line::from("Support: 10 Wood + 2 Metal").yellow(),
|
||||
Line::from("Placed at 80% stress").gray(),
|
||||
Line::from("No funds: collapse risk!").red(),
|
||||
Line::from("t: close task selection").gray(),
|
||||
.fg(Color::Rgb(0, 128, 128)),
|
||||
Line::from("a: toggle auto supports").fg(Color::Rgb(128, 128, 0)),
|
||||
Line::from("Support: 10 Wood + 2 Metal").fg(Color::Rgb(128, 128, 0)),
|
||||
Line::from("Placed at 80% stress").fg(Color::Rgb(192, 192, 192)),
|
||||
Line::from("No funds: collapse risk!").fg(Color::Rgb(128, 0, 0)),
|
||||
Line::from("t: close task selection").fg(Color::Rgb(192, 192, 192)),
|
||||
];
|
||||
if states.skirmish.selected_task == 1 {
|
||||
lines = vec![
|
||||
Line::from("Enter: draw movement route").green(),
|
||||
Line::from("Walkable cells only; no digging").cyan(),
|
||||
Line::from("Collapsed route: wait, do not dig").gray(),
|
||||
Line::from("t: close task selection").gray(),
|
||||
Line::from("Enter: draw movement route").fg(Color::Rgb(0, 128, 0)),
|
||||
Line::from("Walkable cells only; no digging").fg(Color::Rgb(0, 128, 128)),
|
||||
Line::from("Collapsed route: wait, do not dig").fg(Color::Rgb(192, 192, 192)),
|
||||
Line::from("t: close task selection").fg(Color::Rgb(192, 192, 192)),
|
||||
];
|
||||
}
|
||||
let block: Block<'_> = Block::bordered()
|
||||
@@ -150,7 +150,7 @@ pub fn skirmish_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
block.render(side_panel_area, buf);
|
||||
Tabs::new(SkirmishState::TASK_OPTIONS.iter().copied())
|
||||
.select(states.skirmish.selected_task)
|
||||
.highlight_style(Style::default().fg(Color::LightMagenta).bold())
|
||||
.highlight_style(Style::default().fg(Color::Rgb(255, 0, 255)).bold())
|
||||
.render(tabs_area, buf);
|
||||
Paragraph::new(lines).render(details_area, buf);
|
||||
} else if states.skirmish.side_panel {
|
||||
@@ -305,25 +305,30 @@ pub fn skirmish_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
&& site.get_owner() == Players::Player
|
||||
{
|
||||
vec![
|
||||
Line::from(format!("Construction: {}%", site.progress_percent())).cyan(),
|
||||
Line::from(format!("Construction: {}%", site.progress_percent()))
|
||||
.fg(Color::Rgb(0, 128, 128)),
|
||||
if board.has_adjacent_builder(coords, Players::Player) {
|
||||
Line::from("Builder working").green()
|
||||
Line::from("Builder working").fg(Color::Rgb(0, 128, 0))
|
||||
} else {
|
||||
Line::from("Paused: adjacent friendly builder required").yellow()
|
||||
Line::from("Paused: adjacent friendly builder required")
|
||||
.fg(Color::Rgb(128, 128, 0))
|
||||
},
|
||||
Line::from("Delete: cancel and refund full cost").yellow(),
|
||||
Line::from("Delete: cancel and refund full cost").fg(Color::Rgb(128, 128, 0)),
|
||||
]
|
||||
} else if matches!(structure, Structures::Mine(_))
|
||||
&& structure.get_owner() == Players::Player
|
||||
{
|
||||
vec![Line::from("Mine completed").green()]
|
||||
vec![Line::from("Mine completed").fg(Color::Rgb(0, 128, 0))]
|
||||
} else if states
|
||||
.skirmish
|
||||
.can_start_mine_construction(coords, Players::Player)
|
||||
{
|
||||
vec![Line::from("Ready to build: Enter").green()]
|
||||
vec![Line::from("Ready to build: Enter").fg(Color::Rgb(0, 128, 0))]
|
||||
} else {
|
||||
vec![Line::from("Construction unavailable: check site, builder and resources").red()]
|
||||
vec![
|
||||
Line::from("Construction unavailable: check site, builder and resources")
|
||||
.fg(Color::Rgb(128, 0, 0)),
|
||||
]
|
||||
};
|
||||
let mut lines: Vec<Line<'_>> = vec![
|
||||
Line::from(format!(
|
||||
@@ -331,9 +336,10 @@ pub fn skirmish_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
Mine::COST.wood,
|
||||
Mine::COST.metal
|
||||
))
|
||||
.yellow(),
|
||||
Line::from("Requires: neutral Ore + adjacent friendly builder").gray(),
|
||||
Line::from("Produces: 1 Metal/s (2 with a Miner inside)").cyan(),
|
||||
.fg(Color::Rgb(128, 128, 0)),
|
||||
Line::from("Requires: neutral Ore + adjacent friendly builder")
|
||||
.fg(Color::Rgb(192, 192, 192)),
|
||||
Line::from("Produces: 1 Metal/s (2 with a Miner inside)").fg(Color::Rgb(0, 128, 128)),
|
||||
];
|
||||
lines.extend(status);
|
||||
if states.skirmish.selected_building == 1 {
|
||||
@@ -343,22 +349,24 @@ pub fn skirmish_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
Tunnel::SUPPORT_COST.wood,
|
||||
Tunnel::SUPPORT_COST.metal
|
||||
))
|
||||
.yellow(),
|
||||
Line::from("Tunnel + nearby friendly builder required").gray(),
|
||||
Line::from("Stress: 20% at support, +20% per tile").cyan(),
|
||||
.fg(Color::Rgb(128, 128, 0)),
|
||||
Line::from("Tunnel + nearby friendly builder required")
|
||||
.fg(Color::Rgb(192, 192, 192)),
|
||||
Line::from("Stress: 20% at support, +20% per tile").fg(Color::Rgb(0, 128, 128)),
|
||||
if matches!(structure, Structures::Tunnel(tunnel) if tunnel.support_work().is_some())
|
||||
{
|
||||
Line::from("Builder occupied until completion").yellow()
|
||||
Line::from("Builder occupied until completion").fg(Color::Rgb(128, 128, 0))
|
||||
} else if matches!(structure, Structures::Tunnel(tunnel) if tunnel.has_support())
|
||||
&& states.skirmish.can_manage_support(coords, Players::Player)
|
||||
{
|
||||
Line::from("Delete: remove support (no refund)").yellow()
|
||||
Line::from("Delete: remove support (no refund)").fg(Color::Rgb(128, 128, 0))
|
||||
} else if states.skirmish.can_build_support(coords, Players::Player) {
|
||||
Line::from("Enter: build support").green()
|
||||
Line::from("Enter: build support").fg(Color::Rgb(0, 128, 0))
|
||||
} else {
|
||||
Line::from("Support unavailable: site, builder or resources").red()
|
||||
Line::from("Support unavailable: site, builder or resources")
|
||||
.fg(Color::Rgb(128, 0, 0))
|
||||
},
|
||||
Line::from("WARNING: removal can cause fatal collapses").red(),
|
||||
Line::from("WARNING: removal can cause fatal collapses").fg(Color::Rgb(128, 0, 0)),
|
||||
];
|
||||
if let Structures::Tunnel(tunnel) = structure
|
||||
&& let Some(work) = tunnel.support_work()
|
||||
@@ -373,23 +381,25 @@ pub fn skirmish_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
},
|
||||
tunnel.support_progress().unwrap_or(0)
|
||||
))
|
||||
.cyan(),
|
||||
.fg(Color::Rgb(0, 128, 128)),
|
||||
);
|
||||
if board.support_worker(coords, work.owner).is_none() {
|
||||
lines.push(Line::from("Paused: friendly builder required").yellow());
|
||||
lines.push(
|
||||
Line::from("Paused: friendly builder required").fg(Color::Rgb(128, 128, 0)),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Clear.render(popup, buf);
|
||||
let block: Block<'_> = Block::bordered()
|
||||
.title(Line::from("Buildings").magenta().bold())
|
||||
.title(Line::from("Buildings").fg(Color::Rgb(128, 0, 128)).bold())
|
||||
.padding(Padding::uniform(1));
|
||||
let [tabs_area, details_area]: [Rect; 2] =
|
||||
Layout::vertical([Constraint::Length(2), Constraint::Min(0)]).areas(block.inner(popup));
|
||||
block.render(popup, buf);
|
||||
Tabs::new(SkirmishState::BUILDING_OPTIONS.iter().copied())
|
||||
.select(states.skirmish.selected_building)
|
||||
.highlight_style(Style::default().fg(Color::LightMagenta).bold())
|
||||
.highlight_style(Style::default().fg(Color::Rgb(255, 0, 255)).bold())
|
||||
.render(tabs_area, buf);
|
||||
Paragraph::new(lines).render(details_area, buf);
|
||||
}
|
||||
@@ -403,9 +413,9 @@ pub fn skirmish_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
let status: &'static str =
|
||||
base.recruitment_status(cell.get_ref_option_unit().is_some());
|
||||
let action: Line<'_> = if states.skirmish.can_recruit_miner(coords, Players::Player) {
|
||||
Line::from("Enter: queue Miner").green()
|
||||
Line::from("Enter: queue Miner").fg(Color::Rgb(0, 128, 0))
|
||||
} else {
|
||||
Line::from("Insufficient resources or queue full").red()
|
||||
Line::from("Insufficient resources or queue full").fg(Color::Rgb(128, 0, 0))
|
||||
};
|
||||
vec![
|
||||
Line::from(format!(
|
||||
@@ -413,33 +423,33 @@ pub fn skirmish_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
MinerUnit::RECRUIT_COST.wood,
|
||||
MinerUnit::RECRUIT_COST.metal
|
||||
))
|
||||
.yellow(),
|
||||
.fg(Color::Rgb(128, 128, 0)),
|
||||
Line::from(format!(
|
||||
"Queued Miners: {} (includes active)",
|
||||
base.queued_miners()
|
||||
))
|
||||
.cyan(),
|
||||
.fg(Color::Rgb(0, 128, 128)),
|
||||
Line::from(format!(
|
||||
"Current progress: {}%",
|
||||
base.recruitment_progress()
|
||||
))
|
||||
.cyan(),
|
||||
Line::from(status).yellow(),
|
||||
.fg(Color::Rgb(0, 128, 128)),
|
||||
Line::from(status).fg(Color::Rgb(128, 128, 0)),
|
||||
action,
|
||||
]
|
||||
} else {
|
||||
vec![Line::from("Select your Base to recruit Miners").red()]
|
||||
vec![Line::from("Select your Base to recruit Miners").fg(Color::Rgb(128, 0, 0))]
|
||||
};
|
||||
Clear.render(popup, buf);
|
||||
let block: Block<'_> = Block::bordered()
|
||||
.title(Line::from("Recruitment").magenta().bold())
|
||||
.title(Line::from("Recruitment").fg(Color::Rgb(128, 0, 128)).bold())
|
||||
.padding(Padding::uniform(1));
|
||||
let [tabs_area, details_area]: [Rect; 2] =
|
||||
Layout::vertical([Constraint::Length(2), Constraint::Min(0)]).areas(block.inner(popup));
|
||||
block.render(popup, buf);
|
||||
Tabs::new(SkirmishState::RECRUITMENT_OPTIONS.iter().copied())
|
||||
.select(states.skirmish.selected_recruit)
|
||||
.highlight_style(Style::default().fg(Color::LightMagenta).bold())
|
||||
.highlight_style(Style::default().fg(Color::Rgb(255, 0, 255)).bold())
|
||||
.render(tabs_area, buf);
|
||||
Paragraph::new(lines).render(details_area, buf);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,10 @@ impl Widget for BoardWidget<'_> {
|
||||
row_idx + self.state.vertical_offset.get_value(),
|
||||
col_idx + self.state.horizontal_offset.get_value(),
|
||||
);
|
||||
if queued_path.contains(&coords) {
|
||||
if queued_path.contains(&coords)
|
||||
&& (coords != self.state.get_focused_cell().get_coords()
|
||||
|| self.state.marked_cells.marking_cells)
|
||||
{
|
||||
cell.set_marked(true);
|
||||
}
|
||||
if self.stress {
|
||||
|
||||
+19
-10
@@ -39,7 +39,10 @@ impl CellWidget {
|
||||
} else {
|
||||
Color::Rgb(red, 255 - red, 30)
|
||||
};
|
||||
let block: Block<'_> = Block::bordered().border_type(BorderType::Rounded).fg(color);
|
||||
let block: Block<'_> = Block::bordered()
|
||||
.border_type(BorderType::Rounded)
|
||||
.fg(color)
|
||||
.title(format!("{}{}", self.col_to_letters(), self.row));
|
||||
let inner: Rect = block.inner(area);
|
||||
block.render(area, buf);
|
||||
if inner.height == 0 || inner.width == 0 {
|
||||
@@ -132,7 +135,7 @@ impl CellWidget {
|
||||
|
||||
fn display_coords(&self) -> Span<'_> {
|
||||
if self.selected || self.structure != Structures::Stone(Stone::new()) || self.marked {
|
||||
format!("{}{}", self.col_to_letters(), self.row).green()
|
||||
format!("{}{}", self.col_to_letters(), self.row).fg(Color::Rgb(0, 128, 0))
|
||||
} else {
|
||||
"".to_span()
|
||||
}
|
||||
@@ -140,13 +143,18 @@ impl CellWidget {
|
||||
|
||||
fn fg_color(&self) -> Color {
|
||||
if self.marked && self.selected {
|
||||
Color::Magenta
|
||||
Color::Rgb(128, 0, 128)
|
||||
} else if self.marked && !self.selected {
|
||||
Color::LightMagenta
|
||||
Color::Rgb(255, 0, 255)
|
||||
} else if !self.marked && self.selected {
|
||||
Color::LightYellow
|
||||
Color::Rgb(255, 255, 0)
|
||||
} else {
|
||||
self.structure.get_color()
|
||||
match self.structure.get_color() {
|
||||
Color::Rgb(red, green, blue) => {
|
||||
Color::Rgb(red - red / 4, green - green / 4, blue - blue / 4)
|
||||
}
|
||||
color => color,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,11 +175,12 @@ impl CellWidget {
|
||||
let percent: u32 = u32::from(self.structure.get_durability()) * 100
|
||||
/ u32::from(self.structure.get_max_durability());
|
||||
let middle: usize = lines.len() / 2;
|
||||
lines[middle] = Line::from(format!("{percent}%")).cyan();
|
||||
lines[middle] = Line::from(format!("{percent}%")).fg(Color::Rgb(0, 128, 128));
|
||||
}
|
||||
if let Structures::MineConstruction(site) = self.structure {
|
||||
let middle: usize = lines.len() / 2;
|
||||
lines[middle] = Line::from(format!("{}%", site.progress_percent())).cyan();
|
||||
lines[middle] =
|
||||
Line::from(format!("{}%", site.progress_percent())).fg(Color::Rgb(0, 128, 128));
|
||||
}
|
||||
if let Some(unit) = &self.unit
|
||||
&& let Some(Tasks::Moving(task)) = unit.get_ref_tasks().front()
|
||||
@@ -190,13 +199,13 @@ impl CellWidget {
|
||||
} else {
|
||||
format!("{percent}%")
|
||||
};
|
||||
lines[middle] = Line::from(label).cyan();
|
||||
lines[middle] = Line::from(label).fg(Color::Rgb(0, 128, 128));
|
||||
}
|
||||
if let Structures::Tunnel(tunnel) = self.structure
|
||||
&& let Some(percent) = tunnel.support_progress()
|
||||
{
|
||||
let middle: usize = lines.len() / 2;
|
||||
lines[middle] = Line::from(format!("{percent}%")).cyan();
|
||||
lines[middle] = Line::from(format!("{percent}%")).fg(Color::Rgb(0, 128, 128));
|
||||
}
|
||||
lines
|
||||
}
|
||||
|
||||
@@ -83,7 +83,11 @@ impl KeybindingsWidget {
|
||||
description
|
||||
},
|
||||
);
|
||||
Line::from_iter([kb.symbol.red().bold(), " - ".into(), description.into()])
|
||||
Line::from_iter([
|
||||
kb.symbol.fg(Color::Rgb(128, 0, 0)).bold(),
|
||||
" - ".into(),
|
||||
description.into(),
|
||||
])
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
@@ -140,7 +144,7 @@ impl Widget for KeybindingsWidget {
|
||||
.borders(Borders::ALL)
|
||||
.title(block_single_title_helper(
|
||||
"Keybindings".to_string(),
|
||||
Color::Magenta,
|
||||
Color::Rgb(128, 0, 128),
|
||||
));
|
||||
|
||||
let inner: Rect = block.inner(area);
|
||||
|
||||
@@ -54,7 +54,7 @@ impl<'a> SidePanelWidget<'a> {
|
||||
.border_type(BorderType::Double)
|
||||
.title(block_single_title_helper(
|
||||
format!("{}{}", self.col_to_letters(), self.coords.0),
|
||||
Color::Yellow,
|
||||
Color::Rgb(128, 128, 0),
|
||||
))
|
||||
.title_alignment(Alignment::Center)
|
||||
}
|
||||
@@ -108,7 +108,10 @@ impl Widget for SidePanelWidget<'_> {
|
||||
}
|
||||
Paragraph::new(structure_text)
|
||||
.alignment(Alignment::Left)
|
||||
.block(self.get_inner_block(self.structure.get_name().to_string(), Color::Cyan))
|
||||
.block(self.get_inner_block(
|
||||
self.structure.get_name().to_string(),
|
||||
Color::Rgb(0, 128, 128),
|
||||
))
|
||||
.render(structure_area, buf);
|
||||
|
||||
if self.unit.is_unit() {
|
||||
@@ -120,7 +123,7 @@ impl Widget for SidePanelWidget<'_> {
|
||||
|
||||
Paragraph::new(self.unit.text())
|
||||
.alignment(Alignment::Left)
|
||||
.block(self.get_inner_block(unit_name, Color::Green))
|
||||
.block(self.get_inner_block(unit_name, Color::Rgb(0, 128, 0)))
|
||||
.render(unit_area, buf);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user