From fa27d7fbadc35b72fcb33b09179f49b4fa7b0810 Mon Sep 17 00:00:00 2001 From: JumpJetAvocado <90295085+JumpJetAvocado@users.noreply.github.com> Date: Tue, 7 Dec 2021 01:38:54 +0900 Subject: [PATCH] Fix drawing bug reported in issue-555 (#603) * Fix drawing bug reported in issue-555 * Remove unused parameter from commit_undo() in Draw.gd --- src/Tools/Draw.gd | 7 ++++--- src/Tools/Eraser.gd | 4 ++-- src/Tools/LineTool.gd | 4 ++-- src/Tools/Pencil.gd | 4 ++-- src/Tools/Shading.gd | 4 ++-- src/Tools/ShapeDrawer.gd | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Tools/Draw.gd b/src/Tools/Draw.gd index cb96f6a55..1b65fc800 100644 --- a/src/Tools/Draw.gd +++ b/src/Tools/Draw.gd @@ -146,11 +146,13 @@ func update_line_polylines(start: Vector2, end: Vector2) -> void: _line_polylines = _create_polylines(indicator) -func prepare_undo() -> void: +func prepare_undo(action: String) -> void: + var project: Project = Global.current_project _undo_data = _get_undo_data() + project.undo_redo.create_action(action) -func commit_undo(action: String) -> void: +func commit_undo() -> void: var redo_data := _get_undo_data() var project: Project = Global.current_project var frame := -1 @@ -160,7 +162,6 @@ func commit_undo(action: String) -> void: layer = project.current_layer project.undos += 1 - project.undo_redo.create_action(action) for image in redo_data: project.undo_redo.add_do_property(image, "data", redo_data[image]) image.unlock() diff --git a/src/Tools/Eraser.gd b/src/Tools/Eraser.gd index 518034edf..ff9dab4cc 100644 --- a/src/Tools/Eraser.gd +++ b/src/Tools/Eraser.gd @@ -46,7 +46,7 @@ func draw_start(position: Vector2) -> void: _changed = false _drawer.color_op.changed = false - prepare_undo() + prepare_undo("Draw") _drawer.reset() _draw_line = Tools.shift @@ -88,7 +88,7 @@ func draw_end(_position: Vector2) -> void: draw_fill_gap(_line_start, _line_end) _draw_line = false if _changed or _drawer.color_op.changed: - commit_undo("Draw") + commit_undo() cursor_text = "" update_random_image() diff --git a/src/Tools/LineTool.gd b/src/Tools/LineTool.gd index 1e3f07ee7..447cf3d95 100644 --- a/src/Tools/LineTool.gd +++ b/src/Tools/LineTool.gd @@ -148,14 +148,14 @@ func draw_preview() -> void: func _draw_shape() -> void: # var rect := _get_result_rect(origin, dest) var points := _get_points() - prepare_undo() + prepare_undo("Draw Shape") for point in points: # Reset drawer every time because pixel perfect sometimes breaks the tool _drawer.reset() # Draw each point offseted based on the shape's thickness draw_tool(point) - commit_undo("Draw Shape") + commit_undo() func _get_points() -> PoolVector2Array: diff --git a/src/Tools/Pencil.gd b/src/Tools/Pencil.gd index b6a4cf937..a2a06b031 100644 --- a/src/Tools/Pencil.gd +++ b/src/Tools/Pencil.gd @@ -83,7 +83,7 @@ func draw_start(position: Vector2) -> void: _drawer.color_op.overwrite = _overwrite _draw_points = Array() - prepare_undo() + prepare_undo("Draw") _drawer.reset() _draw_line = Tools.shift @@ -141,7 +141,7 @@ func draw_end(_position: Vector2) -> void: if Geometry.is_point_in_polygon(v, _draw_points): draw_tool(v) if _changed or _drawer.color_op.changed: - commit_undo("Draw") + commit_undo() cursor_text = "" update_random_image() diff --git a/src/Tools/Shading.gd b/src/Tools/Shading.gd index fc73d473c..73b076136 100644 --- a/src/Tools/Shading.gd +++ b/src/Tools/Shading.gd @@ -221,7 +221,7 @@ func draw_start(position: Vector2) -> void: _changed = false _drawer.color_op.changed = false - prepare_undo() + prepare_undo("Draw") _drawer.reset() _draw_line = Tools.shift @@ -263,7 +263,7 @@ func draw_end(_position: Vector2) -> void: draw_fill_gap(_line_start, _line_end) _draw_line = false if _changed or _drawer.color_op.changed: - commit_undo("Draw") + commit_undo() cursor_text = "" update_random_image() diff --git a/src/Tools/ShapeDrawer.gd b/src/Tools/ShapeDrawer.gd index 4713394b0..d76514575 100644 --- a/src/Tools/ShapeDrawer.gd +++ b/src/Tools/ShapeDrawer.gd @@ -149,14 +149,14 @@ func draw_preview() -> void: func _draw_shape(origin: Vector2, dest: Vector2) -> void: var rect := _get_result_rect(origin, dest) var points := _get_points(rect.size) - prepare_undo() + prepare_undo("Draw Shape") for point in points: # Reset drawer every time because pixel perfect sometimes breaks the tool _drawer.reset() # Draw each point offseted based on the shape's thickness draw_tool(rect.position + point - Vector2.ONE * (_thickness - 1)) - commit_undo("Draw Shape") + commit_undo() # Given an origin point and destination point, returns a rect representing