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 Sep 1, 2024
2 parents eaf376c + c5abf12 commit a79bba2
Show file tree
Hide file tree
Showing 11 changed files with 176 additions and 9 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,67 @@ jobs:
config:
- {
id: "aspect_ratio_resize_container",
id-name: "aspect_ratio_resize_container",
name: "AspectRatioResizeContainer",
asset-id: "2089",
}
- {
id: "custom_theme_overrides",
id-name: "custom_theme_overrides",
name: "Custom Theme Overrides",
asset-id: "2091",
}
- {
id: "git_sha_project_setting",
id-name: "git_sha_project_setting",
name: "Git SHA Project Setting",
asset-id: "1979",
}
- {
id: "glogging",
id-name: "glogging",
name: "GLogging",
asset-id: "no-deploy",
}
- {
id: "hide_private_properties",
id-name: "hide_private_properties",
name: "Hide Private Properties",
asset-id: "1989",
}
- {
id: "icon_explorer",
id-name: "icon_explorer",
name: "Icon Explorer",
asset-id: "2511",
}
- {
id: "icons_patcher",
id-name: "icons_patcher",
name: "Icons Patcher",
asset-id: "1980",
}
- {
id: "licenses",
id-name: "licenses",
name: "License Manager",
asset-id: "1969",
}
- {
id: "kenyoni/plugin_reloader",
id-name: "plugin_reloader",
name: "Plugin Reloader",
asset-id: "no-deploy",
}
- {
id: "qr_code",
id-name: "qr_code",
name: "QR Code",
asset-id: "2090",
}
- {
id: "texture_button_colored",
id-name: "texture_button_colored",
name: "TextureButtonColored",
asset-id: "2092",
}
Expand Down Expand Up @@ -92,20 +108,20 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.config.name }}
path: archives/${{ matrix.config.id }}-*.zip
path: archives/${{ matrix.config.id-name }}-*.zip

- uses: mukunku/[email protected]
id: checkTag
with:
tag: ${{ matrix.config.id }}-${{ steps.prepare-artifacts.outputs.version }}
tag: ${{ matrix.config.id-name }}-${{ 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 [email protected]
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-name }}-${{ steps.prepare-artifacts.outputs.version }}
git push origin tag ${{ matrix.config.id-name }}-${{ 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
Expand All @@ -117,7 +133,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
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 }}"
gh release create ${{ matrix.config.id-name }}-${{ steps.prepare-artifacts.outputs.version }} ./archives/* --title "${{ matrix.config.name }} ${{ steps.prepare-artifacts.outputs.version }}" --notes "${{ steps.prepare-artifacts.outputs.notes }}"
#- name: Deploy to Godot Asset Library
# if: ${{ matrix.config.asset-id != 'no-deploy' }}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ If you import any plugin or open a Godot project for the first time, the plugins
Manage license and copyright for third party graphics, software or libraries.
- [Logging](https://kenyoni-software.github.io/godot-addons/addons/glogging)
Simple logger.
- [Plugin Reloader](https://kenyoni-software.github.io/godot-addons/addons/plugin_reloader)
Enable or disable plugins from within the editor main screen.
- [QR Code](https://kenyoni-software.github.io/godot-addons/addons/qr_code)
QRCodeRect and QR Code generation.
- [TextureButtonColored](https://kenyoni-software.github.io/godot-addons/addons/texture_button_colored)
Expand Down
61 changes: 61 additions & 0 deletions addons/kenyoni/plugin_reloader/internal/reloader.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@tool
extends MarginContainer

@export var _reload_button: CheckButton
@export var _option_button: OptionButton

var _last_selection: String = ""

func _ready() -> void:
self._option_button.item_selected.connect(func(idx: int) -> void:
self._last_selection = self._option_button.get_item_metadata(idx)
self._update_button_bar()
)
self._reload_button.toggled.connect(func(toggled: bool) -> void:
EditorInterface.set_plugin_enabled("res://addons/" + self._last_selection + "/plugin.cfg", toggled)
self._reload_plugin_list()
)

EditorInterface.get_resource_filesystem().filesystem_changed.connect(self._reload_plugin_list)
self._reload_plugin_list()

func _update_button_bar() -> void:
if self._last_selection != "":
self._reload_button.set_pressed_no_signal(EditorInterface.is_plugin_enabled("res://addons/" + self._last_selection + "/plugin.cfg"))
self._option_button.icon = null
self._reload_button.disabled = self._last_selection == ""

func _reload_plugin_list() -> void:
self._option_button.clear()
for dir: String in DirAccess.get_directories_at("res://addons/"):
self._add_plugin_to_list(dir)
# subfolder
for sub_dir: String in DirAccess.get_directories_at("res://addons/" + dir):
self._add_plugin_to_list(dir + "/" + sub_dir)

if self._last_selection == "" && self._option_button.get_item_count() > 0:
self._last_selection = self._option_button.get_item_metadata(0)
self._update_button_bar()

func _add_plugin_to_list(plugin_id: String) -> void:
# ignore the current plugin
if plugin_id == "kenyoni/plugin_reloader":
return

var cfg_path: String = "res://addons/" + plugin_id + "/plugin.cfg"
if !FileAccess.file_exists(cfg_path):
return

var plugin_cfg: ConfigFile = ConfigFile.new()
plugin_cfg.load(cfg_path)
var plugin_name: String = plugin_cfg.get_value("plugin", "name", plugin_id)
self._option_button.add_item(plugin_name)
var idx: int = self._option_button.get_item_count() - 1
self._option_button.set_item_metadata(idx, plugin_id)
self._option_button.set_item_tooltip(idx, "res://addons/" + plugin_id + "/")
if EditorInterface.is_plugin_enabled(cfg_path):
self._option_button.set_item_icon(idx, self.get_theme_icon(&"TileChecked", &"EditorIcons"))
else:
self._option_button.set_item_icon(idx, self.get_theme_icon(&"TileUnchecked", &"EditorIcons"))
if plugin_id == self._last_selection:
self._option_button.select(idx)
21 changes: 21 additions & 0 deletions addons/kenyoni/plugin_reloader/internal/reloader.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[gd_scene load_steps=2 format=3 uid="uid://dryoyuj4vl0l5"]

[ext_resource type="Script" path="res://addons/kenyoni/plugin_reloader/internal/reloader.gd" id="1_kd7gg"]

[node name="Reloader" type="MarginContainer" node_paths=PackedStringArray("_reload_button", "_option_button")]
offset_right = 76.0
offset_bottom = 24.0
script = ExtResource("1_kd7gg")
_reload_button = NodePath("HBoxContainer/reload_button")
_option_button = NodePath("HBoxContainer/OptionButton")

[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2
theme_override_constants/separation = 0

[node name="reload_button" type="CheckButton" parent="HBoxContainer"]
layout_mode = 2

[node name="OptionButton" type="OptionButton" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
19 changes: 19 additions & 0 deletions addons/kenyoni/plugin_reloader/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[plugin]

name="Plugin Reloader"
description="Quickly reload plugins from the editor."
author="Kenyoni Software"
version="1.0.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"
20 changes: 20 additions & 0 deletions addons/kenyoni/plugin_reloader/plugin.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@tool
extends EditorPlugin

const ReloaderScene: PackedScene = preload("res://addons/kenyoni/plugin_reloader/internal/reloader.tscn")
const Reloader := preload("res://addons/kenyoni/plugin_reloader/internal/reloader.gd")

var _reloader: Reloader

func _get_plugin_name() -> String:
return "Plugin Reloader"

func _enter_tree() -> void:
self._reloader = ReloaderScene.instantiate()
self.add_control_to_container(CustomControlContainer.CONTAINER_TOOLBAR, self._reloader)
# move before editor run bar
self._reloader.get_parent().move_child(self._reloader, self._reloader.get_parent().find_child("@EditorRunBar@*", true, false).get_index())

func _exit_tree() -> void:
self.remove_control_from_container(CustomControlContainer.CONTAINER_TOOLBAR, self._reloader)
self._reloader.queue_free()
20 changes: 20 additions & 0 deletions doc/docs/addons/plugin_reloader.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Plugin Reloader

Enable or disable plugins from within the editor main screen.

## Compatibility

| Godot | Version |
|-------|----------|
| 4.3 | >= 1.0.0 |
| 4.2 | >= 1.0.0 |

## Screenshot

![plugin reloader screenshot](plugin_reloader/plugin_reloader.png "Plugin Reloader")

## Changelog

### 1.0.0

- Initial release
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ gdscript/warnings/unsafe_call_argument=1

[editor_plugins]

enabled=PackedStringArray("res://addons/aspect_ratio_resize_container/plugin.cfg", "res://addons/custom_theme_overrides/plugin.cfg", "res://addons/explore-editor-theme/plugin.cfg", "res://addons/git_sha_project_setting/plugin.cfg", "res://addons/glogging/plugin.cfg", "res://addons/hide_private_properties/plugin.cfg", "res://addons/icon_explorer/plugin.cfg", "res://addons/icons_patcher/plugin.cfg", "res://addons/licenses/plugin.cfg", "res://addons/qr_code/plugin.cfg", "res://addons/texture_button_colored/plugin.cfg")
enabled=PackedStringArray("res://addons/aspect_ratio_resize_container/plugin.cfg", "res://addons/custom_theme_overrides/plugin.cfg", "res://addons/git_sha_project_setting/plugin.cfg", "res://addons/glogging/plugin.cfg", "res://addons/hide_private_properties/plugin.cfg", "res://addons/icon_explorer/plugin.cfg", "res://addons/icons_patcher/plugin.cfg", "res://addons/kenyoni/plugin_reloader/plugin.cfg", "res://addons/licenses/plugin.cfg", "res://addons/qr_code/plugin.cfg", "res://addons/texture_button_colored/plugin.cfg")

[plugins]

Expand Down
4 changes: 2 additions & 2 deletions publisher/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func doActionAssetLibrary(baseDir string, addonId string, cfg assetLibraryAction
assetData := internal.AssetData{
AssetId: cfg.AssetId,
Title: plgCfg.Plugin.Name,
Description: fmt.Sprintf("%s\n\n%s", plgCfg.Plugin.Description, fmt.Sprintf("More detailed information and documentation is available at https://kenyoni-software.github.io/godot-addons/addons/%s", addon.Id())),
Description: fmt.Sprintf("%s\n\n%s", plgCfg.Plugin.Description, fmt.Sprintf("More detailed information and documentation is available at https://kenyoni-software.github.io/godot-addons/addons/%s", addon.IdName())),
VersionString: plgCfg.Plugin.Version,
GodotVersion: gdMinversion,
CategoryId: cfg.Category,
Expand Down Expand Up @@ -222,7 +222,7 @@ func doActionZip(baseDir string, addonId string, cfg zipActionCfg) {
if outputDir == "" {
outputDir = filepath.Join(addon.ProjectPath(), "archives")
}
outputFile := filepath.Join(outputDir, addon.Id()+"-"+strings.ReplaceAll(plgCfg.Plugin.Version, ".", "_")+".zip")
outputFile := filepath.Join(outputDir, addon.IdName()+"-"+strings.ReplaceAll(plgCfg.Plugin.Version, ".", "_")+".zip")
err = addon.Zip(outputFile)
if err != nil {
log.Fatalln(err)
Expand Down
10 changes: 9 additions & 1 deletion publisher/internal/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"os"
"path/filepath"
"strings"

"github.com/pelletier/go-toml/v2"
)
Expand Down Expand Up @@ -39,10 +40,17 @@ func NewAddon(id string, projectPath string) *Addon {
}
}

// Id contains the namespace directory and the addon directory name like "kenyoni/addon_name"
func (addon *Addon) Id() string {
return addon.addonId
}

// IdName is only the addon directory name like "addon_name"
func (addon *Addon) IdName() string {
splitted := strings.Split(addon.addonId, "/")
return splitted[len(splitted)-1]
}

func (addon *Addon) ProjectPath() string {
return addon.projectPath
}
Expand Down Expand Up @@ -74,7 +82,7 @@ func (addon *Addon) Zip(outputFile string) error {
if err != nil {
return err
}
exampleDir := filepath.Join(addon.ProjectPath(), "examples", addon.Id())
exampleDir := filepath.Join(addon.ProjectPath(), "examples", addon.IdName())
// zip example directory only if it exists
if _, err := os.Stat(exampleDir); err == nil {
err = ZipDir(zw, exampleDir, filepath.Join("examples", addon.Id()))
Expand Down

0 comments on commit a79bba2

Please sign in to comment.