-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
176 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters