2 class_name DialogicIndexer
5 ## Script that indexes events, subsystems, settings pages and more. [br]
6 ## Place a script of this type in every folder in "addons/Events". [br]
7 ## Overwrite the methods to return the contents of that folder.
10 var this_folder: String = get_script().resource_path.get_base_dir()
12 ## Overwrite if this module contains any events. [br]
13 ## Return an array with all the paths to the event scripts.[br]
14 ## You can use the [property this_folder].path_join('my_event.gd')
15 func _get_events() -> Array:
16 if ResourceLoader.exists(this_folder.path_join('event.gd')):
17 return [this_folder.path_join('event.gd')]
21 ## Overwrite if this module contains any subsystems.
22 ## Should return an array of dictionaries each with the following keys: [br]
23 ## "name" -> name for this subsystem[br]
24 ## "script" -> array of preview images[br]
25 func _get_subsystems() -> Array[Dictionary]:
29 func _get_editors() -> Array[String]:
33 func _get_settings_pages() -> Array:
37 func _get_character_editor_sections() -> Array:
41 #region TEXT EFFECTS & MODIFIERS
43 ## Should return array of dictionaries with the following keys:[br]
44 ## "command" -> the text e.g. "speed"[br]
45 ## "node_path" or "subsystem" -> whichever contains your effect method[br]
46 ## "method" -> name of the effect method[br]
47 func _get_text_effects() -> Array[Dictionary]:
51 ## Should return array of dictionaries with the same arguments as _get_text_effects()
52 func _get_text_modifiers() -> Array[Dictionary]:
58 ## Return a list of resources, scripts, etc.
59 ## These can later be retrieved with DialogicResourceUtil.
60 ## Each dictionary should contain (at least "type" and "path").
61 ## E.g. {"type":"Animation", "path": "res://..."}
62 func _get_special_resources() -> Dictionary:
66 ## Return a list of dictionaries, each
67 func _get_portrait_scene_presets() -> Array[Dictionary]:
72 ################################################################################
74 func list_dir(subdir:='') -> Array:
75 return Array(DirAccess.get_files_at(this_folder.path_join(subdir))).map(func(file):return this_folder.path_join(subdir).path_join(file))
78 func list_special_resources(subdir:='', extension:="") -> Dictionary:
80 for i in list_dir(subdir):
81 if extension.is_empty() or i.ends_with(extension):
82 dict[DialogicUtil.pretty_name(i).to_lower()] = {"path":i}
86 func list_animations(subdir := "") -> Dictionary:
87 var full_animation_list := {}
88 for path in list_dir(subdir):
89 if not path.ends_with(".gd") and not path.ends_with(".gdc"):
91 var anim_object: DialogicAnimation = load(path).new()
92 var versions := anim_object._get_named_variations()
93 for version_name in versions:
94 full_animation_list[version_name] = versions[version_name]
95 full_animation_list[version_name]["path"] = path
96 anim_object.queue_free()
97 return full_animation_list
102 #region STYLES & LAYOUTS
103 ################################################################################
105 func _get_style_presets() -> Array[Dictionary]:
109 ## Should return an array of dictionaries with the following keys:[br]
110 ## "path" -> the path to the scene[br]
111 ## "name" -> name for this layout[br]
112 ## "description"-> description of this layout. list what features/events are supported[br]
113 ## "preview_image"-> array of preview images[br]
114 func _get_layout_parts() -> Array[Dictionary]:
118 ## Helper that allows scanning sub directories that might be layout parts or styles
119 func scan_for_layout_parts() -> Array[Dictionary]:
120 var dir := DirAccess.open(this_folder)
121 var style_list: Array[Dictionary] = []
125 var dir_name := dir.get_next()
126 while dir_name != "":
127 if !dir.current_is_dir() or !dir.file_exists(dir_name.path_join('part_config.cfg')):
128 dir_name = dir.get_next()
130 var config := ConfigFile.new()
131 config.load(this_folder.path_join(dir_name).path_join('part_config.cfg'))
132 var default_image_path: String = this_folder.path_join(dir_name).path_join('preview.png')
135 'type': config.get_value('style', 'type', 'Unknown type'),
136 'name': config.get_value('style', 'name', 'Unnamed Layout'),
137 'path': this_folder.path_join(dir_name).path_join(config.get_value('style', 'scene', '')),
138 'author': config.get_value('style', 'author', 'Anonymous'),
139 'description': config.get_value('style', 'description', 'No description'),
140 'preview_image': [config.get_value('style', 'image', default_image_path)],
141 'style_path':config.get_value('style', 'style_path', ''),
142 'icon':this_folder.path_join(dir_name).path_join(config.get_value('style', 'icon', '')),
145 if not style_list[-1].style_path.begins_with('res://'):
146 style_list[-1].style_path = this_folder.path_join(dir_name).path_join(style_list[-1].style_path)
148 dir_name = dir.get_next()