Skip to content

Commit

Permalink
[merge] Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
IceflowRE committed Aug 18, 2024
2 parents dee3d23 + 0794b8f commit 6943c26
Show file tree
Hide file tree
Showing 24 changed files with 228 additions and 99 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ You are also not able to use the property `custom_minimum_size` anymore as it is

### Changelog

#### 3.2.2

- Add more static typing

#### 3.2.1

- Revert: Fix ratio calculation, it is clunky on specific settings
Expand Down Expand Up @@ -243,6 +247,10 @@ Downloaded data is saved into `.godot/cache/icon_explorer` to avoid importing it

### Changelog

#### 1.1.0

- Use editor toast notification

#### 1.0.0

- Add icon explorer
Expand All @@ -251,6 +259,8 @@ Downloaded data is saved into `.godot/cache/icon_explorer` to avoid importing it

## Icons Patcher

*Consider using [Icon Explorer](#icon-explorer) instead and save icons in white color.*

If you use Material Design icons from [Pictogrammers](https://pictogrammers.com/library/mdi/), they come without any fill color, automatically rendered black. This is not a convenient color as it makes it impossible to modulate the color. The icon patcher provides a utility to automatically patch the icons to white color.

Set the icon directory in the Project Settings under the menu `Plugins` -> `Icons Patcher`.
Expand All @@ -265,6 +275,10 @@ Consider using [Icon Explorer](#icon-explorer) instead and save it directly in w

### Changelog

#### 1.4.0

- Use editor toast notification

#### 1.3.3

- Use absolute paths in preloads
Expand Down Expand Up @@ -327,6 +341,10 @@ License class.

### Changelog

#### 1.7.8

- Detect movement of licenses json file

#### 1.7.7

- Use absolute paths in preloads
Expand Down Expand Up @@ -589,6 +607,10 @@ Shift JIS encoding utility.

### Changelog

#### 1.1.3

- Code improvements

#### 1.1.2

- Use absolute paths in preloads
Expand Down Expand Up @@ -640,6 +662,10 @@ Let you apply the icon color theme properties for the texture button. Uses `self

### Changelog

#### 1.3.3

- Notify if Custom Themes Override is missing or enable it if disabled

#### 1.3.2

- Use absolute paths in preloads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ func _set(property: StringName, value: Variant) -> bool:
func _get_children_min_size() -> Vector2:
var min_size: Vector2 = Vector2.ZERO
for child: Node in self.get_children():
if !(child is Control) || !child.visible:
if !(child is Control) || !(child as Control).visible:
continue
var child_min: Vector2 = child.get_combined_minimum_size()
var child_min: Vector2 = (child as Control).get_combined_minimum_size()
min_size.x = maxf(min_size.x, child_min.x)
min_size.y = maxf(min_size.y, child_min.y)
return min_size
Expand Down
2 changes: 1 addition & 1 deletion addons/aspect_ratio_resize_container/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name="Aspect Ratio Resize Container"
description="Extending `AspectRatioContainer` and update it's own minimum size based on the children."
author="Iceflower S"
version="3.2.1"
version="3.2.2"
script="plugin.gd"
license="MIT"
repository="https://github.com/kenyoni-software/godot-addons"
Expand Down
33 changes: 33 additions & 0 deletions addons/icon_explorer/editor_toast_notification.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
enum Severity {
INFO = 0,
WARNING = 1,
ERROR = 2
}

static var _editor_toaster: Node

static func do(node: Node) -> void:
if node == null:
print("null")
return
var parent = node.get_parent()
while parent != null:
print(parent.name)
parent = parent.get_parent()

static func _get_editor_toaster() -> Node:
var tmp_plugin: EditorPlugin = EditorPlugin.new()
var tmp_ctrl: Control = Control.new()
tmp_plugin.add_control_to_bottom_panel(tmp_ctrl, "tmp_ctrl")
var toaster: Node = tmp_ctrl.get_parent().find_child("*EditorToaster*", true, false)
tmp_plugin.remove_control_from_bottom_panel(tmp_ctrl)
tmp_ctrl.queue_free()
return toaster

static func notify(message: String, severity: Severity = Severity.INFO, tooltip: String = "") -> void:
if _editor_toaster == null:
_editor_toaster = _get_editor_toaster()
if not is_instance_valid(_editor_toaster):
return

_editor_toaster.call("_popup_str", message, severity, tooltip)
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var _TITLE_TO_SLUG_REPLACEMENTS: Dictionary = {
"ż": "z",
}

var _title_to_slug_range_rx: RegEx = RegEx.new()
var _title_to_slug_range_rx: RegEx = RegEx.create_from_string("[^a-z0-9]")

func _init() -> void:
self.name = "Simple Icons"
Expand All @@ -41,8 +41,6 @@ func _init() -> void:
self.web = "https://github.com/simple-icons/simple-icons"
self.svg_size = 24.0

self._title_to_slug_range_rx.compile("[^a-z0-9]")

# OVERRIDE
func convert_icon_colored(buffer: String, color: String) -> String:
return '<svg fill="#' + color + '"' + buffer.substr(4)
Expand Down
2 changes: 1 addition & 1 deletion addons/icon_explorer/internal/scripts/database.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func _init(scene_tree: SceneTree) -> void:
self.register(CollectionSimpleIcons.new())
self.register(CollectionTabler.new())

func _notification(what):
func _notification(what: int):
if what == NOTIFICATION_PREDELETE:
if self._processing_thread != null:
self._processing_thread.wait_to_finish()
Expand Down
17 changes: 14 additions & 3 deletions addons/icon_explorer/internal/ui/detail_panel/detail_panel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extends PanelContainer
const Toolbar := preload("res://addons/icon_explorer/internal/ui/detail_panel/toolbar.gd")

const Collection := preload("res://addons/icon_explorer/internal/scripts/collection.gd")
const EditorToastNotification := preload("res://addons/icon_explorer/editor_toast_notification.gd")
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")

Expand Down Expand Up @@ -105,20 +106,30 @@ func _on_filepath_selected(path: String, colored: bool) -> void:
if colored:
var buffer: String = FileAccess.get_file_as_string(self._cur_icon.icon_path)
if buffer == "":
push_warning("could not load '" + self._cur_icon.icon_path + "'")
if Engine.is_editor_hint():
EditorToastNotification.notify("[Icon Explorer] Could not save icon.\nCould not load '" + self._cur_icon.icon_path + "'", EditorToastNotification.Severity.WARNING)
else:
push_warning("could not load '" + self._cur_icon.icon_path + "'")
return
buffer = self._cur_icon.collection.convert_icon_colored(buffer, self.preview_color.to_html(false))
var writer: FileAccess = FileAccess.open(path, FileAccess.WRITE)
if writer == null:
writer = null
push_warning("could not save '" + path + "'")
if Engine.is_editor_hint():
EditorToastNotification.notify("[Icon Explorer] Could not save icon (" + self._cur_icon.name + ").\nCould not write to '" + path + "'", EditorToastNotification.Severity.WARNING)
else:
push_warning("could not save '" + path + "'")
return
writer.store_string(buffer)
writer = null
else:
var err: Error = DirAccess.copy_absolute(self._cur_icon.icon_path, path)
if err != OK:
push_error(err)
if Engine.is_editor_hint():
EditorToastNotification.notify("[Icon Explorer] Could not save icon (" + self._cur_icon.name + ").\nCould copy file '" + path + "' to '" + self._cur_icon.icon_path + "'", EditorToastNotification.Severity.WARNING)
else:
push_warning("could not copy file", err)
return
if Engine.is_editor_hint():
EditorToastNotification.notify("[Icon Explorer] Icon '" + self._cur_icon.name + "' saved to '" + path + "'")
EditorInterface.get_resource_filesystem().scan()
18 changes: 18 additions & 0 deletions addons/icon_explorer/internal/ui/explorer/explorer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Icon := preload("res://addons/icon_explorer/internal/scripts/icon.gd")
const IconDatabase := preload("res://addons/icon_explorer/internal/scripts/database.gd")
const DetailPanel := preload("res://addons/icon_explorer/internal/ui/detail_panel/detail_panel.gd")

const EditorToastNotification := preload("res://addons/icon_explorer/editor_toast_notification.gd")
const Options := preload("res://addons/icon_explorer/internal/ui/options/options.gd")

@export var _filter_icon: TextureRect
Expand Down Expand Up @@ -70,6 +71,9 @@ func _ready() -> void:
self._db.loaded.connect(self._on_icon_database_loaded)
self._db.collection_installed.connect(self._on_database_changed)
self._db.collection_removed.connect(self._on_database_changed)
if Engine.is_editor_hint():
self._db.collection_installed.connect(self._on_collection_changed.bind(true))
self._db.collection_removed.connect(self._on_collection_changed.bind(false))

self._options.db = self._db

Expand Down Expand Up @@ -170,3 +174,17 @@ func _on_filter_submitted(_text: String) -> void:

func _on_option_pressed() -> void:
self._options_popup.popup_centered_ratio(0.35)

func _on_collection_changed(id: int, status: Error, is_installation: bool):
var msg: String = "[Icon Explorer] '" + self._db.get_collection(id).name + "' "
if is_installation:
if status == Error.OK:
msg += " successfully installed."
else:
msg += " installation failed."
else:
if status == Error.OK:
msg += " successfully removed."
else:
msg += " removing failed."
EditorToastNotification.notify(msg)
2 changes: 1 addition & 1 deletion addons/icon_explorer/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name="Icon Explorer"
description="Explore icon collections."
author="Iceflower S"
version="1.0.0"
version="1.1.0"
script="plugin.gd"
license="MIT"
repository="https://github.com/kenyoni-software/godot-addons"
Expand Down
33 changes: 33 additions & 0 deletions addons/icons_patcher/editor_toast_notification.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
enum Severity {
INFO = 0,
WARNING = 1,
ERROR = 2
}

static var _editor_toaster: Node

static func do(node: Node) -> void:
if node == null:
print("null")
return
var parent = node.get_parent()
while parent != null:
print(parent.name)
parent = parent.get_parent()

static func _get_editor_toaster() -> Node:
var tmp_plugin: EditorPlugin = EditorPlugin.new()
var tmp_ctrl: Control = Control.new()
tmp_plugin.add_control_to_bottom_panel(tmp_ctrl, "tmp_ctrl")
var toaster: Node = tmp_ctrl.get_parent().find_child("*EditorToaster*", true, false)
tmp_plugin.remove_control_from_bottom_panel(tmp_ctrl)
tmp_ctrl.queue_free()
return toaster

static func notify(message: String, severity: Severity = Severity.INFO, tooltip: String = "") -> void:
if _editor_toaster == null:
_editor_toaster = _get_editor_toaster()
if not is_instance_valid(_editor_toaster):
return

_editor_toaster.call("_popup_str", message, severity, tooltip)
2 changes: 1 addition & 1 deletion addons/icons_patcher/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name="Icons Patcher"
description="Will convert Pictogrammers icon to white."
author="Iceflower S"
version="1.3.3"
version="1.4.0"
script="plugin.gd"
license="MIT"
repository="https://github.com/kenyoni-software/godot-addons"
Expand Down
6 changes: 3 additions & 3 deletions addons/icons_patcher/tool_menu.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extends PopupMenu

const Utils := preload("res://addons/icons_patcher/utils.gd")
const EditorToastNotification := preload("res://addons/icons_patcher/editor_toast_notification.gd")

func _ready() -> void:
self.add_item("Patch Material Design Icons")
Expand Down Expand Up @@ -29,10 +30,9 @@ func _on_id_pressed(id: int) -> void:

func _patch_icons_material_design() -> void:
var base_path: String = ProjectSettings.get_setting(Utils.MDI_DIRECTORY_PATH)
print("Patching " + base_path)


var rx: RegEx = RegEx.new()
rx.compile('(" fill="#[a-fA-F0-9]{6})?">')
var patched_icons: PackedStringArray = Utils.patch_icon_dir(base_path, rx, '" fill="#ffffff">')
EditorInterface.get_resource_filesystem().reimport_files(patched_icons)
print("Patched " + base_path)
EditorToastNotification.notify("[IconsPatcher] Patched " + base_path)
12 changes: 9 additions & 3 deletions addons/licenses/internal/licenses.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ const StringHandler := preload("res://addons/licenses/internal/handler/string.gd
const StringFileHandler := preload("res://addons/licenses/internal/handler/string_file.gd")
const StringMultiLineHandler := preload("res://addons/licenses/internal/handler/string_multiline.gd")

@export_node_path("Tree") var _components_tree_path
@export_node_path("Tree") var _components_tree_path: NodePath
@onready var _components_tree: ComponentsTree = self.get_node(self._components_tree_path)
@export_node_path("Tree") var _component_detail_tree_path
@export_node_path("Tree") var _component_detail_tree_path: NodePath
@onready var _component_detail_tree: ComponentDetailTree = self.get_node(self._component_detail_tree_path)
@export_node_path("HBoxContainer") var _toolbar_path
@export_node_path("HBoxContainer") var _toolbar_path: NodePath
@onready var _toolbar: Toolbar = self.get_node(self._toolbar_path)
@export var _license_file_edit: LineEdit = null
@export var _license_file_load_button: Button = null
Expand Down Expand Up @@ -54,6 +54,7 @@ func _ready() -> void:
self._components.components_changed.connect(self._on_components_changed)
if Engine.is_editor_hint():
self._file_watcher = FileSystemWatcher.new(self._components)
EditorInterface.get_file_system_dock().files_moved.connect(self._on_file_moved)

func reload() -> void:
self._update_set_license_filepath_button()
Expand Down Expand Up @@ -135,3 +136,8 @@ func _on_components_changed() -> void:

func _emit_changed():
self._components.emit_changed()

func _on_file_moved(old_file: String, new_file: String) -> void:
if old_file == Licenses.get_license_data_filepath():
Licenses.set_license_data_filepath(new_file)
self._license_file_edit.text = Licenses.get_license_data_filepath()
2 changes: 1 addition & 1 deletion addons/licenses/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name="License Manager"
description="Manage license and copyright for third party graphics, software or libraries."
author="Iceflower S"
version="1.7.7"
version="1.7.8"
script="plugin.gd"
license="MIT"
repository="https://github.com/kenyoni-software/godot-addons"
Expand Down
2 changes: 1 addition & 1 deletion addons/qr_code/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name="QR Code"
description="QR Code generator."
author="Iceflower S"
version="1.1.2"
version="1.1.3"
script="plugin.gd"
license="MIT"
repository="https://github.com/kenyoni-software/godot-addons"
Expand Down
12 changes: 5 additions & 7 deletions addons/qr_code/qr_code.gd
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,8 @@ const _ALIGNMENT_PATTERN_POSITIONS: Array = [
## remainder bits after structured data bits
const _REMAINDER_BITS: Array = [ 0, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0 ]

static var _number_rx: RegEx = RegEx.new()
static var _alphanumeric_rx: RegEx = RegEx.new()
static var _number_rx: RegEx = RegEx.create_from_string("[^\\d]*")
static var _alphanumeric_rx: RegEx = RegEx.create_from_string("[^0-9A-Z $%*+\\-.\\/:]*")

## cached qr data
var _cached_qr: PackedByteArray = []
Expand Down Expand Up @@ -884,16 +884,14 @@ func _get_char_count_size() -> int:
return 12
return 0

# TODO: TEST IF STATIC VAR WORKS
static func _static_init() -> void:
# TODO: static init is not called in editor if not @tool
if _number_rx == null:
_number_rx = RegEx.new()
_number_rx = RegEx.create_from_string("[^\\d]*")
# TODO: static init is not called in editor if not @tool
if _alphanumeric_rx == null:
_alphanumeric_rx = RegEx.new()

_number_rx.compile("[^\\d]*")
_alphanumeric_rx.compile("[^0-9A-Z $%*+\\-.\\/:]*")
_alphanumeric_rx = RegEx.create_from_string("[^0-9A-Z $%*+\\-.\\/:]*")

func _init(error_correction_: ErrorCorrection = ErrorCorrection.LOW) -> void:
self.error_correction = error_correction_
Expand Down
Loading

0 comments on commit 6943c26

Please sign in to comment.