From f6bb0a9297aa6581a5c00482acbe75f284246809 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Sun, 31 Dec 2023 17:53:14 +0100 Subject: [PATCH] version can be displayed as message --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 4a37d64..de6c39e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -131,6 +131,9 @@ fn main() -> Result<()> { })?; if event::poll(std::time::Duration::from_millis(FRAME_LENGTH))? { if let event::Event::Key(key) = event::read()? { + if key.kind == KeyEventKind::Press && key.code == KeyCode::Char('v') { + game.messages.insert(0, format!("You are playing version '{}'.", env!("GIT_HASH")).to_string()); + } if key.kind == KeyEventKind::Press && key.code == KeyCode::Char('q') { break; } @@ -187,7 +190,6 @@ fn main() -> Result<()> { text += format!("\nYou gained {} experience.", game.get_player().get_experience()).as_str(); text += format!("\nYou collected {} gold.", game.get_player().get_gold()).as_str(); text += format!("\nYou played {} seconds.", playtime.as_secs()).as_str(); - text += format!("\nYou played game version '{}'.", env!("GIT_HASH")).as_str(); let paragraph = Paragraph::new(text).block(block).wrap(Wrap { trim: true }); frame.render_widget(paragraph, area); });