mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-26 16:54:43 -04:00
Created a "UI" folder in src
And a Timeline folder in UI
This commit is contained in:
parent
8d5a673543
commit
c35e4b0613
51 changed files with 1444 additions and 1443 deletions
24
src/UI/Timeline/AnimationTag.tscn
Normal file
24
src/UI/Timeline/AnimationTag.tscn
Normal file
|
@ -0,0 +1,24 @@
|
|||
[gd_scene format=2]
|
||||
|
||||
[node name="AnimationTag" type="VBoxContainer"]
|
||||
margin_right = 39.0
|
||||
margin_bottom = 32.0
|
||||
rect_min_size = Vector2( 39, 32 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Line2D" type="Line2D" parent="."]
|
||||
points = PoolVector2Array( 0, 32, 0, 0, 39, 0, 39, 32 )
|
||||
width = 1.0
|
||||
texture_mode = 1313163520
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
margin_left = 7.0
|
||||
margin_right = 32.0
|
||||
margin_bottom = 32.0
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 3
|
||||
text = "Idle"
|
||||
align = 1
|
||||
valign = 1
|
494
src/UI/Timeline/AnimationTimeline.gd
Normal file
494
src/UI/Timeline/AnimationTimeline.gd
Normal file
|
@ -0,0 +1,494 @@
|
|||
extends Panel
|
||||
|
||||
var fps := 6.0
|
||||
var animation_loop := 1 # 0 is no loop, 1 is cycle loop, 2 is ping-pong loop
|
||||
var animation_forward := true
|
||||
var first_frame := 0
|
||||
var last_frame := Global.canvases.size() - 1
|
||||
|
||||
onready var timeline_scroll : ScrollContainer = $AnimationContainer/TimelineContainer/TimelineScroll
|
||||
onready var tag_scroll_container : ScrollContainer = $AnimationContainer/TimelineContainer/OpacityAndTagContainer/TagScroll
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
timeline_scroll.get_h_scrollbar().connect("value_changed", self, "_h_scroll_changed")
|
||||
Global.animation_timer.wait_time = 1 / fps
|
||||
|
||||
|
||||
func _h_scroll_changed(value : float) -> void:
|
||||
# Let the main timeline ScrollContainer affect the tag ScrollContainer too
|
||||
tag_scroll_container.get_child(0).rect_min_size.x = timeline_scroll.get_child(0).rect_size.x - 212
|
||||
tag_scroll_container.scroll_horizontal = value
|
||||
|
||||
|
||||
func add_frame() -> void:
|
||||
var new_canvas : Canvas = load("res://src/Canvas.tscn").instance()
|
||||
new_canvas.size = Global.canvas.size
|
||||
new_canvas.frame = Global.canvases.size()
|
||||
|
||||
var new_canvases: Array = Global.canvases.duplicate()
|
||||
new_canvases.append(new_canvas)
|
||||
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Add Frame")
|
||||
Global.undo_redo.add_do_method(Global, "redo", [new_canvas])
|
||||
Global.undo_redo.add_undo_method(Global, "undo", [new_canvas])
|
||||
|
||||
Global.undo_redo.add_do_property(Global, "canvases", new_canvases)
|
||||
Global.undo_redo.add_do_property(Global, "canvas", new_canvas)
|
||||
Global.undo_redo.add_do_property(Global, "current_frame", new_canvases.size() - 1)
|
||||
|
||||
for c in Global.canvases:
|
||||
Global.undo_redo.add_do_property(c, "visible", false)
|
||||
Global.undo_redo.add_undo_property(c, "visible", c.visible)
|
||||
|
||||
for l_i in range(Global.layers.size()):
|
||||
if Global.layers[l_i][4]: # If the link button is pressed
|
||||
Global.layers[l_i][5].append(new_canvas)
|
||||
|
||||
Global.undo_redo.add_undo_property(Global, "canvases", Global.canvases)
|
||||
Global.undo_redo.add_undo_property(Global, "canvas", Global.canvas)
|
||||
Global.undo_redo.add_undo_property(Global, "current_frame", Global.current_frame)
|
||||
Global.undo_redo.commit_action()
|
||||
|
||||
|
||||
func _on_DeleteFrame_pressed(frame := -1) -> void:
|
||||
if Global.canvases.size() == 1:
|
||||
return
|
||||
if frame == -1:
|
||||
frame = Global.current_frame
|
||||
|
||||
var canvas : Canvas = Global.canvases[frame]
|
||||
var new_canvases := Global.canvases.duplicate()
|
||||
new_canvases.erase(canvas)
|
||||
var current_frame := Global.current_frame
|
||||
if current_frame > 0 && current_frame == new_canvases.size(): # If it's the last frame
|
||||
current_frame -= 1
|
||||
|
||||
var new_animation_tags := Global.animation_tags.duplicate(true)
|
||||
# Loop through the tags to see if the frame is in one
|
||||
for tag in new_animation_tags:
|
||||
if frame + 1 >= tag[2] && frame + 1 <= tag[3]:
|
||||
if tag[3] == tag[2]: # If we're deleting the only frame in the tag
|
||||
new_animation_tags.erase(tag)
|
||||
else:
|
||||
tag[3] -= 1
|
||||
elif frame + 1 < tag[2]:
|
||||
tag[2] -= 1
|
||||
tag[3] -= 1
|
||||
|
||||
# Check if one of the cels of the frame is linked
|
||||
# if they are, unlink them too
|
||||
# this prevents removed cels being kept in linked memory
|
||||
var new_layers := Global.layers.duplicate(true)
|
||||
for layer in new_layers:
|
||||
for linked in layer[5]:
|
||||
if linked == Global.canvases[frame]:
|
||||
layer[5].erase(linked)
|
||||
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Remove Frame")
|
||||
|
||||
Global.undo_redo.add_do_property(Global, "canvases", new_canvases)
|
||||
Global.undo_redo.add_do_property(Global, "canvas", new_canvases[current_frame])
|
||||
Global.undo_redo.add_do_property(Global, "current_frame", current_frame)
|
||||
Global.undo_redo.add_do_property(Global, "animation_tags", new_animation_tags)
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
|
||||
# Change the frame value of the canvaseso on the right
|
||||
# for example, if frame "3" was deleted, then "4" would have to become "3"
|
||||
for i in range(frame, new_canvases.size()):
|
||||
var c : Canvas = new_canvases[i]
|
||||
Global.undo_redo.add_do_property(c, "frame", i)
|
||||
Global.undo_redo.add_undo_property(c, "frame", c.frame)
|
||||
|
||||
|
||||
Global.undo_redo.add_undo_property(Global, "canvases", Global.canvases)
|
||||
Global.undo_redo.add_undo_property(Global, "canvas", canvas)
|
||||
Global.undo_redo.add_undo_property(Global, "current_frame", Global.current_frame)
|
||||
Global.undo_redo.add_undo_property(Global, "animation_tags", Global.animation_tags)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
|
||||
Global.undo_redo.add_do_method(Global, "redo", [canvas])
|
||||
Global.undo_redo.add_undo_method(Global, "undo", [canvas])
|
||||
Global.undo_redo.commit_action()
|
||||
|
||||
|
||||
func _on_CopyFrame_pressed(frame := -1) -> void:
|
||||
if frame == -1:
|
||||
frame = Global.current_frame
|
||||
|
||||
var canvas : Canvas = Global.canvases[frame]
|
||||
var new_canvas : Canvas = load("res://src/Canvas.tscn").instance()
|
||||
new_canvas.size = Global.canvas.size
|
||||
new_canvas.frame = Global.canvases.size()
|
||||
|
||||
var new_canvases := Global.canvases.duplicate()
|
||||
new_canvases.insert(frame + 1, new_canvas)
|
||||
|
||||
for layer in canvas.layers: # Copy every layer
|
||||
var sprite := Image.new()
|
||||
sprite.copy_from(layer[0])
|
||||
sprite.lock()
|
||||
var tex := ImageTexture.new()
|
||||
tex.create_from_image(sprite, 0)
|
||||
new_canvas.layers.append([sprite, tex, layer[2]])
|
||||
|
||||
var new_animation_tags := Global.animation_tags.duplicate(true)
|
||||
# Loop through the tags to see if the frame is in one
|
||||
for tag in new_animation_tags:
|
||||
if frame + 1 >= tag[2] && frame + 1 <= tag[3]:
|
||||
tag[3] += 1
|
||||
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Add Frame")
|
||||
Global.undo_redo.add_do_method(Global, "redo", [new_canvas])
|
||||
Global.undo_redo.add_undo_method(Global, "undo", [new_canvas])
|
||||
|
||||
Global.undo_redo.add_do_property(Global, "canvases", new_canvases)
|
||||
Global.undo_redo.add_do_property(Global, "canvas", new_canvas)
|
||||
Global.undo_redo.add_do_property(Global, "current_frame", frame + 1)
|
||||
Global.undo_redo.add_do_property(Global, "animation_tags", new_animation_tags)
|
||||
for i in range(Global.layers.size()):
|
||||
for child in Global.layers[i][3].get_children():
|
||||
Global.undo_redo.add_do_property(child, "pressed", false)
|
||||
Global.undo_redo.add_undo_property(child, "pressed", child.pressed)
|
||||
for c in Global.canvases:
|
||||
Global.undo_redo.add_do_property(c, "visible", false)
|
||||
Global.undo_redo.add_undo_property(c, "visible", c.visible)
|
||||
|
||||
for i in range(frame, new_canvases.size()):
|
||||
var c : Canvas = new_canvases[i]
|
||||
Global.undo_redo.add_do_property(c, "frame", i)
|
||||
Global.undo_redo.add_undo_property(c, "frame", c.frame)
|
||||
|
||||
Global.undo_redo.add_undo_property(Global, "canvases", Global.canvases)
|
||||
Global.undo_redo.add_undo_property(Global, "canvas", Global.canvas)
|
||||
Global.undo_redo.add_undo_property(Global, "current_frame", frame)
|
||||
Global.undo_redo.add_undo_property(Global, "animation_tags", Global.animation_tags)
|
||||
Global.undo_redo.commit_action()
|
||||
|
||||
|
||||
func _on_FrameTagButton_pressed() -> void:
|
||||
Global.tag_dialog.popup_centered()
|
||||
|
||||
|
||||
func _on_OnionSkinning_pressed() -> void:
|
||||
Global.onion_skinning = !Global.onion_skinning
|
||||
Global.canvas.update()
|
||||
var theme_type := Global.theme_type
|
||||
if theme_type == "Gold":
|
||||
theme_type = "Light"
|
||||
var texture_button : TextureRect = Global.onion_skinning_button.get_child(0)
|
||||
if Global.onion_skinning:
|
||||
texture_button.texture = load("res://Assets/Graphics/%s Themes/Timeline/onion_skinning.png" % theme_type)
|
||||
else:
|
||||
texture_button.texture = load("res://Assets/Graphics/%s Themes/Timeline/onion_skinning_off.png" % theme_type)
|
||||
|
||||
|
||||
func _on_OnionSkinningSettings_pressed() -> void:
|
||||
$OnionSkinningSettings.popup(Rect2(Global.onion_skinning_button.rect_global_position.x - $OnionSkinningSettings.rect_size.x - 16, Global.onion_skinning_button.rect_global_position.y - 106, 136, 126))
|
||||
|
||||
|
||||
func _on_LoopAnim_pressed() -> void:
|
||||
var texture_button : TextureRect = Global.loop_animation_button.get_child(0)
|
||||
var theme_type := Global.theme_type
|
||||
if theme_type == "Gold":
|
||||
theme_type = "Light"
|
||||
match animation_loop:
|
||||
0: # Make it loop
|
||||
animation_loop = 1
|
||||
texture_button.texture = load("res://Assets/Graphics/%s Themes/Timeline/loop.png" % theme_type)
|
||||
Global.loop_animation_button.hint_tooltip = "Cycle loop"
|
||||
1: # Make it ping-pong
|
||||
animation_loop = 2
|
||||
texture_button.texture = load("res://Assets/Graphics/%s Themes/Timeline/loop_pingpong.png" % theme_type)
|
||||
Global.loop_animation_button.hint_tooltip = "Ping-pong loop"
|
||||
2: # Make it stop
|
||||
animation_loop = 0
|
||||
texture_button.texture = load("res://Assets/Graphics/%s Themes/Timeline/loop_none.png" % theme_type)
|
||||
Global.loop_animation_button.hint_tooltip = "No loop"
|
||||
|
||||
|
||||
func _on_PlayForward_toggled(button_pressed : bool) -> void:
|
||||
var theme_type := Global.theme_type
|
||||
if theme_type == "Gold":
|
||||
theme_type = "Light"
|
||||
if button_pressed:
|
||||
Global.play_forward.get_child(0).texture = load("res://Assets/Graphics/%s Themes/Timeline/pause.png" % theme_type)
|
||||
else:
|
||||
Global.play_forward.get_child(0).texture = load("res://Assets/Graphics/%s Themes/Timeline/play.png" % theme_type)
|
||||
|
||||
play_animation(button_pressed, true)
|
||||
|
||||
|
||||
func _on_PlayBackwards_toggled(button_pressed : bool) -> void:
|
||||
var theme_type := Global.theme_type
|
||||
if theme_type == "Gold":
|
||||
theme_type = "Light"
|
||||
if button_pressed:
|
||||
Global.play_backwards.get_child(0).texture = load("res://Assets/Graphics/%s Themes/Timeline/pause.png" % theme_type)
|
||||
else:
|
||||
Global.play_backwards.get_child(0).texture = load("res://Assets/Graphics/%s Themes/Timeline/play_backwards.png" % theme_type)
|
||||
|
||||
play_animation(button_pressed, false)
|
||||
|
||||
|
||||
func _on_AnimationTimer_timeout() -> void:
|
||||
if animation_forward:
|
||||
if Global.current_frame < last_frame:
|
||||
Global.current_frame += 1
|
||||
else:
|
||||
match animation_loop:
|
||||
0: # No loop
|
||||
Global.play_forward.pressed = false
|
||||
Global.play_backwards.pressed = false
|
||||
Global.animation_timer.stop()
|
||||
1: # Cycle loop
|
||||
Global.current_frame = first_frame
|
||||
2: # Ping pong loop
|
||||
animation_forward = false
|
||||
_on_AnimationTimer_timeout()
|
||||
|
||||
else:
|
||||
if Global.current_frame > first_frame:
|
||||
Global.current_frame -= 1
|
||||
else:
|
||||
match animation_loop:
|
||||
0: # No loop
|
||||
Global.play_backwards.pressed = false
|
||||
Global.play_forward.pressed = false
|
||||
Global.animation_timer.stop()
|
||||
1: # Cycle loop
|
||||
Global.current_frame = last_frame
|
||||
2: # Ping pong loop
|
||||
animation_forward = true
|
||||
_on_AnimationTimer_timeout()
|
||||
|
||||
|
||||
func play_animation(play : bool, forward_dir : bool) -> void:
|
||||
var theme_type := Global.theme_type
|
||||
if theme_type == "Gold":
|
||||
theme_type = "Light"
|
||||
|
||||
if forward_dir:
|
||||
Global.play_backwards.disconnect("toggled", self, "_on_PlayBackwards_toggled")
|
||||
Global.play_backwards.pressed = false
|
||||
Global.play_backwards.get_child(0).texture = load("res://Assets/Graphics/%s Themes/Timeline/play_backwards.png" % theme_type)
|
||||
Global.play_backwards.connect("toggled", self, "_on_PlayBackwards_toggled")
|
||||
else:
|
||||
Global.play_forward.disconnect("toggled", self, "_on_PlayForward_toggled")
|
||||
Global.play_forward.pressed = false
|
||||
Global.play_forward.get_child(0).texture = load("res://Assets/Graphics/%s Themes/Timeline/play.png" % theme_type)
|
||||
Global.play_forward.connect("toggled", self, "_on_PlayForward_toggled")
|
||||
if Global.canvases.size() == 1:
|
||||
if forward_dir:
|
||||
Global.play_forward.pressed = false
|
||||
else:
|
||||
Global.play_backwards.pressed = false
|
||||
return
|
||||
|
||||
first_frame = 0
|
||||
last_frame = Global.canvases.size() - 1
|
||||
if Global.play_only_tags:
|
||||
for tag in Global.animation_tags:
|
||||
if Global.current_frame + 1 >= tag[2] && Global.current_frame + 1 <= tag[3]:
|
||||
first_frame = tag[2] - 1
|
||||
last_frame = min(Global.canvases.size() - 1, tag[3] - 1)
|
||||
|
||||
if play:
|
||||
Global.animation_timer.wait_time = 1 / fps
|
||||
Global.animation_timer.start()
|
||||
animation_forward = forward_dir
|
||||
else:
|
||||
Global.animation_timer.stop()
|
||||
|
||||
|
||||
func _on_NextFrame_pressed() -> void:
|
||||
if Global.current_frame < Global.canvases.size() - 1:
|
||||
Global.current_frame += 1
|
||||
|
||||
|
||||
func _on_PreviousFrame_pressed() -> void:
|
||||
if Global.current_frame > 0:
|
||||
Global.current_frame -= 1
|
||||
|
||||
|
||||
func _on_LastFrame_pressed() -> void:
|
||||
Global.current_frame = Global.canvases.size() - 1
|
||||
|
||||
|
||||
func _on_FirstFrame_pressed() -> void:
|
||||
Global.current_frame = 0
|
||||
|
||||
|
||||
func _on_FPSValue_value_changed(value : float) -> void:
|
||||
fps = float(value)
|
||||
Global.animation_timer.wait_time = 1 / fps
|
||||
|
||||
|
||||
func _on_PastOnionSkinning_value_changed(value : float) -> void:
|
||||
Global.onion_skinning_past_rate = int(value)
|
||||
Global.canvas.update()
|
||||
|
||||
|
||||
func _on_FutureOnionSkinning_value_changed(value : float) -> void:
|
||||
Global.onion_skinning_future_rate = int(value)
|
||||
Global.canvas.update()
|
||||
|
||||
|
||||
func _on_BlueRedMode_toggled(button_pressed : bool) -> void:
|
||||
Global.onion_skinning_blue_red = button_pressed
|
||||
Global.canvas.update()
|
||||
|
||||
|
||||
# Layer buttons
|
||||
|
||||
func add_layer(is_new := true) -> void:
|
||||
var layer_name = null
|
||||
if !is_new: # Clone layer
|
||||
layer_name = Global.layers[Global.current_layer][0] + " (" + tr("copy") + ")"
|
||||
|
||||
var new_layers : Array = Global.layers.duplicate()
|
||||
|
||||
# Store [Layer name (0), Layer visibility boolean (1), Layer lock boolean (2), Frame container (3),
|
||||
# will new frames be linked boolean (4), Array of linked frames (5)]
|
||||
new_layers.append([layer_name, true, false, HBoxContainer.new(), false, []])
|
||||
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Add Layer")
|
||||
|
||||
for c in Global.canvases:
|
||||
var new_layer := Image.new()
|
||||
if is_new:
|
||||
new_layer.create(c.size.x, c.size.y, false, Image.FORMAT_RGBA8)
|
||||
else: # Clone layer
|
||||
new_layer.copy_from(c.layers[Global.current_layer][0])
|
||||
|
||||
new_layer.lock()
|
||||
var new_layer_tex := ImageTexture.new()
|
||||
new_layer_tex.create_from_image(new_layer, 0)
|
||||
|
||||
var new_canvas_layers : Array = c.layers.duplicate()
|
||||
# Store [Image, ImageTexture, Opacity]
|
||||
new_canvas_layers.append([new_layer, new_layer_tex, 1])
|
||||
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
|
||||
Global.undo_redo.add_undo_property(c, "layers", c.layers)
|
||||
|
||||
Global.undo_redo.add_do_property(Global, "current_layer", Global.current_layer + 1)
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
Global.undo_redo.add_undo_property(Global, "current_layer", Global.current_layer)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
|
||||
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvas])
|
||||
Global.undo_redo.add_do_method(Global, "redo", [Global.canvas])
|
||||
Global.undo_redo.commit_action()
|
||||
|
||||
|
||||
func _on_RemoveLayer_pressed() -> void:
|
||||
var new_layers : Array = Global.layers.duplicate()
|
||||
new_layers.remove(Global.current_layer)
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Remove Layer")
|
||||
if Global.current_layer > 0:
|
||||
Global.undo_redo.add_do_property(Global, "current_layer", Global.current_layer - 1)
|
||||
else:
|
||||
Global.undo_redo.add_do_property(Global, "current_layer", Global.current_layer)
|
||||
|
||||
for c in Global.canvases:
|
||||
var new_canvas_layers : Array = c.layers.duplicate()
|
||||
new_canvas_layers.remove(Global.current_layer)
|
||||
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
|
||||
Global.undo_redo.add_undo_property(c, "layers", c.layers)
|
||||
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
Global.undo_redo.add_undo_property(Global, "current_layer", Global.current_layer)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
Global.undo_redo.add_do_method(Global, "redo", [Global.canvas])
|
||||
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvas])
|
||||
Global.undo_redo.commit_action()
|
||||
|
||||
|
||||
func change_layer_order(rate : int) -> void:
|
||||
var change = Global.current_layer + rate
|
||||
|
||||
var new_layers : Array = Global.layers.duplicate()
|
||||
var temp = new_layers[Global.current_layer]
|
||||
new_layers[Global.current_layer] = new_layers[change]
|
||||
new_layers[change] = temp
|
||||
Global.undo_redo.create_action("Change Layer Order")
|
||||
for c in Global.canvases:
|
||||
var new_layers_canvas : Array = c.layers.duplicate()
|
||||
var temp_canvas = new_layers_canvas[Global.current_layer]
|
||||
new_layers_canvas[Global.current_layer] = new_layers_canvas[change]
|
||||
new_layers_canvas[change] = temp_canvas
|
||||
Global.undo_redo.add_do_property(c, "layers", new_layers_canvas)
|
||||
Global.undo_redo.add_undo_property(c, "layers", c.layers)
|
||||
|
||||
Global.undo_redo.add_do_property(Global, "current_layer", change)
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
Global.undo_redo.add_undo_property(Global, "current_layer", Global.current_layer)
|
||||
|
||||
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvas])
|
||||
Global.undo_redo.add_do_method(Global, "redo", [Global.canvas])
|
||||
Global.undo_redo.commit_action()
|
||||
|
||||
|
||||
func _on_MergeDownLayer_pressed() -> void:
|
||||
var new_layers : Array = Global.layers.duplicate(true)
|
||||
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Merge Layer")
|
||||
for c in Global.canvases:
|
||||
var new_layers_canvas : Array = c.layers.duplicate(true)
|
||||
var selected_layer := Image.new()
|
||||
selected_layer.copy_from(new_layers_canvas[Global.current_layer][0])
|
||||
selected_layer.lock()
|
||||
|
||||
if c.layers[Global.current_layer][2] < 1: # If we have layer transparency
|
||||
for xx in selected_layer.get_size().x:
|
||||
for yy in selected_layer.get_size().y:
|
||||
var pixel_color : Color = selected_layer.get_pixel(xx, yy)
|
||||
var alpha : float = pixel_color.a * c.layers[Global.current_layer][2]
|
||||
selected_layer.set_pixel(xx, yy, Color(pixel_color.r, pixel_color.g, pixel_color.b, alpha))
|
||||
|
||||
var new_layer := Image.new()
|
||||
new_layer.copy_from(c.layers[Global.current_layer - 1][0])
|
||||
new_layer.lock()
|
||||
c.blend_rect(new_layer, selected_layer, Rect2(c.position, c.size), Vector2.ZERO)
|
||||
new_layers_canvas.remove(Global.current_layer)
|
||||
if !selected_layer.is_invisible() and Global.layers[Global.current_layer - 1][5].size() > 1 and (c in Global.layers[Global.current_layer - 1][5]):
|
||||
new_layers[Global.current_layer - 1][5].erase(c)
|
||||
var tex := ImageTexture.new()
|
||||
tex.create_from_image(new_layer, 0)
|
||||
new_layers_canvas[Global.current_layer - 1][0] = new_layer
|
||||
new_layers_canvas[Global.current_layer - 1][1] = tex
|
||||
else:
|
||||
Global.undo_redo.add_do_property(c.layers[Global.current_layer - 1][0], "data", new_layer.data)
|
||||
Global.undo_redo.add_undo_property(c.layers[Global.current_layer - 1][0], "data", c.layers[Global.current_layer - 1][0].data)
|
||||
|
||||
Global.undo_redo.add_do_property(c, "layers", new_layers_canvas)
|
||||
Global.undo_redo.add_undo_property(c, "layers", c.layers)
|
||||
|
||||
new_layers.remove(Global.current_layer)
|
||||
Global.undo_redo.add_do_property(Global, "current_layer", Global.current_layer - 1)
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
Global.undo_redo.add_undo_property(Global, "current_layer", Global.current_layer)
|
||||
|
||||
Global.undo_redo.add_undo_method(Global, "undo", Global.canvases)
|
||||
Global.undo_redo.add_do_method(Global, "redo", Global.canvases)
|
||||
Global.undo_redo.commit_action()
|
||||
|
||||
|
||||
func _on_OpacitySlider_value_changed(value) -> void:
|
||||
Global.canvas.layers[Global.current_layer][2] = value / 100
|
||||
Global.layer_opacity_slider.value = value
|
||||
Global.layer_opacity_slider.value = value
|
||||
Global.layer_opacity_spinbox.value = value
|
||||
Global.canvas.update()
|
||||
|
||||
|
||||
func _on_OnionSkinningSettings_popup_hide() -> void:
|
||||
Global.can_draw = true
|
838
src/UI/Timeline/AnimationTimeline.tscn
Normal file
838
src/UI/Timeline/AnimationTimeline.tscn
Normal file
|
@ -0,0 +1,838 @@
|
|||
[gd_scene load_steps=51 format=2]
|
||||
|
||||
[ext_resource path="res://src/UI/Timeline/AnimationTimeline.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/New_Layer.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/New_Layer_Hover.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Delete_Layer.png" type="Texture" id=4]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Delete_Layer_Hover.png" type="Texture" id=5]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Delete_Layer_Disabled.png" type="Texture" id=6]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Move_Up.png" type="Texture" id=7]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Move_Up_Hover.png" type="Texture" id=8]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Move_Up_Disabled.png" type="Texture" id=9]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Move_Down.png" type="Texture" id=10]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Move_Down_Hover.png" type="Texture" id=11]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Move_Down_Disabled.png" type="Texture" id=12]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Clone_Layer.png" type="Texture" id=13]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Clone_Layer_Hover.png" type="Texture" id=14]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Merge_Down.png" type="Texture" id=15]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Merge_Down_Hover.png" type="Texture" id=16]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Merge_Down_Disabled.png" type="Texture" id=17]
|
||||
[ext_resource path="res://src/UI/Timeline/LayerButton.tscn" type="PackedScene" id=18]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/new_frame.png" type="Texture" id=19]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/remove_frame.png" type="Texture" id=20]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/go_to_first_frame.png" type="Texture" id=21]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/play.png" type="Texture" id=22]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/previous_frame.png" type="Texture" id=23]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/play_backwards.png" type="Texture" id=24]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/go_to_last_frame.png" type="Texture" id=25]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/next_frame.png" type="Texture" id=26]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/copy_frame.png" type="Texture" id=27]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/tag.png" type="Texture" id=28]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/onion_skinning_off.png" type="Texture" id=29]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/expandable.png" type="Texture" id=30]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/loop.png" type="Texture" id=31]
|
||||
[ext_resource path="res://src/UI/Dialogs/FrameTagDialog.tscn" type="PackedScene" id=42]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[sub_resource type="InputEventKey" id=1]
|
||||
control = true
|
||||
command = true
|
||||
scancode = 16777229
|
||||
|
||||
[sub_resource type="ShortCut" id=2]
|
||||
shortcut = SubResource( 1 )
|
||||
|
||||
[sub_resource type="InputEventKey" id=3]
|
||||
control = true
|
||||
command = true
|
||||
scancode = 16777231
|
||||
|
||||
[sub_resource type="ShortCut" id=4]
|
||||
shortcut = SubResource( 3 )
|
||||
|
||||
[sub_resource type="InputEventKey" id=5]
|
||||
scancode = 16777247
|
||||
|
||||
[sub_resource type="ShortCut" id=6]
|
||||
shortcut = SubResource( 5 )
|
||||
|
||||
[sub_resource type="InputEventKey" id=7]
|
||||
scancode = 16777248
|
||||
|
||||
[sub_resource type="ShortCut" id=8]
|
||||
shortcut = SubResource( 7 )
|
||||
|
||||
[sub_resource type="InputEventKey" id=9]
|
||||
control = true
|
||||
command = true
|
||||
scancode = 16777233
|
||||
|
||||
[sub_resource type="ShortCut" id=10]
|
||||
shortcut = SubResource( 9 )
|
||||
|
||||
[sub_resource type="InputEventKey" id=11]
|
||||
control = true
|
||||
command = true
|
||||
scancode = 16777230
|
||||
|
||||
[sub_resource type="ShortCut" id=12]
|
||||
shortcut = SubResource( 11 )
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=13]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=14]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=15]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=16]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=17]
|
||||
|
||||
[sub_resource type="Theme" id=18]
|
||||
HScrollBar/icons/decrement = null
|
||||
HScrollBar/icons/decrement_highlight = null
|
||||
HScrollBar/icons/increment = null
|
||||
HScrollBar/icons/increment_highlight = null
|
||||
HScrollBar/styles/grabber = SubResource( 13 )
|
||||
HScrollBar/styles/grabber_highlight = SubResource( 14 )
|
||||
HScrollBar/styles/grabber_pressed = SubResource( 15 )
|
||||
HScrollBar/styles/scroll = SubResource( 16 )
|
||||
HScrollBar/styles/scroll_focus = SubResource( 17 )
|
||||
|
||||
[node name="AnimationTimeline" type="Panel"]
|
||||
margin_top = 438.0
|
||||
margin_right = 704.0
|
||||
margin_bottom = 620.0
|
||||
rect_min_size = Vector2( 0, 200 )
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="AnimationContainer" type="HBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ForLayerButtons" type="VBoxContainer" parent="AnimationContainer"]
|
||||
margin_right = 68.0
|
||||
margin_bottom = 200.0
|
||||
|
||||
[node name="SpacerControl" type="Control" parent="AnimationContainer/ForLayerButtons"]
|
||||
margin_right = 68.0
|
||||
margin_bottom = 30.0
|
||||
rect_min_size = Vector2( 0, 30 )
|
||||
|
||||
[node name="LayerButtons" type="GridContainer" parent="AnimationContainer/ForLayerButtons"]
|
||||
margin_top = 34.0
|
||||
margin_right = 68.0
|
||||
margin_bottom = 138.0
|
||||
size_flags_vertical = 0
|
||||
custom_constants/vseparation = 4
|
||||
custom_constants/hseparation = 4
|
||||
columns = 2
|
||||
|
||||
[node name="AddLayer" type="TextureButton" parent="AnimationContainer/ForLayerButtons/LayerButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_right = 32.0
|
||||
margin_bottom = 32.0
|
||||
hint_tooltip = "Create a new layer"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
texture_normal = ExtResource( 2 )
|
||||
texture_hover = ExtResource( 3 )
|
||||
|
||||
[node name="RemoveLayer" type="TextureButton" parent="AnimationContainer/ForLayerButtons/LayerButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 36.0
|
||||
margin_right = 68.0
|
||||
margin_bottom = 32.0
|
||||
hint_tooltip = "Remove current layer"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 8
|
||||
disabled = true
|
||||
texture_normal = ExtResource( 4 )
|
||||
texture_hover = ExtResource( 5 )
|
||||
texture_disabled = ExtResource( 6 )
|
||||
|
||||
[node name="MoveUpLayer" type="TextureButton" parent="AnimationContainer/ForLayerButtons/LayerButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_top = 36.0
|
||||
margin_right = 32.0
|
||||
margin_bottom = 68.0
|
||||
hint_tooltip = "Move up the current layer"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 8
|
||||
disabled = true
|
||||
texture_normal = ExtResource( 7 )
|
||||
texture_hover = ExtResource( 8 )
|
||||
texture_disabled = ExtResource( 9 )
|
||||
|
||||
[node name="MoveDownLayer" type="TextureButton" parent="AnimationContainer/ForLayerButtons/LayerButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 36.0
|
||||
margin_top = 36.0
|
||||
margin_right = 68.0
|
||||
margin_bottom = 68.0
|
||||
hint_tooltip = "Move down the current layer"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 8
|
||||
disabled = true
|
||||
texture_normal = ExtResource( 10 )
|
||||
texture_hover = ExtResource( 11 )
|
||||
texture_disabled = ExtResource( 12 )
|
||||
|
||||
[node name="CloneLayer" type="TextureButton" parent="AnimationContainer/ForLayerButtons/LayerButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_top = 72.0
|
||||
margin_right = 32.0
|
||||
margin_bottom = 104.0
|
||||
hint_tooltip = "Clone current layer"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
texture_normal = ExtResource( 13 )
|
||||
texture_hover = ExtResource( 14 )
|
||||
|
||||
[node name="MergeDownLayer" type="TextureButton" parent="AnimationContainer/ForLayerButtons/LayerButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 36.0
|
||||
margin_top = 72.0
|
||||
margin_right = 68.0
|
||||
margin_bottom = 104.0
|
||||
hint_tooltip = "Merge current layer with the one below"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 8
|
||||
disabled = true
|
||||
texture_normal = ExtResource( 15 )
|
||||
texture_hover = ExtResource( 16 )
|
||||
texture_disabled = ExtResource( 17 )
|
||||
|
||||
[node name="SpacerControl" type="Control" parent="AnimationContainer"]
|
||||
margin_left = 72.0
|
||||
margin_right = 88.0
|
||||
margin_bottom = 200.0
|
||||
rect_min_size = Vector2( 16, 0 )
|
||||
|
||||
[node name="TimelineContainer" type="VBoxContainer" parent="AnimationContainer"]
|
||||
margin_left = 92.0
|
||||
margin_right = 696.0
|
||||
margin_bottom = 200.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="SpacerControl" type="Control" parent="AnimationContainer/TimelineContainer"]
|
||||
margin_right = 604.0
|
||||
|
||||
[node name="AnimationButtons" type="HBoxContainer" parent="AnimationContainer/TimelineContainer"]
|
||||
margin_top = 4.0
|
||||
margin_right = 604.0
|
||||
margin_bottom = 28.0
|
||||
rect_min_size = Vector2( 0, 24 )
|
||||
|
||||
[node name="CurrentFrame" type="Label" parent="AnimationContainer/TimelineContainer/AnimationButtons"]
|
||||
margin_top = 5.0
|
||||
margin_right = 150.0
|
||||
margin_bottom = 19.0
|
||||
rect_min_size = Vector2( 150, 0 )
|
||||
text = "Current frame: 1/1"
|
||||
|
||||
[node name="AddFrame" type="Button" parent="AnimationContainer/TimelineContainer/AnimationButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 154.0
|
||||
margin_right = 174.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
hint_tooltip = "Add a new frame"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="AnimationContainer/TimelineContainer/AnimationButtons/AddFrame"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -6.0
|
||||
margin_top = -6.0
|
||||
margin_right = 6.0
|
||||
margin_bottom = 6.0
|
||||
texture = ExtResource( 19 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="DeleteFrame" type="Button" parent="AnimationContainer/TimelineContainer/AnimationButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 178.0
|
||||
margin_right = 198.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
hint_tooltip = "Remove Frame"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="AnimationContainer/TimelineContainer/AnimationButtons/DeleteFrame"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -6.0
|
||||
margin_top = -1.0
|
||||
margin_right = 6.0
|
||||
margin_bottom = 1.0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
texture = ExtResource( 20 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="CopyFrame" type="Button" parent="AnimationContainer/TimelineContainer/AnimationButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 202.0
|
||||
margin_right = 222.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
hint_tooltip = "Clone Frame"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="AnimationContainer/TimelineContainer/AnimationButtons/CopyFrame"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -5.0
|
||||
margin_top = -7.0
|
||||
margin_right = 5.0
|
||||
margin_bottom = 7.0
|
||||
texture = ExtResource( 27 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="FrameTagButton" type="Button" parent="AnimationContainer/TimelineContainer/AnimationButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 226.0
|
||||
margin_right = 246.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
hint_tooltip = "Manage frame tags"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="AnimationContainer/TimelineContainer/AnimationButtons/FrameTagButton"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -7.0
|
||||
margin_top = -7.0
|
||||
margin_right = 7.0
|
||||
margin_bottom = 7.0
|
||||
texture = ExtResource( 28 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="PlaybackButtons" type="HBoxContainer" parent="AnimationContainer/TimelineContainer/AnimationButtons"]
|
||||
margin_left = 286.0
|
||||
margin_right = 426.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 6
|
||||
|
||||
[node name="FirstFrame" type="Button" parent="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_right = 20.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
hint_tooltip = "FIRSTFRAME_HT"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_vertical = 0
|
||||
shortcut_in_tooltip = false
|
||||
shortcut = SubResource( 2 )
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons/FirstFrame"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -5.5
|
||||
margin_top = -6.0
|
||||
margin_right = 5.5
|
||||
margin_bottom = 6.0
|
||||
texture = ExtResource( 21 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="PreviousFrame" type="Button" parent="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 24.0
|
||||
margin_right = 44.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
hint_tooltip = "PREVIOUSFRAME_HT"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_vertical = 0
|
||||
shortcut_in_tooltip = false
|
||||
shortcut = SubResource( 4 )
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons/PreviousFrame"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -5.5
|
||||
margin_top = -6.0
|
||||
margin_right = 5.5
|
||||
margin_bottom = 6.0
|
||||
texture = ExtResource( 23 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="PlayBackwards" type="Button" parent="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 48.0
|
||||
margin_right = 68.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
hint_tooltip = "PLAYBACKWARDS_HT"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_vertical = 0
|
||||
toggle_mode = true
|
||||
shortcut_in_tooltip = false
|
||||
shortcut = SubResource( 6 )
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons/PlayBackwards"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -4.0
|
||||
margin_top = -6.0
|
||||
margin_right = 3.0
|
||||
margin_bottom = 6.0
|
||||
texture = ExtResource( 24 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="PlayForward" type="Button" parent="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 72.0
|
||||
margin_right = 92.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
hint_tooltip = "PLAYFORWARD_HT"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
toggle_mode = true
|
||||
shortcut_in_tooltip = false
|
||||
shortcut = SubResource( 8 )
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons/PlayForward"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -3.5
|
||||
margin_top = -6.0
|
||||
margin_right = 3.5
|
||||
margin_bottom = 6.0
|
||||
texture = ExtResource( 22 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="NextFrame" type="Button" parent="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 96.0
|
||||
margin_right = 116.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
hint_tooltip = "NEXTFRAME_HT"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_vertical = 0
|
||||
shortcut_in_tooltip = false
|
||||
shortcut = SubResource( 10 )
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons/NextFrame"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -5.5
|
||||
margin_top = -6.0
|
||||
margin_right = 5.5
|
||||
margin_bottom = 6.0
|
||||
texture = ExtResource( 26 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="LastFrame" type="Button" parent="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 120.0
|
||||
margin_right = 140.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
hint_tooltip = "LASTFRAME_HT"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_vertical = 0
|
||||
shortcut_in_tooltip = false
|
||||
shortcut = SubResource( 12 )
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons/LastFrame"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -5.5
|
||||
margin_top = -6.0
|
||||
margin_right = 5.5
|
||||
margin_bottom = 6.0
|
||||
texture = ExtResource( 25 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="LoopButtons" type="HBoxContainer" parent="AnimationContainer/TimelineContainer/AnimationButtons"]
|
||||
margin_left = 466.0
|
||||
margin_right = 604.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 0
|
||||
|
||||
[node name="OnionSkinningSettings" type="Button" parent="AnimationContainer/TimelineContainer/AnimationButtons/LoopButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_right = 12.0
|
||||
margin_bottom = 20.0
|
||||
hint_tooltip = "Onion Skinning settings"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="AnimationContainer/TimelineContainer/AnimationButtons/LoopButtons/OnionSkinningSettings"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -3.0
|
||||
margin_top = -6.0
|
||||
margin_right = 3.0
|
||||
margin_bottom = 6.0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
texture = ExtResource( 30 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="OnionSkinning" type="Button" parent="AnimationContainer/TimelineContainer/AnimationButtons/LoopButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 16.0
|
||||
margin_right = 36.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
hint_tooltip = "Enable/disable Onion Skinning"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="AnimationContainer/TimelineContainer/AnimationButtons/LoopButtons/OnionSkinning"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -7.0
|
||||
margin_top = -7.0
|
||||
margin_right = 7.0
|
||||
margin_bottom = 7.0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
texture = ExtResource( 29 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="LoopAnim" type="Button" parent="AnimationContainer/TimelineContainer/AnimationButtons/LoopButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 40.0
|
||||
margin_right = 60.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
hint_tooltip = "Cycle loop"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="AnimationContainer/TimelineContainer/AnimationButtons/LoopButtons/LoopAnim"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -7.0
|
||||
margin_top = -7.0
|
||||
margin_right = 7.0
|
||||
margin_bottom = 7.0
|
||||
texture = ExtResource( 31 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="FPSValue" type="SpinBox" parent="AnimationContainer/TimelineContainer/AnimationButtons/LoopButtons"]
|
||||
margin_left = 64.0
|
||||
margin_right = 138.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "How many frames per second should the animation preview be?
|
||||
The more FPS, the faster the animation plays."
|
||||
mouse_default_cursor_shape = 2
|
||||
min_value = 0.1
|
||||
step = 0.1
|
||||
value = 6.0
|
||||
align = 1
|
||||
suffix = "FPS"
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="AnimationContainer/TimelineContainer"]
|
||||
margin_top = 32.0
|
||||
margin_right = 604.0
|
||||
margin_bottom = 36.0
|
||||
|
||||
[node name="OpacityAndTagContainer" type="HBoxContainer" parent="AnimationContainer/TimelineContainer"]
|
||||
margin_top = 40.0
|
||||
margin_right = 604.0
|
||||
margin_bottom = 72.0
|
||||
custom_constants/separation = 2
|
||||
|
||||
[node name="OpacityContainer" type="HBoxContainer" parent="AnimationContainer/TimelineContainer/OpacityAndTagContainer"]
|
||||
margin_right = 214.0
|
||||
margin_bottom = 32.0
|
||||
rect_min_size = Vector2( 214, 0 )
|
||||
|
||||
[node name="OpacityLabel" type="Label" parent="AnimationContainer/TimelineContainer/OpacityAndTagContainer/OpacityContainer"]
|
||||
margin_right = 53.0
|
||||
margin_bottom = 32.0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 1
|
||||
text = "Opacity:"
|
||||
valign = 1
|
||||
|
||||
[node name="OpacitySlider" type="HSlider" parent="AnimationContainer/TimelineContainer/OpacityAndTagContainer/OpacityContainer"]
|
||||
margin_left = 57.0
|
||||
margin_right = 136.0
|
||||
margin_bottom = 32.0
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
value = 100.0
|
||||
ticks_on_borders = true
|
||||
|
||||
[node name="OpacitySpinBox" type="SpinBox" parent="AnimationContainer/TimelineContainer/OpacityAndTagContainer/OpacityContainer"]
|
||||
margin_left = 140.0
|
||||
margin_top = 4.0
|
||||
margin_right = 214.0
|
||||
margin_bottom = 28.0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_vertical = 4
|
||||
value = 100.0
|
||||
align = 1
|
||||
|
||||
[node name="TagScroll" type="ScrollContainer" parent="AnimationContainer/TimelineContainer/OpacityAndTagContainer"]
|
||||
margin_left = 216.0
|
||||
margin_right = 604.0
|
||||
margin_bottom = 32.0
|
||||
rect_min_size = Vector2( 0, 32 )
|
||||
size_flags_horizontal = 3
|
||||
theme = SubResource( 18 )
|
||||
scroll_vertical_enabled = false
|
||||
|
||||
[node name="TagContainer" type="Control" parent="AnimationContainer/TimelineContainer/OpacityAndTagContainer/TagScroll"]
|
||||
|
||||
[node name="TimelineScroll" type="ScrollContainer" parent="AnimationContainer/TimelineContainer"]
|
||||
margin_top = 76.0
|
||||
margin_right = 604.0
|
||||
margin_bottom = 200.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="LayersAndFrames" type="HBoxContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll"]
|
||||
margin_right = 252.0
|
||||
margin_bottom = 124.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="LayerVBoxCont" type="VBoxContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames"]
|
||||
margin_right = 212.0
|
||||
margin_bottom = 124.0
|
||||
|
||||
[node name="LayerLabel" type="Label" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames/LayerVBoxCont"]
|
||||
margin_right = 212.0
|
||||
margin_bottom = 16.0
|
||||
rect_min_size = Vector2( 0, 16 )
|
||||
text = "Layers"
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="LayersContainer" type="VBoxContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames/LayerVBoxCont"]
|
||||
margin_top = 20.0
|
||||
margin_right = 212.0
|
||||
margin_bottom = 56.0
|
||||
|
||||
[node name="LayerContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames/LayerVBoxCont/LayersContainer" instance=ExtResource( 18 )]
|
||||
margin_right = 212.0
|
||||
|
||||
[node name="FrameButtonsAndIds" type="VBoxContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames"]
|
||||
margin_left = 216.0
|
||||
margin_right = 252.0
|
||||
margin_bottom = 124.0
|
||||
|
||||
[node name="FrameIDs" type="HBoxContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames/FrameButtonsAndIds"]
|
||||
margin_right = 36.0
|
||||
margin_bottom = 16.0
|
||||
rect_min_size = Vector2( 0, 16 )
|
||||
|
||||
[node name="Label" type="Label" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames/FrameButtonsAndIds/FrameIDs"]
|
||||
margin_top = 1.0
|
||||
margin_right = 36.0
|
||||
margin_bottom = 15.0
|
||||
rect_min_size = Vector2( 36, 0 )
|
||||
text = "1"
|
||||
align = 1
|
||||
|
||||
[node name="FramesContainer" type="VBoxContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames/FrameButtonsAndIds"]
|
||||
margin_top = 20.0
|
||||
margin_right = 36.0
|
||||
margin_bottom = 20.0
|
||||
|
||||
[node name="VSeparator" type="VSeparator" parent="AnimationContainer"]
|
||||
margin_left = 700.0
|
||||
margin_right = 704.0
|
||||
margin_bottom = 200.0
|
||||
|
||||
[node name="AnimationTimer" type="Timer" parent="."]
|
||||
|
||||
[node name="OnionSkinningSettings" type="WindowDialog" parent="."]
|
||||
rect_min_size = Vector2( 220, 126 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="OnionSkinningButtons" type="VBoxContainer" parent="OnionSkinningSettings"]
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
margin_left = 4.0
|
||||
margin_top = -58.0
|
||||
margin_right = -4.0
|
||||
margin_bottom = 58.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="OnionSkinningPast" type="Label" parent="OnionSkinningSettings/OnionSkinningButtons"]
|
||||
margin_right = 212.0
|
||||
margin_bottom = 14.0
|
||||
text = "Past Frames"
|
||||
|
||||
[node name="PastOnionSkinning" type="SpinBox" parent="OnionSkinningSettings/OnionSkinningButtons"]
|
||||
margin_top = 18.0
|
||||
margin_right = 212.0
|
||||
margin_bottom = 42.0
|
||||
mouse_default_cursor_shape = 2
|
||||
min_value = 1.0
|
||||
value = 1.0
|
||||
align = 1
|
||||
|
||||
[node name="OnionSkinningFuture" type="Label" parent="OnionSkinningSettings/OnionSkinningButtons"]
|
||||
margin_top = 46.0
|
||||
margin_right = 212.0
|
||||
margin_bottom = 60.0
|
||||
text = "Future Frames"
|
||||
|
||||
[node name="FutureOnionSkinning" type="SpinBox" parent="OnionSkinningSettings/OnionSkinningButtons"]
|
||||
margin_top = 64.0
|
||||
margin_right = 212.0
|
||||
margin_bottom = 88.0
|
||||
mouse_default_cursor_shape = 2
|
||||
min_value = 1.0
|
||||
value = 1.0
|
||||
align = 1
|
||||
|
||||
[node name="BlueRedMode" type="CheckBox" parent="OnionSkinningSettings/OnionSkinningButtons"]
|
||||
margin_top = 92.0
|
||||
margin_right = 212.0
|
||||
margin_bottom = 116.0
|
||||
mouse_default_cursor_shape = 2
|
||||
text = "Blue-Red Mode"
|
||||
|
||||
[node name="FrameTagDialog" parent="." instance=ExtResource( 42 )]
|
||||
[connection signal="pressed" from="AnimationContainer/ForLayerButtons/LayerButtons/AddLayer" to="." method="add_layer" binds= [ true ]]
|
||||
[connection signal="pressed" from="AnimationContainer/ForLayerButtons/LayerButtons/RemoveLayer" to="." method="_on_RemoveLayer_pressed"]
|
||||
[connection signal="pressed" from="AnimationContainer/ForLayerButtons/LayerButtons/MoveUpLayer" to="." method="change_layer_order" binds= [ 1 ]]
|
||||
[connection signal="pressed" from="AnimationContainer/ForLayerButtons/LayerButtons/MoveDownLayer" to="." method="change_layer_order" binds= [ -1 ]]
|
||||
[connection signal="pressed" from="AnimationContainer/ForLayerButtons/LayerButtons/CloneLayer" to="." method="add_layer" binds= [ false ]]
|
||||
[connection signal="pressed" from="AnimationContainer/ForLayerButtons/LayerButtons/MergeDownLayer" to="." method="_on_MergeDownLayer_pressed"]
|
||||
[connection signal="pressed" from="AnimationContainer/TimelineContainer/AnimationButtons/AddFrame" to="." method="add_frame"]
|
||||
[connection signal="pressed" from="AnimationContainer/TimelineContainer/AnimationButtons/DeleteFrame" to="." method="_on_DeleteFrame_pressed"]
|
||||
[connection signal="pressed" from="AnimationContainer/TimelineContainer/AnimationButtons/CopyFrame" to="." method="_on_CopyFrame_pressed"]
|
||||
[connection signal="pressed" from="AnimationContainer/TimelineContainer/AnimationButtons/FrameTagButton" to="." method="_on_FrameTagButton_pressed"]
|
||||
[connection signal="pressed" from="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons/FirstFrame" to="." method="_on_FirstFrame_pressed"]
|
||||
[connection signal="pressed" from="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons/PreviousFrame" to="." method="_on_PreviousFrame_pressed"]
|
||||
[connection signal="toggled" from="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons/PlayBackwards" to="." method="_on_PlayBackwards_toggled"]
|
||||
[connection signal="toggled" from="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons/PlayForward" to="." method="_on_PlayForward_toggled"]
|
||||
[connection signal="pressed" from="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons/NextFrame" to="." method="_on_NextFrame_pressed"]
|
||||
[connection signal="pressed" from="AnimationContainer/TimelineContainer/AnimationButtons/PlaybackButtons/LastFrame" to="." method="_on_LastFrame_pressed"]
|
||||
[connection signal="pressed" from="AnimationContainer/TimelineContainer/AnimationButtons/LoopButtons/OnionSkinningSettings" to="." method="_on_OnionSkinningSettings_pressed"]
|
||||
[connection signal="pressed" from="AnimationContainer/TimelineContainer/AnimationButtons/LoopButtons/OnionSkinning" to="." method="_on_OnionSkinning_pressed"]
|
||||
[connection signal="pressed" from="AnimationContainer/TimelineContainer/AnimationButtons/LoopButtons/LoopAnim" to="." method="_on_LoopAnim_pressed"]
|
||||
[connection signal="value_changed" from="AnimationContainer/TimelineContainer/AnimationButtons/LoopButtons/FPSValue" to="." method="_on_FPSValue_value_changed"]
|
||||
[connection signal="value_changed" from="AnimationContainer/TimelineContainer/OpacityAndTagContainer/OpacityContainer/OpacitySlider" to="." method="_on_OpacitySlider_value_changed"]
|
||||
[connection signal="value_changed" from="AnimationContainer/TimelineContainer/OpacityAndTagContainer/OpacityContainer/OpacitySpinBox" to="." method="_on_OpacitySlider_value_changed"]
|
||||
[connection signal="timeout" from="AnimationTimer" to="." method="_on_AnimationTimer_timeout"]
|
||||
[connection signal="popup_hide" from="OnionSkinningSettings" to="." method="_on_OnionSkinningSettings_popup_hide"]
|
||||
[connection signal="value_changed" from="OnionSkinningSettings/OnionSkinningButtons/PastOnionSkinning" to="." method="_on_PastOnionSkinning_value_changed"]
|
||||
[connection signal="value_changed" from="OnionSkinningSettings/OnionSkinningButtons/FutureOnionSkinning" to="." method="_on_FutureOnionSkinning_value_changed"]
|
||||
[connection signal="toggled" from="OnionSkinningSettings/OnionSkinningButtons/BlueRedMode" to="." method="_on_BlueRedMode_toggled"]
|
121
src/UI/Timeline/CelButton.gd
Normal file
121
src/UI/Timeline/CelButton.gd
Normal file
|
@ -0,0 +1,121 @@
|
|||
extends Button
|
||||
|
||||
var frame := 0
|
||||
var layer := 0
|
||||
|
||||
onready var popup_menu : PopupMenu = $PopupMenu
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
hint_tooltip = "Frame: %s, Layer: %s" % [frame + 1, layer]
|
||||
if Global.canvases[frame] in Global.layers[layer][5]:
|
||||
get_node("LinkedIndicator").visible = true
|
||||
popup_menu.set_item_text(4, "Unlink Cel")
|
||||
popup_menu.set_item_metadata(4, "Unlink Cel")
|
||||
else:
|
||||
get_node("LinkedIndicator").visible = false
|
||||
popup_menu.set_item_text(4, "Link Cel")
|
||||
popup_menu.set_item_metadata(4, "Link Cel")
|
||||
|
||||
|
||||
func _on_CelButton_pressed() -> void:
|
||||
if Input.is_action_just_released("left_mouse"):
|
||||
Global.current_frame = frame
|
||||
Global.current_layer = layer
|
||||
elif Input.is_action_just_released("right_mouse"):
|
||||
if Global.canvases.size() == 1:
|
||||
popup_menu.set_item_disabled(0, true)
|
||||
popup_menu.set_item_disabled(2, true)
|
||||
popup_menu.set_item_disabled(3, true)
|
||||
else:
|
||||
popup_menu.set_item_disabled(0, false)
|
||||
if frame > 0:
|
||||
popup_menu.set_item_disabled(2, false)
|
||||
if frame < Global.canvases.size() - 1:
|
||||
popup_menu.set_item_disabled(3, false)
|
||||
popup_menu.popup(Rect2(get_global_mouse_position(), Vector2.ONE))
|
||||
pressed = !pressed
|
||||
elif Input.is_action_just_released("middle_mouse"): # Middle mouse click
|
||||
pressed = !pressed
|
||||
Global.animation_timeline._on_DeleteFrame_pressed(frame)
|
||||
else: # An example of this would be Space
|
||||
pressed = !pressed
|
||||
|
||||
|
||||
func _on_PopupMenu_id_pressed(ID : int) -> void:
|
||||
match ID:
|
||||
0: # Remove Frame
|
||||
Global.animation_timeline._on_DeleteFrame_pressed(frame)
|
||||
1: # Clone Frame
|
||||
Global.animation_timeline._on_CopyFrame_pressed(frame)
|
||||
2: # Move Left
|
||||
change_frame_order(-1)
|
||||
3: # Move Right
|
||||
change_frame_order(1)
|
||||
4: # Unlink Cel
|
||||
var cel_index : int = Global.layers[layer][5].find(Global.canvases[frame])
|
||||
var c = Global.canvases[frame]
|
||||
var new_layers := Global.layers.duplicate(true)
|
||||
var new_canvas_layers : Array = c.layers.duplicate(true)
|
||||
|
||||
if popup_menu.get_item_metadata(4) == "Unlink Cel":
|
||||
new_layers[layer][5].remove(cel_index)
|
||||
var sprite := Image.new()
|
||||
sprite.copy_from(Global.canvases[frame].layers[layer][0])
|
||||
sprite.lock()
|
||||
var tex := ImageTexture.new()
|
||||
tex.create_from_image(sprite, 0)
|
||||
new_canvas_layers[layer][0] = sprite
|
||||
new_canvas_layers[layer][1] = tex
|
||||
|
||||
Global.undo_redo.create_action("Unlink Cel")
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
Global.undo_redo.add_undo_property(c, "layers", c.layers)
|
||||
|
||||
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvases[frame]], layer)
|
||||
Global.undo_redo.add_do_method(Global, "redo", [Global.canvases[frame]], layer)
|
||||
Global.undo_redo.commit_action()
|
||||
elif popup_menu.get_item_metadata(4) == "Link Cel":
|
||||
new_layers[layer][5].append(Global.canvases[frame])
|
||||
Global.undo_redo.create_action("Link Cel")
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
if new_layers[layer][5].size() > 1:
|
||||
# If there are already linked cels, set the current cel's image
|
||||
# to the first linked cel's image
|
||||
new_canvas_layers[layer][0] = new_layers[layer][5][0].layers[layer][0]
|
||||
new_canvas_layers[layer][1] = new_layers[layer][5][0].layers[layer][1]
|
||||
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
|
||||
Global.undo_redo.add_undo_property(c, "layers", c.layers)
|
||||
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvases[frame]], layer)
|
||||
Global.undo_redo.add_do_method(Global, "redo", [Global.canvases[frame]], layer)
|
||||
Global.undo_redo.commit_action()
|
||||
|
||||
|
||||
func change_frame_order(rate : int) -> void:
|
||||
var change = frame + rate
|
||||
var new_canvases := Global.canvases.duplicate()
|
||||
var temp = new_canvases[frame]
|
||||
new_canvases[frame] = new_canvases[change]
|
||||
new_canvases[change] = temp
|
||||
|
||||
Global.undo_redo.create_action("Change Frame Order")
|
||||
Global.undo_redo.add_do_property(Global, "canvases", new_canvases)
|
||||
Global.undo_redo.add_do_property(Global.canvases[frame], "frame", change)
|
||||
Global.undo_redo.add_do_property(Global.canvases[change], "frame", frame)
|
||||
|
||||
if Global.current_frame == frame:
|
||||
Global.undo_redo.add_do_property(Global, "current_frame", change)
|
||||
Global.undo_redo.add_undo_property(Global, "current_frame", Global.current_frame)
|
||||
|
||||
Global.undo_redo.add_undo_property(Global, "canvases", Global.canvases)
|
||||
Global.undo_redo.add_undo_property(Global.canvases[frame], "frame", frame)
|
||||
Global.undo_redo.add_undo_property(Global.canvases[change], "frame", change)
|
||||
|
||||
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvases[frame]])
|
||||
Global.undo_redo.add_do_method(Global, "redo", [Global.canvases[frame]])
|
||||
Global.undo_redo.commit_action()
|
||||
|
49
src/UI/Timeline/CelButton.tscn
Normal file
49
src/UI/Timeline/CelButton.tscn
Normal file
|
@ -0,0 +1,49 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://src/UI/Timeline/CelButton.gd" type="Script" id=1]
|
||||
|
||||
|
||||
|
||||
[node name="CelButton" type="Button"]
|
||||
margin_top = 18.0
|
||||
margin_right = 36.0
|
||||
margin_bottom = 54.0
|
||||
rect_min_size = Vector2( 36, 36 )
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
toggle_mode = true
|
||||
button_mask = 7
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="CelTexture" type="TextureRect" parent="."]
|
||||
margin_left = 2.0
|
||||
margin_top = 1.78536
|
||||
margin_right = 34.0
|
||||
margin_bottom = 33.7854
|
||||
rect_min_size = Vector2( 32, 32 )
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
expand = true
|
||||
stretch_mode = 6
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="PopupMenu" type="PopupMenu" parent="."]
|
||||
margin_right = 20.0
|
||||
margin_bottom = 20.0
|
||||
mouse_default_cursor_shape = 2
|
||||
items = [ "Remove Frame", null, 0, false, true, -1, 0, null, "", false, "Clone Frame", null, 0, false, false, -1, 0, null, "", false, "Move Left", null, 0, false, true, -1, 0, null, "", false, "Move Right", null, 0, false, true, -1, 0, null, "", false, "Link Cel", null, 0, false, false, -1, 0, null, "", false ]
|
||||
|
||||
[node name="LinkedIndicator" type="Polygon2D" parent="."]
|
||||
visible = false
|
||||
color = Color( 0.0627451, 0.741176, 0.215686, 1 )
|
||||
invert_enable = true
|
||||
invert_border = 1.0
|
||||
polygon = PoolVector2Array( 0, 0, 36, 0, 36, 36, 0, 36 )
|
||||
[connection signal="pressed" from="." to="." method="_on_CelButton_pressed"]
|
||||
[connection signal="id_pressed" from="PopupMenu" to="." method="_on_PopupMenu_id_pressed"]
|
80
src/UI/Timeline/LayerButton.gd
Normal file
80
src/UI/Timeline/LayerButton.gd
Normal file
|
@ -0,0 +1,80 @@
|
|||
class_name LayerButton
|
||||
extends Button
|
||||
|
||||
var i := 0
|
||||
var visibility_button : BaseButton
|
||||
var lock_button : BaseButton
|
||||
var linked_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")
|
||||
linked_button = Global.find_node_by_name(self, "LinkButton")
|
||||
label = Global.find_node_by_name(self, "Label")
|
||||
line_edit = Global.find_node_by_name(self, "LineEdit")
|
||||
|
||||
if Global.layers[i][1]:
|
||||
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)
|
||||
else:
|
||||
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)
|
||||
|
||||
if Global.layers[i][4]: # If new layers will be linked
|
||||
linked_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Linked_Layer.png" % Global.theme_type)
|
||||
linked_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Linked_Layer_Hover.png" % Global.theme_type)
|
||||
else:
|
||||
linked_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Unlinked_Layer.png" % Global.theme_type)
|
||||
linked_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Unlinked_Layer_Hover.png" % Global.theme_type)
|
||||
|
||||
|
||||
func _input(event : InputEvent) -> void:
|
||||
if (event.is_action_released("ui_accept") or event.is_action_released("ui_cancel")) and line_edit.visible and event.scancode != KEY_SPACE:
|
||||
save_layer_name(line_edit.text)
|
||||
|
||||
|
||||
func _on_LayerContainer_pressed() -> void:
|
||||
pressed = !pressed
|
||||
label.visible = false
|
||||
line_edit.visible = true
|
||||
line_edit.editable = true
|
||||
line_edit.grab_focus()
|
||||
|
||||
|
||||
func _on_LineEdit_focus_exited() -> void:
|
||||
save_layer_name(line_edit.text)
|
||||
|
||||
|
||||
func save_layer_name(new_name : String) -> void:
|
||||
label.visible = true
|
||||
line_edit.visible = false
|
||||
line_edit.editable = false
|
||||
label.text = new_name
|
||||
Global.layers_changed_skip = true
|
||||
Global.layers[i][0] = new_name
|
||||
|
||||
|
||||
func _on_VisibilityButton_pressed() -> void:
|
||||
Global.layers[i][1] = !Global.layers[i][1]
|
||||
Global.canvas.update()
|
||||
|
||||
|
||||
func _on_LockButton_pressed() -> void:
|
||||
Global.layers[i][2] = !Global.layers[i][2]
|
||||
|
||||
|
||||
func _on_LinkButton_pressed() -> void:
|
||||
Global.layers[i][4] = !Global.layers[i][4]
|
||||
if Global.layers[i][4] && !Global.layers[i][5]:
|
||||
Global.layers[i][5].append(Global.canvas)
|
||||
Global.layers[i][3].get_child(Global.current_frame)._ready()
|
120
src/UI/Timeline/LayerButton.tscn
Normal file
120
src/UI/Timeline/LayerButton.tscn
Normal file
|
@ -0,0 +1,120 @@
|
|||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://src/UI/Timeline/LayerButton.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Layer_Visible_Hover.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Unlock.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Unlinked_Layer.png" type="Texture" id=4]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Layer_Visible.png" type="Texture" id=5]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Unlock_Hover.png" type="Texture" id=6]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Unlinked_Layer_Hover.png" type="Texture" id=7]
|
||||
|
||||
|
||||
[node name="LayerContainer" type="Button"]
|
||||
margin_right = 210.0
|
||||
margin_bottom = 36.0
|
||||
rect_min_size = Vector2( 212, 36 )
|
||||
size_flags_horizontal = 0
|
||||
toggle_mode = true
|
||||
action_mode = 0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_horizontal_guides_": [ ],
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="LayerButtons" type="HBoxContainer" parent="HBoxContainer"]
|
||||
margin_right = 104.0
|
||||
margin_bottom = 36.0
|
||||
|
||||
[node name="VisibilityButton" type="TextureButton" parent="HBoxContainer/LayerButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_top = 2.0
|
||||
margin_right = 32.0
|
||||
margin_bottom = 34.0
|
||||
hint_tooltip = "Toggle layer's visibility"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 4
|
||||
texture_normal = ExtResource( 5 )
|
||||
texture_hover = ExtResource( 2 )
|
||||
|
||||
[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"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 4
|
||||
texture_normal = ExtResource( 3 )
|
||||
texture_hover = ExtResource( 6 )
|
||||
|
||||
[node name="LinkButton" type="TextureButton" parent="HBoxContainer/LayerButtons" groups=[
|
||||
"UIButtons",
|
||||
]]
|
||||
margin_left = 72.0
|
||||
margin_top = 2.0
|
||||
margin_right = 104.0
|
||||
margin_bottom = 34.0
|
||||
hint_tooltip = "Enable/disable cel linking
|
||||
|
||||
Linked cels are being shared across multiple frames"
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 4
|
||||
texture_normal = ExtResource( 4 )
|
||||
texture_hover = ExtResource( 7 )
|
||||
|
||||
[node name="LayerName" type="HBoxContainer" parent="HBoxContainer"]
|
||||
margin_left = 108.0
|
||||
margin_right = 212.0
|
||||
margin_bottom = 36.0
|
||||
rect_min_size = Vector2( 104, 0 )
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
alignment = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxContainer/LayerName"]
|
||||
margin_top = 11.0
|
||||
margin_right = 104.0
|
||||
margin_bottom = 25.0
|
||||
size_flags_horizontal = 3
|
||||
text = "Layer 0"
|
||||
align = 1
|
||||
clip_text = true
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="HBoxContainer/LayerName"]
|
||||
visible = false
|
||||
margin_left = 86.0
|
||||
margin_top = 5.0
|
||||
margin_right = 166.0
|
||||
margin_bottom = 37.0
|
||||
rect_min_size = Vector2( 80, 32 )
|
||||
size_flags_vertical = 4
|
||||
text = "Layer 0"
|
||||
editable = false
|
||||
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"]
|
||||
[connection signal="pressed" from="HBoxContainer/LayerButtons/LinkButton" to="." method="_on_LinkButton_pressed"]
|
||||
[connection signal="focus_exited" from="HBoxContainer/LayerName/LineEdit" to="." method="_on_LineEdit_focus_exited"]
|
Loading…
Add table
Add a link
Reference in a new issue