added nice containers for assets
authorEduardo <[email protected]>
Tue, 25 Jun 2024 17:01:44 +0000 (19:01 +0200)
committerEduardo <[email protected]>
Tue, 25 Jun 2024 17:01:44 +0000 (19:01 +0200)
scripts/interface.gd
ui/square_line_flat.svg [new file with mode: 0644]
ui/square_line_flat.svg.import [new file with mode: 0644]

index d13759eec2de2cffc804dacd09e093e7a4caae5c..78607216b7b4cac394728ea58da1c68e8466f98b 100644 (file)
@@ -231,24 +231,38 @@ func _on_section_list(sections: Array[Globals.Section]):
 
 
 func _on_section_content(sections: Array[Globals.Section]):
+       const ASSET_CONTAINER_SIZE = Vector2(100, 100)
+       const ASSET_MIN_SIZE = Vector2(50, 50)
+       const ASSET_MARGIN = 8
+       
        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_rect := TextureRect.new()
+                       texture_rect.stretch_mode = TextureRect.StretchMode.STRETCH_KEEP_ASPECT_CENTERED
+                       texture_rect.ignore_texture_size = true
+                       texture_rect.texture = load("res://ui/square_line_flat.svg")
+                       texture_rect.custom_minimum_size = ASSET_CONTAINER_SIZE
+                       texture_rect.set_meta("file_path", file_path)
+                       
                        var texture_button := TextureButton.new()
                        texture_button.set_meta("file_path", file_path)
                        texture_button.stretch_mode = TextureButton.StretchMode.STRETCH_KEEP_ASPECT_CENTERED
+                       texture_button.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT, Control.PRESET_MODE_KEEP_SIZE, ASSET_MARGIN)
                        texture_button.ignore_texture_size = true
-                       texture_button.custom_minimum_size = Vector2(100, 100)
+                       texture_button.custom_minimum_size = ASSET_MIN_SIZE
 
                        var image = Image.load_from_file(miniature_file_path)
                        var texture = ImageTexture.create_from_image(image)
                        texture_button.texture_normal = texture
                        
+                       texture_rect.add_child(texture_button)
+                       
                        for child in sections_tabs.get_children():
                                if child.name == section.name:
-                                       child.add_child(texture_button)
+                                       child.add_child(texture_rect)
 
 
 #endregion
diff --git a/ui/square_line_flat.svg b/ui/square_line_flat.svg
new file mode 100644 (file)
index 0000000..90b10e3
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   width="64"
+   height="64"
+   version="1.1"
+   id="svg3"
+   sodipodi:docname="square_line_flat.svg"
+   inkscape:version="1.3.2 (091e20ef0f, 2023-11-25)"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:svg="http://www.w3.org/2000/svg">
+  <sodipodi:namedview
+     id="namedview3"
+     pagecolor="#505050"
+     bordercolor="#ffffff"
+     borderopacity="1"
+     inkscape:showpageshadow="0"
+     inkscape:pageopacity="0"
+     inkscape:pagecheckerboard="1"
+     inkscape:deskcolor="#505050"
+     inkscape:zoom="9.1015625"
+     inkscape:cx="-6.1527897"
+     inkscape:cy="29.720172"
+     inkscape:window-width="2560"
+     inkscape:window-height="1371"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="g3" />
+  <defs
+     id="defs1" />
+  <g
+     id="g3">
+    <path
+       stroke="none"
+       fill="#9696A3"
+       d="M62 6 L61.95 5.05 Q61.5 2 58 2 L6 2 Q2.5 2 2.1 5.05 L2 6 2 58 Q2 62 6 62 L58 62 Q62 62 62 58 L62 6 M0 58.25 L0 6 Q0 0 6 0 L58 0 Q64 0 64 6 L64 58.25 Q63.85 64 58 64 L6 64 Q0.15 64 0 58.25"
+       id="path1" />
+    <path
+       stroke="none"
+       fill="#ffffff"
+       d="m 62,6 v 52 c 0,2.666667 -1.333333,4 -4,4 H 6 C 3.3333333,62 2,60.666667 2,58 V 6 L 2.1,5.05 C 2.3666667,3.0166667 3.6666667,2 6,2 h 52 c 2.333333,0 3.65,1.0166667 3.95,3.05 L 62,6 M 3.4697425,3.4969957 60.217167,3.2832618 60.876824,60.009871 C 60.2878,60.038801 3.5083691,60.512876 3.5083691,60.512876 L 3.4697425,3.4969957"
+       id="path2"
+       sodipodi:nodetypes="cssssccssccccccc" />
+  </g>
+</svg>
diff --git a/ui/square_line_flat.svg.import b/ui/square_line_flat.svg.import
new file mode 100644 (file)
index 0000000..7ea43f6
--- /dev/null
@@ -0,0 +1,37 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://b60p6yw0a1sex"
+path="res://.godot/imported/square_line_flat.svg-cd41120d8b11aea6f71c31ebf47fdd95.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://ui/square_line_flat.svg"
+dest_files=["res://.godot/imported/square_line_flat.svg-cd41120d8b11aea6f71c31ebf47fdd95.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
+svg/scale=1.0
+editor/scale_with_editor_scale=false
+editor/convert_colors_with_editor_theme=false