From 0d69e45cab1b1a4f4978d1777bd35a58e5554066 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Thu, 31 Oct 2019 21:34:42 +0200 Subject: [PATCH] UndoRedo - Should work with multiple layers and frames - UndoRedo should work with multiple layers and frames - When pressing right click while left click is being pressed, undo/redo logic is being discarded. It is still buggy, however, when the user holds the right click first and then left click, as well as, when the user holds left click, then holds right click, releases left click and then releases right click. --- Main.tscn | 4 ++-- Scripts/Canvas.gd | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Main.tscn b/Main.tscn index b0e0dc8bd..6357e2735 100644 --- a/Main.tscn +++ b/Main.tscn @@ -887,8 +887,8 @@ resizable = true mode = 1 access = 2 filters = PoolStringArray( "*.bmp ; BMP Image", "*.hdr ; Radiance HDR Image", "*.jpg,*.jpeg ; JPEG Image", "*.png ; PNG Image", "*.svg ; SVG Image", "*.tga ; TGA Image", "*.webp ; WebP Image" ) -current_dir = "/home/danielnaoexiste/Documents/Prog/Pixelorama" -current_path = "/home/danielnaoexiste/Documents/Prog/Pixelorama/" +current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama" +current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/" [node name="ExportSprites" type="FileDialog" parent="."] anchor_left = 0.5 diff --git a/Scripts/Canvas.gd b/Scripts/Canvas.gd index 11b544452..7e1583935 100644 --- a/Scripts/Canvas.gd +++ b/Scripts/Canvas.gd @@ -95,15 +95,15 @@ func _process(delta) -> void: #Handle Undo/Redo - if point_in_rectangle(mouse_pos, location, location + size) && Global.can_draw && Global.has_focus: - if Input.is_action_just_pressed("left_mouse") || Input.is_action_just_pressed("right_mouse"): + if point_in_rectangle(mouse_pos, location, location + size) && Global.can_draw && Global.has_focus && Global.current_frame == frame: + if Input.is_action_just_pressed("left_mouse") || (Input.is_action_just_pressed("right_mouse") && !Input.is_action_pressed("left_mouse")): if current_action != "None": if current_action == "RectSelect": handle_undo("Rectangle Select") else: handle_undo("Draw") - elif Input.is_action_just_released("left_mouse") || Input.is_action_just_released("right_mouse"): + elif Input.is_action_just_released("left_mouse") || (Input.is_action_just_released("right_mouse") && !Input.is_action_pressed("left_mouse")): if previous_action != "None" && previous_action != "RectSelect": handle_redo("Draw") @@ -254,7 +254,9 @@ func handle_redo(action : String) -> void: func update_texture(layer_index : int) -> void: layers[layer_index][1].create_from_image(layers[layer_index][0], 0) - get_layer_container(layer_index).get_child(0).get_child(1).texture = layers[layer_index][1] + var layer_container := get_layer_container(layer_index) + if layer_container: + layer_container.get_child(0).get_child(1).texture = layers[layer_index][1] #This code is used to update the texture in the animation timeline frame button #but blend_rect causes major performance issues on large images