Skip to content

Commit

Permalink
1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaifungamedev committed Nov 6, 2024
1 parent e24499f commit e9b0721
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions addons/local_assets/menu/menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var item = load("res://addons/local_assets/Components/Item/Item.tscn")
const fileExtentions = ["png", "jpeg", "jpg", "bmp", "tga", "webp", "svg"]


## Called when the node is added to the scene.
# Called when the node is added to the scene.
func _ready():
# Set up the editor settings and load assets based on the current settings.
editorSettings.settings_changed.connect(_eSettings_changed)
Expand All @@ -32,7 +32,7 @@ func _ready():
get_assets(assetPath.text)


## Updates settings from the EditorSettings object.
# Updates settings from the EditorSettings object.
func _eSettings_changed():
if editorSettings.has_setting("Local_Assets/asset_dir"):
assetPath.text = editorSettings.get_setting("Local_Assets/asset_dir")
Expand All @@ -47,7 +47,7 @@ func _eSettings_changed():
uniformImageSize = editorSettings.get_setting("Local_Assets/uniform_image_size")


## Sets up default editor settings if they are not present.
# Sets up default editor settings if they are not present.
func set_up_settings():
if !editorSettings.has_setting("Local_Assets/asset_dir"):
set_editor_setting("Local_Assets/asset_dir", "", TYPE_STRING)
Expand All @@ -65,36 +65,36 @@ func set_up_settings():
set_editor_setting("Local_Assets/uniform_image_size", Vector2i(918, 515), TYPE_VECTOR2I)


## Helper function to set an editor setting and update its type.
# Helper function to set an editor setting and update its type.
func set_editor_setting(s_name: String, value: Variant, type: Variant.Type):
editorSettings.set_setting(s_name, value)
editorSettings.add_property_info({"name": s_name, "type": type})


## Cleans up the cache when exiting the scene tree.
# Cleans up the cache when exiting the scene tree.
func _exit_tree():
if thread1.is_started():
await thread1.wait_to_finish()
DirAccess.remove_absolute(cache_path)


## Opens a file dialog to select a directory for assets.
# Opens a file dialog to select a directory for assets.
func _on_open_dir_pressed():
Files.show()
var f = await Files.dir_selected
assetPath.text = f
_on_assets_path_changed(f)


## Updates the displayed assets when the asset path changes.
# Updates the displayed assets when the asset path changes.
func _on_assets_path_changed(new_text: String):
for child in grid.get_children():
child.queue_free()
if assetFinder:
get_assets(new_text)


## Searches assets by name and tag, displaying matched items.
# Searches assets by name and tag, displaying matched items.
func search(search_string: String):
backgroundText.hide()
if search_string.is_empty():
Expand Down Expand Up @@ -231,10 +231,11 @@ func _notification(what: int) -> void:
await DirAccess.remove_absolute(cache_path)


# turns an array to a string
func array_to_string(array: Array) -> String:
var string: String
for i in array:
string += i + " "
string += str(i) + " "
return string


Expand Down
2 changes: 1 addition & 1 deletion addons/local_assets/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="local_assets"
description=""
author="kaifungamedev"
version="1.2"
version="1.3"
script="local_assets.gd"

0 comments on commit e9b0721

Please sign in to comment.