diff --git a/Assets/Graphics/Dark Themes/Layers/Lock.png b/Assets/Graphics/Dark Themes/Layers/Lock.png new file mode 100644 index 000000000..0681a44f1 Binary files /dev/null and b/Assets/Graphics/Dark Themes/Layers/Lock.png differ diff --git a/Assets/Graphics/Dark Themes/Layers/Lock.png.import b/Assets/Graphics/Dark Themes/Layers/Lock.png.import new file mode 100644 index 000000000..064132d8b --- /dev/null +++ b/Assets/Graphics/Dark Themes/Layers/Lock.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Lock.png-9253af0d80ec5684a17613b6e5d28ded.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Dark Themes/Layers/Lock.png" +dest_files=[ "res://.import/Lock.png-9253af0d80ec5684a17613b6e5d28ded.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/Graphics/Dark Themes/Layers/Lock_Hover.png b/Assets/Graphics/Dark Themes/Layers/Lock_Hover.png new file mode 100644 index 000000000..0d8e6d3db Binary files /dev/null and b/Assets/Graphics/Dark Themes/Layers/Lock_Hover.png differ diff --git a/Assets/Graphics/Dark Themes/Layers/Lock_Hover.png.import b/Assets/Graphics/Dark Themes/Layers/Lock_Hover.png.import new file mode 100644 index 000000000..a4f9e5b3f --- /dev/null +++ b/Assets/Graphics/Dark Themes/Layers/Lock_Hover.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Lock_Hover.png-b9a0e5f411d19706e8262906e2e525a4.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Dark Themes/Layers/Lock_Hover.png" +dest_files=[ "res://.import/Lock_Hover.png-b9a0e5f411d19706e8262906e2e525a4.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/Graphics/Dark Themes/Layers/Unlock.png b/Assets/Graphics/Dark Themes/Layers/Unlock.png new file mode 100644 index 000000000..8e7090840 Binary files /dev/null and b/Assets/Graphics/Dark Themes/Layers/Unlock.png differ diff --git a/Assets/Graphics/Dark Themes/Layers/Unlock.png.import b/Assets/Graphics/Dark Themes/Layers/Unlock.png.import new file mode 100644 index 000000000..97fc8a7f6 --- /dev/null +++ b/Assets/Graphics/Dark Themes/Layers/Unlock.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Unlock.png-9d9c7e247255647a55364f4f306f9095.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Dark Themes/Layers/Unlock.png" +dest_files=[ "res://.import/Unlock.png-9d9c7e247255647a55364f4f306f9095.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/Graphics/Dark Themes/Layers/Unlock_Hover.png b/Assets/Graphics/Dark Themes/Layers/Unlock_Hover.png new file mode 100644 index 000000000..dabde5491 Binary files /dev/null and b/Assets/Graphics/Dark Themes/Layers/Unlock_Hover.png differ diff --git a/Assets/Graphics/Dark Themes/Layers/Unlock_Hover.png.import b/Assets/Graphics/Dark Themes/Layers/Unlock_Hover.png.import new file mode 100644 index 000000000..9feeeb0bd --- /dev/null +++ b/Assets/Graphics/Dark Themes/Layers/Unlock_Hover.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Unlock_Hover.png-b5ce9295ff6e785f6e3679320f3b65d9.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Dark Themes/Layers/Unlock_Hover.png" +dest_files=[ "res://.import/Unlock_Hover.png-b5ce9295ff6e785f6e3679320f3b65d9.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/Graphics/Gold Themes/Layers/Lock.png b/Assets/Graphics/Gold Themes/Layers/Lock.png new file mode 100644 index 000000000..af5921ae1 Binary files /dev/null and b/Assets/Graphics/Gold Themes/Layers/Lock.png differ diff --git a/Assets/Graphics/Gold Themes/Layers/Lock.png.import b/Assets/Graphics/Gold Themes/Layers/Lock.png.import new file mode 100644 index 000000000..79446bc78 --- /dev/null +++ b/Assets/Graphics/Gold Themes/Layers/Lock.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Lock.png-416bf727369200d7502932659c7deec1.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Gold Themes/Layers/Lock.png" +dest_files=[ "res://.import/Lock.png-416bf727369200d7502932659c7deec1.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/Graphics/Gold Themes/Layers/Lock_Hover.png b/Assets/Graphics/Gold Themes/Layers/Lock_Hover.png new file mode 100644 index 000000000..e948e5923 Binary files /dev/null and b/Assets/Graphics/Gold Themes/Layers/Lock_Hover.png differ diff --git a/Assets/Graphics/Gold Themes/Layers/Lock_Hover.png.import b/Assets/Graphics/Gold Themes/Layers/Lock_Hover.png.import new file mode 100644 index 000000000..df22b1d4b --- /dev/null +++ b/Assets/Graphics/Gold Themes/Layers/Lock_Hover.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Lock_Hover.png-428f700716402bc09c16ba354a2758f1.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Gold Themes/Layers/Lock_Hover.png" +dest_files=[ "res://.import/Lock_Hover.png-428f700716402bc09c16ba354a2758f1.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/Graphics/Gold Themes/Layers/Unlock.png b/Assets/Graphics/Gold Themes/Layers/Unlock.png new file mode 100644 index 000000000..397d2dac7 Binary files /dev/null and b/Assets/Graphics/Gold Themes/Layers/Unlock.png differ diff --git a/Assets/Graphics/Gold Themes/Layers/Unlock.png.import b/Assets/Graphics/Gold Themes/Layers/Unlock.png.import new file mode 100644 index 000000000..2af112e06 --- /dev/null +++ b/Assets/Graphics/Gold Themes/Layers/Unlock.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Unlock.png-ae00d42d445f8264be1092ce547d974a.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Gold Themes/Layers/Unlock.png" +dest_files=[ "res://.import/Unlock.png-ae00d42d445f8264be1092ce547d974a.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/Graphics/Gold Themes/Layers/Unlock_Hover.png b/Assets/Graphics/Gold Themes/Layers/Unlock_Hover.png new file mode 100644 index 000000000..b5955393d Binary files /dev/null and b/Assets/Graphics/Gold Themes/Layers/Unlock_Hover.png differ diff --git a/Assets/Graphics/Gold Themes/Layers/Unlock_Hover.png.import b/Assets/Graphics/Gold Themes/Layers/Unlock_Hover.png.import new file mode 100644 index 000000000..2c2c336fe --- /dev/null +++ b/Assets/Graphics/Gold Themes/Layers/Unlock_Hover.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Unlock_Hover.png-78e723e6649c4ab922f37eb6469206ce.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Gold Themes/Layers/Unlock_Hover.png" +dest_files=[ "res://.import/Unlock_Hover.png-78e723e6649c4ab922f37eb6469206ce.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/Graphics/Light Themes/Layers/Lock.png b/Assets/Graphics/Light Themes/Layers/Lock.png new file mode 100644 index 000000000..7dd0e9f9a Binary files /dev/null and b/Assets/Graphics/Light Themes/Layers/Lock.png differ diff --git a/Assets/Graphics/Light Themes/Layers/Lock.png.import b/Assets/Graphics/Light Themes/Layers/Lock.png.import new file mode 100644 index 000000000..7f0309ccb --- /dev/null +++ b/Assets/Graphics/Light Themes/Layers/Lock.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Lock.png-dc7e2c18836835a8b8a96271217c9efd.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Light Themes/Layers/Lock.png" +dest_files=[ "res://.import/Lock.png-dc7e2c18836835a8b8a96271217c9efd.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/Graphics/Light Themes/Layers/Lock_Hover.png b/Assets/Graphics/Light Themes/Layers/Lock_Hover.png new file mode 100644 index 000000000..c1db4f768 Binary files /dev/null and b/Assets/Graphics/Light Themes/Layers/Lock_Hover.png differ diff --git a/Assets/Graphics/Light Themes/Layers/Lock_Hover.png.import b/Assets/Graphics/Light Themes/Layers/Lock_Hover.png.import new file mode 100644 index 000000000..6f4a52183 --- /dev/null +++ b/Assets/Graphics/Light Themes/Layers/Lock_Hover.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Lock_Hover.png-4da93394f176989a60b6e85874cfa07e.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Light Themes/Layers/Lock_Hover.png" +dest_files=[ "res://.import/Lock_Hover.png-4da93394f176989a60b6e85874cfa07e.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/Graphics/Light Themes/Layers/Unlock.png b/Assets/Graphics/Light Themes/Layers/Unlock.png new file mode 100644 index 000000000..268757338 Binary files /dev/null and b/Assets/Graphics/Light Themes/Layers/Unlock.png differ diff --git a/Assets/Graphics/Light Themes/Layers/Unlock.png.import b/Assets/Graphics/Light Themes/Layers/Unlock.png.import new file mode 100644 index 000000000..d4131b5a8 --- /dev/null +++ b/Assets/Graphics/Light Themes/Layers/Unlock.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Unlock.png-abf213a919e6bf6f9a20575b5ee07cf4.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Light Themes/Layers/Unlock.png" +dest_files=[ "res://.import/Unlock.png-abf213a919e6bf6f9a20575b5ee07cf4.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Assets/Graphics/Light Themes/Layers/Unlock_Hover.png b/Assets/Graphics/Light Themes/Layers/Unlock_Hover.png new file mode 100644 index 000000000..98107c01d Binary files /dev/null and b/Assets/Graphics/Light Themes/Layers/Unlock_Hover.png differ diff --git a/Assets/Graphics/Light Themes/Layers/Unlock_Hover.png.import b/Assets/Graphics/Light Themes/Layers/Unlock_Hover.png.import new file mode 100644 index 000000000..26aa8707e --- /dev/null +++ b/Assets/Graphics/Light Themes/Layers/Unlock_Hover.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Unlock_Hover.png-55cd8b99f1a29eabf99f8ac183068a35.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Light Themes/Layers/Unlock_Hover.png" +dest_files=[ "res://.import/Unlock_Hover.png-55cd8b99f1a29eabf99f8ac183068a35.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Prefabs/LayerContainer.tscn b/Prefabs/LayerContainer.tscn index 439554a80..e08241d71 100644 --- a/Prefabs/LayerContainer.tscn +++ b/Prefabs/LayerContainer.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://Scripts/LayerContainer.gd" type="Script" id=1] [ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Layer_Visible.png" type="Texture" id=2] [ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Layer_Visible_Hover.png" type="Texture" id=3] +[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Unlock_Hover.png" type="Texture" id=4] +[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Unlock.png" type="Texture" id=5] [node name="LayerContainer" type="Button"] margin_right = 210.0 @@ -25,7 +27,7 @@ __meta__ = { } [node name="LayerButtons" type="HBoxContainer" parent="HBoxContainer"] -margin_right = 32.0 +margin_right = 68.0 margin_bottom = 36.0 [node name="VisibilityButton" type="TextureButton" parent="HBoxContainer/LayerButtons" groups=[ @@ -41,11 +43,25 @@ size_flags_vertical = 4 texture_normal = ExtResource( 2 ) texture_hover = ExtResource( 3 ) -[node name="LayerName" type="HBoxContainer" parent="HBoxContainer"] +[node name="LockButton" type="TextureButton" parent="HBoxContainer/LayerButtons" groups=[ +"UIButtons", +]] margin_left = 36.0 +margin_top = 2.0 +margin_right = 68.0 +margin_bottom = 34.0 +hint_tooltip = "Lock/unlock layer." +mouse_default_cursor_shape = 2 +size_flags_horizontal = 0 +size_flags_vertical = 4 +texture_normal = ExtResource( 5 ) +texture_hover = ExtResource( 4 ) + +[node name="LayerName" type="HBoxContainer" parent="HBoxContainer"] +margin_left = 72.0 margin_right = 212.0 margin_bottom = 36.0 -rect_min_size = Vector2( 176, 0 ) +rect_min_size = Vector2( 140, 0 ) mouse_default_cursor_shape = 2 size_flags_horizontal = 0 alignment = 1 @@ -55,7 +71,7 @@ __meta__ = { [node name="Label" type="Label" parent="HBoxContainer/LayerName"] margin_top = 11.0 -margin_right = 176.0 +margin_right = 140.0 margin_bottom = 25.0 size_flags_horizontal = 3 text = "Layer 0" @@ -76,3 +92,4 @@ caret_blink = true caret_blink_speed = 0.5 [connection signal="pressed" from="." to="." method="_on_LayerContainer_pressed"] [connection signal="pressed" from="HBoxContainer/LayerButtons/VisibilityButton" to="." method="_on_VisibilityButton_pressed"] +[connection signal="pressed" from="HBoxContainer/LayerButtons/LockButton" to="." method="_on_LockButton_pressed"] diff --git a/Scripts/AnimationTimeline.gd b/Scripts/AnimationTimeline.gd index 5fdb0aaa6..cd99d3858 100644 --- a/Scripts/AnimationTimeline.gd +++ b/Scripts/AnimationTimeline.gd @@ -146,8 +146,8 @@ func add_layer(is_new := true) -> void: var new_layers : Array = Global.layers.duplicate() - # Store [Layer name, Layer visibility boolean, Frame container] - new_layers.append([layer_name, true, HBoxContainer.new()]) + # Store [Layer name, Layer visibility boolean, Layer lock boolean, Frame container] + new_layers.append([layer_name, true, false, HBoxContainer.new()]) Global.undos += 1 Global.undo_redo.create_action("Add Layer") @@ -156,7 +156,7 @@ func add_layer(is_new := true) -> void: var new_layer := Image.new() if is_new: new_layer.create(c.size.x, c.size.y, false, Image.FORMAT_RGBA8) - else: # clone layer + else: # Clone layer new_layer.copy_from(c.layers[Global.current_layer][0]) new_layer.lock() diff --git a/Scripts/Canvas.gd b/Scripts/Canvas.gd index 5bfa2958e..0b88081dc 100644 --- a/Scripts/Canvas.gd +++ b/Scripts/Canvas.gd @@ -180,7 +180,7 @@ func _input(event : InputEvent) -> void: can_undo = true current_pixel = get_local_mouse_position() + location - if Global.current_frame != frame: + if Global.current_frame != frame || Global.layers[Global.current_layer][2]: previous_mouse_pos = current_pixel previous_mouse_pos.x = clamp(previous_mouse_pos.x, location.x, location.x + size.x) previous_mouse_pos.y = clamp(previous_mouse_pos.y, location.y, location.y + size.y) @@ -493,7 +493,7 @@ func update_texture(layer_index : int) -> void: layers[layer_index][1].create_from_image(layers[layer_index][0], 0) var frame_texture_rect : TextureRect - frame_texture_rect = Global.find_node_by_name(Global.layers[layer_index][2].get_child(frame),"FrameTexture") + frame_texture_rect = Global.find_node_by_name(Global.layers[layer_index][3].get_child(frame),"FrameTexture") frame_texture_rect.texture = layers[layer_index][1] func pencil_and_eraser(sprite : Image, mouse_pos : Vector2, color : Color, current_mouse_button : String, current_action := "None") -> void: diff --git a/Scripts/Global.gd b/Scripts/Global.gd index 49f5235dd..5a2558110 100644 --- a/Scripts/Global.gd +++ b/Scripts/Global.gd @@ -371,8 +371,8 @@ func _ready() -> void: error_dialog = find_node_by_name(root, "ErrorDialog") - # Store [Layer name, Layer visibility boolean, Frame container] - layers.append([tr("Layer") + " 0", true, HBoxContainer.new()]) + # Store [Layer name, Layer visibility boolean, Layer lock boolean, Frame container] + layers.append([tr("Layer") + " 0", true, false, HBoxContainer.new()]) # Thanks to https://godotengine.org/qa/17524/how-to-find-an-instanced-scene-by-its-name func find_node_by_name(root, node_name) -> Node: @@ -477,7 +477,7 @@ func canvases_changed(value : Array) -> void: frame_id.queue_free() for i in range(layers.size() - 1, -1, -1): - frames_container.add_child(layers[i][2]) + frames_container.add_child(layers[i][3]) for j in range(canvases.size()): var label := Label.new() @@ -492,7 +492,7 @@ func canvases_changed(value : Array) -> void: frame_button.layer = i frame_button.get_child(0).texture = Global.canvases[j].layers[i][1] - layers[i][2].add_child(frame_button) + layers[i][3].add_child(frame_button) func layers_changed(value : Array) -> void: layers = value @@ -516,14 +516,14 @@ func layers_changed(value : Array) -> void: layer_container.label.text = layers[i][0] layer_container.line_edit.text = layers[i][0] - frames_container.add_child(layers[i][2]) + frames_container.add_child(layers[i][3]) for j in range(canvases.size()): var frame_button = load("res://Prefabs/FrameButton.tscn").instance() frame_button.frame = j frame_button.layer = i frame_button.get_child(0).texture = Global.canvases[j].layers[i][1] - layers[i][2].add_child(frame_button) + layers[i][3].add_child(frame_button) var layer_button = layers_container.get_child(layers_container.get_child_count() - 1 - current_layer) layer_button.pressed = true @@ -556,16 +556,16 @@ func frame_changed(value : int) -> void: text_color = Color.black frame_ids.get_child(i).add_color_override("font_color", text_color) for layer in layers: - if i < layer[2].get_child_count(): - layer[2].get_child(i).pressed = false + if i < layer[3].get_child_count(): + layer[3].get_child(i).pressed = false i += 1 # Select the new canvas/frame canvas = canvases[current_frame] canvas.visible = true frame_ids.get_child(current_frame).add_color_override("font_color", Color("#3c5d75")) - if current_frame < layers[current_layer][2].get_child_count(): - layers[current_layer][2].get_child(current_frame).pressed = true + if current_frame < layers[current_layer][3].get_child_count(): + layers[current_layer][3].get_child(current_frame).pressed = true func layer_changed(value : int) -> void: current_layer = value diff --git a/Scripts/LayerContainer.gd b/Scripts/LayerContainer.gd index d03e24af5..ec2b8fd47 100644 --- a/Scripts/LayerContainer.gd +++ b/Scripts/LayerContainer.gd @@ -3,11 +3,13 @@ extends Button var i := 0 var visibility_button : BaseButton +var lock_button : BaseButton var label : Label var line_edit : LineEdit func _ready() -> void: visibility_button = Global.find_node_by_name(self, "VisibilityButton") + lock_button = Global.find_node_by_name(self, "LockButton") label = Global.find_node_by_name(self, "Label") line_edit = Global.find_node_by_name(self, "LineEdit") @@ -18,6 +20,13 @@ func _ready() -> void: visibility_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Layer_Invisible.png" % Global.theme_type) visibility_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Layer_Invisible_Hover.png" % Global.theme_type) + if Global.layers[i][2]: + lock_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Lock.png" % Global.theme_type) + lock_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Lock_Hover.png" % Global.theme_type) + else: + lock_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Unlock.png" % Global.theme_type) + lock_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Unlock_Hover.png" % Global.theme_type) + func _input(event : InputEvent) -> void: if event.is_action_released("ui_accept") && line_edit.visible && event.scancode != KEY_SPACE: label.visible = true @@ -51,3 +60,13 @@ func _on_VisibilityButton_pressed() -> void: visibility_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Layer_Visible.png" % Global.theme_type) visibility_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Layer_Visible_Hover.png" % Global.theme_type) Global.canvas.update() + +func _on_LockButton_pressed() -> void: + if Global.layers[i][2]: + Global.layers[i][2] = false + lock_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Unlock.png" % Global.theme_type) + lock_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Unlock_Hover.png" % Global.theme_type) + else: + Global.layers[i][2] = true + lock_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Lock.png" % Global.theme_type) + lock_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Lock_Hover.png" % Global.theme_type) diff --git a/Scripts/Main.gd b/Scripts/Main.gd index 7c9de8f9f..9a5eb4536 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -407,8 +407,9 @@ func _on_OpenSprite_file_selected(path : String) -> void: while global_layer_line == ".": var layer_name := file.get_line() var layer_visibility := file.get_8() - # Store [Layer name, Layer visibility boolean, Frame container] - Global.layers.append([layer_name, layer_visibility, HBoxContainer.new()]) + var layer_lock := file.get_8() + # Store [Layer name, Layer visibility boolean, Layer lock boolean, Frame container] + Global.layers.append([layer_name, layer_visibility, layer_lock, HBoxContainer.new()]) global_layer_line = file.get_line() var frame_line := file.get_line() @@ -519,6 +520,7 @@ func _on_SaveSprite_file_selected(path : String) -> void: file.store_line(".") file.store_line(layer[0]) # Layer name file.store_8(layer[1]) # Layer visibility + file.store_8(layer[2]) # Layer lock file.store_line("END_GLOBAL_LAYERS") for canvas in Global.canvases: # Store frames diff --git a/Scripts/SelectionRectangle.gd b/Scripts/SelectionRectangle.gd index 42d40f772..ddf1e4b50 100644 --- a/Scripts/SelectionRectangle.gd +++ b/Scripts/SelectionRectangle.gd @@ -19,6 +19,8 @@ func _ready() -> void: # warning-ignore:unused_argument func _process(delta : float) -> void: + if Global.layers[Global.current_layer][2]: + return var mouse_pos: Vector2 = get_local_mouse_position() - Global.canvas.location var mouse_pos_floored := mouse_pos.floor() var start_pos := polygon[0]