Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
IceflowRE committed Jan 15, 2024
2 parents 750d9e4 + 821d5c2 commit b80fb8a
Show file tree
Hide file tree
Showing 82 changed files with 2,630 additions and 108 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jobs:
id: "hide_private_properties",
name: "Hide Private Properties",
}
- {
id: "icon_explorer",
name: "Icon Explorer",
}
- {
id: "icons_patcher",
name: "Icons Patcher",
Expand Down
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ If you import any plugin or open a Godot project for the first time, the plugins
Add Git SHA as project setting.
- [Hide Private Properties](#hide-private-properties)
Hide private properties of instantiated child scenes.
- [Icon Explorer](#icon-explorer)
Browse different icons and save them.
- [Icons Patcher](#icons-patcher)
Patch Pictogrammers icons to white.
- [License Manager](#license-manager)
Expand Down Expand Up @@ -59,6 +61,10 @@ You are also not able to use the property `custom_minimum_size` anymore as it is

### Changelog

#### 3.1.1

- Code improvement

#### 3.1.0

- Require Godot 4.2
Expand Down Expand Up @@ -187,6 +193,38 @@ This plugin will hide exported private properties in the inspector for instantia

---

## Icon Explorer

Browse and save icons from popular icon collections.

Install or update them via the options menu in the right upper corner. This can take several minutes.

The following collections are available:

- [Bootstrap Icons](https://github.com/twbs/icons)
- [Font Awesome 6](https://github.com/FortAwesome/Font-Awesome)
- [Material Design](https://github.com/Templarian/MaterialDesign-SVG)
- [Simple Icons](https://github.com/simple-icons/simple-icons)
- [tabler Icons](https://github.com/tabler/tabler-icons)

Downloaded data is saved into `.godot/cache/icon_explorer` to avoid importing it.

### Compatibility

- Godot 4.2

### Screenshot

![Icon Explorer screenshot](./doc/icon_explorer.png "Icon Explorer")

### Changelog

#### 1.0.0

- Add icon explorer

---

## Icons Patcher

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.
Expand All @@ -201,6 +239,14 @@ Then use `Project` -> `Tools` -> `Icons Patcher` to patch the icons.

### Changelog

#### 1.3.2

- Code improvement

#### 1.3.1

- Replace legacy code

#### 1.3.0

- Require Godot 4.2
Expand Down Expand Up @@ -251,6 +297,11 @@ License class.

### Changelog

#### 1.7.6

- Fix scene id
- Code improvement

#### 1.7.5

- Fix license file existing check
Expand Down Expand Up @@ -375,6 +426,10 @@ If not log level is set, the log level of the parent logger will be used.

### Changelog

#### 1.5.1

- Code improvement

#### 1.5.0

- Require Godot 4.2
Expand Down Expand Up @@ -500,6 +555,10 @@ Shift JIS encoding utility.

### Changelog

#### 1.1.1

- Code optimizing

#### 1.1.0

- Require Godot 4.2
Expand Down Expand Up @@ -543,6 +602,10 @@ Let you apply the icon color theme properties for the texture button. Uses `self

### Changelog

#### 1.3.1

- Code improvement

#### 1.3.0

- Require Godot 4.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ func _get_children_min_size() -> Vector2:
if !(child is Control) || !child.visible:
continue
var child_min: Vector2 = child.get_combined_minimum_size()
min_size.x = max(min_size.x, child_min.x)
min_size.y = max(min_size.y, child_min.y)
min_size.x = maxf(min_size.x, child_min.x)
min_size.y = maxf(min_size.y, child_min.y)
return min_size

func _get_minimum_size() -> Vector2:
var min_size: Vector2 = self._get_children_min_size()
if self.stretch_mode == STRETCH_WIDTH_CONTROLS_HEIGHT:
var width: float = max(min_size.x, self.size.x)
var width: float = maxf(min_size.x, self.size.x)
min_size.y = width * self.ratio
elif self.stretch_mode == STRETCH_HEIGHT_CONTROLS_WIDTH:
var height: float = max(min_size.y, self.size.y)
var height: float = maxf(min_size.y, self.size.y)
min_size.x = height * self.ratio
return min_size
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.1.0"
version="3.1.1"
script="plugin.gd"
license="MIT"
repository="https://github.com/kenyoni-software/godot-addons"
Expand Down
2 changes: 1 addition & 1 deletion addons/glogging/glogging.gd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Logger:
self._log_level = level

func log_level() -> int:
if self.parent != null and self._log_level == LEVEL_NOTSET:
if self.parent != null && self._log_level == LEVEL_NOTSET:
return self.parent.log_level()
return self._log_level

Expand Down
2 changes: 1 addition & 1 deletion addons/glogging/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name="GLogging"
description="Adds a 'GLogging' singleton."
author="Iceflower S"
version="1.5.0"
version="1.5.1"
script="plugin.gd"
license="MIT"
repository="https://github.com/kenyoni-software/godot-addons"
Expand Down
66 changes: 66 additions & 0 deletions addons/icon_explorer/internal/scripts/collection.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
extends RefCounted

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
const TEXTURE_SIZE: float = 128.0

var name: String
var version: String
var author: String
var license: String
var license_text: String
var web: String

## base size of svg
var svg_size: float

# is set on registering it at the IconDatabase
var _id: int = -1

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

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

# VIRTUAL
func convert_icon_colored(buffer: String, color: String) -> String:
return ""

# VIRTUAL
# called in a thread
func load() -> Array[Icon]:
assert(false, "virtual function")
return []

# VIRTUAL
# called in a thread
func install(http: HTTPRequest, version: String) -> Error:
assert(false, "virtual function")
return Error.FAILED

# VIRTUAL
# called in a thread
func remove() -> Error:
if Io.rrm_dir(self.directory()):
return Error.OK
return Error.FAILED

# VIRTUAL
func icon_directory() -> String:
assert(false, "virtual function")
return ""

func directory() -> String:
if Engine.is_editor_hint():
if ProjectSettings.get_setting("application/config/use_hidden_project_data_directory", true):
return "res://.godot/cache/icon_explorer".path_join(self.directory_name())
else:
return "res://godot/cache/icon_explorer".path_join(self.directory_name())
assert(false, "TODO")
return ""

func directory_name() -> String:
return self.name.to_snake_case()
124 changes: 124 additions & 0 deletions addons/icon_explorer/internal/scripts/collections/bootstrap.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
extends "res://addons/icon_explorer/internal/scripts/collection.gd"

const IconBootstrap := preload("res://addons/icon_explorer/internal/scripts/collections/icon_bootstrap.gd")
const ZipUnpacker := preload("res://addons/icon_explorer/internal/scripts/tools/zip_unpacker.gd")

const _DOWNLOAD_FILE: String = "https://github.com/twbs/icons/archive/main.zip"

func _init() -> void:
self.name = "Bootstrap Icons"
self.version = ""
self.author = "The Bootstrap Authors"
self.license = "MIT"
self.web = "https://github.com/twbs/icons"
self.svg_size = 16.0

# OVERRIDE
func convert_icon_colored(buffer: String, color: String) -> String:
return buffer.replace("currentColor", "#" + color)

# OVERRIDE
func load() -> Array:
var dir: DirAccess = DirAccess.open(self._meta_directory())
if !dir:
return []

var icons: Array[Icon] = []
var buffers: PackedStringArray = PackedStringArray()
dir.list_dir_begin()
var file_name: String = dir.get_next()
while file_name != "":
if dir.current_is_dir():
continue
var res: Array = self._load_item(file_name)
if res.size() == 2:
icons.append(res[0])
buffers.append(res[1])
file_name = dir.get_next()

var parser_version: JSON = JSON.new()
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 [[], PackedStringArray()]
self.version = parser_version.data["version"]

return [icons, buffers]

func _load_item(file_name: String) -> Array:
var icon: IconBootstrap = IconBootstrap.new()
icon.collection = self

var meta: String = FileAccess.get_file_as_string(self._meta_directory().path_join(file_name))
if meta == "":
push_warning("could not read bootstrap meta file '", file_name, "'")
return []

var cur_token: int = 0
for line: String in meta.split("\n"):
if line.begins_with("title: "):
icon.name = line.lstrip("title: ")
cur_token = 0
continue
if line == "categories:":
cur_token = 1
continue
if line == "tags:":
cur_token = 2
continue
if line.begins_with(" - "):
match cur_token:
1:
icon.categories.append(line.lstrip(" - "))
2:
icon.tags.append(line.lstrip(" - "))
continue
if line.begins_with("added:"):
icon.version_added = line.lstrip("added: ")

if icon.name == "":
push_warning("bootstrap '", file_name, "' has no name")
return []

icon.icon_path = self.icon_directory().path_join(file_name.get_basename() + ".svg")
var buffer: String = FileAccess.get_file_as_string(icon.icon_path)
if buffer == "":
push_warning("could not load '" + icon.icon_path + "'")
return []

return [icon, self.convert_icon_colored(buffer, "FFFFFF")]

# OVERRIDE
func install(http: HTTPRequest, _version: String) -> Error:
DirAccess.make_dir_recursive_absolute(self.directory())
var zip_path: String = self.directory().path_join("icons.zip")
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

var unzipper: ZipUnpacker = ZipUnpacker.new(zip_path, self.directory(), [
"icons-main/package.json",
"icons-main/icons/",
"icons-main/docs/content/icons/",
"icons-main/LICENSE",
])
if !unzipper.unpack_mt(maxi(OS.get_processor_count() / 2, 1)):
return Error.FAILED
DirAccess.remove_absolute(zip_path)
return Error.OK

# OVERRIDE
func remove() -> Error:
self.version = ""
return super.remove()

# OVERRIDE
func icon_directory() -> String:
return self.directory().path_join("icons-main/icons/")

func _meta_directory() -> String:
return self.directory().path_join("icons-main/docs/content/icons/")
Loading

0 comments on commit b80fb8a

Please sign in to comment.