Skip to content

Commit

Permalink
[*] Update snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
IceflowRE committed Jan 13, 2024
1 parent 1174675 commit 6baca09
Show file tree
Hide file tree
Showing 31 changed files with 250 additions and 208 deletions.
6 changes: 0 additions & 6 deletions addons/icon_explorer/internal/scripts/collection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ const Icon := preload("res://addons/icon_explorer/internal/scripts/icon.gd")
# target svg texture size
const TEXTURE_SIZE: float = 128.0

enum Id {
MATERIAL_DESIGN,
SIMPLE_ICONS,
BOOTSTRAP_ICONS,
}

var name: String
var version: String
var author: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func load() -> Array:
var res_version: int = parser_version.parse(FileAccess.get_file_as_string(self.directory().path_join("icons-main/package.json")))
if res_version != OK:
push_warning("could not parse bootstrap package.json: '%s'", [parser_version.get_error_message()])
return []
return [[], PackedStringArray()]
self.version = parser_version.data["version"]

return [icons, buffers]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func load() -> Array:
var res_version: int = parser_version.parse(FileAccess.get_file_as_string(self.directory().path_join("Font-Awesome-6.x/js-packages/@fortawesome/fontawesome-free/package.json")))
if res_version != OK:
push_warning("could not parse font awesome package.json: '%s'", [parser_version.get_error_message()])
return [[], []]
return [[], PackedStringArray()]
self.version = parser_version.data["version"]

var meta_string: String = FileAccess.get_file_as_string(self.directory().path_join("Font-Awesome-6.x/metadata/icons.json"))
Expand Down Expand Up @@ -62,7 +62,6 @@ func install(http: HTTPRequest, _version: String) -> Error:
http.download_file = zip_path
var downloader: Io.FileDownloader = Io.FileDownloader.new(http)
downloader.request.bind(_DOWNLOAD_FILE).call_deferred()

downloader.wait()
if downloader.result != HTTPRequest.RESULT_SUCCESS:
return Error.FAILED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ func load() -> Array:
var res_version: int = parser_version.parse(FileAccess.get_file_as_string(self.directory().path_join("simple-icons-master/package.json")))
if res_version != OK:
push_warning("could not parse simple icons package.json: '%s'", [parser_version.get_error_message()])
return [[], []]
return [[], PackedStringArray()]
self.version = parser_version.data["version"]

var parser: JSON = JSON.new()
var res: int = parser.parse(FileAccess.get_file_as_string(self.directory().path_join("simple-icons-master/_data/simple-icons.json")))
if res != OK:
push_warning("could not parse simple icons simple-icons.json: '%s'", [parser.get_error_message()])
return [[], []]
return [[], PackedStringArray()]

var icons: Array[Icon] = []
var buffers: PackedStringArray = PackedStringArray()
Expand Down
4 changes: 2 additions & 2 deletions addons/icon_explorer/internal/scripts/collections/tabler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ func load() -> Array:
var res_version: int = parser_version.parse(FileAccess.get_file_as_string(self.directory().path_join("tabler-icons-master/package.json")))
if res_version != OK:
push_warning("could not parse tabler icons package.json: '%s'", [parser_version.get_error_message()])
return [[], []]
return [[], PackedStringArray()]
self.version = parser_version.data["version"]

var parser: JSON = JSON.new()
var res: int = parser.parse(FileAccess.get_file_as_string(self.directory().path_join("tabler-icons-master/tags.json")))
if res != OK:
push_warning("could not parse tabler icons tags.json: '%s'", [parser.get_error_message()])
return [[], []]
return [[], PackedStringArray()]

var icon_path: String = self.icon_directory()
var icons: Array[Icon] = []
Expand Down
22 changes: 11 additions & 11 deletions addons/icon_explorer/internal/scripts/database.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const CollectionSimpleIcons := preload("res://addons/icon_explorer/internal/scri
const CollectionTabler := preload("res://addons/icon_explorer/internal/scripts/collections/tabler.gd")
const Icon := preload("res://addons/icon_explorer/internal/scripts/icon.gd")

signal collection_installed(id: Collection.Id, status: Error)
signal collection_removed(id: Collection.Id, status: Error)
signal collection_installed(id: int, status: Error)
signal collection_removed(id: int, status: Error)
## emitted after calling load()
signal loaded()

var _loaded_collections: Array[Collection.Id] = []
var _loaded_collections: Array[int] = []
var _collections: Array[Collection] = []
var _icons: Array[Icon] = []

Expand Down Expand Up @@ -46,7 +46,7 @@ func _notification(what):
func collections() -> Array[Collection]:
return self._collections

func get_collection(id: Collection.Id) -> Collection:
func get_collection(id: int) -> Collection:
for coll: Collection in self._collections:
if coll.id() == id:
return coll
Expand Down Expand Up @@ -84,7 +84,7 @@ func _install(coll: Collection, http: HTTPRequest, version: String) -> void:
self._load()
self._install_done.bind(coll.id(), status).call_deferred()

func _install_done(id: Collection.Id, status: Error) -> void:
func _install_done(id: int, status: Error) -> void:
if self._loaded_collections.has(id):
self._icons = self._icons.filter(func (icon: Icon) -> bool: return icon.collection.id() != id)
if !self._loaded_collections.has(id):
Expand All @@ -105,7 +105,7 @@ func _remove(coll: Collection) -> void:
var status: Error = coll.remove()
self._remove_done.bind(coll.id(), status).call_deferred()

func _remove_done(id: Collection.Id, status: Error) -> void:
func _remove_done(id: int, status: Error) -> void:
self._icons = self._icons.filter(func (icon: Icon) -> bool: return icon.collection.id() != id)
self.collection_removed.emit(id, status)

Expand Down Expand Up @@ -134,14 +134,14 @@ func _load() -> void:
self._loaded_collections.append(coll.id())
self._load_done.bind(loaded_icons, buffers).call_deferred()

func _load_done(icons: Array[Icon], buffers: PackedStringArray) -> void:
func _load_done(loaded_icons: Array[Icon], buffers: PackedStringArray) -> void:
var start_time: float = Time.get_unix_time_from_system()
for idx: int in range(icons.size()):
for idx: int in range(loaded_icons.size()):
if idx % 50 == 0:
self._load_progress = float(idx + 1) / icons.size() * 100.0
self._load_progress = float(idx + 1) / loaded_icons.size() * 100.0
await self._scene_tree.process_frame
_load_texture(icons[idx], buffers[idx])
self._icons.append_array(icons)
_load_texture(loaded_icons[idx], buffers[idx])
self._icons.append_array(loaded_icons)
print("load textures in: ", "%.1f" % (Time.get_unix_time_from_system() - start_time), "s")
self.loaded.emit()

Expand Down
1 change: 1 addition & 0 deletions addons/icon_explorer/internal/scripts/tools/io.gd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## recursive remove directory
static func rrm_dir(dir_path: String) -> bool:
var dir: DirAccess = DirAccess.open(dir_path)
if !dir:
Expand Down
2 changes: 1 addition & 1 deletion addons/icon_explorer/internal/ui/detail_panel/bootstrap.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#@tool
@tool
extends VBoxContainer

const IconBootstrap := preload("res://addons/icon_explorer/internal/scripts/collections/icon_bootstrap.gd")
Expand Down
2 changes: 0 additions & 2 deletions addons/icon_explorer/internal/ui/detail_panel/bootstrap.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ _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
37 changes: 26 additions & 11 deletions addons/icon_explorer/internal/ui/detail_panel/detail_panel.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#@tool
extends Control
@tool
extends PanelContainer

const Toolbar := preload("res://addons/icon_explorer/internal/ui/detail_panel/toolbar.gd")

Expand All @@ -8,16 +8,20 @@ const Icon := preload("res://addons/icon_explorer/internal/scripts/icon.gd")
const TextField := preload("res://addons/icon_explorer/internal/ui/detail_panel/text_field.gd")

@export var _detail_container: VBoxContainer
@export var _hint_container: PanelContainer
@export var _hint_container: CenterContainer
@export var _toolbar_path: NodePath
@onready var _toolbar: Toolbar = self.get_node(self._toolbar_path)
@export var _detail_tabs: TabContainer

@export var _icon: TextureRect
@export var _preview_background: TextureRect
@export var _preview_panel: PanelContainer
@export var _name: Label
@export var _collection: Label
@export var _size: Label

@export var _toolbar_panel: PanelContainer

var preview_size: int = 64:
set = set_preview_size

Expand All @@ -29,23 +33,34 @@ var _cur_icon: Icon
func set_preview_size(new_size: int) -> void:
preview_size = new_size
if self._icon != null:
self._icon.custom_minimum_size = Vector2(new_size, new_size)
self._preview_panel.custom_minimum_size = Vector2(0, new_size)
#if self._preview_background != null:
#self._preview_background.texture = gen_checkboard_texture(new_size, 8)

func set_preview_color(new_color: Color) -> void:
preview_color = new_color
if self._icon != null:
self._icon.self_modulate = new_color

static func gen_checkboard_texture(size: int, check_size: int) -> Texture2D:
var img: Image = Image.create(size, size, false, Image.FORMAT_RGBA8)
var white: Color = Color(1, 1, 1, 0.2)
var black: Color = Color(0, 0, 0, 0.2)
for x: int in range(size):
for y: int in range(size):
if (int(x / check_size) % 2 + int(y / check_size) % 2) % 2 == 0:
img.set_pixel(x, y, white)
else:
img.set_pixel(x, y, black)
return ImageTexture.create_from_image(img)

func _ready() -> void:
if Engine.is_editor_hint() || true:
self._toolbar_panel.add_theme_stylebox_override(&"panel", self.get_theme_stylebox(&"LaunchPadNormal", &"EditorStyles"))
self._toolbar.save_pressed.connect(self._on_save_pressed)
self._icon.self_modulate = self.preview_color
self.display(null)

func _get_minimum_size() -> Vector2:
var detail_min: Vector2 = self._detail_container.get_combined_minimum_size()
var hint_min: Vector2 = self._hint_container.get_combined_minimum_size()
return Vector2(maxf(detail_min.x, hint_min.x), maxf(detail_min.y, hint_min.y))

func display(icon: Icon) -> void:
self._cur_icon = icon

Expand All @@ -62,8 +77,8 @@ func display(icon: Icon) -> void:
icon.texture.get_size().y / Collection.TEXTURE_SIZE * icon.collection.svg_size
]

self._detail_tabs.current_tab = int(icon.collection.id())
self._detail_tabs.get_child(int(icon.collection.id())).display(icon)
self._detail_tabs.current_tab = icon.collection.id()
self._detail_tabs.get_child(icon.collection.id()).display(icon)

func _on_save_pressed() -> void:
var dialog: FileDialog = FileDialog.new()
Expand Down
Loading

0 comments on commit 6baca09

Please sign in to comment.