fix: bindings manipulations
This commit is contained in:
@@ -501,6 +501,16 @@ impl<Gs: GameState> Bindings<Gs> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn customizable(mut self) -> Self {
|
||||
self.options = OptionsMode::Customizable;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn immutable(mut self) -> Self {
|
||||
self.options = OptionsMode::Immutable;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_option_mode(mut self, options: OptionsMode) -> Self {
|
||||
self.options = options;
|
||||
self
|
||||
@@ -672,7 +682,7 @@ impl<A: Action, Gs: GameState> Controls<A, Gs> {
|
||||
}
|
||||
|
||||
/// Push new binding for action
|
||||
pub fn push(&mut self, action: A, binding: Binding<Gs>) {
|
||||
pub fn push_binding(&mut self, action: A, binding: Binding<Gs>) {
|
||||
// TODO: warning if config is not exist yet
|
||||
// TODO: interface for [`ActivationOptions`]
|
||||
self
|
||||
@@ -684,7 +694,7 @@ impl<A: Action, Gs: GameState> Controls<A, Gs> {
|
||||
}
|
||||
|
||||
/// Remove all bindings for action
|
||||
pub fn remove(&mut self, action: A) {
|
||||
pub fn clear_bindings(&mut self, action: A) {
|
||||
// TODO: warning if config is not exist yet
|
||||
self
|
||||
.0
|
||||
@@ -694,9 +704,10 @@ impl<A: Action, Gs: GameState> Controls<A, Gs> {
|
||||
.clear();
|
||||
}
|
||||
|
||||
/// Remove binding for action
|
||||
pub fn remove_binding(&mut self, action: A, binding: Binding<Gs>) {
|
||||
if let Some(config) = self.0.get_mut(&action) {
|
||||
config.bindings.retain(|b| *b == binding);
|
||||
config.bindings.retain(|b| *b != binding);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user