spinners and gems
This commit is contained in:
@@ -26,6 +26,8 @@ pub(crate) enum MenuLevel {
|
||||
Machines,
|
||||
/// Various directions of pushers
|
||||
Pushers,
|
||||
/// Collectible items the player picks up (e.g. gems)
|
||||
Items,
|
||||
}
|
||||
|
||||
impl MenuLevel {
|
||||
@@ -38,6 +40,7 @@ impl MenuLevel {
|
||||
MenuLevel::Terrain => "Terrain",
|
||||
MenuLevel::Machines => "Machines",
|
||||
MenuLevel::Pushers => "Pushers",
|
||||
MenuLevel::Items => "Items",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +57,7 @@ impl MenuLevel {
|
||||
MenuEntry::item('f', "Floor", |ed| ed.menu.push(MenuLevel::Floor)),
|
||||
MenuEntry::item('t', "Terrain", |ed| ed.menu.push(MenuLevel::Terrain)),
|
||||
MenuEntry::item('m', "Machines", |ed| ed.menu.push(MenuLevel::Machines)),
|
||||
MenuEntry::item('i', "Items", |ed| ed.menu.push(MenuLevel::Items)),
|
||||
],
|
||||
MenuLevel::World => vec![
|
||||
MenuEntry::item('n', "Name", |ed| ed.open_name_dialog()),
|
||||
@@ -96,6 +100,10 @@ impl MenuLevel {
|
||||
ed.set_current(Archetype::Pusher(Direction::West))
|
||||
}),
|
||||
],
|
||||
MenuLevel::Items => vec![MenuEntry::item('t', "♦ Gem", |ed| {
|
||||
// gem and glyph start with the same letter
|
||||
ed.set_current(Archetype::Gem)
|
||||
})],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-3
@@ -5,6 +5,9 @@
|
||||
//! presentational: it reads `health`/`gems` values handed in at construction and
|
||||
//! never mutates game state.
|
||||
|
||||
use crate::utils::rgba8_to_color;
|
||||
use kiln_core::Archetype;
|
||||
use kiln_core::cp437::tile_to_char;
|
||||
use ratatui::buffer::Buffer;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::style::{Color, Style};
|
||||
@@ -18,8 +21,6 @@ const MAX_HEARTS: u32 = 5;
|
||||
const HEART_FULL: Color = Color::Rgb(255, 0, 0);
|
||||
/// A depleted heart: dark red.
|
||||
const HEART_EMPTY: Color = Color::Rgb(90, 0, 0);
|
||||
/// The gem glyph color: blue.
|
||||
const GEM: Color = Color::Rgb(80, 80, 255);
|
||||
|
||||
/// A ratatui widget that renders the play-mode status sidebar.
|
||||
///
|
||||
@@ -51,13 +52,19 @@ impl Widget for StatusSidebarWidget {
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Draw the gem indicator from the gem archetype's default glyph, so the
|
||||
// sidebar matches what gems look like on the board (no hardcoded ♦/color).
|
||||
let gem_glyph = Archetype::Gem.default_glyph();
|
||||
let gem_char = tile_to_char(gem_glyph.tile).to_string();
|
||||
let gem_style = Style::default().fg(rgba8_to_color(gem_glyph.fg));
|
||||
|
||||
let lines = vec![
|
||||
Line::from("Health:"),
|
||||
Line::from(hearts),
|
||||
Line::from(""),
|
||||
Line::from(vec![
|
||||
Span::raw("Gems: "),
|
||||
Span::styled("♦", Style::default().fg(GEM)),
|
||||
Span::styled(gem_char, gem_style),
|
||||
Span::raw(format!(" {}", self.gems)),
|
||||
]),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user