优化 animation loader 逻辑
BIN
asset/art/gif/【胖小孩背着残疾小孩】-侧面呼吸.gif
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
asset/art/gif/【胖小孩背着残疾小孩】-呼吸.gif
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
asset/art/gif/【胖小孩背着残疾小孩】-正面呼吸.gif
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
asset/art/gif/【胖小孩背着残疾小孩】-正面抖肩.gif
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
asset/art/gif/【胖小孩背着残疾小孩】-画画.gif
Normal file
After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
@ -1,4 +1,4 @@
|
|||||||
extends Panel
|
extends Control
|
||||||
|
|
||||||
var config_path = "res://config/animation/frames_config.json"
|
var config_path = "res://config/animation/frames_config.json"
|
||||||
var scan_path = "res://asset/art/animation/"
|
var scan_path = "res://asset/art/animation/"
|
||||||
@ -15,7 +15,7 @@ var all_keys := []
|
|||||||
var matched_keys := []
|
var matched_keys := []
|
||||||
var all_pages := 1
|
var all_pages := 1
|
||||||
var current_page := 1
|
var current_page := 1
|
||||||
const PAGE_SIZE = 6
|
const PAGE_SIZE = 14
|
||||||
|
|
||||||
# 0.png
|
# 0.png
|
||||||
# 12.png
|
# 12.png
|
||||||
|
@ -3,19 +3,23 @@
|
|||||||
[ext_resource type="Script" path="res://config/animation/animation_loader.gd" id="1_qwa4g"]
|
[ext_resource type="Script" path="res://config/animation/animation_loader.gd" id="1_qwa4g"]
|
||||||
[ext_resource type="Script" path="res://ui/button/sound_button.gd" id="2_1tl0v"]
|
[ext_resource type="Script" path="res://ui/button/sound_button.gd" id="2_1tl0v"]
|
||||||
|
|
||||||
[node name="AnimationLoader" type="Panel"]
|
[node name="AnimationLoader" type="Control"]
|
||||||
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
offset_right = 564.0
|
||||||
|
offset_bottom = 316.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
script = ExtResource("1_qwa4g")
|
script = ExtResource("1_qwa4g")
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 2
|
||||||
anchors_preset = 15
|
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
offset_right = 36.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
|
||||||
@ -66,9 +70,10 @@ script = ExtResource("2_1tl0v")
|
|||||||
|
|
||||||
[node name="ConfigEdit" type="TextEdit" parent="HBoxContainer/MarginContainer2/VBoxContainer"]
|
[node name="ConfigEdit" type="TextEdit" parent="HBoxContainer/MarginContainer2/VBoxContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(120, 200)
|
custom_minimum_size = Vector2(170, 200)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 0
|
size_flags_horizontal = 0
|
||||||
|
size_flags_vertical = 3
|
||||||
editable = false
|
editable = false
|
||||||
|
|
||||||
[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"]
|
[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"]
|
||||||
@ -81,4 +86,4 @@ vertical_scroll_mode = 2
|
|||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(400, 50)
|
custom_minimum_size = Vector2(400, 50)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
columns = 3
|
columns = 7
|
||||||
|
@ -515,6 +515,29 @@
|
|||||||
"6"
|
"6"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"c01_小小蝶_walking (8帧-317px高)": {
|
||||||
|
"path": "res://asset/art/animation/c01_小小蝶_walking (8帧-317px高)",
|
||||||
|
"frames": {
|
||||||
|
"1": "res://asset/art/animation/c01_小小蝶_walking (8帧-317px高)/1.png",
|
||||||
|
"2": "res://asset/art/animation/c01_小小蝶_walking (8帧-317px高)/2.png",
|
||||||
|
"3": "res://asset/art/animation/c01_小小蝶_walking (8帧-317px高)/3.png",
|
||||||
|
"4": "res://asset/art/animation/c01_小小蝶_walking (8帧-317px高)/4.png",
|
||||||
|
"5": "res://asset/art/animation/c01_小小蝶_walking (8帧-317px高)/5.png",
|
||||||
|
"6": "res://asset/art/animation/c01_小小蝶_walking (8帧-317px高)/6.png",
|
||||||
|
"7": "res://asset/art/animation/c01_小小蝶_walking (8帧-317px高)/7.png",
|
||||||
|
"8": "res://asset/art/animation/c01_小小蝶_walking (8帧-317px高)/8.png"
|
||||||
|
},
|
||||||
|
"ids": [
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"5",
|
||||||
|
"6",
|
||||||
|
"7",
|
||||||
|
"8"
|
||||||
|
]
|
||||||
|
},
|
||||||
"c01_小小蝶_walking_l": {
|
"c01_小小蝶_walking_l": {
|
||||||
"path": "res://asset/art/animation/c01_小小蝶_walking_l",
|
"path": "res://asset/art/animation/c01_小小蝶_walking_l",
|
||||||
"frames": {
|
"frames": {
|
||||||
@ -534,6 +557,64 @@
|
|||||||
"6"
|
"6"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"c01_小小蝶_侧面下蹲": {
|
||||||
|
"path": "res://asset/art/animation/c01_小小蝶_侧面下蹲",
|
||||||
|
"frames": {
|
||||||
|
"1": "res://asset/art/animation/c01_小小蝶_侧面下蹲/1.png",
|
||||||
|
"10": "res://asset/art/animation/c01_小小蝶_侧面下蹲/10.png",
|
||||||
|
"11": "res://asset/art/animation/c01_小小蝶_侧面下蹲/11.png",
|
||||||
|
"2": "res://asset/art/animation/c01_小小蝶_侧面下蹲/2.png",
|
||||||
|
"3": "res://asset/art/animation/c01_小小蝶_侧面下蹲/3.png",
|
||||||
|
"4": "res://asset/art/animation/c01_小小蝶_侧面下蹲/4.png",
|
||||||
|
"5": "res://asset/art/animation/c01_小小蝶_侧面下蹲/5.png",
|
||||||
|
"6": "res://asset/art/animation/c01_小小蝶_侧面下蹲/6.png",
|
||||||
|
"7": "res://asset/art/animation/c01_小小蝶_侧面下蹲/7.png",
|
||||||
|
"8": "res://asset/art/animation/c01_小小蝶_侧面下蹲/8.png",
|
||||||
|
"9": "res://asset/art/animation/c01_小小蝶_侧面下蹲/9.png"
|
||||||
|
},
|
||||||
|
"ids": [
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"5",
|
||||||
|
"6",
|
||||||
|
"7",
|
||||||
|
"8",
|
||||||
|
"9",
|
||||||
|
"10",
|
||||||
|
"11"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c01_小小蝶_床上看书": {
|
||||||
|
"path": "res://asset/art/animation/c01_小小蝶_床上看书",
|
||||||
|
"frames": {
|
||||||
|
"1": "res://asset/art/animation/c01_小小蝶_床上看书/1.png",
|
||||||
|
"10": "res://asset/art/animation/c01_小小蝶_床上看书/10.png",
|
||||||
|
"11": "res://asset/art/animation/c01_小小蝶_床上看书/11.png",
|
||||||
|
"2": "res://asset/art/animation/c01_小小蝶_床上看书/2.png",
|
||||||
|
"3": "res://asset/art/animation/c01_小小蝶_床上看书/3.png",
|
||||||
|
"4": "res://asset/art/animation/c01_小小蝶_床上看书/4.png",
|
||||||
|
"5": "res://asset/art/animation/c01_小小蝶_床上看书/5.png",
|
||||||
|
"6": "res://asset/art/animation/c01_小小蝶_床上看书/6.png",
|
||||||
|
"7": "res://asset/art/animation/c01_小小蝶_床上看书/7.png",
|
||||||
|
"8": "res://asset/art/animation/c01_小小蝶_床上看书/8.png",
|
||||||
|
"9": "res://asset/art/animation/c01_小小蝶_床上看书/9.png"
|
||||||
|
},
|
||||||
|
"ids": [
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"5",
|
||||||
|
"6",
|
||||||
|
"7",
|
||||||
|
"8",
|
||||||
|
"9",
|
||||||
|
"10",
|
||||||
|
"11"
|
||||||
|
]
|
||||||
|
},
|
||||||
"c01_小小蝶_抬头": {
|
"c01_小小蝶_抬头": {
|
||||||
"path": "res://asset/art/animation/c01_小小蝶_抬头",
|
"path": "res://asset/art/animation/c01_小小蝶_抬头",
|
||||||
"frames": {
|
"frames": {
|
||||||
@ -576,6 +657,37 @@
|
|||||||
"7"
|
"7"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"c01_小小蝶_拿鸡毛掸子": {
|
||||||
|
"path": "res://asset/art/animation/c01_小小蝶_拿鸡毛掸子",
|
||||||
|
"frames": {
|
||||||
|
"1": "res://asset/art/animation/c01_小小蝶_拿鸡毛掸子/1.png",
|
||||||
|
"10": "res://asset/art/animation/c01_小小蝶_拿鸡毛掸子/10.png",
|
||||||
|
"11": "res://asset/art/animation/c01_小小蝶_拿鸡毛掸子/11.png",
|
||||||
|
"12": "res://asset/art/animation/c01_小小蝶_拿鸡毛掸子/12.png",
|
||||||
|
"2": "res://asset/art/animation/c01_小小蝶_拿鸡毛掸子/2.png",
|
||||||
|
"3": "res://asset/art/animation/c01_小小蝶_拿鸡毛掸子/3.png",
|
||||||
|
"4": "res://asset/art/animation/c01_小小蝶_拿鸡毛掸子/4.png",
|
||||||
|
"5": "res://asset/art/animation/c01_小小蝶_拿鸡毛掸子/5.png",
|
||||||
|
"6": "res://asset/art/animation/c01_小小蝶_拿鸡毛掸子/6.png",
|
||||||
|
"7": "res://asset/art/animation/c01_小小蝶_拿鸡毛掸子/7.png",
|
||||||
|
"8": "res://asset/art/animation/c01_小小蝶_拿鸡毛掸子/8.png",
|
||||||
|
"9": "res://asset/art/animation/c01_小小蝶_拿鸡毛掸子/9.png"
|
||||||
|
},
|
||||||
|
"ids": [
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"5",
|
||||||
|
"6",
|
||||||
|
"7",
|
||||||
|
"8",
|
||||||
|
"9",
|
||||||
|
"10",
|
||||||
|
"11",
|
||||||
|
"12"
|
||||||
|
]
|
||||||
|
},
|
||||||
"c01_捡球男孩_关键帧": {
|
"c01_捡球男孩_关键帧": {
|
||||||
"path": "res://asset/art/animation/c01_捡球男孩_关键帧",
|
"path": "res://asset/art/animation/c01_捡球男孩_关键帧",
|
||||||
"frames": {
|
"frames": {
|
||||||
@ -1630,4 +1742,4 @@
|
|||||||
"c01_小小蝶_idle": 2,
|
"c01_小小蝶_idle": 2,
|
||||||
"c01_小小蝶_idle_l": 2
|
"c01_小小蝶_idle_l": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,7 +24,7 @@ func _ready() -> void:
|
|||||||
frames_speed_line_edit.text = str(frames_per_sec)
|
frames_speed_line_edit.text = str(frames_per_sec)
|
||||||
first_frame_mapping_edit.text = first_frame_mapping
|
first_frame_mapping_edit.text = first_frame_mapping
|
||||||
mirror_mapping_edit.text = mirror_mapping
|
mirror_mapping_edit.text = mirror_mapping
|
||||||
reload_frames()
|
display_frames()
|
||||||
mapping_line_edit.text_submitted.connect(_on_mapping_submitted)
|
mapping_line_edit.text_submitted.connect(_on_mapping_submitted)
|
||||||
frames_speed_line_edit.text_submitted.connect(_on_frames_speed_submitted)
|
frames_speed_line_edit.text_submitted.connect(_on_frames_speed_submitted)
|
||||||
first_frame_mapping_edit.text_submitted.connect(_on_first_frame_mapping_submitted)
|
first_frame_mapping_edit.text_submitted.connect(_on_first_frame_mapping_submitted)
|
||||||
@ -34,6 +34,19 @@ func _ready() -> void:
|
|||||||
var reload_lock := Mutex.new()
|
var reload_lock := Mutex.new()
|
||||||
|
|
||||||
|
|
||||||
|
func display_frames():
|
||||||
|
if mapping_name and animated_sprite.sprite_frames.has_animation(mapping_name):
|
||||||
|
animated_sprite.play(mapping_name)
|
||||||
|
# scale down if the frame is too big
|
||||||
|
var frame_size = animated_sprite.sprite_frames.get_frame_texture(mapping_name, 0).get_size()
|
||||||
|
if frame_size.x > 128 or frame_size.y > 128:
|
||||||
|
var ratio = min(128 / frame_size.x, 128 / frame_size.y)
|
||||||
|
animated_sprite.scale = Vector2(ratio, ratio)
|
||||||
|
reload_lock.unlock()
|
||||||
|
else:
|
||||||
|
reload_frames()
|
||||||
|
|
||||||
|
|
||||||
func reload_frames():
|
func reload_frames():
|
||||||
# 暂不启用,使用手动调整
|
# 暂不启用,使用手动调整
|
||||||
# return
|
# return
|
||||||
@ -67,28 +80,9 @@ func reload_frames():
|
|||||||
var frame_texture = load(frame_path) as Texture2D
|
var frame_texture = load(frame_path) as Texture2D
|
||||||
sprite_frames.add_frame(mapping_name, frame_texture)
|
sprite_frames.add_frame(mapping_name, frame_texture)
|
||||||
sprite_frames.set_animation_speed(mapping_name, frames_per_sec)
|
sprite_frames.set_animation_speed(mapping_name, frames_per_sec)
|
||||||
# mirror the frame
|
|
||||||
if mirror_mapping != "":
|
|
||||||
# mkdir the mirror mapping
|
|
||||||
var mirror_dir_path = "res://asset/art/animation/" + mirror_mapping
|
|
||||||
if !DirAccess.dir_exists_absolute(mirror_dir_path):
|
|
||||||
DirAccess.make_dir_absolute(mirror_dir_path)
|
|
||||||
var mirrored_frame = frame_texture.duplicate() as Texture2D
|
|
||||||
var flipped_image = mirrored_frame.get_image() as Image
|
|
||||||
flipped_image.flip_x()
|
|
||||||
var flipped_img_path = mirror_dir_path + "/" + id + ".png"
|
|
||||||
flipped_image.resource_path = flipped_img_path
|
|
||||||
flipped_image.save_png(flipped_img_path)
|
|
||||||
sprite_frames.add_frame(mirror_mapping, load(flipped_img_path))
|
|
||||||
sprite_frames.set_animation_speed(mapping_name, frames_per_sec)
|
|
||||||
animated_sprite.play(mapping_name)
|
|
||||||
# scale down if the frame is too big
|
|
||||||
var frame_size = sprite_frames.get_frame_texture(mapping_name, 0).get_size()
|
|
||||||
if frame_size.x > 128 or frame_size.y > 128:
|
|
||||||
var ratio = min(128 / frame_size.x, 128 / frame_size.y)
|
|
||||||
animated_sprite.scale = Vector2(ratio, ratio)
|
|
||||||
reload_lock.unlock()
|
|
||||||
_save_and_update_frames_and_config()
|
_save_and_update_frames_and_config()
|
||||||
|
if mapping_name and animated_sprite.sprite_frames.has_animation(mapping_name):
|
||||||
|
display_frames()
|
||||||
|
|
||||||
|
|
||||||
func _on_mapping_submitted(new_text: String):
|
func _on_mapping_submitted(new_text: String):
|
||||||
@ -133,11 +127,37 @@ func _on_mirror_mapping_submitted(new_text: String):
|
|||||||
sprite_frames.remove_animation(mirror_mapping)
|
sprite_frames.remove_animation(mirror_mapping)
|
||||||
mirror_mapping = new_text
|
mirror_mapping = new_text
|
||||||
frames_config.data.mirror_mapping[frame_dir_name] = mirror_mapping
|
frames_config.data.mirror_mapping[frame_dir_name] = mirror_mapping
|
||||||
reload_frames()
|
_create_mirror()
|
||||||
mirror_mapping_edit.release_focus()
|
mirror_mapping_edit.release_focus()
|
||||||
_save_and_update_frames_and_config()
|
_save_and_update_frames_and_config()
|
||||||
|
|
||||||
|
|
||||||
|
func _create_mirror():
|
||||||
|
if not mirror_mapping:
|
||||||
|
return
|
||||||
|
var mirror_dir_path = "res://asset/art/animation/" + mirror_mapping
|
||||||
|
if !DirAccess.dir_exists_absolute(mirror_dir_path):
|
||||||
|
DirAccess.make_dir_absolute(mirror_dir_path)
|
||||||
|
else:
|
||||||
|
DirAccess.remove_absolute(mirror_dir_path)
|
||||||
|
DirAccess.make_dir_absolute(mirror_dir_path)
|
||||||
|
var sprite_frames = animated_sprite.sprite_frames as SpriteFrames
|
||||||
|
# {"path": "", "frames": {}, "ids": []}
|
||||||
|
var frames_data = frames_config.data.dirs[frame_dir_name]
|
||||||
|
for id in frames_data.ids:
|
||||||
|
var frame_path = frames_data.frames[id] as String
|
||||||
|
var frame_texture = load(frame_path) as Texture2D
|
||||||
|
# mkdir the mirror mapping
|
||||||
|
var mirrored_frame = frame_texture.duplicate() as Texture2D
|
||||||
|
var flipped_image = mirrored_frame.get_image() as Image
|
||||||
|
flipped_image.flip_x()
|
||||||
|
var flipped_img_path = mirror_dir_path + "/" + id + ".png"
|
||||||
|
flipped_image.resource_path = flipped_img_path
|
||||||
|
flipped_image.save_png(flipped_img_path)
|
||||||
|
sprite_frames.add_frame(mirror_mapping, load(flipped_img_path))
|
||||||
|
sprite_frames.set_animation_speed(mapping_name, frames_per_sec)
|
||||||
|
|
||||||
|
|
||||||
func _save_and_update_frames_and_config():
|
func _save_and_update_frames_and_config():
|
||||||
# save the sprite_frames
|
# save the sprite_frames
|
||||||
if animated_sprite:
|
if animated_sprite:
|
||||||
|
@ -76,6 +76,17 @@ enabled=PackedStringArray("res://addons/debug_menu/plugin.cfg", "res://addons/di
|
|||||||
theme/custom="res://config/default_theme.tres"
|
theme/custom="res://config/default_theme.tres"
|
||||||
theme/custom_font="res://asset/font/zpix-commercial-one-grand.ttf"
|
theme/custom_font="res://asset/font/zpix-commercial-one-grand.ttf"
|
||||||
|
|
||||||
|
[importer_defaults]
|
||||||
|
|
||||||
|
gif.animated.texture.plugin={
|
||||||
|
"Filter": false,
|
||||||
|
"MipMaps": false
|
||||||
|
}
|
||||||
|
import_gif_to_animated_texture={}
|
||||||
|
import_gif_to_sprite_frames={
|
||||||
|
"frames_per_second": 30
|
||||||
|
}
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
save={
|
save={
|
||||||
|