mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-12-14 07:34:43 -05:00
The way frames are being added has changed, and now you can modify existing tags too. Deletion will come soon.
86 lines
2.9 KiB
GDScript
86 lines
2.9 KiB
GDScript
extends ConfirmationDialog
|
|
|
|
|
|
var current_tag_id := 0
|
|
var tag_vboxes := []
|
|
|
|
onready var main_vbox_cont : VBoxContainer = $ScrollContainer/VBoxContainer
|
|
onready var add_tag_button : TextureButton = $ScrollContainer/VBoxContainer/AddTag
|
|
onready var options_dialog = $TagOptions
|
|
|
|
|
|
func _on_FrameTagDialog_about_to_show() -> void:
|
|
Global.can_draw = false
|
|
for vbox in tag_vboxes:
|
|
vbox.queue_free()
|
|
tag_vboxes.clear()
|
|
|
|
var i := 0
|
|
for tag in Global.animation_tags:
|
|
var vbox_cont := VBoxContainer.new()
|
|
|
|
var hbox_cont := HBoxContainer.new()
|
|
var tag_label := Label.new()
|
|
if tag[2] == tag[3]:
|
|
tag_label.text = "Tag %s (Frame %s)" % [i + 1, tag[2]]
|
|
else:
|
|
tag_label.text = "Tag %s (Frames %s-%s)" % [i + 1, tag[2], tag[3]]
|
|
hbox_cont.add_child(tag_label)
|
|
|
|
var edit_button := Button.new()
|
|
edit_button.text = "Edit"
|
|
edit_button.connect("pressed", self, "_on_EditButton_pressed", [i])
|
|
hbox_cont.add_child(edit_button)
|
|
vbox_cont.add_child(hbox_cont)
|
|
|
|
var name_label := Label.new()
|
|
name_label.text = tag[0]
|
|
name_label.modulate = tag[1]
|
|
vbox_cont.add_child(name_label)
|
|
|
|
var hsep := HSeparator.new()
|
|
hsep.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
vbox_cont.add_child(hsep)
|
|
|
|
main_vbox_cont.add_child(vbox_cont)
|
|
tag_vboxes.append(vbox_cont)
|
|
|
|
i += 1
|
|
|
|
add_tag_button.visible = true
|
|
main_vbox_cont.move_child(add_tag_button, main_vbox_cont.get_child_count() - 1)
|
|
|
|
|
|
func _on_FrameTagDialog_popup_hide() -> void:
|
|
Global.can_draw = true
|
|
|
|
|
|
func _on_AddTag_pressed() -> void:
|
|
options_dialog.popup_centered()
|
|
current_tag_id = Global.animation_tags.size()
|
|
|
|
|
|
func _on_EditButton_pressed(_tag_id : int) -> void:
|
|
options_dialog.popup_centered()
|
|
current_tag_id = _tag_id
|
|
options_dialog.get_node("GridContainer/NameLineEdit").text = Global.animation_tags[_tag_id][0]
|
|
options_dialog.get_node("GridContainer/ColorPickerButton").color = Global.animation_tags[_tag_id][1]
|
|
options_dialog.get_node("GridContainer/FromSpinBox").value = Global.animation_tags[_tag_id][2]
|
|
options_dialog.get_node("GridContainer/ToSpinBox").value = Global.animation_tags[_tag_id][3]
|
|
|
|
|
|
func _on_TagOptions_confirmed() -> void:
|
|
var tag_name : String = options_dialog.get_node("GridContainer/NameLineEdit").text
|
|
var tag_color : Color = options_dialog.get_node("GridContainer/ColorPickerButton").color
|
|
var tag_from : int = options_dialog.get_node("GridContainer/FromSpinBox").value
|
|
var tag_to : int = options_dialog.get_node("GridContainer/ToSpinBox").value
|
|
if current_tag_id == Global.animation_tags.size():
|
|
Global.animation_tags.append([tag_name, tag_color, tag_from, tag_to])
|
|
else:
|
|
Global.animation_tags[current_tag_id][0] = tag_name
|
|
Global.animation_tags[current_tag_id][1] = tag_color
|
|
Global.animation_tags[current_tag_id][2] = tag_from
|
|
Global.animation_tags[current_tag_id][3] = tag_to
|
|
|
|
Global.animation_tags = Global.animation_tags # To execute animation_tags_changed()
|
|
_on_FrameTagDialog_about_to_show()
|