From 667a3c8335762aa626943a5ca0bcf64c653d0d0f Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Mon, 9 Nov 2020 22:13:26 +0100 Subject: Fix editor not using the configured keybindings --- src/editor.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index 0999448..c756990 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -35,17 +35,12 @@ impl Editor { pub fn update(&mut self, rl: &RaylibHandle, transform: &Transform) { // Handle keybindings for tool change - self.active = if rl.is_key_pressed(KeyboardKey::KEY_R) { - ToolType::RoomTool as usize - } else if rl.is_key_pressed(KeyboardKey::KEY_W) { - ToolType::WallTool as usize - } else if rl.is_key_pressed(KeyboardKey::KEY_I) { - ToolType::IconTool as usize - } else if rl.is_key_pressed(KeyboardKey::KEY_D) { - ToolType::DeletionTool as usize - } else { - self.active - }; + for (i, tool) in self.tools.iter().enumerate() { + if tool.activation_key().is_pressed(rl) { + self.active = i; + break; + } + } // Handle saving and loading the editor contents to the swap file if rl.is_key_pressed(KeyboardKey::KEY_S) { -- cgit v1.2.3-70-g09d2