diff --git a/Main.tscn b/Main.tscn index d399cba97..8fa5b344c 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=48 format=2] -[ext_resource path="res://Main Theme.tres" type="Theme" id=1] +[ext_resource path="res://Themes & Styles/Main Theme.tres" type="Theme" id=1] [ext_resource path="res://Scripts/Main.gd" type="Script" id=2] [ext_resource path="res://Assets/Graphics/Tools/RectSelect.png" type="Texture" id=3] [ext_resource path="res://Assets/Graphics/Tools/ColorPicker.png" type="Texture" id=4] @@ -11,7 +11,7 @@ [ext_resource path="res://Assets/Graphics/Color switch.png" type="Texture" id=9] [ext_resource path="res://Assets/Graphics/Color defaults.png" type="Texture" id=10] [ext_resource path="res://Assets/Graphics/Brush_button.png" type="Texture" id=11] -[ext_resource path="res://Styles/RulerStyle.tres" type="StyleBox" id=12] +[ext_resource path="res://Themes & Styles/RulerStyle.tres" type="StyleBox" id=12] [ext_resource path="res://Scripts/HorizontalRuler.gd" type="Script" id=13] [ext_resource path="res://Scripts/VerticalRuler.gd" type="Script" id=14] [ext_resource path="res://Prefabs/Canvas.tscn" type="PackedScene" id=15] @@ -1114,6 +1114,7 @@ script = ExtResource( 18 ) offset = Vector2( 32, 32 ) current = true zoom = Vector2( 0.15, 0.15 ) +script = ExtResource( 16 ) [node name="LayerLabel" type="Label" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc"] margin_top = 167.0 diff --git a/Scripts/CameraMovement.gd b/Scripts/CameraMovement.gd index 28795736a..c12e61526 100644 --- a/Scripts/CameraMovement.gd +++ b/Scripts/CameraMovement.gd @@ -16,7 +16,7 @@ func _input(event : InputEvent) -> void: elif event.is_action_released("camera_drag"): drag = false - if Global.can_draw && Global.has_focus && Rect2(Vector2.ZERO, viewport_size).has_point(mouse_pos): + if Global.can_draw && Rect2(Vector2.ZERO, viewport_size).has_point(mouse_pos): if event.is_action_pressed("zoom_in"): # Wheel Up Event zoom_camera(-1) elif event.is_action_pressed("zoom_out"): # Wheel Down Event diff --git a/Scripts/Canvas.gd b/Scripts/Canvas.gd index 4d503bd52..7ec7acac6 100644 --- a/Scripts/Canvas.gd +++ b/Scripts/Canvas.gd @@ -12,6 +12,7 @@ var frame_texture_rect : TextureRect var current_pixel := Vector2.ZERO #pretty much same as mouse_pos, but can be accessed externally var previous_mouse_pos := Vector2.ZERO +var cursor_inside_canvas := false var previous_action := "None" var mouse_inside_canvas := false #used for undo var sprite_changed_this_frame := false #for optimization purposes @@ -105,19 +106,23 @@ func _process(delta : float) -> void: if Global.current_frame == frame: if mouse_in_canvas && Global.has_focus: Global.cursor_position_label.text = "[%s×%s] %s, %s" % [size.x, size.y, mouse_pos_floored.x, mouse_pos_floored.y] - if Global.current_left_tool == "Bucket": - Input.set_custom_mouse_cursor(preload("res://Assets/Graphics/Tools/Bucket_Cursor.png"), 0, Vector2(6, 27)) - elif Global.current_left_tool == "ColorPicker": - Input.set_custom_mouse_cursor(preload("res://Assets/Graphics/Tools/ColorPicker_Cursor.png"), 0, Vector2(5, 28)) - elif Global.current_left_tool != "RectSelect": - Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN) + if !cursor_inside_canvas: + cursor_inside_canvas = true + if Global.current_left_tool == "Bucket": + Input.set_custom_mouse_cursor(preload("res://Assets/Graphics/Tools/Bucket_Cursor.png"), 0, Vector2(6, 27)) + elif Global.current_left_tool == "ColorPicker": + Input.set_custom_mouse_cursor(preload("res://Assets/Graphics/Tools/ColorPicker_Cursor.png"), 0, Vector2(5, 28)) + elif Global.current_left_tool != "RectSelect": + Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN) else: if !Input.is_mouse_button_pressed(BUTTON_LEFT) && !Input.is_mouse_button_pressed(BUTTON_RIGHT): if mouse_inside_canvas: mouse_inside_canvas = false Global.cursor_position_label.text = "[%s×%s]" % [size.x, size.y] - Input.set_custom_mouse_cursor(null) - Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + if cursor_inside_canvas: + cursor_inside_canvas = false + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + Input.set_custom_mouse_cursor(null) #Handle Undo/Redo diff --git a/Scripts/Main.gd b/Scripts/Main.gd index d24b754fc..8723dce56 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -43,8 +43,8 @@ func _ready() -> void: "Save..." : KEY_MASK_CTRL + KEY_S, "Save as..." : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_S, "Import..." : KEY_MASK_CTRL + KEY_I, - "Export..." : KEY_MASK_CTRL + KEY_E, - "Export as..." : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_E, + "Export PNG..." : KEY_MASK_CTRL + KEY_E, + "Export PNG as..." : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_E, "Quit" : KEY_MASK_CTRL + KEY_Q } var edit_menu_items := { @@ -527,8 +527,9 @@ func export_project() -> void: func save_sprite(canvas : Canvas, path : String) -> void: var whole_image := Image.new() whole_image.create(canvas.size.x, canvas.size.y, false, Image.FORMAT_RGBA8) + whole_image.lock() for layer in canvas.layers: - whole_image.blend_rect(layer[0], Rect2(canvas.position, canvas.size), Vector2.ZERO) + canvas.blend_rect(whole_image, layer[0], Rect2(canvas.position, canvas.size), Vector2.ZERO) layer[0].lock() var err = whole_image.save_png(path) if err != OK: @@ -553,10 +554,11 @@ func save_spritesheet() -> void: height = canvas.size.y var whole_image := Image.new() whole_image.create(width, height, false, Image.FORMAT_RGBA8) + whole_image.lock() var dst := Vector2.ZERO for canvas in Global.canvases: for layer in canvas.layers: - whole_image.blend_rect(layer[0], Rect2(canvas.position, canvas.size), dst) + canvas.blend_rect(whole_image, layer[0], Rect2(canvas.position, canvas.size), dst) layer[0].lock() if export_vertical_spritesheet.pressed: dst += Vector2(0, canvas.size.y) @@ -744,7 +746,8 @@ func _on_MergeLayer_pressed() -> void: var new_layer := Image.new() new_layer.copy_from(Global.canvas.layers[Global.canvas.current_layer_index - 1][0]) - new_layer.blend_rect(selected_layer, Rect2(Global.canvas.position, Global.canvas.size), Vector2.ZERO) + new_layer.lock() + Global.canvas.blend_rect(new_layer, selected_layer, Rect2(Global.canvas.position, Global.canvas.size), Vector2.ZERO) Global.undos += 1 Global.undo_redo.create_action("Merge Layer") diff --git a/Main Theme.tres b/Themes & Styles/Main Theme.tres similarity index 100% rename from Main Theme.tres rename to Themes & Styles/Main Theme.tres diff --git a/Styles/RulerStyle.tres b/Themes & Styles/RulerStyle.tres similarity index 100% rename from Styles/RulerStyle.tres rename to Themes & Styles/RulerStyle.tres