Log panel

This commit is contained in:
2026-06-03 22:46:54 -05:00
parent de1870432f
commit 0187162e85
6 changed files with 262 additions and 53 deletions
+15 -4
View File
@@ -1,3 +1,4 @@
use crate::log::LogLine;
use color::Rgba8;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
@@ -35,7 +36,7 @@ impl Hash for Glyph {
}
impl Glyph {
/// Returns the glyph used to render the player: tile 64 (`@`) in light blue on black.
/// Returns the glyph used to render the player: tile 64 (`@`) in white on dark blue.
///
/// This is the only hardcoded glyph; all other glyphs come from the map
/// file palette. It will be removed once the player becomes a scripted
@@ -43,8 +44,8 @@ impl Glyph {
pub const fn player() -> Self {
Self {
tile: 64,
fg: Rgba8 { r: 173, g: 216, b: 230, a: 255 }, // light blue
bg: Rgba8 { r: 0, g: 0, b: 0, a: 255 }, // black
fg: Rgba8 { r: 255, g: 255, b: 255, a: 255 }, // white
bg: Rgba8 { r: 0, g: 0, b: 200, a: 255 }, // dark blue
}
}
}
@@ -394,12 +395,22 @@ impl Board {
pub struct GameState {
/// The currently active board.
pub board: Board,
/// The in-game message log, oldest first (newest pushed at the end).
pub log: Vec<LogLine>,
}
impl GameState {
/// Creates a `GameState` from a pre-loaded [`Board`].
pub fn new(board: Board) -> Self {
Self { board }
Self {
board,
log: Vec::new(),
}
}
/// Appends a styled message to the log.
pub fn log(&mut self, line: LogLine) {
self.log.push(line);
}
/// Attempts to move the player by `(dx, dy)` cells.