]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Modules/Character/DialogicPortraitAnimationsUtil.gd
Initial Godot project with Dialogic 2.0-Alpha-17
[wolf-seeking-sheep.git] / addons / dialogic / Modules / Character / DialogicPortraitAnimationsUtil.gd
1 @tool
2 class_name DialogicPortraitAnimationUtil
3
4 enum AnimationType {ALL=-1, IN=1, OUT=2, ACTION=3, CROSSFADE=4}
5
6
7 static func guess_animation(string:String, type := AnimationType.ALL) -> String:
8         var default := {}
9         var filter := {}
10         var ignores := []
11         match type:
12                 AnimationType.ALL:
13                         pass
14                 AnimationType.IN:
15                         filter = {"type":AnimationType.IN}
16                         ignores = ["in"]
17                 AnimationType.OUT:
18                         filter = {"type":AnimationType.OUT}
19                         ignores = ["out"]
20                 AnimationType.ACTION:
21                         filter = {"type":AnimationType.ACTION}
22                 AnimationType.CROSSFADE:
23                         filter = {"type":AnimationType.CROSSFADE}
24                         ignores = ["cross"]
25         return DialogicResourceUtil.guess_special_resource(&"PortraitAnimation", string, default, filter, ignores).get("path", "")
26
27
28 static func get_portrait_animations_filtered(type := AnimationType.ALL) -> Dictionary:
29         var filter := {"type":type}
30         if type == AnimationType.ALL:
31                 filter["type"] = [AnimationType.IN, AnimationType.OUT, AnimationType.ACTION]
32         return DialogicResourceUtil.list_special_resources("PortraitAnimation", filter)
33
34
35 static func get_suggestions(_search_text := "", current_value:= "", empty_text := "Default", action := AnimationType.ALL) -> Dictionary:
36         var suggestions := {}
37
38         if empty_text and current_value:
39                 suggestions[empty_text] = {'value':"", 'editor_icon':["GuiRadioUnchecked", "EditorIcons"]}
40
41         for anim_name in get_portrait_animations_filtered(action):
42                 suggestions[DialogicUtil.pretty_name(anim_name)] = {
43                         'value'                 : DialogicUtil.pretty_name(anim_name),
44                         'editor_icon'   : ["Animation", "EditorIcons"]
45                         }
46
47         return suggestions