1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Import Animation dialogue improvements (#1041)

* splash ambient

* change fill to radial

* make import tag work with frame button

* hide Import tag dialog when clicking outside

* Icon shows the first frame of a tag

* formatting
This commit is contained in:
Variable 2024-07-30 22:22:22 +05:00 committed by GitHub
parent cdf50ce00d
commit 9ba556282a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 123 additions and 99 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=18 format=3 uid="uid://dbylw5k04ulp8"] [gd_scene load_steps=19 format=3 uid="uid://dbylw5k04ulp8"]
[ext_resource type="Theme" uid="uid://bkb4syj8110el" path="res://assets/themes/dark/theme.tres" id="1"] [ext_resource type="Theme" uid="uid://bkb4syj8110el" path="res://assets/themes/dark/theme.tres" id="1"]
[ext_resource type="Script" path="res://src/Main.gd" id="2"] [ext_resource type="Script" path="res://src/Main.gd" id="2"]
@ -14,6 +14,7 @@
[ext_resource type="PackedScene" uid="uid://c0nuukjakmai2" path="res://src/UI/Dialogs/TileModeOffsetsDialog.tscn" id="14"] [ext_resource type="PackedScene" uid="uid://c0nuukjakmai2" path="res://src/UI/Dialogs/TileModeOffsetsDialog.tscn" id="14"]
[ext_resource type="PackedScene" uid="uid://c6fyrnyt3663o" path="res://src/UI/Timeline/TagProperties.tscn" id="14_fw6cf"] [ext_resource type="PackedScene" uid="uid://c6fyrnyt3663o" path="res://src/UI/Timeline/TagProperties.tscn" id="14_fw6cf"]
[ext_resource type="Script" path="res://src/HandleExtensions.gd" id="15_v0k2h"] [ext_resource type="Script" path="res://src/HandleExtensions.gd" id="15_v0k2h"]
[ext_resource type="PackedScene" uid="uid://clsp16gq4sng3" path="res://src/UI/Dialogs/ImportTagDialog.tscn" id="16_ohhks"]
[ext_resource type="Script" path="res://src/Classes/SteamManager.gd" id="17_k1xhp"] [ext_resource type="Script" path="res://src/Classes/SteamManager.gd" id="17_k1xhp"]
[ext_resource type="PackedScene" uid="uid://clbjfkdupw52l" path="res://src/UI/Timeline/CelProperties.tscn" id="17_ucs64"] [ext_resource type="PackedScene" uid="uid://clbjfkdupw52l" path="res://src/UI/Timeline/CelProperties.tscn" id="17_ucs64"]
[ext_resource type="PackedScene" uid="uid://clgu8wb5o6oup" path="res://src/UI/Dialogs/ExportDialog.tscn" id="39"] [ext_resource type="PackedScene" uid="uid://clgu8wb5o6oup" path="res://src/UI/Dialogs/ExportDialog.tscn" id="39"]
@ -87,11 +88,15 @@ dialog_autowrap = true
[node name="CelProperties" parent="Dialogs" instance=ExtResource("17_ucs64")] [node name="CelProperties" parent="Dialogs" instance=ExtResource("17_ucs64")]
[node name="FrameProperties" parent="Dialogs" instance=ExtResource("9")] [node name="FrameProperties" parent="Dialogs" instance=ExtResource("9")]
size = Vector2i(224, 146)
[node name="LayerProperties" parent="Dialogs" instance=ExtResource("13_4dhva")] [node name="LayerProperties" parent="Dialogs" instance=ExtResource("13_4dhva")]
[node name="TagProperties" parent="Dialogs" instance=ExtResource("14_fw6cf")] [node name="TagProperties" parent="Dialogs" instance=ExtResource("14_fw6cf")]
[node name="ImportTagDialog" parent="Dialogs" instance=ExtResource("16_ohhks")]
popup_window = true
[node name="TileModeOffsetsDialog" parent="Dialogs" instance=ExtResource("14")] [node name="TileModeOffsetsDialog" parent="Dialogs" instance=ExtResource("14")]
[node name="DownloadImageConfirmationDialog" type="ConfirmationDialog" parent="Dialogs"] [node name="DownloadImageConfirmationDialog" type="ConfirmationDialog" parent="Dialogs"]

View file

@ -1,56 +1,57 @@
extends Popup extends AcceptDialog
var from_project: Project var from_project: Project
var create_new_tags := false var create_new_tags := false
var frame: int
var tag_id: int
@onready var from_project_list: OptionButton = %ProjectList @onready var from_project_list: OptionButton = %ProjectList
@onready var create_tags: CheckButton = %CreateTags @onready var create_tags: CheckButton = %CreateTags
@onready var animation_tags_list: ItemList = %TagList @onready var animation_tags_list: ItemList = %TagList
@onready var start_frame: Label = %StartFrame
func _ready() -> void: func _ready() -> void:
var tag_container: Control = Global.animation_timeline.find_child("TagContainer")
# connect signals # connect signals
tag_container.connect("gui_input", _on_TagContainer_gui_input) from_project_list.item_selected.connect(_on_FromProject_changed)
from_project_list.connect("item_selected", _on_FromProject_changed) animation_tags_list.item_selected.connect(_on_TagList_id_pressed)
animation_tags_list.connect("item_selected", _on_TagList_id_pressed) animation_tags_list.empty_clicked.connect(_on_TagList_empty_clicked)
create_tags.connect("toggled", _on_CreateTags_toggled) create_tags.toggled.connect(_on_CreateTags_toggled)
func refresh_list() -> void: func refresh_list() -> void:
animation_tags_list.clear() animation_tags_list.clear()
for tag in from_project.animation_tags: get_ok_button().disabled = true
var img := Image.create(5, 5, true, Image.FORMAT_RGBA8) for tag: AnimationTag in from_project.animation_tags:
img.fill(tag.color) var img = Image.create(from_project.size.x, from_project.size.y, true, Image.FORMAT_RGBA8)
DrawingAlgos.blend_layers(
img, from_project.frames[tag.from - 1], Vector2i.ZERO, from_project
)
var tex := ImageTexture.create_from_image(img) var tex := ImageTexture.create_from_image(img)
var tag_title := tag.name var tag_title := tag.name
if tag_title == "": if tag_title == "":
tag_title = "(Untitled)" tag_title = "(Untitled)"
animation_tags_list.add_item(tag_title, tex) var idx = animation_tags_list.add_item(tag_title, tex)
animation_tags_list.set_item_custom_fg_color(idx, tag.color)
func _on_CreateTags_toggled(pressed: bool) -> void: func _on_CreateTags_toggled(pressed: bool) -> void:
create_new_tags = pressed create_new_tags = pressed
func _on_TagContainer_gui_input(event: InputEvent) -> void: func prepare_and_show(frame_no: int) -> void:
if !event is InputEventMouseButton: # Reset UI
return frame = frame_no
if Input.is_action_just_released("right_mouse"): from_project_list.clear()
# Reset UI if Global.projects.find(from_project) < 0:
from_project_list.clear() from_project = Global.current_project
if Global.projects.find(from_project) < 0: # Populate project list
from_project = Global.current_project for project in Global.projects:
# Populate project list from_project_list.add_item(project.name)
for project in Global.projects: from_project_list.select(Global.projects.find(from_project))
from_project_list.add_item(project.name) # Populate tag list
from_project_list.select(Global.projects.find(from_project)) refresh_list()
# Populate tag list title = str("Import Tag (After Frame ", frame + 1, ")")
refresh_list() popup_centered()
var frame_idx := Global.current_project.current_frame + 2
start_frame.text = str("The pasted frames will start at (Frame ", frame_idx, ")")
popup(Rect2i(Global.control.get_global_mouse_position(), Vector2i.ONE))
func _on_FromProject_changed(id: int) -> void: func _on_FromProject_changed(id: int) -> void:
@ -58,16 +59,25 @@ func _on_FromProject_changed(id: int) -> void:
refresh_list() refresh_list()
func _on_TagList_id_pressed(id: int) -> void: func _on_confirmed() -> void:
var tag: AnimationTag = from_project.animation_tags[id] var tag: AnimationTag = from_project.animation_tags[tag_id]
var frames := [] var frames := []
for i in range(tag.from - 1, tag.to): for i in range(tag.from - 1, tag.to):
frames.append(i) frames.append(i)
if create_new_tags: if create_new_tags:
add_animation(frames, Global.current_project.current_frame, tag) add_animation(frames, frame, tag)
else: else:
add_animation(frames, Global.current_project.current_frame) add_animation(frames, frame)
hide()
func _on_TagList_id_pressed(id: int) -> void:
get_ok_button().disabled = false
tag_id = id
func _on_TagList_empty_clicked() -> void:
animation_tags_list.deselect_all()
get_ok_button().disabled = true
## Gets frame indices of [member from_project] and dumps it in the current project. ## Gets frame indices of [member from_project] and dumps it in the current project.
@ -236,3 +246,7 @@ func add_animation(indices: Array, destination: int, from_tag: AnimationTag = nu
project.undo_redo.add_do_method(Global.undo_or_redo.bind(false)) project.undo_redo.add_do_method(Global.undo_or_redo.bind(false))
project.undo_redo.add_undo_method(Global.undo_or_redo.bind(true)) project.undo_redo.add_undo_method(Global.undo_or_redo.bind(true))
project.undo_redo.commit_action() project.undo_redo.commit_action()
func _on_close_requested() -> void:
hide()

View file

@ -0,0 +1,59 @@
[gd_scene load_steps=2 format=3 uid="uid://clsp16gq4sng3"]
[ext_resource type="Script" path="res://src/UI/Dialogs/ImportTagDialog.gd" id="1_5fb6k"]
[node name="ImportTagDialog" type="ConfirmationDialog"]
title = "Import Tag"
size = Vector2i(270, 300)
exclusive = false
min_size = Vector2i(250, 0)
ok_button_text = "Import"
script = ExtResource("1_5fb6k")
[node name="PanelContainer" type="PanelContainer" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 8.0
offset_top = 8.0
offset_right = -8.0
offset_bottom = -49.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "From: "
[node name="ProjectList" type="OptionButton" parent="PanelContainer/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
alignment = 1
[node name="CreateTags" type="CheckButton" parent="PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Create new tags"
[node name="Instructions" type="Label" parent="PanelContainer/VBoxContainer"]
custom_minimum_size = Vector2(250, 23)
layout_mode = 2
text = "Available tags:"
autowrap_mode = 3
[node name="TagList" type="ItemList" parent="PanelContainer/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 150)
layout_mode = 2
size_flags_vertical = 3
fixed_icon_size = Vector2i(32, 32)
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
[connection signal="confirmed" from="." to="." method="_on_confirmed"]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=74 format=3 uid="uid://dbr6mulku2qju"] [gd_scene load_steps=73 format=3 uid="uid://dbr6mulku2qju"]
[ext_resource type="Script" path="res://src/UI/Timeline/AnimationTimeline.gd" id="1"] [ext_resource type="Script" path="res://src/UI/Timeline/AnimationTimeline.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://d36mlbmq06q4e" path="res://assets/graphics/layers/new.png" id="2"] [ext_resource type="Texture2D" uid="uid://d36mlbmq06q4e" path="res://assets/graphics/layers/new.png" id="2"]
@ -12,7 +12,6 @@
[ext_resource type="Texture2D" uid="uid://dt6cysvv1w77u" path="res://assets/graphics/layers/fx.png" id="9_yphnd"] [ext_resource type="Texture2D" uid="uid://dt6cysvv1w77u" path="res://assets/graphics/layers/fx.png" id="9_yphnd"]
[ext_resource type="Texture2D" uid="uid://ct8wn8m6x4m54" path="res://assets/graphics/misc/value_arrow.svg" id="10"] [ext_resource type="Texture2D" uid="uid://ct8wn8m6x4m54" path="res://assets/graphics/misc/value_arrow.svg" id="10"]
[ext_resource type="Script" path="res://src/UI/Timeline/FrameScrollContainer.gd" id="11"] [ext_resource type="Script" path="res://src/UI/Timeline/FrameScrollContainer.gd" id="11"]
[ext_resource type="Script" path="res://src/UI/Timeline/PasteTagPopup.gd" id="12"]
[ext_resource type="Texture2D" uid="uid://d1urikaf1lxwl" path="res://assets/graphics/timeline/new_frame.png" id="19"] [ext_resource type="Texture2D" uid="uid://d1urikaf1lxwl" path="res://assets/graphics/timeline/new_frame.png" id="19"]
[ext_resource type="Texture2D" uid="uid://bt72662c3gp2f" path="res://assets/graphics/timeline/remove_frame.png" id="20"] [ext_resource type="Texture2D" uid="uid://bt72662c3gp2f" path="res://assets/graphics/timeline/remove_frame.png" id="20"]
[ext_resource type="Texture2D" uid="uid://bujrukk5ii3bi" path="res://assets/graphics/timeline/go_to_first_frame.png" id="21"] [ext_resource type="Texture2D" uid="uid://bujrukk5ii3bi" path="res://assets/graphics/timeline/go_to_first_frame.png" id="21"]
@ -1011,64 +1010,6 @@ offset_bottom = 40.0
mouse_filter = 2 mouse_filter = 2
color = Color(0, 0.741176, 1, 0.501961) color = Color(0, 0.741176, 1, 0.501961)
[node name="PasteTagPopup" type="Popup" parent="."]
size = Vector2i(250, 335)
min_size = Vector2i(250, 0)
script = ExtResource("12")
[node name="PanelContainer" type="PanelContainer" parent="PasteTagPopup"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="PasteTagPopup/PanelContainer"]
layout_mode = 2
[node name="Title" type="Label" parent="PasteTagPopup/PanelContainer/VBoxContainer"]
layout_mode = 2
theme_type_variation = &"HeaderSmall"
text = "Import Tags"
horizontal_alignment = 1
[node name="HBoxContainer" type="HBoxContainer" parent="PasteTagPopup/PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="PasteTagPopup/PanelContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "From: "
[node name="ProjectList" type="OptionButton" parent="PasteTagPopup/PanelContainer/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
alignment = 1
[node name="CreateTags" type="CheckButton" parent="PasteTagPopup/PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Create new tags"
[node name="Instructions" type="Label" parent="PasteTagPopup/PanelContainer/VBoxContainer"]
custom_minimum_size = Vector2(250, 23)
layout_mode = 2
text = "Available tags:"
autowrap_mode = 3
[node name="TagList" type="ItemList" parent="PasteTagPopup/PanelContainer/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 150)
layout_mode = 2
size_flags_vertical = 3
[node name="StartFrame" type="Label" parent="PasteTagPopup/PanelContainer/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(250, 23)
layout_mode = 2
horizontal_alignment = 1
autowrap_mode = 3
[connection signal="pressed" from="TimelineContainer/TimelineButtons/LayerTools/MarginContainer/LayerSettingsContainer/LayerButtons/AddLayer" to="." method="add_layer"] [connection signal="pressed" from="TimelineContainer/TimelineButtons/LayerTools/MarginContainer/LayerSettingsContainer/LayerButtons/AddLayer" to="." method="add_layer"]
[connection signal="pressed" from="TimelineContainer/TimelineButtons/LayerTools/MarginContainer/LayerSettingsContainer/LayerButtons/RemoveLayer" to="." method="_on_RemoveLayer_pressed"] [connection signal="pressed" from="TimelineContainer/TimelineButtons/LayerTools/MarginContainer/LayerSettingsContainer/LayerButtons/RemoveLayer" to="." method="_on_RemoveLayer_pressed"]
[connection signal="pressed" from="TimelineContainer/TimelineButtons/LayerTools/MarginContainer/LayerSettingsContainer/LayerButtons/MoveUpLayer" to="." method="change_layer_order" binds= [true]] [connection signal="pressed" from="TimelineContainer/TimelineButtons/LayerTools/MarginContainer/LayerSettingsContainer/LayerButtons/MoveUpLayer" to="." method="change_layer_order" binds= [true]]

View file

@ -1,12 +1,13 @@
extends Button extends Button
enum { PROPERTIES, REMOVE, CLONE, MOVE_LEFT, MOVE_RIGHT, NEW_TAG, REVERSE, CENTER } enum { PROPERTIES, REMOVE, CLONE, MOVE_LEFT, MOVE_RIGHT, NEW_TAG, IMPORT_TAG, REVERSE, CENTER }
var frame := 0 var frame := 0
@onready var popup_menu: PopupMenu = $PopupMenu @onready var popup_menu: PopupMenu = $PopupMenu
@onready var frame_properties := Global.control.find_child("FrameProperties") as ConfirmationDialog @onready var frame_properties := Global.control.find_child("FrameProperties") as ConfirmationDialog
@onready var tag_properties := Global.control.find_child("TagProperties") as ConfirmationDialog @onready var tag_properties := Global.control.find_child("TagProperties") as ConfirmationDialog
@onready var append_tag_dialog := Global.control.find_child("ImportTagDialog") as AcceptDialog
func _ready() -> void: func _ready() -> void:
@ -95,6 +96,8 @@ func _on_PopupMenu_id_pressed(id: int) -> void:
NEW_TAG: NEW_TAG:
var current_tag_id := Global.current_project.animation_tags.size() var current_tag_id := Global.current_project.animation_tags.size()
tag_properties.show_dialog(Rect2i(), current_tag_id, false, indices) tag_properties.show_dialog(Rect2i(), current_tag_id, false, indices)
IMPORT_TAG:
append_tag_dialog.prepare_and_show(frame)
REVERSE: REVERSE:
Global.animation_timeline.reverse_frames(indices) Global.animation_timeline.reverse_frames(indices)
CENTER: CENTER:

View file

@ -14,7 +14,7 @@ text = "1"
script = ExtResource("1") script = ExtResource("1")
[node name="PopupMenu" type="PopupMenu" parent="."] [node name="PopupMenu" type="PopupMenu" parent="."]
item_count = 8 item_count = 9
item_0/text = "Properties" item_0/text = "Properties"
item_0/id = -1 item_0/id = -1
item_1/text = "Remove Frame" item_1/text = "Remove Frame"
@ -30,10 +30,12 @@ item_4/id = -1
item_4/disabled = true item_4/disabled = true
item_5/text = "New Tag" item_5/text = "New Tag"
item_5/id = 5 item_5/id = 5
item_6/text = "Reverse Frames" item_6/text = "Import Tag"
item_6/id = 6 item_6/id = 6
item_6/disabled = true item_7/text = "Reverse Frames"
item_7/text = "Center Frames"
item_7/id = 7 item_7/id = 7
item_7/disabled = true
item_8/text = "Center Frames"
item_8/id = 8
[connection signal="id_pressed" from="PopupMenu" to="." method="_on_PopupMenu_id_pressed"] [connection signal="id_pressed" from="PopupMenu" to="." method="_on_PopupMenu_id_pressed"]