starting work to populate miniatures
authorEduardo Fernandez <[email protected]>
Sat, 22 Jun 2024 00:35:09 +0000 (02:35 +0200)
committerEduardo Fernandez <[email protected]>
Sat, 22 Jun 2024 00:35:09 +0000 (02:35 +0200)
scenes/interface.gd
scripts/globals.gd
scripts/splash_screen.gd

index 1d493e2cf585a9d41877139b1308a58a4a7e5d36..50e1ae812dddf1feee6fdb9f97d8537a8be44902 100644 (file)
@@ -40,6 +40,7 @@ func _init():
 
 func _ready():
        _on_section_list(Globals.sections)
+       _on_section_content(Globals.sections)
 
 
 #endregion
@@ -210,6 +211,11 @@ func add_timer_with_timeout(function: Callable, seconds: float = 2):
 #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():
@@ -223,4 +229,25 @@ func _on_section_list(sections: Array[Globals.Section]):
                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
index 071758d32e3fc8f40fdc4fad86d1ff012e1868a1..e18f1c1619cdc25185b519bcbf2b7f59d115b00e 100644 (file)
@@ -3,6 +3,7 @@ extends Node
 
 class Section:
        var name: String
+       var color_placeholder: Color
        var colors: Array[Color]
        var image_paths: Array[String]
 
@@ -75,10 +76,11 @@ func _load_texture(image_file_path: 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
index ff75821dcd2bad2d6cc891397bb9c0835b9aefcb..3bf20f09dc69d9a65dd4436736e530bddeaa3412 100644 (file)
@@ -60,6 +60,7 @@ func _ready():
        
        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()
@@ -124,5 +125,24 @@ func load_options(section: String):
                        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)