From 8126888b5bec20c916d2ba11cdb5bb5853e9b6ae Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Wed, 3 Jul 2019 16:22:30 -0700 Subject: [PATCH] Drawing Strokes and Undo/Redo Functionality * Add new pkg/drawtool with utilities to abstract away drawing actions into Strokes and track undo/redo History for them. * The freehand Pencil tool in EditorMode has been refactored to create a Stroke of Shape=Freehand and queue up its world pixels there instead of directly modifying the level chunker in real time. When the mouse button is released, the freehand Stroke is committed to the level chunker and added to the UndoHistory. * UndoHistory is (temporarily) stored with the level.Level so it can survive trips to PlayScene and back, but is not stored as JSON on disk. * Ctrl-Z and Ctrl-Y in EditorMode for undo and redo, respectively. --- sdl/events.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdl/events.go b/sdl/events.go index 6c958da..152c906 100644 --- a/sdl/events.go +++ b/sdl/events.go @@ -146,12 +146,13 @@ func (r *Renderer) Poll() (*events.State, error) { case sdl.SCANCODE_LSHIFT: case sdl.SCANCODE_RSHIFT: s.ShiftActive.Push(t.State == 1) - continue case sdl.SCANCODE_LALT: case sdl.SCANCODE_RALT: - case sdl.SCANCODE_LCTRL: - case sdl.SCANCODE_RCTRL: continue + case sdl.SCANCODE_LCTRL: + s.ControlActive.Push(t.State == 1) + case sdl.SCANCODE_RCTRL: + s.ControlActive.Push(t.State == 1) case sdl.SCANCODE_BACKSPACE: // Make it a key event with "\b" as the sequence. if t.State == 1 || t.Repeat == 1 {