Use multiple console instances so we can render the log in a larger font
This commit is contained in:
parent
dedbb0927c
commit
4e506cd0be
@ -10,7 +10,7 @@ use ::serde::{Deserialize, Serialize};
|
|||||||
pub use builder::*;
|
pub use builder::*;
|
||||||
pub use events::*;
|
pub use events::*;
|
||||||
use logstore::*;
|
use logstore::*;
|
||||||
pub use logstore::{clear_log, clone_log, log_display, restore_log};
|
pub use logstore::{clear_log, clone_log, print_log, restore_log};
|
||||||
|
|
||||||
/// A section of colored text for the game log
|
/// A section of colored text for the game log
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
|
@ -3,6 +3,7 @@ use std::sync::Mutex;
|
|||||||
use ::rltk::prelude::*;
|
use ::rltk::prelude::*;
|
||||||
|
|
||||||
use super::LogFragment;
|
use super::LogFragment;
|
||||||
|
use crate::colors;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref LOG: Mutex<Vec<Vec<LogFragment>>> = Mutex::new(Vec::new());
|
static ref LOG: Mutex<Vec<Vec<LogFragment>>> = Mutex::new(Vec::new());
|
||||||
@ -21,18 +22,24 @@ pub fn clear_log() {
|
|||||||
LOG.lock().unwrap().clear();
|
LOG.lock().unwrap().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn log_display() -> TextBuilder {
|
pub fn print_log(console: &mut Box<dyn Console>, pos: Point) {
|
||||||
let mut buf = TextBuilder::empty();
|
let mut y = pos.y;
|
||||||
|
let mut x = pos.x;
|
||||||
LOG.lock().unwrap().iter().rev().take(12).for_each(|log| {
|
LOG.lock().unwrap().iter().rev().take(6).for_each(|log| {
|
||||||
log.iter().for_each(|frag| {
|
log.iter().for_each(|frag| {
|
||||||
buf.fg(frag.color);
|
console.print_color(
|
||||||
buf.line_wrap(&frag.text);
|
x,
|
||||||
|
y,
|
||||||
|
frag.color.to_rgba(1.0),
|
||||||
|
colors::BLACK.to_rgba(1.0),
|
||||||
|
&frag.text,
|
||||||
|
);
|
||||||
|
x += frag.text.len() as i32;
|
||||||
|
x += 1;
|
||||||
});
|
});
|
||||||
buf.ln();
|
y += 1;
|
||||||
|
x = pos.x;
|
||||||
});
|
});
|
||||||
|
|
||||||
buf
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clone_log() -> Vec<Vec<LogFragment>> {
|
pub fn clone_log() -> Vec<Vec<LogFragment>> {
|
||||||
|
@ -200,6 +200,8 @@ fn main() -> ::rltk::BError {
|
|||||||
let context = RltkBuilder::simple(80, 60)
|
let context = RltkBuilder::simple(80, 60)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_title("Roguelike Tutorial")
|
.with_title("Roguelike Tutorial")
|
||||||
|
.with_font("vga8x16.png", 8, 16)
|
||||||
|
.with_sparse_console(80, 30, "vga8x16.png")
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
main_loop(context, init_state())
|
main_loop(context, init_state())
|
||||||
|
@ -184,6 +184,9 @@ impl GameState for State {
|
|||||||
newrunstate = *runstate;
|
newrunstate = *runstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.set_active_console(1);
|
||||||
|
ctx.cls();
|
||||||
|
ctx.set_active_console(0);
|
||||||
ctx.cls();
|
ctx.cls();
|
||||||
particle_system::update_particles(&mut self.ecs, ctx);
|
particle_system::update_particles(&mut self.ecs, ctx);
|
||||||
|
|
||||||
@ -201,6 +204,9 @@ impl GameState for State {
|
|||||||
if !SHOW_MAPGEN_VISUALIZER {
|
if !SHOW_MAPGEN_VISUALIZER {
|
||||||
newrunstate = self.mapgen_next_state.unwrap();
|
newrunstate = self.mapgen_next_state.unwrap();
|
||||||
}
|
}
|
||||||
|
ctx.set_active_console(1);
|
||||||
|
ctx.cls();
|
||||||
|
ctx.set_active_console(0);
|
||||||
ctx.cls();
|
ctx.cls();
|
||||||
if self.mapgen_index < self.mapgen_history.len() {
|
if self.mapgen_index < self.mapgen_history.len() {
|
||||||
camera::render_debug_map(&self.mapgen_history[self.mapgen_index], ctx);
|
camera::render_debug_map(&self.mapgen_history[self.mapgen_index], ctx);
|
||||||
|
Loading…
Reference in New Issue
Block a user