version can be displayed as message

This commit is contained in:
Joachim Lusiardi 2023-12-31 17:53:14 +01:00
parent b6d61e4bd1
commit f6bb0a9297
1 changed files with 3 additions and 1 deletions

View File

@ -131,6 +131,9 @@ fn main() -> Result<()> {
})?; })?;
if event::poll(std::time::Duration::from_millis(FRAME_LENGTH))? { if event::poll(std::time::Duration::from_millis(FRAME_LENGTH))? {
if let event::Event::Key(key) = event::read()? { 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') { if key.kind == KeyEventKind::Press && key.code == KeyCode::Char('q') {
break; break;
} }
@ -187,7 +190,6 @@ fn main() -> Result<()> {
text += format!("\nYou gained {} experience.", game.get_player().get_experience()).as_str(); 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 collected {} gold.", game.get_player().get_gold()).as_str();
text += format!("\nYou played {} seconds.", playtime.as_secs()).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 }); let paragraph = Paragraph::new(text).block(block).wrap(Wrap { trim: true });
frame.render_widget(paragraph, area); frame.render_widget(paragraph, area);
}); });