mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 21:34:43 -04:00
Added AnimationTag class
Replaces nested Global.animation_tags arrays. Also replaced array.duplicate(true) with looping through the array and creating a new class for each array element, because duplicate(true) does not create new classes, unfortunately, which was causing issues with undo/redo.
This commit is contained in:
parent
e229ad1519
commit
34bc528e97
14 changed files with 134 additions and 83 deletions
|
@ -1,9 +1,9 @@
|
|||
extends Node
|
||||
|
||||
|
||||
const Drawer = preload("res://src/Drawers.gd").Drawer
|
||||
const SimpleDrawer = preload("res://src/Drawers.gd").SimpleDrawer
|
||||
const PixelPerfectDrawer = preload("res://src/Drawers.gd").PixelPerfectDrawer
|
||||
const Drawer = preload("res://src/Classes/Drawers.gd").Drawer
|
||||
const SimpleDrawer = preload("res://src/Classes/Drawers.gd").SimpleDrawer
|
||||
const PixelPerfectDrawer = preload("res://src/Classes/Drawers.gd").PixelPerfectDrawer
|
||||
|
||||
var pixel_perfect_drawer := PixelPerfectDrawer.new()
|
||||
var pixel_perfect_drawer_h_mirror := PixelPerfectDrawer.new()
|
||||
|
|
|
@ -53,7 +53,7 @@ var right_cursor_tool_texture : ImageTexture
|
|||
|
||||
var selected_pixels := []
|
||||
var image_clipboard : Image
|
||||
var animation_tags := [] setget animation_tags_changed # [Name, Color, From, To]
|
||||
var animation_tags := [] setget animation_tags_changed
|
||||
var play_only_tags := true
|
||||
|
||||
var theme_type : int = Theme_Types.DARK
|
||||
|
@ -512,9 +512,9 @@ func canvases_changed(value : Array) -> void:
|
|||
animation_timeline.last_frame = canvases.size() - 1
|
||||
if play_only_tags:
|
||||
for tag in animation_tags:
|
||||
if current_frame + 1 >= tag[2] && current_frame + 1 <= tag[3]:
|
||||
animation_timeline.first_frame = tag[2] - 1
|
||||
animation_timeline.last_frame = min(canvases.size() - 1, tag[3] - 1)
|
||||
if current_frame + 1 >= tag.from && current_frame + 1 <= tag.to:
|
||||
animation_timeline.first_frame = tag.from - 1
|
||||
animation_timeline.last_frame = min(canvases.size() - 1, tag.to - 1)
|
||||
|
||||
|
||||
func clear_canvases() -> void:
|
||||
|
@ -704,13 +704,13 @@ func animation_tags_changed(value : Array) -> void:
|
|||
tag_container.add_child(tag_c)
|
||||
var tag_position := tag_container.get_child_count() - 1
|
||||
tag_container.move_child(tag_c, tag_position)
|
||||
tag_c.get_node("Label").text = tag[0]
|
||||
tag_c.get_node("Label").modulate = tag[1]
|
||||
tag_c.get_node("Line2D").default_color = tag[1]
|
||||
tag_c.get_node("Label").text = tag.name
|
||||
tag_c.get_node("Label").modulate = tag.color
|
||||
tag_c.get_node("Line2D").default_color = tag.color
|
||||
|
||||
tag_c.rect_position.x = (tag[2] - 1) * 39 + tag[2]
|
||||
tag_c.rect_position.x = (tag.from - 1) * 39 + tag.from
|
||||
|
||||
var size : int = tag[3] - tag[2]
|
||||
var size : int = tag.to - tag.from
|
||||
tag_c.rect_min_size.x = (size + 1) * 39
|
||||
tag_c.get_node("Line2D").points[2] = Vector2(tag_c.rect_min_size.x, 0)
|
||||
tag_c.get_node("Line2D").points[3] = Vector2(tag_c.rect_min_size.x, 32)
|
||||
|
@ -722,9 +722,9 @@ func animation_tags_changed(value : Array) -> void:
|
|||
animation_timeline.last_frame = canvases.size() - 1
|
||||
if play_only_tags:
|
||||
for tag in animation_tags:
|
||||
if current_frame + 1 >= tag[2] && current_frame + 1 <= tag[3]:
|
||||
animation_timeline.first_frame = tag[2] - 1
|
||||
animation_timeline.last_frame = min(canvases.size() - 1, tag[3] - 1)
|
||||
if current_frame + 1 >= tag.from && current_frame + 1 <= tag.to:
|
||||
animation_timeline.first_frame = tag.from - 1
|
||||
animation_timeline.last_frame = min(canvases.size() - 1, tag.to - 1)
|
||||
|
||||
|
||||
func update_hint_tooltips() -> void:
|
||||
|
|
|
@ -158,7 +158,7 @@ func open_pxo_file(path : String, untitled_backup : bool = false) -> void:
|
|||
var tag_color : Color = file.get_var()
|
||||
var tag_from := file.get_8()
|
||||
var tag_to := file.get_8()
|
||||
Global.animation_tags.append([tag_name, tag_color, tag_from, tag_to])
|
||||
Global.animation_tags.append(AnimationTag.new(tag_name, tag_color, tag_from, tag_to))
|
||||
Global.animation_tags = Global.animation_tags # To execute animation_tags_changed()
|
||||
tag_line = file.get_line()
|
||||
|
||||
|
@ -239,10 +239,10 @@ func save_pxo_file(path : String, autosave : bool) -> void:
|
|||
# Store animation tags
|
||||
for tag in Global.animation_tags:
|
||||
file.store_line(".T/")
|
||||
file.store_line(tag[0]) # Tag name
|
||||
file.store_var(tag[1]) # Tag color
|
||||
file.store_8(tag[2]) # Tag "from", the first frame
|
||||
file.store_8(tag[3]) # Tag "to", the last frame
|
||||
file.store_line(tag.name)
|
||||
file.store_var(tag.color)
|
||||
file.store_8(tag.from)
|
||||
file.store_8(tag.to)
|
||||
file.store_line("END_FRAME_TAGS")
|
||||
|
||||
file.close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue