mirror of
https://github.com/lucaspalomodevelop/binbreak.git
synced 2026-03-13 00:07:28 +00:00
cleanup
This commit is contained in:
parent
6c7f3e0729
commit
8cb9adf833
@ -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;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user