aboutsummaryrefslogtreecommitdiff
path: root/src/editor.rs
diff options
context:
space:
mode:
authorArne Dußin2020-11-09 22:13:26 +0100
committerArne Dußin2020-11-09 22:13:26 +0100
commit667a3c8335762aa626943a5ca0bcf64c653d0d0f (patch)
tree02df28cce48917ee32cee301826d0b6ed9032cb6 /src/editor.rs
parentb8edcda33f5c305a5e48f84ed5880bd720f6dfc0 (diff)
downloadgraf_karto-667a3c8335762aa626943a5ca0bcf64c653d0d0f.tar.gz
graf_karto-667a3c8335762aa626943a5ca0bcf64c653d0d0f.zip
Fix editor not using the configured keybindings
Diffstat (limited to 'src/editor.rs')
-rw-r--r--src/editor.rs17
1 files 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) {