diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7a17ae6..3fdca06 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -71,8 +71,8 @@ jobs: id: "prepare-artifacts" working-directory: publisher run: | - go run . zip ../ ${{ matrix.config.id }} - echo "version=$(go run . version ../ ${{ matrix.config.id }})" >> $GITHUB_OUTPUT + go run . zip -b ../ -a ${{ matrix.config.id }} -o ../archives/ + go run . github -b ../ -a ${{ matrix.config.id }} -o $GITHUB_OUTPUT - name: Upload Artifacts uses: actions/upload-artifact@v3 @@ -83,15 +83,15 @@ jobs: - uses: mukunku/tag-exists-action@v1.2.0 id: checkTag with: - tag: ${{ matrix.config.id }}-${{steps.prepare-artifacts.outputs.version}} + tag: ${{ matrix.config.id }}-${{ steps.prepare-artifacts.outputs.version }} - name: Prepare Release if: ${{ steps.checkTag.outputs.exists == 'false' }} run: | git config user.name github-actions git config user.email github-actions@github.com - git tag ${{ matrix.config.id }}-${{steps.prepare-artifacts.outputs.version}} - git push origin tag ${{ matrix.config.id }}-${{steps.prepare-artifacts.outputs.version}} + git tag ${{ matrix.config.id }}-${{ steps.prepare-artifacts.outputs.version }} + git push origin tag ${{ matrix.config.id }}-${{ steps.prepare-artifacts.outputs.version }} # wait 5s that the pushed tag is available in the next step, sometimes the next step saw only the local tag - name: Wait 5s @@ -102,11 +102,8 @@ jobs: if: ${{ steps.checkTag.outputs.exists == 'false' }} env: GITHUB_TOKEN: ${{ github.token }} - NOTES: | - ${{ matrix.config.name }} - Version: ${{steps.prepare-artifacts.outputs.version}} run: | - gh release create ${{ matrix.config.id }}-${{steps.prepare-artifacts.outputs.version}} ./archives/* --title "${{ matrix.config.name }} ${{steps.prepare-artifacts.outputs.version}}" --notes "${{ env.NOTES }}" + gh release create ${{ matrix.config.id }}-${{ steps.prepare-artifacts.outputs.version }} ./archives/* --title "${{ matrix.config.name }} ${{ steps.prepare-artifacts.outputs.version }}" --notes "${{ steps.prepare-artifacts.outputs.notes }}" combined-release: name: Combined Release diff --git a/README.md b/README.md index d0f32c1..fe37beb 100644 --- a/README.md +++ b/README.md @@ -47,12 +47,20 @@ You are also not able to use the property `custom_minimum_size` anymore as it is ### Compatibility -- Godot 4.1 +- Godot 4.2 ### Example [examples/aspect_ratio_resize_container](./examples/aspect_ratio_resize_container) +### Changelog + +#### 3.1.0 + +- Require Godot 4.2 +- Add more values to plugin.cfg +- Add static typing in for loops + --- ## Custom Theme Overrides @@ -67,7 +75,7 @@ If everything is set up, your theme override variables can be handled like every ### Compatibility -- Godot 4.1 +- Godot 4.2 ### Screenshot @@ -113,6 +121,14 @@ func _property_get_revert(_property: StringName) -> Variant: [examples/custom_theme_overrides](./examples/custom_theme_overrides) +### Changelog + +#### 1.1.0 + +- Require Godot 4.2 +- Add more values to plugin.cfg +- Add static typing in for loops + --- ## Git SHA Project Setting @@ -124,7 +140,7 @@ This one is automatically set and updated when you run any scene or on exporting ### Compatibility -- Godot 4.1 +- Godot 4.2 ### Example @@ -132,10 +148,15 @@ This one is automatically set and updated when you run any scene or on exporting ### Changelog +#### 2.1.0 + +- Require Godot 4.2 +- Add more values to plugin.cfg + #### 2.0.0 -Added an initial Git SHA load on opening the project. -Removed `application/config/version`, there was no need that this was part of the addon. The value can still be added manually. +- Added an initial Git SHA load on opening the project. +- Removed `application/config/version`, there was no need that this was part of the addon. The value can still be added manually. --- @@ -147,12 +168,19 @@ This plugin will hide exported private properties in the inspector for instantia ### Compatibility -- Godot 4.1 +- Godot 4.2 ### Example [examples/hide_private_properties](./examples/hide_private_properties) +### Changelog + +#### 1.1.0 + +- Require Godot 4.2 +- Add more values to plugin.cfg + --- ## Icons Patcher @@ -165,10 +193,15 @@ Then use `Project` -> `Tools` -> `Icons Patcher` to patch the icons. ### Compatibility -- Godot 4.1 +- Godot 4.2 ### Changelog +#### 1.3.0 + +- Require Godot 4.2 +- Add more values to plugin.cfg + #### 1.2.0 - Added automatic file reimporting. @@ -186,7 +219,7 @@ You can change the project license file either with a button at the upper right, ### Compatibility -- Godot 4.1 +- Godot 4.2 ### Screenshot @@ -212,6 +245,13 @@ License class. ### Changelog +#### 1.6.0 + +- Require Godot 4.2 +- Add more values to plugin.cfg +- Add static typing in for loops +- Use static sorting function as lambda + #### 1.5.0 - Removed overriden engine methods @@ -232,7 +272,7 @@ Logging into a file is not supported yet. The output will be always done via pri ### Compatibility -- Godot 4.1 +- Godot 4.2 ### Example @@ -295,6 +335,12 @@ If not log level is set, the log level of the parent logger will be used. - `log(level: int, message: Variant, values: Array[Variant] = []) -> void` log at custom level +### Changelog + +#### 1.5.0 + +- Require Godot 4.2 +- Add more values to plugin.cfg --- @@ -304,7 +350,7 @@ QR Code generation either with the included `QRCodeRect` node or use the encodin ### Compatibility -- Godot 4.1 +- Godot 4.2 ### Screenshot @@ -416,6 +462,12 @@ Shift JIS encoding utility. ### Changelog +#### 1.1.0 + +- Require Godot 4.2 +- Add more values to plugin.cfg +- Add static typing in for loops + #### 1.0.0 - Renamed `get_string_from_jis_2004` to `get_string_from_shift_jis_2004` @@ -441,7 +493,7 @@ Let you apply the icon color theme properties for the texture button. Uses `self ### Compatibility -- Godot 4.1 +- Godot 4.2 ### Dependencies @@ -453,6 +505,11 @@ Let you apply the icon color theme properties for the texture button. Uses `self ### Changelog +#### 1.3.0 + +- Require Godot 4.2 +- Add more values to plugin.cfg + #### 1.2.3 - Rename method `get_theme_color` to `get_theme_coloring`, this function was never called by the engine anyway and should not be overridden diff --git a/addons/aspect_ratio_resize_container/aspect_ratio_resize_container.gd b/addons/aspect_ratio_resize_container/aspect_ratio_resize_container.gd index 0ff0153..62661eb 100644 --- a/addons/aspect_ratio_resize_container/aspect_ratio_resize_container.gd +++ b/addons/aspect_ratio_resize_container/aspect_ratio_resize_container.gd @@ -14,7 +14,7 @@ func _set(property: StringName, value: Variant) -> bool: func _get_children_min_size() -> Vector2: var min_size: Vector2 = Vector2.ZERO - for child in self.get_children(): + for child: Node in self.get_children(): if !(child is Control) || !child.visible: continue var child_min: Vector2 = child.get_combined_minimum_size() diff --git a/addons/aspect_ratio_resize_container/plugin.cfg b/addons/aspect_ratio_resize_container/plugin.cfg index b6cf33b..bd78ebe 100644 --- a/addons/aspect_ratio_resize_container/plugin.cfg +++ b/addons/aspect_ratio_resize_container/plugin.cfg @@ -1,7 +1,19 @@ [plugin] name="Aspect Ratio Resize Container" -description="MIT License" +description="Extending `AspectRatioContainer` and update it's own minimum size based on the children." author="Iceflower S" -version="3.0.2" +version="3.1.0" script="plugin.gd" +license="MIT" +repository="https://github.com/kenyoni-software/godot-addons" +keywords=[ + "node" +] +classifiers=[ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License" +] + +[plugin.dependencies] +godot=">=4.2" \ No newline at end of file diff --git a/addons/custom_theme_overrides/plugin.cfg b/addons/custom_theme_overrides/plugin.cfg index c78b810..c939aa5 100644 --- a/addons/custom_theme_overrides/plugin.cfg +++ b/addons/custom_theme_overrides/plugin.cfg @@ -1,7 +1,19 @@ [plugin] name="Custom Theme Overrides" -description="MIT License" +description="Utility to provide custom theme overrides for any node." author="Iceflower S" -version="1.0.2" +version="1.1.0" script="plugin.gd" +license="MIT" +repository="https://github.com/kenyoni-software/godot-addons" +keywords=[ + "utility" +] +classifiers=[ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License" +] + +[plugin.dependencies] +godot=">=4.2" \ No newline at end of file diff --git a/addons/custom_theme_overrides/theme_overrides.gd b/addons/custom_theme_overrides/theme_overrides.gd index 54652eb..9f1c867 100644 --- a/addons/custom_theme_overrides/theme_overrides.gd +++ b/addons/custom_theme_overrides/theme_overrides.gd @@ -28,7 +28,7 @@ class Item: return self.name func _init(overrides: Array[Array]) -> void: - for item in overrides: + for item: Array in overrides: self._overrides.append(Item.new(item[0], item[1])) func theme_property_list(obj: Control) -> Array[Dictionary]: @@ -41,7 +41,7 @@ func theme_property_list(obj: Control) -> Array[Dictionary]: "usage": PROPERTY_USAGE_GROUP, "hint_string": "theme_override_" }] - for item in self._overrides: + for item: Item in self._overrides: var prop_type: Variant.Type var prop_hint: PropertyHint var prop_hint_string: String @@ -79,7 +79,7 @@ func theme_property_list(obj: Control) -> Array[Dictionary]: return props func can_revert(prop_name: StringName) -> bool: - for item in self._overrides: + for item: Item in self._overrides: if item.full_name() == prop_name: return true return false diff --git a/addons/git_sha_project_setting/plugin.cfg b/addons/git_sha_project_setting/plugin.cfg index 28b11d5..ddedd8c 100644 --- a/addons/git_sha_project_setting/plugin.cfg +++ b/addons/git_sha_project_setting/plugin.cfg @@ -1,7 +1,19 @@ [plugin] name="Git SHA Project Setting" -description="Adds Git SHA as prohect setting at application/config/git_sha - MIT License" +description="Adds Git SHA as prohect setting at application/config/git_sha" author="Iceflower S" -version="2.0.1" +version="2.1.0" script="plugin.gd" +license="MIT" +repository="https://github.com/kenyoni-software/godot-addons" +keywords=[ + "tool" +] +classifiers=[ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License" +] + +[plugin.dependencies] +godot=">=4.2" \ No newline at end of file diff --git a/addons/glogging/plugin.cfg b/addons/glogging/plugin.cfg index ad7a5f0..2199947 100644 --- a/addons/glogging/plugin.cfg +++ b/addons/glogging/plugin.cfg @@ -1,7 +1,19 @@ [plugin] name="GLogging" -description="Adds a 'GLogging' singleton. - MIT License" +description="Adds a 'GLogging' singleton." author="Iceflower S" -version="1.4.1" +version="1.5.0" script="plugin.gd" +license="MIT" +repository="https://github.com/kenyoni-software/godot-addons" +keywords=[ + "tool" +] +classifiers=[ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License" +] + +[plugin.dependencies] +godot=">=4.2" \ No newline at end of file diff --git a/addons/hide_private_properties/inspector_plugin.gd b/addons/hide_private_properties/inspector_plugin.gd index bb3a54d..9bae842 100644 --- a/addons/hide_private_properties/inspector_plugin.gd +++ b/addons/hide_private_properties/inspector_plugin.gd @@ -1,10 +1,8 @@ extends EditorInspectorPlugin -var editor_interface: EditorInterface - func _can_handle(object: Object) -> bool: var scene_path: Variant = object.get("scene_file_path") - return scene_path != null && scene_path != "" && object != self.editor_interface.get_edited_scene_root() + return scene_path != null && scene_path != "" && object != EditorInterface.get_edited_scene_root() func _parse_property(object: Object, type: Variant.Type, name: String, hint_type: PropertyHint, hint_string: String, usage_flags: int, wide: bool) -> bool: if name.begins_with("_"): diff --git a/addons/hide_private_properties/plugin.cfg b/addons/hide_private_properties/plugin.cfg index 9f3b84d..efa0ba7 100644 --- a/addons/hide_private_properties/plugin.cfg +++ b/addons/hide_private_properties/plugin.cfg @@ -1,7 +1,19 @@ [plugin] name="Hide Private Properties" -description="MIT License" +description="Hide exported private properties in the inspector for instantiated child scenes." author="Iceflower S" -version="1.0.2" +version="1.1.0" script="plugin.gd" +license="MIT" +repository="https://github.com/kenyoni-software/godot-addons" +keywords=[ + "tool" +] +classifiers=[ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License" +] + +[plugin.dependencies] +godot=">=4.2" \ No newline at end of file diff --git a/addons/hide_private_properties/plugin.gd b/addons/hide_private_properties/plugin.gd index 1e6e8b0..298430c 100644 --- a/addons/hide_private_properties/plugin.gd +++ b/addons/hide_private_properties/plugin.gd @@ -7,7 +7,6 @@ var _inspector_plugin: InspectorPlugin func _enter_tree() -> void: self._inspector_plugin = InspectorPlugin.new() - self._inspector_plugin.editor_interface = self.get_editor_interface() self.add_inspector_plugin(self._inspector_plugin) func _exit_tree() -> void: diff --git a/addons/icons_patcher/plugin.cfg b/addons/icons_patcher/plugin.cfg index f43ef9c..636cad4 100644 --- a/addons/icons_patcher/plugin.cfg +++ b/addons/icons_patcher/plugin.cfg @@ -1,7 +1,19 @@ [plugin] name="Icons Patcher" -description="MIT License" +description="Will convert Pictogrammers icon to white." author="Iceflower S" -version="1.2.1" +version="1.3.0" script="plugin.gd" +license="MIT" +repository="https://github.com/kenyoni-software/godot-addons" +keywords=[ + "tool" +] +classifiers=[ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License" +] + +[plugin.dependencies] +godot=">=4.2" \ No newline at end of file diff --git a/addons/licenses/component.gd b/addons/licenses/component.gd index 9ada304..02032ca 100644 --- a/addons/licenses/component.gd +++ b/addons/licenses/component.gd @@ -109,7 +109,7 @@ func get_warnings() -> PackedStringArray: if self.copyright.is_empty(): res.append("no copyright") var path_missing: bool = false - for path in self.paths: + for path: String in self.paths: if FileAccess.file_exists(path) || DirAccess.dir_exists_absolute(path): continue res.append("path '" + path + "' does not exst") @@ -117,7 +117,7 @@ func get_warnings() -> PackedStringArray: func serialize() -> Dictionary: var licenses: Array[Dictionary] = [] - for license in self.licenses: + for license: License in self.licenses: licenses.append(license.serialize()) return { "id": self.id, @@ -142,6 +142,6 @@ func deserialize(data: Dictionary): self.description = data.get("description", "") self.web = data.get("web", "") self.paths = data.get("paths", []) - for license in data.get("licenses", []): + for license: Dictionary in data.get("licenses", []): self.licenses.append(License.new().deserialize(license)) return self diff --git a/addons/licenses/export_plugin.gd b/addons/licenses/export_plugin.gd index 2d2e60c..0a96087 100644 --- a/addons/licenses/export_plugin.gd +++ b/addons/licenses/export_plugin.gd @@ -1,6 +1,7 @@ extends EditorExportPlugin const Licenses := preload("licenses.gd") +const Component := preload("component.gd") func _get_name() -> String: return "kenyoni_licenses_exporter" @@ -13,8 +14,8 @@ func _export_begin(features: PackedStringArray, is_debug: bool, path: String, fl if res.err_msg != "": push_error("Failed to export license files: " + res.err_msg) return - for component in res.components: - for license in component.licenses: + for component: Component in res.components: + for license: Component.License in component.licenses: if license.file != "": self._add_file(license.file) diff --git a/addons/licenses/internal/component_detail_tree.gd b/addons/licenses/internal/component_detail_tree.gd index bbae259..a684057 100644 --- a/addons/licenses/internal/component_detail_tree.gd +++ b/addons/licenses/internal/component_detail_tree.gd @@ -14,7 +14,7 @@ enum BUTTON_ID { var _component: Component : set = set_component, get = get_component -var handlers: Array = [] +var handlers: Array[GDScript] = [] var _selected_item: TreeItem = null func set_component(new_component: Component) -> void: @@ -41,11 +41,11 @@ func reload() -> void: self.set_readonly(self.get_root()) func set_readonly(item: TreeItem) -> void: - for column in range(self.columns): + for column: int in range(self.columns): item.set_editable(column, false) - for idx in range(item.get_button_count(column)): + for idx: int in range(item.get_button_count(column)): item.erase_button(column, 0) - for child in item.get_children(): + for child: TreeItem in item.get_children(): self.set_readonly(child) if item.get_next() != null: self.set_readonly(item.get_next()) @@ -74,7 +74,7 @@ func _on_item_edited(item: TreeItem = null) -> void: self.component_edited.emit(self._component) func _get_handler(property: Dictionary) -> GDScript: - for handler in self.handlers: + for handler: GDScript in self.handlers: if handler.can_handle(property): return handler return null diff --git a/addons/licenses/internal/components_tree.gd b/addons/licenses/internal/components_tree.gd index 497f53c..f9f08e4 100644 --- a/addons/licenses/internal/components_tree.gd +++ b/addons/licenses/internal/components_tree.gd @@ -36,7 +36,7 @@ func _ready() -> void: func add_component(component: Component) -> void: self._components.append(component) - self._components.sort_custom(Licenses.new().compare_components_ascending) + self._components.sort_custom(Licenses.compare_components_ascending) self.reload() # will not emit components_changed signal @@ -104,8 +104,7 @@ func reload() -> void: var cur_idx: int = 0 var cmp: bool = false if idx < len(self._components) and readonly_idx < len(self._readonly_components): - # TODO: will be static later on - cmp = Licenses.new().compare_components_ascending(self._components[idx], self._readonly_components[readonly_idx]) + cmp = Licenses.compare_components_ascending(self._components[idx], self._readonly_components[readonly_idx]) if readonly_idx >= len(self._readonly_components) or cmp: component = self._components[idx] cur_idx = idx @@ -154,7 +153,7 @@ func _drop_data(at_position: Vector2, data: Variant) -> void: if cur_component.category == category: return cur_component.category = category - self._components.sort_custom(Licenses.new().compare_components_ascending) + self._components.sort_custom(Licenses.compare_components_ascending) self.components_changed.emit() self.reload() self._component_detail.reload() @@ -175,7 +174,7 @@ func _on_button_clicked(item: TreeItem, column: int, id: int, mouse_button_idx: _BTN_ID_REMOVE: var comp: Component = self._components[item.get_meta("idx")] self._components.remove_at(item.get_meta("idx")) - self._components.sort_custom(Licenses.new().compare_components_ascending) + self._components.sort_custom(Licenses.compare_components_ascending) self.components_changed.emit() # refresh detail view if the current component was removed if comp == self._component_detail.get_component(): @@ -184,7 +183,7 @@ func _on_button_clicked(item: TreeItem, column: int, id: int, mouse_button_idx: # callback from commponent detail tree func _on_component_edited(component: Component) -> void: - self._components.sort_custom(Licenses.new().compare_components_ascending) + self._components.sort_custom(Licenses.compare_components_ascending) self.components_changed.emit() self.reload() @@ -193,11 +192,11 @@ func _on_item_edited() -> void: var old_category: String = category_item.get_meta("category") var new_category: String = category_item.get_text(0) category_item.set_meta("category", new_category) - for component in self._components: + for component: Component in self._components: if component.category == old_category: component.category = new_category - self._components.sort_custom(Licenses.new().compare_components_ascending) + self._components.sort_custom(Licenses.compare_components_ascending) self.components_changed.emit() # we cannot reload the tree while it is processing any kind of input/signals # https://github.com/godotengine/godot/issues/50084 diff --git a/addons/licenses/internal/handler/array.gd b/addons/licenses/internal/handler/array.gd index d2d7a9d..10b5234 100644 --- a/addons/licenses/internal/handler/array.gd +++ b/addons/licenses/internal/handler/array.gd @@ -17,7 +17,7 @@ func _init(tree_: ComponentDetailTree, item_: TreeItem, value_: Variant, propert TYPE_OBJECT: self._constructor = self.property["constructor"] - for idx in range(len(self.value)): + for idx: int in range(len(self.value)): self.tree._add_item(self.item, self.value[idx], self._get_child_property(str(idx))) func _get_child_property(name: String) -> Dictionary: diff --git a/addons/licenses/internal/handler/object.gd b/addons/licenses/internal/handler/object.gd index 320f51b..482ba8e 100644 --- a/addons/licenses/internal/handler/object.gd +++ b/addons/licenses/internal/handler/object.gd @@ -7,7 +7,7 @@ func _init(tree_: ComponentDetailTree, item_: TreeItem, value_: Variant, propert self.item.set_text(0, self.property["name"].capitalize()) self.item.set_selectable(1, false) - for prop in Utils.get_updated_property_list(self.value): + for prop: Dictionary in Utils.get_updated_property_list(self.value): # ignore private variables and ignore non supported types and already added items if prop["name"].begins_with("_"): continue diff --git a/addons/licenses/internal/licenses.gd b/addons/licenses/internal/licenses.gd index c82be8c..fcd1331 100644 --- a/addons/licenses/internal/licenses.gd +++ b/addons/licenses/internal/licenses.gd @@ -27,7 +27,7 @@ func reload() -> void: else: self._license_file_edit.right_icon = self.get_theme_icon("NodeWarning", "EditorIcons") self._license_file_edit.tooltip_text = res.err_msg - res.components.sort_custom(Licenses.new().compare_components_ascending) + res.components.sort_custom(Licenses.compare_components_ascending) self._components_tree.set_components(res.components) func _update_set_license_filepath_button() -> void: diff --git a/addons/licenses/internal/toolbar.gd b/addons/licenses/internal/toolbar.gd index 2592d8d..a57336e 100644 --- a/addons/licenses/internal/toolbar.gd +++ b/addons/licenses/internal/toolbar.gd @@ -47,9 +47,9 @@ func _get_plugin_config(path: String) -> Dictionary: return {} var cfg_data: Dictionary = {} - for section in config.get_sections(): + for section: String in config.get_sections(): var section_data: Dictionary = {} - for key in config.get_section_keys(section): + for key: String in config.get_section_keys(section): section_data[key] = config.get_value(section, key) cfg_data[section] = section_data return cfg_data @@ -61,7 +61,7 @@ func _create_engine_menu_items() -> void: self._add_menu.add_child(self._add_engine_menu) var idx: int = 0 - for info in Engine.get_copyright_info(): + for info: Dictionary in Engine.get_copyright_info(): self._add_engine_menu.add_item(info["name"]) self._add_engine_menu.set_item_metadata(idx, info["name"]) idx = idx + 1 diff --git a/addons/licenses/internal/utils.gd b/addons/licenses/internal/utils.gd index 1b98507..3f02467 100644 --- a/addons/licenses/internal/utils.gd +++ b/addons/licenses/internal/utils.gd @@ -4,8 +4,8 @@ static func get_updated_property_list(object: Object) -> Array: var properties: Array = object.get_property_list() var patched_properties: Array = object._get_property_list() properties = properties.slice(0, properties.size() - patched_properties.size()) - for p_prop_idx in range(patched_properties.size()): - for prop_idx in range(properties.size()): + for p_prop_idx: int in range(patched_properties.size()): + for prop_idx: int in range(properties.size()): if properties[prop_idx]["name"] == patched_properties[p_prop_idx]["name"]: properties[prop_idx] = patched_properties[p_prop_idx] break diff --git a/addons/licenses/licenses.gd b/addons/licenses/licenses.gd index d62143b..ad0fc67 100644 --- a/addons/licenses/licenses.gd +++ b/addons/licenses/licenses.gd @@ -4,15 +4,14 @@ const Component := preload("component.gd") const DATA_FILE: String = "plugins/licenses/data_file" -# TODO: make static https://github.com/godotengine/godot/issues/69491 -func compare_components_ascending(lhs: Component, rhs: Component) -> bool: +static func compare_components_ascending(lhs: Component, rhs: Component) -> bool: var lhs_cat_lower: String = lhs.category.to_lower() var rhs_cat_lower: String = rhs.category.to_lower() return lhs_cat_lower < rhs_cat_lower or (lhs_cat_lower == rhs_cat_lower and lhs.name.to_lower() < rhs.name.to_lower()) static func get_engine_component(name: String) -> Component: var license_keys: Array = Engine.get_license_info().keys() - for info in Engine.get_copyright_info(): + for info: Dictionary in Engine.get_copyright_info(): if info["name"] != name: continue var component: Component = Component.new() @@ -23,7 +22,7 @@ static func get_engine_component(name: String) -> Component: component.copyright = info["parts"][0]["copyright"] var license_str: String = info["parts"][0]["license"] - for license_key in license_keys: + for license_key: String in license_keys: if license_key in license_str: var license: Component.License = Component.License.new() license.name = license_key @@ -43,30 +42,18 @@ static func get_engine_component(name: String) -> Component: return null static func get_engine_components() -> Array[Component]: - # https://github.com/godotengine/godot/issues/69491 - var compare_components_ascending: Callable = func(lhs: Component, rhs: Component) -> bool: - var lhs_cat_lower: String = lhs.category.to_lower() - var rhs_cat_lower: String = rhs.category.to_lower() - return lhs_cat_lower < rhs_cat_lower or (lhs_cat_lower == rhs_cat_lower and lhs.name.to_lower() < rhs.name.to_lower()) - var engine_components: Array[Component] = [] - for info in Engine.get_copyright_info(): + for info: Dictionary in Engine.get_copyright_info(): engine_components.append(get_engine_component(info["name"])) engine_components.sort_custom(compare_components_ascending) return engine_components static func get_required_engine_components() -> Array[Component]: - # https://github.com/godotengine/godot/issues/69491 - var compare_components_ascending: Callable = func(lhs: Component, rhs: Component) -> bool: - var lhs_cat_lower: String = lhs.category.to_lower() - var rhs_cat_lower: String = rhs.category.to_lower() - return lhs_cat_lower < rhs_cat_lower or (lhs_cat_lower == rhs_cat_lower and lhs.name.to_lower() < rhs.name.to_lower()) - var engine_components: Array[Component] = [] - for name in ["Godot Engine", "ENet", "The FreeType Project", "Mbed TLS"]: + for name: String in ["Godot Engine", "ENet", "The FreeType Project", "Mbed TLS"]: engine_components.append(get_engine_component(name)) engine_components.sort_custom(compare_components_ascending) @@ -77,7 +64,7 @@ static func save(components: Array[Component], file_path: String) -> int: if file == null: return FileAccess.get_open_error() var raw: Array = [] - for component in components: + for component: Component in components: raw.append(component.serialize()) file.store_line(JSON.stringify({"components": raw})) file = null @@ -109,7 +96,7 @@ static func load(file_path: String) -> LoadResult: return LoadResult.new([], "'%s' does not have a 'components' field" % [file_path]) var components: Array[Component] = [] - for raw in parser.data["components"]: + for raw: Dictionary in parser.data["components"]: components.append(Component.new().deserialize(raw)) components = components return LoadResult.new(components) diff --git a/addons/licenses/plugin.cfg b/addons/licenses/plugin.cfg index dfbff86..fc2237a 100644 --- a/addons/licenses/plugin.cfg +++ b/addons/licenses/plugin.cfg @@ -1,7 +1,19 @@ [plugin] name="License Manager" -description="MIT License" +description="Manage license and copyright for third party graphics, software or libraries." author="Iceflower S" -version="1.5.0" +version="1.6.0" script="plugin.gd" +license="MIT" +repository="https://github.com/kenyoni-software/godot-addons" +keywords=[ + "tool" +] +classifiers=[ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License" +] + +[plugin.dependencies] +godot=">=4.2" \ No newline at end of file diff --git a/addons/licenses/plugin.gd b/addons/licenses/plugin.gd index cb7411d..02c8fe4 100644 --- a/addons/licenses/plugin.gd +++ b/addons/licenses/plugin.gd @@ -12,21 +12,25 @@ func _get_plugin_name() -> String: return "Licenses" func _enter_tree() -> void: - self.set_project_setting(Licenses.DATA_FILE, "res://licenses.json", TYPE_STRING, PROPERTY_HINT_FILE) + set_project_setting(Licenses.DATA_FILE, "res://licenses.json", TYPE_STRING, PROPERTY_HINT_FILE) self.export_plugin = ExportPlugin.new() self.add_export_plugin(self.export_plugin) self.licenses_dialog = LicensesDialogScene.instantiate() - self.get_editor_interface().get_base_control().add_child(self.licenses_dialog) + EditorInterface.get_base_control().add_child(self.licenses_dialog) self.add_tool_menu_item(self._get_plugin_name() + "...", self._show_popup) func _exit_tree() -> void: self.remove_tool_menu_item(self._get_plugin_name() + "...") + self.licenses_dialog.queue_free() self.remove_export_plugin(self.export_plugin) func _show_popup() -> void: - self.licenses_dialog.popup_centered_ratio(0.4) + if licenses_dialog.visible: + self.licenses_dialog.grab_focus() + else: + self.licenses_dialog.popup_centered_ratio(0.4) static func set_project_setting(key: String, initial_value, type: int, type_hint: int) -> void: if not ProjectSettings.has_setting(key): diff --git a/addons/qr_code/bit_stream.gd b/addons/qr_code/bit_stream.gd index ac422c1..19e11e9 100644 --- a/addons/qr_code/bit_stream.gd +++ b/addons/qr_code/bit_stream.gd @@ -23,7 +23,7 @@ func to_byte_array() -> PackedByteArray: var byte_arr: PackedByteArray = [] var cur_byte: int = 0 - for idx in range(self._data.size()): + for idx: int in range(self._data.size()): var byte_idx: int = 7 - idx % 8 if self._data[idx]: cur_byte = _set_state(cur_byte, byte_idx) @@ -42,15 +42,15 @@ func append_stream(stream) -> void: self._data.append_array(stream.get_array()) func append_byte_array(arr: PackedByteArray) -> void: - for val in arr: + for val: int in arr: self.append(val, 8) func prepend(value: int, total_bits: int) -> void: - for idx in range(total_bits - 1, -1, -1): + for idx: int in range(total_bits - 1, -1, -1): self._data.insert(0, int(get_state(value, idx))) func append(value: int, total_bits: int) -> void: - for idx in range(total_bits - 1, -1, -1): + for idx: int in range(total_bits - 1, -1, -1): self._data.append(int(get_state(value, idx))) func set_bit(idx: int, bit: bool) -> void: @@ -61,7 +61,7 @@ func get_bit(idx: int) -> bool: func _to_string() -> String: var val: String = "" - for idx in range(self._data.size()): + for idx: int in range(self._data.size()): if (idx + 1) % 8 == 1: val += "[" val += str(self._data[idx]) diff --git a/addons/qr_code/plugin.cfg b/addons/qr_code/plugin.cfg index 9eb4f3d..eb5274b 100644 --- a/addons/qr_code/plugin.cfg +++ b/addons/qr_code/plugin.cfg @@ -1,7 +1,20 @@ [plugin] name="QR Code" -description="QR Code generator. - MIT License" +description="QR Code generator." author="Iceflower S" -version="1.0.0" +version="1.1.0" script="plugin.gd" +license="MIT" +repository="https://github.com/kenyoni-software/godot-addons" +keywords=[ + "node", + "tool" +] +classifiers=[ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License" +] + +[plugin.dependencies] +godot=">=4.2" \ No newline at end of file diff --git a/addons/qr_code/qr_code.gd b/addons/qr_code/qr_code.gd index 594997b..ab2e739 100644 --- a/addons/qr_code/qr_code.gd +++ b/addons/qr_code/qr_code.gd @@ -783,7 +783,7 @@ func get_module_count() -> int: ## returns -1 if too huge func calc_min_version() -> int: var input_size: int = self._get_input_data_size() - for idx in range(_DATA_CAPACITY.size()): + for idx: int in range(_DATA_CAPACITY.size()): var cap: int = _DATA_CAPACITY[idx][self.error_correction][self.mode] if self.eci_value != ECI.ISO_8859_1: # subtract roughly eci header size @@ -830,8 +830,8 @@ static func _calc_module_count(version: int) -> int: func _get_allignment_pattern_positions() -> Array[Vector2i]: var module_count: int = self.get_module_count() var positions: Array[Vector2i] = [] - for row in _ALIGNMENT_PATTERN_POSITIONS[self.version - 1]: - for col in _ALIGNMENT_PATTERN_POSITIONS[self.version - 1]: + for row: int in _ALIGNMENT_PATTERN_POSITIONS[self.version - 1]: + for col: int in _ALIGNMENT_PATTERN_POSITIONS[self.version - 1]: # do not overlap finder positions if row - 2 < 8 && col - 2 < 8 || \ row > module_count - 8 && col - 2 < 8 || \ @@ -914,16 +914,16 @@ func generate_image(module_px_size: int = 1, light_module_color: Color = Color.W var image: Image = Image.create(image_size, image_size, false, Image.FORMAT_RGB8) image.fill(light_module_color) - for y in range(module_count): - for x in range(module_count): + for y: int in range(module_count): + for x: int in range(module_count): var color: Color = Color.PINK match qr_code[x + y * module_count]: 0: color = light_module_color 1: color = dark_module_color - for offset_x in range(module_px_size): - for offset_y in range(module_px_size): + for offset_x: int in range(module_px_size): + for offset_y: int in range(module_px_size): image.set_pixel((x + quiet_zone_size) * module_px_size + offset_x, (y + quiet_zone_size) * module_px_size + offset_y, color) return image @@ -1014,7 +1014,7 @@ func _encode_data() -> BitStream: # pad bytes to capacity var missing_bytes = required_bytes - stream.size() / 8 - for idx in range(missing_bytes): + for idx: int in range(missing_bytes): if idx % 2 == 0: stream.append(236, 8) else: @@ -1029,7 +1029,7 @@ func _encode_numeric(stream: BitStream) -> void: assert(typeof(self._input_data) == TYPE_STRING) const GROUP_SIZE: int = 3 - for idx in range(ceili(self._input_data.length() / float(GROUP_SIZE))): + for idx: int in range(ceili(self._input_data.length() / float(GROUP_SIZE))): var chars: String = self._input_data.substr(idx * GROUP_SIZE, GROUP_SIZE) var number: int = chars.to_int() var bit_count: int = 0 @@ -1046,7 +1046,7 @@ func _encode_alphanumeric(stream: BitStream) -> void: assert(typeof(self._input_data) == TYPE_STRING) const GROUP_SIZE: int = 2 - for idx in range(ceili(self._input_data.length() / float(GROUP_SIZE))): + for idx: int in range(ceili(self._input_data.length() / float(GROUP_SIZE))): var chars: String = self._input_data.substr(idx * GROUP_SIZE, GROUP_SIZE) var number: int = _get_alphanumeric_number(chars[0]) if chars.length() == 2: @@ -1058,14 +1058,14 @@ func _encode_alphanumeric(stream: BitStream) -> void: func _encode_byte(stream: BitStream) -> void: assert(typeof(self._input_data) == TYPE_PACKED_BYTE_ARRAY) - for val in self._input_data: + for val: int in self._input_data: stream.append(val, 8) func _encode_kanji(stream: BitStream) -> void: assert(typeof(self._input_data) == TYPE_STRING) var jis_bytes: PackedByteArray = ShiftJIS.to_shift_jis_2004_buffer(self._input_data) - for idx in range(jis_bytes.size() / 2): + for idx: int in range(jis_bytes.size() / 2): var value = jis_bytes.decode_u16(idx * 2) if value >= 0x8140 && value <= 0x9FFC: value = value - 0x8140 @@ -1092,12 +1092,12 @@ func _error_correction(stream: BitStream) -> Array[PackedByteArray]: groups += 1 var err_corr: Array[PackedByteArray] = [] - for group_idx in range(groups): + for group_idx: int in range(groups): var block_size: int = group_codewords[group_idx] - for block_idx in range(group_blocks[group_idx]): + for block_idx: int in range(group_blocks[group_idx]): var start_idx: int = 0 # add offset to current group - for group_off in range(group_idx): + for group_off: int in range(group_idx): start_idx += group_blocks[group_off] * group_codewords[group_off] start_idx = start_idx + block_idx * block_size var cur_data: PackedByteArray = data.slice(start_idx, start_idx + block_size) @@ -1129,21 +1129,21 @@ func _structure_data(data_stream: BitStream, err_correction: Array[PackedByteArr # interleave data code words var max_code_words: int = group_codewords.max() - for codeword_idx in range(max_code_words): - for group_idx in range(groups): + for codeword_idx: int in range(max_code_words): + for group_idx: int in range(groups): # if current group/block has not this much codewords skip if codeword_idx >= group_codewords[group_idx]: continue var group_offset: int = 0 - for group_off in range(group_idx): + for group_off: int in range(group_idx): group_offset += group_blocks[group_off] * group_codewords[group_off] - for block_idx in range(group_blocks[group_idx]): + for block_idx: int in range(group_blocks[group_idx]): var idx: int = group_offset + codeword_idx + block_idx * group_codewords[group_idx] res.append(data_arr[idx], 8) # interleave error code words - for word_idx in range(self._get_ec_codeword_count()): - for block in range(err_correction.size()): + for word_idx: int in range(self._get_ec_codeword_count()): + for block: int in range(err_correction.size()): res.append(err_correction[block][word_idx], 8) # append remainder bits @@ -1154,30 +1154,30 @@ func _structure_data(data_stream: BitStream, err_correction: Array[PackedByteArr # pos is upper left black corner # 7 x 7 size static func _place_finder(data: PackedByteArray, module_count: int, pos: Vector2i) -> void: - for row in range(7): - for col in range(7): + for row: int in range(7): + for col: int in range(7): data[(pos.x + row) + (pos.y + col) * module_count] = 1 - for idx in range(5): + for idx: int in range(5): data[(pos.x + 1 + idx) + (pos.y + 1) * module_count] = 0 data[(pos.x + 1 + idx) + (pos.y + 5) * module_count] = 0 - for idx in range(3): + for idx: int in range(3): data[(pos.x + 1) + (pos.y + 2 + idx) * module_count] = 0 data[(pos.x + 5) + (pos.y + 2 + idx) * module_count] = 0 # pos is center # 5 x 5 size static func _place_align_pattern(data: PackedByteArray, module_count: int, pos: Vector2i) -> void: - for row in range(5): - for col in range(5): + for row: int in range(5): + for col: int in range(5): data[(pos.x - 2 + row) + (pos.y - 2 + col) * module_count] = 1 - for idx in range(3): + for idx: int in range(3): data[(pos.x - 1 + idx) + (pos.y - 1) * module_count] = 0 data[(pos.x - 1 + idx) + (pos.y + 1) * module_count] = 0 data[(pos.x - 1) + (pos.y) * module_count] = 0 data[(pos.x + 1) + (pos.y) * module_count] = 0 static func _place_separators(data: PackedByteArray, module_count: int) -> void: - for idx in range(8): + for idx: int in range(8): # upper left data[idx + 7 * module_count] = 0 data[7 + idx * module_count] = 0 @@ -1189,7 +1189,7 @@ static func _place_separators(data: PackedByteArray, module_count: int) -> void: data[7 + (module_count - idx - 1) * module_count] = 0 static func _place_timing_patterns(data: PackedByteArray, module_count: int) -> void: - for idx in range(module_count - 6 * 2): + for idx: int in range(module_count - 6 * 2): data[6 + idx + 6 * module_count] = (idx + 1) % 2 data[6 + (6 + idx) * module_count] = (idx + 1) % 2 @@ -1208,7 +1208,7 @@ static func _is_data_module(module_count: int, alignment_pattern_pos: Array[Vect return false # check if in alignment pattern - for align_pos in alignment_pattern_pos: + for align_pos: Vector2i in alignment_pattern_pos: if pos.x >= align_pos.x - 2 && pos.x <= align_pos.x + 2 && pos.y >= align_pos.y - 2 && pos.y <= align_pos.y + 2: return false @@ -1225,10 +1225,10 @@ static func _place_data(data: PackedByteArray, module_count: int, alignment_patt if base_col == 6: base_col -= 1 - for row in range(module_count): + for row: int in range(module_count): if upwards: row = module_count - 1 - row - for offset in range(2): + for offset: int in range(2): var pos: Vector2i = Vector2i(base_col - offset, row) if _is_data_module(module_count, alignment_pattern_pos, pos): data[pos.x + pos.y * module_count] = int(structured_data.get_bit(data_idx)) @@ -1245,10 +1245,10 @@ static func _calc_mask_rating(data: PackedByteArray, module_count: int) -> int: # condition 1 # horizontal - for y in range(module_count): + for y: int in range(module_count): var count: int = 0 var block_value: int = 0 - for x in range(module_count): + for x: int in range(module_count): var cur_value: int = data[x + y * module_count] if cur_value == block_value: count += 1 @@ -1260,10 +1260,10 @@ static func _calc_mask_rating(data: PackedByteArray, module_count: int) -> int: if count >= 5: rating += count - 2 # vertical - for x in range(module_count): + for x: int in range(module_count): var count: int = 0 var block_value: int = 0 - for y in range(module_count): + for y: int in range(module_count): var cur_value: int = data[x + y * module_count] if cur_value == block_value: count += 1 @@ -1276,15 +1276,15 @@ static func _calc_mask_rating(data: PackedByteArray, module_count: int) -> int: rating += count - 2 # condition 2 - for x in range(module_count - 1): - for y in range(module_count - 1): + for x: int in range(module_count - 1): + for y: int in range(module_count - 1): var val: int = data[x + y * module_count] + data[x + 1 + y * module_count] + data[x + (y + 1) * module_count] + data[x + 1 + (y + 1) * module_count] if val == 0 or val == 4: rating += 3 # condition 3 - for y in range(module_count): - for x in range(module_count - 6): + for y: int in range(module_count): + for x: int in range(module_count - 6): var start_idx: int = x + y * module_count if (!data[start_idx] && data[start_idx + 1] @@ -1298,8 +1298,8 @@ static func _calc_mask_rating(data: PackedByteArray, module_count: int) -> int: if x <= (module_count - 10) && data[start_idx + 7] && data[start_idx + 8] && data[start_idx + 9] && data[start_idx + 10]: rating += 40 - for x in range(module_count): - for y in range(module_count - 6): + for x: int in range(module_count): + for y: int in range(module_count - 6): if (!data[x + y * module_count] && data[x + (y + 1) * module_count] && !data[x + (y + 2) * module_count] @@ -1323,12 +1323,12 @@ static func _place_format(qr_data: PackedByteArray, module_count: int, error_cor var base_code: int = (int(error_corr) << 3) | mask_pattern_val var code: int = base_code - for _idx in range(10): + for _idx: int in range(10): code = (code << 1) ^ ((code >> 9) * 0x537) code = (base_code << 10 | code) ^ 0x5412 # upper left finder - for idx in range(8): + for idx: int in range(8): # skip timing pattern var pos: int = idx if idx > 5: @@ -1338,10 +1338,10 @@ static func _place_format(qr_data: PackedByteArray, module_count: int, error_cor # vertical qr_data[8 + pos * module_count] = int(_get_state(code, idx)) # lower left finder - for idx in range(7): + for idx: int in range(7): qr_data[8 + (module_count - 1 - idx) * module_count] = int(_get_state(code, 14 - idx)) # upper right finder - for idx in range(8): + for idx: int in range(8): qr_data[(module_count - 1 - idx) + 8 * module_count] = int(_get_state(code, idx)) static func _place_version(qr_data: PackedByteArray, version: int) -> void: @@ -1349,12 +1349,12 @@ static func _place_version(qr_data: PackedByteArray, version: int) -> void: return var code: int = version - for _idx in range(12): + for _idx: int in range(12): code = (code << 1) ^ ((code >> 11) * 0x1F25) code = version << 12 | code var module_count: int = _calc_module_count(version) - for idx in range(18): + for idx: int in range(18): var x: int = idx / 3 var y: int = module_count - 11 + idx % 3 qr_data[x + y * module_count] = int(_get_state(code, idx)) @@ -1379,7 +1379,7 @@ func _place_modules(structured_data: BitStream) -> PackedByteArray: _place_separators(qr_data, module_count) var alignment_pattern_pos: Array[Vector2i] = self._get_allignment_pattern_positions() - for pos in alignment_pattern_pos: + for pos: Vector2i in alignment_pattern_pos: _place_align_pattern(qr_data, module_count, pos) _place_timing_patterns(qr_data, module_count) @@ -1395,8 +1395,8 @@ func _place_modules(structured_data: BitStream) -> PackedByteArray: static func _mask(qr_data: PackedByteArray, module_count: int, alignment_pattern_pos: Array[Vector2i], mask_pattern: int) -> void: var mask_fn: Callable = _mask_pattern_fns()[mask_pattern] - for x in range(module_count): - for y in range(module_count): + for x: int in range(module_count): + for y: int in range(module_count): var pos: Vector2i = Vector2i(x, y) if _is_data_module(module_count, alignment_pattern_pos, pos): var idx: int = x + y * module_count @@ -1407,7 +1407,7 @@ func _get_best_qr_mask(masked_qrs: Array[PackedByteArray], module_count: int) -> var min_idx: int = 0 # integer max var cur_min_value: int = 9223372036854775807 - for idx in range(masked_qrs.size()): + for idx: int in range(masked_qrs.size()): var rating: int = _calc_mask_rating(masked_qrs[idx], module_count) if rating < cur_min_value: min_idx = idx @@ -1431,7 +1431,7 @@ func _mask_qr(qr_data: PackedByteArray) -> PackedByteArray: var masked_qr: Array[PackedByteArray] = [] var mask_fns: Array[Callable] = _mask_pattern_fns() - for pattern_idx in range(mask_fns.size()): + for pattern_idx: int in range(mask_fns.size()): var cur_qr: PackedByteArray = qr_data.duplicate() _mask(cur_qr, module_count, alignment_pattern_pos, pattern_idx) # normally the format version is applied AFTER getting the best pattern, but will produce worse qr codes @@ -1447,9 +1447,9 @@ func _mask_qr(qr_data: PackedByteArray) -> PackedByteArray: #### DEVEL TOOLS static func _print_qr(data: PackedByteArray, module_count: int) -> void: - for y in range(module_count): + for y: int in range(module_count): var row: String = "" - for x in range(module_count): + for x: int in range(module_count): var value: int = data[y * module_count + x] match value: 0: @@ -1466,7 +1466,7 @@ static func _print_qr(data: PackedByteArray, module_count: int) -> void: static func _bin_to_string(value: int, bits: int = 8) -> String: var val: String = "" - for idx in range(bits): + for idx: int in range(bits): if idx % 4 == 0: val = " " + val val = str(int(bool(value & (1 << idx)))) + val @@ -1474,6 +1474,6 @@ static func _bin_to_string(value: int, bits: int = 8) -> String: static func _arr_to_string(arr: PackedByteArray) -> String: var val: String = "" - for byte in arr: + for byte: int in arr: val += "[" + _bin_to_string(byte, 8) + "] " return val.strip_edges() diff --git a/addons/qr_code/reed_solomon.gd b/addons/qr_code/reed_solomon.gd index 84e348f..de09fbf 100644 --- a/addons/qr_code/reed_solomon.gd +++ b/addons/qr_code/reed_solomon.gd @@ -23,7 +23,7 @@ static func _create_log_anti_log_tables() -> void: _anti_log_table.fill(0) _log_table.resize(256) _log_table.fill(0) - for degree in range(0, 256): + for degree: int in range(0, 256): var value: int = _anti_log(degree) _anti_log_table[degree] = value _log_table[value] = degree % 255 @@ -47,9 +47,9 @@ static func generator_polynom(size: int) -> PackedByteArray: res[0] = 1 var a_j: int = 1 - for exp in range(0, size): + for exp: int in range(0, size): var cur_val: int = a_j - for cur_exp in range(1, exp + 1): + for cur_exp: int in range(1, exp + 1): var old_res: int = res[cur_exp] res[cur_exp] = cur_val ^ old_res cur_val = mul(old_res, a_j) @@ -65,12 +65,12 @@ static func encode(data: PackedByteArray, code_words: int) -> PackedByteArray: enc_msg.resize(len(data) + len(gen_poly) - 1) enc_msg.fill(0) - for idx in range(len(data)): + for idx: int in range(len(data)): enc_msg[idx] = data[idx] - for idx in range(len(data)): + for idx: int in range(len(data)): var coef: int = enc_msg[idx] - for p_idx in range(1, len(gen_poly)): + for p_idx: int in range(1, len(gen_poly)): enc_msg[idx+p_idx] ^= mul(gen_poly[p_idx], coef) return enc_msg.slice(len(data)) diff --git a/addons/qr_code/shift_jis.gd b/addons/qr_code/shift_jis.gd index cbd1f59..69a6fca 100644 --- a/addons/qr_code/shift_jis.gd +++ b/addons/qr_code/shift_jis.gd @@ -35,7 +35,7 @@ static func get_string_from_shift_jis_2004(arr: PackedByteArray) -> String: assert(arr.size() % 2 == 0) var res: String = "" - for idx in range(arr.size() / 2): + for idx: int in range(arr.size() / 2): var unicode: int = _SHIFT_JIS_TO_UNICODE_TABLE.get(arr.decode_u16(idx * 2), -1) if unicode != -1: res += char(unicode) @@ -50,7 +50,7 @@ static func to_jis_8_buffer(text: String) -> PackedByteArray: res.resize(text.length()) var byte_idx: int = 0 - for idx in range(text.length()): + for idx: int in range(text.length()): var unicode: int = text.unicode_at(idx) var jis_val: int = _UNICODE_TO_SHIFT_JIS_TABLE.get(unicode, -1) if jis_val != -1 && jis_val <= 0xFF: @@ -66,7 +66,7 @@ static func to_jis_8_buffer(text: String) -> PackedByteArray: static func get_string_from_jis_8(arr: PackedByteArray) -> String: var res: String = "" - for idx in range(arr.size()): + for idx: int in range(arr.size()): var unicode: int = _SHIFT_JIS_TO_UNICODE_TABLE.get(arr.decode_u8(idx), -1) if unicode != -1: res += char(unicode) diff --git a/addons/texture_button_colored/plugin.cfg b/addons/texture_button_colored/plugin.cfg index 6813021..edb2023 100644 --- a/addons/texture_button_colored/plugin.cfg +++ b/addons/texture_button_colored/plugin.cfg @@ -1,7 +1,19 @@ [plugin] name="TextureButtonColored" -description="TextureButton with color theme. - MIT License" +description="TextureButton with color theme." author="Iceflower S" -version="1.2.3" +version="1.3.0" script="plugin.gd" +license="MIT" +repository="https://github.com/kenyoni-software/godot-addons" +keywords=[ + "node" +] +classifiers=[ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License" +] + +[plugin.dependencies] +godot=">=4.2" \ No newline at end of file diff --git a/project.godot b/project.godot index 71431ee..0c56908 100644 --- a/project.godot +++ b/project.godot @@ -11,9 +11,9 @@ config_version=5 [application] config/name="Godot Addons" -config/features=PackedStringArray("4.1", "Forward Plus") -config/icon="res://icon.svg" config/version="1.0.0" +config/features=PackedStringArray("4.2", "Forward Plus") +config/icon="res://icon.svg" [autoload] diff --git a/publisher/addon_cfg.go b/publisher/addon.go similarity index 52% rename from publisher/addon_cfg.go rename to publisher/addon.go index c974b08..364228a 100644 --- a/publisher/addon_cfg.go +++ b/publisher/addon.go @@ -2,52 +2,65 @@ package main import ( "archive/zip" + "log" "os" "path/filepath" - "strings" "github.com/pelletier/go-toml/v2" ) -type addonConfig struct { +type pluginCfg struct { + Plugin struct { + Author string `toml:"author"` + Description string `toml:"description"` + Classifiers []string `toml:"classifiers"` + License string `toml:"license"` + Keywords []string `toml:"keywords"` + Name string `toml:"name"` + Repository string `toml:"repository"` + Script string `toml:"script"` + Version string `toml:"version"` + + Dependencies struct { + Godot string `toml:"godot"` + } `toml:"dependencies"` + } `toml:"plugin"` +} + +type addon struct { addonId string projectPath string } -func newAddonConfig(name string, projectPath string) *addonConfig { - return &addonConfig{ +func newAddon(name string, projectPath string) *addon { + return &addon{ addonId: name, projectPath: projectPath, } } -func (addon *addonConfig) Id() string { +func (addon *addon) Id() string { return addon.addonId } -func (addon *addonConfig) ProjectPath() string { +func (addon *addon) ProjectPath() string { return addon.projectPath } -func (addon *addonConfig) Path() string { +func (addon *addon) Path() string { return filepath.Join(addon.projectPath, "addons", addon.Id()) } -func (addon *addonConfig) PluginCfgPath() string { +func (addon *addon) PluginCfgPath() string { return filepath.Join(addon.Path(), "plugin.cfg") } -func (addon *addonConfig) Zip() error { - exampleDir := filepath.Join(addon.ProjectPath(), "examples", addon.Id()) - - version, err := addon.GetVersion() +func (addon *addon) Zip(outputFile string) error { + err := os.MkdirAll(filepath.Dir(outputFile), os.ModePerm) if err != nil { - return err + log.Fatalln(err) } - - destZip := filepath.Join(addon.ProjectPath(), "archives", addon.Id()+"-"+strings.ReplaceAll(version, ".", "_")+".zip") - - file, err := os.Create(destZip) + file, err := os.Create(outputFile) if err != nil { return err } @@ -61,6 +74,7 @@ func (addon *addonConfig) Zip() error { if err != nil { return err } + exampleDir := filepath.Join(addon.ProjectPath(), "examples", addon.Id()) err = zipDir(zw, exampleDir, filepath.Join("examples", addon.Id())) if err != nil { return err @@ -78,20 +92,16 @@ func (addon *addonConfig) Zip() error { return nil } -func (addon *addonConfig) GetVersion() (string, error) { +func (addon *addon) GetPluginCfg() (*pluginCfg, error) { dat, err := os.ReadFile(addon.PluginCfgPath()) if err != nil { - return "", err + return nil, err } - tmp := struct { - Plugin struct { - Version string `toml:"version"` - } `toml:"plugin"` - }{} - err = toml.Unmarshal(dat, &tmp) + tmp := &pluginCfg{} + err = toml.Unmarshal(dat, tmp) if err != nil { - return "", err + return nil, err } - return tmp.Plugin.Version, nil + return tmp, nil } diff --git a/publisher/cli.go b/publisher/cli.go new file mode 100644 index 0000000..efb4244 --- /dev/null +++ b/publisher/cli.go @@ -0,0 +1,132 @@ +package main + +import ( + "errors" + "fmt" + "io" + "log" + "os" + "path/filepath" + "strings" + + "github.com/spf13/cobra" +) + +const ( + actionGithub = "github" + actionZip = "zip" +) + +type cli struct { + rootCmd *cobra.Command + + Addon string + BaseDir string + + GithubAction struct { + OutputFile string + } + ZipAction struct { + OutputDir string + } +} + +func newCli() *cli { + c := cli{ + GithubAction: struct{ OutputFile string }{}, + ZipAction: struct{ OutputDir string }{}, + } + + c.rootCmd = &cobra.Command{ + Use: "publisher", + Short: "Kenyoni Godot Addon publishing helper", + } + c.rootCmd.PersistentFlags().StringVarP(&c.BaseDir, "baseDir", "b", "./", "Base directory of the project.") + c.rootCmd.MarkFlagRequired("baseDir") + c.rootCmd.PersistentFlags().StringVarP(&c.Addon, "addon", "a", "", "Addon to proceed.") + c.rootCmd.MarkFlagRequired("addon") + + ghCmd := &cobra.Command{ + Use: "github", + Short: "Save information about an addon to the given file, to be used with $GITHUB_OUTPUT", + Run: func(cmd *cobra.Command, args []string) { + doActionGithub(c.BaseDir, c.Addon, c.GithubAction.OutputFile) + }, + } + ghCmd.Flags().StringVarP(&c.GithubAction.OutputFile, "output", "o", "", "Output file to write the result into.") + ghCmd.MarkFlagRequired("output") + + zipCmd := &cobra.Command{ + Use: "zip", + Short: "Zip specified addon release ready.", + Run: func(cmd *cobra.Command, args []string) { + doActionZip(c.BaseDir, c.Addon, c.ZipAction.OutputDir) + }, + } + zipCmd.Flags().StringVarP(&c.ZipAction.OutputDir, "output", "o", "", "Output directory to place the archive into.") + zipCmd.MarkFlagRequired("output") + + c.rootCmd.AddCommand(ghCmd, zipCmd) + + return &c +} + +func (c *cli) Execute() { + err := c.rootCmd.Execute() + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} + +func doActionGithub(baseDir string, addon string, outputFile string) { + addonCfg := newAddon(addon, baseDir) + plg, err := addonCfg.GetPluginCfg() + if err != nil { + log.Fatalln(err) + } + outputStr := fmt.Sprintf("version=%s\n", plg.Plugin.Version) + descStr := "" + if plg.Plugin.Name != "" { + descStr += plg.Plugin.Name + " - " + plg.Plugin.Version + "\n" + } + if plg.Plugin.Description != "" { + descStr += plg.Plugin.Description + "\n" + } + if plg.Plugin.Dependencies.Godot != "" { + descStr += "Godot Compatibility: " + plg.Plugin.Dependencies.Godot + "\n" + } + outputStr += fmt.Sprintf("notes<<%s\n%s%s\n", io.EOF, descStr, io.EOF) + + oFile, err := os.OpenFile(outputFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + log.Fatalln(err) + } + defer oFile.Close() + _, err = oFile.WriteString(outputStr) + if err != nil { + log.Fatalln(err) + } +} + +func doActionZip(baseDir string, addon string, outputDir string) { + addonDir := filepath.Join(baseDir, "addons", addon) + _, err := os.Stat(addonDir) + if errors.Is(err, os.ErrNotExist) { + log.Fatalf("Directory '%s' does not exist", addonDir) + } + if err != nil { + log.Fatalln(err) + } + + addonCfg := newAddon(addon, baseDir) + plgCfg, err := addonCfg.GetPluginCfg() + if err != nil { + log.Fatalln(err) + } + outputFile := filepath.Join(addonCfg.ProjectPath(), "archives", addonCfg.Id()+"-"+strings.ReplaceAll(plgCfg.Plugin.Version, ".", "_")+".zip") + err = addonCfg.Zip(outputFile) + if err != nil { + log.Fatalln(err) + } +} diff --git a/publisher/cmd_parser.go b/publisher/cmd_parser.go deleted file mode 100644 index 3f7df69..0000000 --- a/publisher/cmd_parser.go +++ /dev/null @@ -1,50 +0,0 @@ -package main - -import ( - "flag" - "log" - "os" -) - -const ( - actionZip = "zip" - actionVersion = "version" -) - -type cmdParser struct { - fs *flag.FlagSet - Action string - Directory string - Addons []string -} - -// Parse might exit the program -func (cp *cmdParser) Parse(arguments []string) { - err := cp.fs.Parse(arguments) - if err != nil { - log.Fatalln(err) - } - - if cp.fs.NArg() < 2 { - cp.fs.Usage() - log.Fatalln() - } - cp.Action = cp.fs.Arg(0) - if cp.Action != actionVersion && cp.Action != actionZip { - cp.fs.Usage() - log.Fatalln() - } - cp.Directory = cp.fs.Arg(1) - cp.Addons = cp.fs.Args()[2:] - if cp.Action == actionZip && len(cp.Addons) != 1 { - cp.fs.Usage() - log.Fatalln() - } -} - -func newCmdParser() *cmdParser { - cp := cmdParser{ - fs: flag.NewFlagSet(os.Args[0], flag.ExitOnError), - } - return &cp -} diff --git a/publisher/go.mod b/publisher/go.mod index 6cdc039..21ace8e 100644 --- a/publisher/go.mod +++ b/publisher/go.mod @@ -1,5 +1,13 @@ module github.com/kenyoni-software/godot-addons/publisher -go 1.20 +go 1.21 -require github.com/pelletier/go-toml/v2 v2.0.8 +require ( + github.com/pelletier/go-toml/v2 v2.1.0 + github.com/spf13/cobra v1.7.0 +) + +require ( + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect +) diff --git a/publisher/go.sum b/publisher/go.sum index ec2379f..7367744 100644 --- a/publisher/go.sum +++ b/publisher/go.sum @@ -1,17 +1,25 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= -github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= +github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/publisher/main.go b/publisher/main.go index 4d4a2c8..06ebdfd 100644 --- a/publisher/main.go +++ b/publisher/main.go @@ -1,55 +1,5 @@ package main -import ( - "fmt" - "log" - "os" - "path/filepath" -) - func main() { - cmdP := newCmdParser() - cmdP.Parse(os.Args[1:]) - - var err error - switch cmdP.Action { - case actionVersion: - addonCfg := newAddonConfig(cmdP.Addons[0], cmdP.Directory) - version, err := addonCfg.GetVersion() - if err != nil { - log.Fatalln(err) - } - fmt.Println(version) - case actionZip: - err = iterDirectories(cmdP.Directory, cmdP.Addons) - } - if err != nil { - log.Fatalln(err) - } -} - -func iterDirectories(baseDir string, addons []string) error { - err := os.MkdirAll(filepath.Join(baseDir, "archives"), os.ModePerm) - if err != nil { - return err - } - - dirs, err := os.ReadDir(filepath.Join(baseDir, "addons")) - if err != nil { - return err - } - for _, dir := range dirs { - if !dir.IsDir() { - continue - } - if len(addons) != 0 && !contains(addons, dir.Name()) { - continue - } - addonCfg := newAddonConfig(dir.Name(), baseDir) - err = addonCfg.Zip() - if err != nil { - return err - } - } - return nil + newCli().Execute() } diff --git a/publisher/utils.go b/publisher/utils.go index 4009a89..1db78e0 100644 --- a/publisher/utils.go +++ b/publisher/utils.go @@ -34,12 +34,3 @@ func zipFile(zw *zip.Writer, src string, dest string) error { _, err = io.Copy(zf, file) return err } - -func contains[T comparable](elems []T, v T) bool { - for _, s := range elems { - if v == s { - return true - } - } - return false -}