diff --git a/src/app.rs b/src/app.rs index 85d1983..b0d00f5 100644 --- a/src/app.rs +++ b/src/app.rs @@ -5,7 +5,7 @@ use crossterm::event; use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers}; use ratatui::buffer::Buffer; use ratatui::layout::Rect; -use ratatui::prelude::{Color, Modifier, Span, StatefulWidget, Style, Widget}; +use ratatui::prelude::{Color, Modifier, Span, Style, Widget}; use ratatui::widgets::{List, ListItem, ListState}; use std::collections::HashMap; use std::thread; diff --git a/src/binary_numbers.rs b/src/binary_numbers.rs index 52cfd38..b5df321 100644 --- a/src/binary_numbers.rs +++ b/src/binary_numbers.rs @@ -22,7 +22,6 @@ struct StatsSnapshot { max_streak: u32, rounds: u32, lives: u32, - max_lives: u32, bits: Bits, hearts: String, game_state: GameState, // NEW: overall game state replaces old boolean flags @@ -479,7 +478,6 @@ impl BinaryNumbersGame { max_streak: self.max_streak, rounds: self.rounds, lives: self.lives, - max_lives: self.max_lives, bits: self.bits.clone(), hearts: self.lives_hearts(), game_state: self.game_state, @@ -607,10 +605,16 @@ fn render_ascii_gauge(area: Rect, buf: &mut Buffer, ratio: f64, color: Color) { for x in 0..area.width { let filled = x < fill_width; let symbol = if filled { "=" } else { " " }; - let style = if filled { Style::default().fg(color) } else { Style::default().fg(Color::DarkGray) }; - let cell = buf.get_mut(area.x + x, area.y); - cell.set_symbol(symbol); - cell.set_style(style); + let style = if filled { + Style::default().fg(color) + } else { + Style::default().fg(Color::DarkGray) + }; + + if let Some(cell) = buf.cell_mut((area.x + x, area.y)) { + cell.set_symbol(symbol); + cell.set_style(style); + } } } diff --git a/src/main_screen_widget.rs b/src/main_screen_widget.rs index a454e1b..dbc0872 100644 --- a/src/main_screen_widget.rs +++ b/src/main_screen_widget.rs @@ -8,6 +8,6 @@ pub trait WidgetRef { pub trait MainScreenWidget: WidgetRef { fn run(&mut self, dt: f64) -> (); - fn handle_input(&mut self, input: KeyEvent); + fn handle_input(&mut self, input: KeyEvent) -> (); fn is_exit_intended(&self) -> bool; } \ No newline at end of file