From: Eduardo Date: Tue, 25 Jun 2024 17:01:44 +0000 (+0200) Subject: added nice containers for assets X-Git-Url: http://git.edufdez.es/?a=commitdiff_plain;h=d4c7f31d227fdab85636a0557c5aa9c65ffc937f;p=local-picrew.git added nice containers for assets --- diff --git a/scripts/interface.gd b/scripts/interface.gd index d13759e..7860721 100644 --- a/scripts/interface.gd +++ b/scripts/interface.gd @@ -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 index 0000000..90b10e3 --- /dev/null +++ b/ui/square_line_flat.svg @@ -0,0 +1,47 @@ + + + + + + + + + diff --git a/ui/square_line_flat.svg.import b/ui/square_line_flat.svg.import new file mode 100644 index 0000000..7ea43f6 --- /dev/null +++ b/ui/square_line_flat.svg.import @@ -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