1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Prevent undoing/redoing while drawing

Prevents errors (and potentially unwanted behavior) if attempting to undo while in the middle of drawing with the Pencil, Eraser of Shading tools. Needs more testing in case I broke something else.
This commit is contained in:
Emmanouil Papadeas 2022-09-29 01:50:12 +03:00
parent cc332c6cbf
commit af2b1feb1f
2 changed files with 7 additions and 0 deletions

View file

@ -8,6 +8,7 @@ var size: Vector2 setget _size_changed
var undo_redo := UndoRedo.new() var undo_redo := UndoRedo.new()
var tiles: Tiles var tiles: Tiles
var undos := 0 # The number of times we added undo properties var undos := 0 # The number of times we added undo properties
var can_undo = true
var fill_color := Color(0) var fill_color := Color(0)
var has_changed := false setget _has_changed_changed var has_changed := false setget _has_changed_changed
# frames and layers Arrays should generally only be modified directly when # frames and layers Arrays should generally only be modified directly when
@ -95,6 +96,8 @@ func remove() -> void:
func commit_undo() -> void: func commit_undo() -> void:
if not can_undo:
return
if Global.canvas.selection.is_moving_content: if Global.canvas.selection.is_moving_content:
Global.canvas.selection.transform_content_cancel() Global.canvas.selection.transform_content_cancel()
else: else:
@ -102,6 +105,8 @@ func commit_undo() -> void:
func commit_redo() -> void: func commit_redo() -> void:
if not can_undo:
return
Global.control.redone = true Global.control.redone = true
undo_redo.redo() undo_redo.redo()
Global.control.redone = false Global.control.redone = false

View file

@ -50,6 +50,7 @@ func update_config() -> void:
func draw_start(_position: Vector2) -> void: func draw_start(_position: Vector2) -> void:
_draw_cache = [] _draw_cache = []
is_moving = true is_moving = true
Global.current_project.can_undo = false
func draw_move(position: Vector2) -> void: func draw_move(position: Vector2) -> void:
@ -62,6 +63,7 @@ func draw_move(position: Vector2) -> void:
func draw_end(_position: Vector2) -> void: func draw_end(_position: Vector2) -> void:
is_moving = false is_moving = false
_draw_cache = [] _draw_cache = []
Global.current_project.can_undo = true
func cursor_move(position: Vector2) -> void: func cursor_move(position: Vector2) -> void: