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
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user