Skip to content

Commit

Permalink
[*] Update snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
IceflowRE committed Jan 12, 2024
1 parent 2610c85 commit 1174675
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 78 deletions.
9 changes: 2 additions & 7 deletions addons/icon_explorer/internal/scripts/collection.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends RefCounted

const Io := preload("res://addons/icon_explorer/internal/scripts/io.gd")
const Io := preload("res://addons/icon_explorer/internal/scripts/tools/io.gd")
const Icon := preload("res://addons/icon_explorer/internal/scripts/icon.gd")

# target svg texture size
Expand All @@ -24,15 +24,10 @@ var svg_size: float

# is set on registering it at the IconDatabase
var _id: int = -1
# set value on installing from 0 - 100
var _install_progress: float

func id() -> int:
return self._id

func install_progress() -> float:
return self._install_progress

func is_installed() -> bool:
return DirAccess.dir_exists_absolute(self.icon_directory())

Expand Down Expand Up @@ -61,7 +56,7 @@ func icon_directory() -> String:
return ""

func directory() -> String:
if Engine.is_editor_hint() || true: # TODO: remove development true
if Engine.is_editor_hint() || true:
if ProjectSettings.get_setting("application/config/use_hidden_project_data_directory", true):
return "res://.godot/cache/icon_explorer".path_join(self.directory_name())
else:
Expand Down
10 changes: 5 additions & 5 deletions addons/icon_explorer/internal/scripts/database.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var _icons: Array[Icon] = []

## used to await next frame on texture loading
var _scene_tree: SceneTree
## no mutex required as loading is suspended while main thread runs
## as this progress is exclusively used in loading the textures
var _load_progress: float
var _processing_thread: Thread

Expand Down Expand Up @@ -118,20 +120,19 @@ func load() -> void:

# thread function
func _load() -> void:
var icons: Array[Icon] = []
var loaded_icons: Array[Icon] = []
var buffers: PackedStringArray = PackedStringArray()
self._load_progress = 0.0
for idx: int in range(self._collections.size()):
var coll: Collection = self._collections[idx]
if !self._loaded_collections.has(coll.id()) && coll.is_installed():
var start_time: float = Time.get_unix_time_from_system()
var res: Array = coll.load()
icons.append_array(res[0])
loaded_icons.append_array(res[0])
buffers.append_array(res[1])
print(coll.name, " loaded in: ", "%.1f" % (Time.get_unix_time_from_system() - start_time), "s")
self._loaded_collections.append(coll.id())
#self._load_progress = float(idx + 1) / self._collections.size() * 50.0
self._load_done.bind(icons, buffers).call_deferred()
self._load_done.bind(loaded_icons, buffers).call_deferred()

func _load_done(icons: Array[Icon], buffers: PackedStringArray) -> void:
var start_time: float = Time.get_unix_time_from_system()
Expand All @@ -144,7 +145,6 @@ func _load_done(icons: Array[Icon], buffers: PackedStringArray) -> void:
print("load textures in: ", "%.1f" % (Time.get_unix_time_from_system() - start_time), "s")
self.loaded.emit()


static func _load_texture(icon: Icon, buffer: String) -> void:
var img: Image = Image.new()
# scale texture to 128
Expand Down
File renamed without changes.
38 changes: 13 additions & 25 deletions addons/icon_explorer/internal/scripts/tools/zip_unpacker.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
extends RefCounted

var _progress: float

var _zip_path: String
var _output_path: String
var _unpack_only: PackedStringArray
Expand All @@ -12,9 +10,6 @@ func _init(zip_path: String, output_path: String, unpack_only: PackedStringArray
self._output_path = output_path
self._unpack_only = unpack_only

func progress() -> float:
return self._progress

func _has_filter() -> bool:
return self._unpack_only.size() != 0

Expand All @@ -26,40 +21,27 @@ func _is_in_filter(path: String) -> bool:
return true
return false

func _pre_unpack() -> bool:
for path: String in self._unpack_only:
var res: Error = DirAccess.make_dir_recursive_absolute(self._output_path.path_join(path.get_base_dir()))
if res != Error.OK:
return false
return true

func unpack() -> bool:
var start_time: int = Time.get_ticks_msec()
var reader := ZIPReader.new()
var err: Error = reader.open(self._zip_path)
if err != Error.OK:
return false

if !self._pre_unpack():
if !self._create_directories(reader.get_files()):
return Error.FAILED
var files: PackedStringArray = reader.get_files()
for idx: int in range(files.size()):
var path: String = files[idx]
if !self._is_in_filter(path):
continue
if !self._has_filter() && path.ends_with("/"):
var res: Error = DirAccess.make_dir_recursive_absolute(self._output_path.path_join(path))
if res != Error.OK:
return Error.FAILED
var buffer: PackedByteArray = reader.read_file(path)
var file: FileAccess = FileAccess.open(self._output_path.path_join(path), FileAccess.WRITE)
if file == null:
reader.close()
self._progress = 100.0
return false
file.store_buffer(buffer)
file = null
self._progress = float(idx) / files.size() * 100.0
reader.close()
print("unpacked (ST) in: ", Time.get_ticks_msec() - start_time, "ms")
return true
Expand All @@ -76,12 +58,8 @@ func unpack_mt(thread_count: int) -> bool:
if err != Error.OK:
return false

if !self._pre_unpack():
if !self._create_directories(reader.get_files()):
return Error.FAILED
if !self._has_filter():
for path: String in reader.get_files():
if path.ends_with("/"):
DirAccess.make_dir_recursive_absolute(self._output_path.path_join(path))
var file_count: int = reader.get_files().size()
reader.close()

Expand All @@ -96,7 +74,17 @@ func unpack_mt(thread_count: int) -> bool:
thread.wait_to_finish()
print("unpacked (MT) in: ", Time.get_ticks_msec() - start_time, "ms")
return true


func _create_directories(paths: PackedStringArray) -> bool:
var created: Dictionary = {}
for path: String in paths:
var dir_path: String = path.get_base_dir()
if (!self._has_filter() || self._is_in_filter(path)) && !(dir_path in created):
if DirAccess.make_dir_recursive_absolute(self._output_path.path_join(path.get_base_dir())) != Error.OK:
return false
created[dir_path] = null
return true

func _unpack_fn(from: int, to: int) -> void:
var reader := ZIPReader.new()
var err: Error = reader.open(self._zip_path)
Expand Down
2 changes: 2 additions & 0 deletions addons/icon_explorer/internal/ui/detail_panel/bootstrap.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ _version_added_path = NodePath("version_added")
[node name="categories" parent="." instance=ExtResource("2_n1r08")]
layout_mode = 2
title = "Categories"
items = []

[node name="aliases" parent="." instance=ExtResource("2_n1r08")]
layout_mode = 2
title = "Aliases"
items = []

[node name="version_added" parent="." instance=ExtResource("3_5y6bb")]
layout_mode = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ theme_override_constants/separation = 0

[node name="size" type="Label" parent="detail_container/panel_container2/v_box_container"]
layout_mode = 2
text = "16x1600000"

[node name="preview" type="PanelContainer" parent="detail_container/panel_container2/v_box_container"]
layout_mode = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ title = "Style"
[node name="aliases" parent="." instance=ExtResource("3_fm2h0")]
layout_mode = 2
title = "Aliases"
items = []
4 changes: 2 additions & 2 deletions addons/icon_explorer/internal/ui/detail_panel/simple_icons.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ func display(icon: IconSimpleIcons) -> void:
self._color_panel.color = icon.hex
self._color_label.text = "#" + icon.hex.to_html(false).to_upper()
if (icon.hex.r * 0.299 + icon.hex.g * 0.587 + icon.hex.b * 0.114) > 186.0 / 255.0:
self._color_label.add_theme_color_override("font_color", Color.BLACK)
self._color_label.add_theme_color_override(&"font_color", Color.BLACK)
else:
self._color_label.add_theme_color_override("font_color", Color.WHITE)
self._color_label.add_theme_color_override(&"font_color", Color.WHITE)

self._aliases.set_items(icon.aliases)
self._guidelines.text = icon.guidelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ custom_minimum_size = Vector2(0, 32)
layout_mode = 2
tooltip_text = "Click to copy!"
focus_mode = 2
mouse_default_cursor_shape = 2

[node name="color" type="Label" parent="margin_container"]
layout_mode = 2
Expand All @@ -39,6 +40,7 @@ horizontal_alignment = 1
[node name="aliases" parent="." instance=ExtResource("2_vc8om")]
layout_mode = 2
title = "Aliases"
items = []

[node name="guidelines" parent="." instance=ExtResource("2_64an6")]
layout_mode = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func set_uri(new_uri: String) -> void:
self._button.visible = new_uri != ""

func _ready() -> void:
self._button.icon = self.get_theme_icon("ExternalLink", "EditorIcons")
self._button.icon = self.get_theme_icon(&"ExternalLink", &"EditorIcons")
self._button.pressed.connect(self._on_pressed)
self.title = self.title
self.text = self.text
Expand Down
2 changes: 1 addition & 1 deletion addons/icon_explorer/internal/ui/detail_panel/toolbar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ signal save_pressed()
@export var _save_button: Button

func _ready() -> void:
self._save_button.icon = self.get_theme_icon("Save", "EditorIcons")
self._save_button.icon = self.get_theme_icon(&"Save", &"EditorIcons")
self._save_button.pressed.connect(self._on_save_button_pressed)

func _on_save_button_pressed() -> void:
Expand Down
14 changes: 3 additions & 11 deletions addons/icon_explorer/internal/ui/explorer/explorer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func _ready() -> void:
self._update_timer.timeout.connect(self.update)
self.add_child(self._update_timer, true)
self.get_viewport().gui_embed_subwindows = false
self._filter_icon.texture = self.get_theme_icon("Search", "EditorIcons")
self._filter_options.icon = self.get_theme_icon("AnimationFilter", "EditorIcons")
self._filter_icon.texture = self.get_theme_icon(&"Search", &"EditorIcons")
self._filter_options.icon = self.get_theme_icon(&"AnimationFilter", &"EditorIcons")
self._filter_options.options_changed.connect(self.update)
self._icon_list.item_selected.connect(self._on_icon_selected)
self._filter.text_changed.connect(self._on_filter_changed)
Expand All @@ -48,7 +48,7 @@ func _ready() -> void:
self._detail_panel.preview_color = self._preview_color.color
self._detail_panel.preview_size = int(pow(2.0, self._preview_size.value))

self._options_button.icon = self.get_theme_icon("Tools", "EditorIcons")
self._options_button.icon = self.get_theme_icon(&"Tools", &"EditorIcons")
self._options_button.pressed.connect(self._on_option_pressed)

self._db = IconDatabase.new(self.get_tree())
Expand Down Expand Up @@ -105,14 +105,6 @@ func update() -> void:
self._icon_list.set_item_metadata(idx, icon)
self._icon_list.set_item_icon_modulate(idx, color)

func _gen_progress_texture() -> AnimatedTexture:
var anim: AnimatedTexture = AnimatedTexture.new()
anim.frames = 8
for idx: int in range(8):
anim.set_frame_texture(idx, self.get_theme_icon("Progress"+str(idx + 1), "EditorIcons"))
anim.set_frame_duration(idx, 0.2)
return anim

func _on_database_changed(_id: Collection.Id, status: Error) -> void:
if status == Error.OK:
self.update()
Expand Down
16 changes: 9 additions & 7 deletions addons/icon_explorer/internal/ui/explorer/explorer.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[gd_scene load_steps=7 format=3 uid="uid://dnxwdqwt2eqfi"]
[gd_scene load_steps=8 format=3 uid="uid://dnxwdqwt2eqfi"]

[ext_resource type="Script" path="res://addons/icon_explorer/internal/ui/explorer/explorer.gd" id="1_2oqmk"]
[ext_resource type="Script" path="res://addons/icon_explorer/internal/ui/explorer/explorer_root.gd" id="1_sb5ho"]
[ext_resource type="Script" path="res://addons/icon_explorer/internal/ui/explorer/filter_options.gd" id="2_dkuya"]
[ext_resource type="PackedScene" uid="uid://c3s1t8hiu6xll" path="res://addons/icon_explorer/internal/ui/detail_panel/detail_panel.tscn" id="3_w4j77"]
[ext_resource type="Script" path="res://addons/icon_explorer/internal/ui/explorer/option_popup.gd" id="4_03l1v"]
Expand All @@ -14,6 +15,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_sb5ho")

[node name="explorer" type="MarginContainer" parent="."]
layout_mode = 2
Expand Down Expand Up @@ -93,12 +95,6 @@ size_flags_stretch_ratio = 0.34
[node name="preview_options" type="HBoxContainer" parent="explorer/icon_viewer/HSplitContainer/v_box_container"]
layout_mode = 2

[node name="preview_color" type="ColorPickerButton" parent="explorer/icon_viewer/HSplitContainer/v_box_container/preview_options"]
custom_minimum_size = Vector2(32, 24)
layout_mode = 2
color = Color(1, 1, 1, 1)
edit_alpha = false

[node name="preview_size" type="HSlider" parent="explorer/icon_viewer/HSplitContainer/v_box_container/preview_options"]
layout_mode = 2
size_flags_horizontal = 3
Expand All @@ -107,6 +103,12 @@ min_value = 4.0
max_value = 8.0
value = 6.0

[node name="preview_color" type="ColorPickerButton" parent="explorer/icon_viewer/HSplitContainer/v_box_container/preview_options"]
custom_minimum_size = Vector2(32, 24)
layout_mode = 2
color = Color(1, 1, 1, 1)
edit_alpha = false

[node name="detail_panel" parent="explorer/icon_viewer/HSplitContainer/v_box_container" instance=ExtResource("3_w4j77")]
layout_mode = 2
size_flags_stretch_ratio = 0.34
Expand Down
5 changes: 5 additions & 0 deletions addons/icon_explorer/internal/ui/explorer/explorer_root.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends PanelContainer

func _ready():
if Engine.is_editor_hint():
self.add_theme_stylebox_override(&"panel", self.get_theme_stylebox(&"panel", &"PopupPanel"))
1 change: 0 additions & 1 deletion addons/icon_explorer/internal/ui/explorer_dialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ func _notification(what: int) -> void:
self.hide()

func _on_about_to_popup() -> void:
print(ProjectSettings.get_setting("plugins/icon_explorer/load_on_startup", false))
if !self._already_loaded && Engine.is_editor_hint() && !ProjectSettings.get_setting("plugins/icon_explorer/load_on_startup", false):
self._explorer._db.load()
self._already_loaded = true
8 changes: 7 additions & 1 deletion addons/icon_explorer/internal/ui/explorer_dialog.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ disable_3d = true
title = "Icon Explorer"
position = Vector2i(210, 133)
size = Vector2i(1920, 1080)
visible = false
wrap_controls = true
transient = true
script = ExtResource("1_yupxp")
_explorer_path = NodePath("explorer")

[node name="panel" type="Panel" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="explorer" parent="." instance=ExtResource("2_3tinl")]

[connection signal="about_to_popup" from="." to="." method="_on_about_to_popup"]
Loading

0 comments on commit 1174675

Please sign in to comment.