cleanup and bugfixes, standardising log colours
This commit is contained in:
parent
dd4e0aaee4
commit
ff1afed92c
10 changed files with 153 additions and 73 deletions
|
|
@ -449,6 +449,15 @@ pub fn obfuscate_name_ecs(ecs: &World, item: Entity) -> (String, String) {
|
|||
return (singular, plural);
|
||||
}
|
||||
|
||||
/// Gets renderable colour as tuple of u8
|
||||
pub fn renderable_colour(renderables: &ReadStorage<Renderable>, entity: Entity) -> (u8, u8, u8) {
|
||||
return if let Some(renderable) = renderables.get(entity) {
|
||||
((renderable.fg.r * 255.0) as u8, (renderable.fg.g * 255.0) as u8, (renderable.fg.b * 255.0) as u8)
|
||||
} else {
|
||||
WHITE
|
||||
};
|
||||
}
|
||||
|
||||
pub fn item_colour_ecs(ecs: &World, item: Entity) -> (u8, u8, u8) {
|
||||
let dm = ecs.fetch::<MasterDungeonMap>();
|
||||
if let Some(name) = ecs.read_storage::<Name>().get(item) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use super::{camera::get_screen_bounds, Attributes, Hidden, Map, Pools, Position, Renderable, Rltk, World, RGB};
|
||||
use super::{camera::get_screen_bounds, Attributes, Hidden, Map, Name, Pools, Position, Renderable, Rltk, World, RGB};
|
||||
use rltk::prelude::*;
|
||||
use specs::prelude::*;
|
||||
|
||||
|
|
@ -43,6 +43,7 @@ impl Tooltip {
|
|||
pub fn draw_tooltips(ecs: &World, ctx: &mut Rltk) {
|
||||
let (min_x, _max_x, min_y, _max_y, x_offset, y_offset) = get_screen_bounds(ecs, ctx);
|
||||
let map = ecs.fetch::<Map>();
|
||||
let names = ecs.read_storage::<Name>();
|
||||
let positions = ecs.read_storage::<Position>();
|
||||
let renderables = ecs.read_storage::<Renderable>();
|
||||
let hidden = ecs.read_storage::<Hidden>();
|
||||
|
|
@ -69,7 +70,7 @@ pub fn draw_tooltips(ecs: &World, ctx: &mut Rltk) {
|
|||
}
|
||||
|
||||
let mut tooltips: Vec<Tooltip> = Vec::new();
|
||||
for (entity, position, renderable, _hidden) in (&entities, &positions, &renderables, !&hidden).join() {
|
||||
for (entity, position, renderable, _name, _hidden) in (&entities, &positions, &renderables, &names, !&hidden).join() {
|
||||
if position.x == mouse_pos_adjusted.0 && position.y == mouse_pos_adjusted.1 {
|
||||
let mut tip = Tooltip::new();
|
||||
tip.add(crate::gui::obfuscate_name_ecs(ecs, entity).0, renderable.fg);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue