From f2caebd11512fce214338b054c1b061b86d84aee Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Tue, 10 Nov 2020 11:52:56 +0100 Subject: Fix next icon still being drawn when tool is inactive The icon that would be placed next, but is not on the map was always drawn once the icon-tool was activated once. This is no longer the case. Also, the tool now saves the last icon that was selected and keeps the rotation of it between placements, which I deemed more intuitive. --- src/editor.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/editor.rs') diff --git a/src/editor.rs b/src/editor.rs index c756990..f8ee4bc 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -37,7 +37,17 @@ impl Editor { // Handle keybindings for tool change for (i, tool) in self.tools.iter().enumerate() { if tool.activation_key().is_pressed(rl) { + // Don't do anything if the tool does not change. + if i == self.active { + break; + } + + /* Deactivate the current tool and activate the tool, of which the keybinding has + * been pressed. + */ + self.tools[self.active].deactivate(); self.active = i; + self.tools[self.active].activate(); break; } } -- cgit v1.2.3-70-g09d2