generated from GarandPLG/rust-flake-template
Refactor view handling and keybinding API
Move the `View` enum to a dedicated module and implement `Widget` for `&App` there. Rename `default_view_keybindings` to `default_keybindings` and adjust its signature. Redesign `KeybindingsWidget` to accept an explicit list of bindings instead of a `View`. Update imports, function signatures, and rendering logic across the codebase to reflect these changes.
This commit is contained in:
+3
-11
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
app::{GameStates, handle_keybindings},
|
||||
app::{GameStates, handle_keybindings, view::View},
|
||||
cli::Cli,
|
||||
};
|
||||
use clap::ValueEnum;
|
||||
@@ -34,15 +34,6 @@ pub struct App {
|
||||
pub skill_points_limit: u16,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, ValueEnum)]
|
||||
pub enum View {
|
||||
MainMenu,
|
||||
Skirmish,
|
||||
PerkDecks,
|
||||
SkillsConfig,
|
||||
Settings,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, ValueEnum)]
|
||||
pub enum GameMode {
|
||||
LastManStanding,
|
||||
@@ -100,7 +91,8 @@ impl App {
|
||||
}
|
||||
|
||||
fn handle_key_event(&mut self, key_event: KeyEvent) -> Result<()> {
|
||||
handle_keybindings(self, key_event)
|
||||
handle_keybindings(self, key_event);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user