From 55c537dcbe6ec6ce89f2872c162ca1389a2bd085 Mon Sep 17 00:00:00 2001 From: willnationsdev Date: Sat, 7 Dec 2024 14:56:07 -0600 Subject: [PATCH 1/3] Root Godot project opened in 4.3. --- icon.png.import | 32 +++++++++++------------ project.godot | 69 +++++++++++++++++++++++++------------------------ 2 files changed, 51 insertions(+), 50 deletions(-) diff --git a/icon.png.import b/icon.png.import index 96cbf46..0a2f66c 100644 --- a/icon.png.import +++ b/icon.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture" -path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +type="CompressedTexture2D" +uid="uid://c1hfjj7vmjkda" +path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" metadata={ "vram_texture": false } @@ -10,25 +11,24 @@ metadata={ [deps] source_file="res://icon.png" -dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] +dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] [params] compress/mode=0 +compress/high_quality=false compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 +compress/hdr_compression=1 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/project.godot b/project.godot index 77bd0b5..616b6b0 100644 --- a/project.godot +++ b/project.godot @@ -6,97 +6,98 @@ ; [section] ; section goes between [] ; param=value ; assign values to parameters -config_version=4 - -_global_script_classes=[ ] -_global_script_class_icons={ -} +config_version=5 [application] config/name="Godot Plugin Refresher" run/main_scene="res://addons/godot-plugin-refresher/plugin_refresher.tscn" +config/features=PackedStringArray("4.3") config/icon="res://icon.png" +[dotnet] + +project/assembly_name="Godot Plugin Refresher" + [editor_plugins] -enabled=PoolStringArray( "godot-plugin-refresher" ) +enabled=PackedStringArray("res://addons/godot-plugin-refresher/plugin.cfg") [input] ui_accept={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777222,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null) - ] +] } ui_select={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":3,"pressure":0.0,"pressed":false,"script":null) - ] +] } ui_cancel={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null) - ] +] } ui_focus_next={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777218,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] } ui_focus_prev={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":true,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777218,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] } ui_left={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null) - ] +] } ui_right={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null) - ] +] } ui_up={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null) - ] +] } ui_down={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null) - ] +] } ui_page_up={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777235,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] } ui_page_down={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777236,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] } ui_home={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777229,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] } ui_end={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777230,"unicode":0,"echo":false,"script":null) - ] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] } [rendering] From 1d8e93df207b17d7daa7b8ce275e4417adb6b055 Mon Sep 17 00:00:00 2001 From: willnationsdev Date: Sat, 7 Dec 2024 14:56:47 -0600 Subject: [PATCH 2/3] GDScript Formatting applied. --- addons/godot-plugin-refresher/plugin_refresher.gd | 12 ++++++++---- .../plugin_refresher_plugin.gd | 15 +++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/addons/godot-plugin-refresher/plugin_refresher.gd b/addons/godot-plugin-refresher/plugin_refresher.gd index 52241e3..a528381 100644 --- a/addons/godot-plugin-refresher/plugin_refresher.gd +++ b/addons/godot-plugin-refresher/plugin_refresher.gd @@ -6,9 +6,10 @@ signal confirm_refresh_plugin(p_name) @onready var options = $OptionButton + func _ready(): if get_tree().edited_scene_root == self: - return # This is the scene opened in the editor! + return # This is the scene opened in the editor! $RefreshButton.icon = EditorInterface.get_editor_theme().get_icon("Reload", "EditorIcons") @@ -39,7 +40,7 @@ func select_plugin(p_name): func _on_RefreshButton_pressed(): if options.selected == -1: - return # nothing selected + return # nothing selected var plugin = options.get_item_metadata(options.selected) if not plugin or plugin.is_empty(): @@ -48,10 +49,13 @@ func _on_RefreshButton_pressed(): func show_warning(p_name): - $ConfirmationDialog.dialog_text = """ + $ConfirmationDialog.dialog_text = ( + """ Plugin `%s` is currently disabled.\n Do you want to enable it now? - """ % [p_name] + """ + % [p_name] + ) $ConfirmationDialog.popup_centered() diff --git a/addons/godot-plugin-refresher/plugin_refresher_plugin.gd b/addons/godot-plugin-refresher/plugin_refresher_plugin.gd index 6922821..9781f6f 100644 --- a/addons/godot-plugin-refresher/plugin_refresher_plugin.gd +++ b/addons/godot-plugin-refresher/plugin_refresher_plugin.gd @@ -10,6 +10,7 @@ const SETTING_RECENT = "recently_used" var plugin_config = ConfigFile.new() var refresher + func _enter_tree(): refresher = preload("plugin_refresher.tscn").instantiate() add_control_to_container(CONTAINER_TOOLBAR, refresher) @@ -40,15 +41,14 @@ func _reload_plugins_list(): dir.list_dir_begin() var file_name = dir.get_next() while file_name != "": - var addon_dir = ADDONS_PATH.path_join(file_name) if dir.dir_exists(addon_dir) and file_name != refresher_dir: var display_name = file_name - + var plugin_config_path = addon_dir.path_join("plugin.cfg") if not dir.file_exists(plugin_config_path): file_name = dir.get_next() - continue # not a plugin + continue # not a plugin var plugin_cfg = ConfigFile.new() plugin_cfg.load(plugin_config_path) display_name = plugin_cfg.get_value("plugin", "name", file_name) @@ -68,6 +68,7 @@ func _reload_plugins_list(): refresher.update_items(plugins) + func _load_settings(): var path = get_config_path() @@ -79,6 +80,7 @@ func _load_settings(): else: plugin_config.load(path) + func _save_settings(): plugin_config.save(get_config_path()) @@ -86,12 +88,13 @@ func _save_settings(): func get_config_path() -> String: var editor_paths = EditorInterface.get_editor_paths() var dir = editor_paths.get_project_settings_dir() - + var home = dir.path_join(PLUGIN_CONFIG_DIR) var path = home.path_join(PLUGIN_CONFIG) return path + func _on_filesystem_changed(): if refresher: _reload_plugins_list() @@ -100,7 +103,7 @@ func _on_filesystem_changed(): func get_recent_plugin(): if not plugin_config.has_section_key(SETTINGS, SETTING_RECENT): - return null # not saved yet + return null # not saved yet var recent = plugin_config.get_value(SETTINGS, SETTING_RECENT) return recent @@ -128,7 +131,7 @@ func refresh_plugin(p_name): print("Refreshing plugin: ", p_name) var enabled = get_editor_interface().is_plugin_enabled(p_name) - if enabled: # can only disable an active plugin + if enabled: # can only disable an active plugin get_editor_interface().set_plugin_enabled(p_name, false) get_editor_interface().set_plugin_enabled(p_name, true) From 012e9762359e3b6691ee0061ff88a12fe3e82d3c Mon Sep 17 00:00:00 2001 From: willnationsdev Date: Sat, 7 Dec 2024 17:11:50 -0600 Subject: [PATCH 3/3] Fix EditorInterface. Add type hints. --- .../plugin_refresher.gd | 41 ++++----- .../plugin_refresher_plugin.gd | 83 ++++++++++--------- 2 files changed, 63 insertions(+), 61 deletions(-) diff --git a/addons/godot-plugin-refresher/plugin_refresher.gd b/addons/godot-plugin-refresher/plugin_refresher.gd index a528381..e7ecf50 100644 --- a/addons/godot-plugin-refresher/plugin_refresher.gd +++ b/addons/godot-plugin-refresher/plugin_refresher.gd @@ -1,54 +1,55 @@ @tool extends HBoxContainer -signal request_refresh_plugin(p_name) -signal confirm_refresh_plugin(p_name) +signal request_refresh_plugin(p_name: String) +signal confirm_refresh_plugin(p_name: String) -@onready var options = $OptionButton +@onready var options: OptionButton = $OptionButton -func _ready(): +func _ready() -> void: if get_tree().edited_scene_root == self: return # This is the scene opened in the editor! $RefreshButton.icon = EditorInterface.get_editor_theme().get_icon("Reload", "EditorIcons") -func update_items(p_plugins): +func update_items(p_plugins: Dictionary) -> void: if not options: return options.clear() - var plugin_dirs = p_plugins.keys() + var plugin_dirs: Array[String] = [] + plugin_dirs.assign(p_plugins.keys()) for idx in plugin_dirs.size(): - var plugin_dirname = plugin_dirs[idx] - var plugin_name = p_plugins[plugin_dirname] + var plugin_dirname := plugin_dirs[idx] as String + var plugin_name := p_plugins[plugin_dirname] as String options.add_item(plugin_name, idx) options.set_item_metadata(idx, plugin_dirname) -func select_plugin(p_name): - if not options: - return - if p_name == null or p_name.is_empty(): +# Note: For whatever reason, statically typing `p_name` inexplicably causes +# an error about converting from Nil to String, even if the value is converted. +func select_plugin(p_name) -> void: + if not options or not p_name: return for idx in options.get_item_count(): - var plugin = options.get_item_metadata(idx) - if plugin == p_name: + var plugin := str(options.get_item_metadata(idx)) + if plugin == str(p_name): options.selected = options.get_item_id(idx) break -func _on_RefreshButton_pressed(): +func _on_RefreshButton_pressed() -> void: if options.selected == -1: return # nothing selected - var plugin = options.get_item_metadata(options.selected) - if not plugin or plugin.is_empty(): + var plugin := str(options.get_item_metadata(options.selected)) + if not plugin: return emit_signal("request_refresh_plugin", plugin) -func show_warning(p_name): +func show_warning(p_name: String) -> void: $ConfirmationDialog.dialog_text = ( """ Plugin `%s` is currently disabled.\n @@ -59,6 +60,6 @@ func show_warning(p_name): $ConfirmationDialog.popup_centered() -func _on_ConfirmationDialog_confirmed(): - var plugin = options.get_item_metadata(options.selected) +func _on_ConfirmationDialog_confirmed() -> void: + var plugin := options.get_item_metadata(options.selected) as String emit_signal("confirm_refresh_plugin", plugin) diff --git a/addons/godot-plugin-refresher/plugin_refresher_plugin.gd b/addons/godot-plugin-refresher/plugin_refresher_plugin.gd index 9781f6f..4aad8e1 100644 --- a/addons/godot-plugin-refresher/plugin_refresher_plugin.gd +++ b/addons/godot-plugin-refresher/plugin_refresher_plugin.gd @@ -1,22 +1,23 @@ @tool extends EditorPlugin -const ADDONS_PATH = "res://addons/" -const PLUGIN_CONFIG_DIR = "plugins/plugin_refresher" -const PLUGIN_CONFIG = "settings.cfg" -const SETTINGS = "settings" -const SETTING_RECENT = "recently_used" +const ADDONS_PATH := "res://addons/" +const PLUGIN_CONFIG_DIR := "plugins/plugin_refresher" +const PLUGIN_CONFIG := "settings.cfg" +const SETTINGS := "settings" +const SETTING_RECENT := "recently_used" +const Refresher := preload("plugin_refresher.gd") -var plugin_config = ConfigFile.new() -var refresher +var plugin_config := ConfigFile.new() +var refresher: Refresher = null -func _enter_tree(): - refresher = preload("plugin_refresher.tscn").instantiate() +func _enter_tree() -> void: + refresher = preload("plugin_refresher.tscn").instantiate() as Refresher add_control_to_container(CONTAINER_TOOLBAR, refresher) # Watch whether any plugin is changed, added or removed on the filesystem - var efs = get_editor_interface().get_resource_filesystem() + var efs := EditorInterface.get_resource_filesystem() efs.filesystem_changed.connect(_on_filesystem_changed) refresher.request_refresh_plugin.connect(_on_request_refresh_plugin) @@ -26,30 +27,30 @@ func _enter_tree(): _load_settings() -func _exit_tree(): +func _exit_tree() -> void: remove_control_from_container(CONTAINER_TOOLBAR, refresher) refresher.free() -func _reload_plugins_list(): - var refresher_dir = get_plugin_path().get_file() - var plugins = {} - var origins = {} +func _reload_plugins_list() -> void: + var refresher_dir := get_plugin_path().get_file() + var plugins := {} + var origins := {} - var dir = DirAccess.open(ADDONS_PATH) + var dir := DirAccess.open(ADDONS_PATH) if dir: dir.list_dir_begin() - var file_name = dir.get_next() + var file_name := dir.get_next() while file_name != "": - var addon_dir = ADDONS_PATH.path_join(file_name) + var addon_dir := ADDONS_PATH.path_join(file_name) if dir.dir_exists(addon_dir) and file_name != refresher_dir: - var display_name = file_name + var display_name := file_name - var plugin_config_path = addon_dir.path_join("plugin.cfg") + var plugin_config_path := addon_dir.path_join("plugin.cfg") if not dir.file_exists(plugin_config_path): file_name = dir.get_next() continue # not a plugin - var plugin_cfg = ConfigFile.new() + var plugin_cfg := ConfigFile.new() plugin_cfg.load(plugin_config_path) display_name = plugin_cfg.get_value("plugin", "name", file_name) if not display_name in origins: @@ -69,72 +70,72 @@ func _reload_plugins_list(): refresher.update_items(plugins) -func _load_settings(): - var path = get_config_path() +func _load_settings() -> void: + var path := get_config_path() if not FileAccess.file_exists(path): # Create new if running for the first time - var config = ConfigFile.new() + var config := ConfigFile.new() DirAccess.make_dir_recursive_absolute(path.get_base_dir()) config.save(path) else: plugin_config.load(path) -func _save_settings(): +func _save_settings() -> void: plugin_config.save(get_config_path()) func get_config_path() -> String: - var editor_paths = EditorInterface.get_editor_paths() - var dir = editor_paths.get_project_settings_dir() + var editor_paths := EditorInterface.get_editor_paths() + var dir := editor_paths.get_project_settings_dir() - var home = dir.path_join(PLUGIN_CONFIG_DIR) - var path = home.path_join(PLUGIN_CONFIG) + var home := dir.path_join(PLUGIN_CONFIG_DIR) + var path := home.path_join(PLUGIN_CONFIG) return path -func _on_filesystem_changed(): +func _on_filesystem_changed() -> void: if refresher: _reload_plugins_list() refresher.select_plugin(get_recent_plugin()) -func get_recent_plugin(): +func get_recent_plugin() -> String: if not plugin_config.has_section_key(SETTINGS, SETTING_RECENT): - return null # not saved yet + return "" # not saved yet var recent = plugin_config.get_value(SETTINGS, SETTING_RECENT) - return recent + return recent if recent != null and not recent.is_empty() else "" -func _on_request_refresh_plugin(p_name): +func _on_request_refresh_plugin(p_name: String) -> void: assert(not p_name.is_empty()) - var disabled = not get_editor_interface().is_plugin_enabled(p_name) + var disabled := not EditorInterface.is_plugin_enabled(p_name) if disabled: refresher.show_warning(p_name) else: refresh_plugin(p_name) -func _on_confirm_refresh_plugin(p_name): +func _on_confirm_refresh_plugin(p_name: String) -> void: refresh_plugin(p_name) -func get_plugin_path(): +func get_plugin_path() -> String: return get_script().resource_path.get_base_dir() -func refresh_plugin(p_name): +func refresh_plugin(p_name: String) -> void: print("Refreshing plugin: ", p_name) - var enabled = get_editor_interface().is_plugin_enabled(p_name) + var enabled := EditorInterface.is_plugin_enabled(p_name) if enabled: # can only disable an active plugin - get_editor_interface().set_plugin_enabled(p_name, false) + EditorInterface.set_plugin_enabled(p_name, false) - get_editor_interface().set_plugin_enabled(p_name, true) + EditorInterface.set_plugin_enabled(p_name, true) plugin_config.set_value(SETTINGS, SETTING_RECENT, p_name) _save_settings()