aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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) {