Pretty table
Build Failed The build failed
Gitea/epoch_forge/pipeline/head There was a failure building this commit
Details
Build Failed The build failed
Gitea/epoch_forge/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
58f22fb0c0
commit
1c02a37f66
|
|
@ -1,4 +1,5 @@
|
|||
//! Implementation of all needed traits for the Entity struct
|
||||
use cli_table::format::{Border, HorizontalLine, Separator, VerticalLine};
|
||||
use cli_table::{Style, WithTitle, print_stdout};
|
||||
use colored::*;
|
||||
use rand::distr::Distribution;
|
||||
|
|
@ -16,25 +17,30 @@ impl Displayable for Entity {
|
|||
// Detailed multi-line view (used e.g. in logs)
|
||||
fn print_full(&self) {
|
||||
println!(
|
||||
"{:?}\n{}",
|
||||
self.metadata.position, // Display
|
||||
format!(
|
||||
"{:?} | {:?} | {:?} | {:?} | {}",
|
||||
self.metadata.capital,
|
||||
self.metadata.governor,
|
||||
self.metadata.faction,
|
||||
self.metadata.links,
|
||||
self.metadata.prestige
|
||||
)
|
||||
.blue() // colour the whole line (you can tweak colours per field)
|
||||
"{}\n{}",
|
||||
self.to_pretty_tree(),
|
||||
format!("{:?} | {:?}", self.metadata.governor, self.metadata.faction).blue() // colour the whole line (you can tweak colours per field)
|
||||
);
|
||||
let meta_ext = format!(
|
||||
"{:?} | {:?} | {:?} | {:?}",
|
||||
self.duration, self.effect_nature, self.effect_bounds, self.entity_type
|
||||
print_stdout(
|
||||
vec![&self.stats, &self.temp_stats]
|
||||
.with_title()
|
||||
.bold(true)
|
||||
.border(
|
||||
Border::builder()
|
||||
.top(HorizontalLine::new('┌', '┐', '┬', '─'))
|
||||
.bottom(HorizontalLine::new('└', '┘', '┴', '─'))
|
||||
.left(VerticalLine::new('│'))
|
||||
.right(VerticalLine::new('│'))
|
||||
.build(),
|
||||
)
|
||||
.separator(
|
||||
Separator::builder()
|
||||
.column(Some(VerticalLine::new('│')))
|
||||
.row(Some(HorizontalLine::new('├', '┤', '┼', '─')))
|
||||
.build(),
|
||||
),
|
||||
)
|
||||
.green(); // another colour
|
||||
println!("{meta_ext}");
|
||||
print_stdout(vec![&self.stats, &self.temp_stats].with_title().bold(true)).expect("");
|
||||
.expect("");
|
||||
}
|
||||
|
||||
// Short, single-line representation
|
||||
|
|
@ -105,8 +111,8 @@ impl Entity {
|
|||
let mut out = String::new();
|
||||
|
||||
// out.push_str(&indent(0, "self\n"));
|
||||
out.push_str(&indent(0, &format!("name: {}\n", self.name)));
|
||||
out.push_str(&indent(1, "├─ metadata\n"));
|
||||
out.push_str(&indent(0, &format!("├─ name: {}\n", self.name)));
|
||||
out.push_str(&indent(1, &format!("├─ {}\n", "metadata")));
|
||||
out.push_str(&indent(
|
||||
2,
|
||||
&format!("├─ position: {:?}\n", self.metadata.position),
|
||||
|
|
@ -128,6 +134,12 @@ impl Entity {
|
|||
1,
|
||||
&format!("├─ effect_bounds: {:?}\n", self.effect_bounds),
|
||||
));
|
||||
if !self.metadata.links.is_empty() {
|
||||
out.push_str(&indent(1, &format!("├─ {}\n", "links")));
|
||||
for link in &self.metadata.links {
|
||||
out.push_str(&indent(2, &format!("├─ {:?}\n", link)));
|
||||
}
|
||||
}
|
||||
out.push_str(&indent(
|
||||
1,
|
||||
&format!("└─ entity_type: {:?}\n", self.entity_type),
|
||||
|
|
|
|||
Loading…
Reference in New Issue