func _ready():
_on_section_list(Globals.sections)
+ _on_section_content(Globals.sections)
#endregion
#region signal callbacks
+#endregion
+
+#region initial content drawing
+
+
func _on_section_list(sections: Array[Globals.Section]):
# TODO: remove: debug only
for child in sections_tabs.get_children():
sections_tabs.add_child(container)
+func _on_section_content(sections: Array[Globals.Section]):
+ for section in sections:
+ for file_path in section.image_paths:
+ var file_name := file_path.split("/")[-1]
+ var miniature_file_path := file_path.trim_suffix(file_name) + ".thumb/" + file_name
+
+ var texture_button := TextureButton.new()
+ texture_button.set_meta("file_path", file_path)
+ texture_button.stretch_mode = TextureButton.StretchMode.STRETCH_KEEP_ASPECT
+ texture_button.ignore_texture_size = true
+ texture_button.custom_minimum_size = Vector2(100, 100)
+
+ var image = Image.load_from_file(miniature_file_path)
+ var texture = ImageTexture.create_from_image(image)
+ texture_button.texture_normal = texture
+
+ for child in sections_tabs.get_children():
+ if child.name == section.name:
+ child.add_child(texture_button)
+
+
#endregion
class Section:
var name: String
+ var color_placeholder: Color
var colors: Array[Color]
var image_paths: Array[String]
#region utils
-func get_section_index(section_name: String):
+func get_section_index(section_name: String) -> int:
for section in sections:
if section.name == section_name:
return sections.find(section)
-
+
+ return -1
#endregion
for section in Globals.sections:
load_options(section.name)
+ load_colors(section.name)
var new_scene = load("res://scenes/interface.tscn")
var timer = Timer.new()
Globals.files_to_process.append(file_path)
-func load_colors():
- pass
+func load_colors(section: String):
+ var dir := DirAccess.open("./assets/" + section)
+ if not dir.file_exists("config.txt"):
+ return
+
+ var s_index: int = Globals.get_section_index(section)
+
+ var config = ConfigFile.new()
+ var err = config.load("./assets/" + section + "/config.txt")
+
+ if not err == OK:
+ print(err)
+ return
+
+ if config.get_value("", "color_placeholder") is String:
+ var color_placeholder: Color = config.get_value("", "color_placeholder")
+ Globals.sections[s_index].color_placeholder = color_placeholder
+
+ if config.get_value("", "colors") is Array:
+ var colors = config.get_value("", "colors") as Array[Color]
+ Globals.sections[s_index].colors.append_array(colors)