diff options
| author | Arne Dußin | 2020-11-10 11:52:56 +0100 |
|---|---|---|
| committer | Arne Dußin | 2020-11-10 11:52:56 +0100 |
| commit | f2caebd11512fce214338b054c1b061b86d84aee (patch) | |
| tree | 37c717b08f252f6e539d24545aac00b7f0e1ef2c /src/editor.rs | |
| parent | 667a3c8335762aa626943a5ca0bcf64c653d0d0f (diff) | |
| download | graf_karto-f2caebd11512fce214338b054c1b061b86d84aee.tar.gz graf_karto-f2caebd11512fce214338b054c1b061b86d84aee.zip | |
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.
Diffstat (limited to 'src/editor.rs')
| -rw-r--r-- | src/editor.rs | 10 |
1 files changed, 10 insertions, 0 deletions
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; } } |
