diff --git a/addons/godot-plugin-refresher/icons/icon_reload_small.svg.import b/addons/godot-plugin-refresher/icons/icon_reload_small.svg.import index 238b7ae..73c703d 100644 --- a/addons/godot-plugin-refresher/icons/icon_reload_small.svg.import +++ b/addons/godot-plugin-refresher/icons/icon_reload_small.svg.import @@ -3,6 +3,9 @@ importer="texture" type="StreamTexture" path="res://.import/icon_reload_small.svg-2fb3864c9ab2acd4651c8b485b98ddf5.stex" +metadata={ +"vram_texture": false +} [deps] @@ -14,6 +17,7 @@ dest_files=[ "res://.import/icon_reload_small.svg-2fb3864c9ab2acd4651c8b485b98dd compress/mode=0 compress/lossy_quality=0.7 compress/hdr_mode=0 +compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 flags/filter=true @@ -23,6 +27,7 @@ flags/srgb=2 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 diff --git a/addons/godot-plugin-refresher/plugin.cfg b/addons/godot-plugin-refresher/plugin.cfg index 021b676..960ce89 100644 --- a/addons/godot-plugin-refresher/plugin.cfg +++ b/addons/godot-plugin-refresher/plugin.cfg @@ -4,4 +4,4 @@ name="Godot Plugin Refresher" description="A toolbar addition to facilitate toggling off/on a selected plugin." author="willnationsdev" version="1.0" -script="plugin_refresher_plugin.gd" \ No newline at end of file +script="plugin_refresher_plugin.gd" diff --git a/addons/godot-plugin-refresher/plugin_refresher.gd b/addons/godot-plugin-refresher/plugin_refresher.gd index adfe5c2..c4fd551 100644 --- a/addons/godot-plugin-refresher/plugin_refresher.gd +++ b/addons/godot-plugin-refresher/plugin_refresher.gd @@ -1,6 +1,9 @@ tool extends HBoxContainer +const ADDONS_PATH = "res://addons/" +const PLUGIN_PATH = "godot-plugin-refresher" + signal request_refresh_plugin(p_name) onready var options = $OptionButton @@ -12,17 +15,31 @@ func reload_items(): if not options: return var dir = Directory.new() - dir.change_dir("res://addons/") + dir.change_dir(ADDONS_PATH) dir.list_dir_begin(true, true) var file = dir.get_next() options.clear() while file: - if dir.dir_exists("res://addons/" + file) and file != "godot-plugin-refresher": + if dir.dir_exists(ADDONS_PATH.plus_file(file)) and file != PLUGIN_PATH: options.add_item(file) file = dir.get_next() +func select_plugin(p_name): + if not options: + return + if p_name == null or p_name.empty(): + return + + for idx in options.get_item_count(): + var plugin = options.get_item_text(idx) + if plugin == p_name: + options.selected = options.get_item_id(idx) + func _on_RefreshButton_pressed(): + if options.selected == -1: + return # nothing selected + var plugin = options.get_item_text(options.selected) - if not plugin: + if not plugin or plugin.empty(): return - emit_signal("request_refresh_plugin", plugin) \ No newline at end of file + emit_signal("request_refresh_plugin", plugin) diff --git a/addons/godot-plugin-refresher/plugin_refresher_plugin.gd b/addons/godot-plugin-refresher/plugin_refresher_plugin.gd index 025feef..01e06e3 100644 --- a/addons/godot-plugin-refresher/plugin_refresher_plugin.gd +++ b/addons/godot-plugin-refresher/plugin_refresher_plugin.gd @@ -1,6 +1,13 @@ tool extends EditorPlugin +const PLUGIN_CONFIG_DIR = 'plugins/plugin_refresher' +const PLUGIN_CONFIG = 'settings.cfg' +const SETTINGS = 'settings' +const SETTING_RECENT = 'recently_used' + +var plugin_config = ConfigFile.new() + const PluginRefresherScn = preload("plugin_refresher.tscn") var refresher @@ -8,21 +15,59 @@ var refresher func _enter_tree(): refresher = PluginRefresherScn.instance() add_control_to_container(CONTAINER_TOOLBAR, refresher) - + var efs = get_editor_interface().get_resource_filesystem() efs.connect("filesystem_changed", self, "_on_filesystem_changed") - + refresher.connect("request_refresh_plugin", self, "_on_request_refresh_plugin") + _load_settings() + func _exit_tree(): remove_control_from_container(CONTAINER_TOOLBAR, refresher) refresher.free() +func _load_settings(): + var path = get_config_path() + + var fs = Directory.new() + if not fs.file_exists(path): + # Create new if running for the first time + var config = ConfigFile.new() + fs.make_dir_recursive(path.get_base_dir()) + config.save(path) + else: + plugin_config.load(path) + +func _save_settings(): + plugin_config.save(get_config_path()) + +func get_config_path(): + var dir = get_editor_interface().get_editor_settings().get_project_settings_dir() + var home = dir.plus_file(PLUGIN_CONFIG_DIR) + var path = home.plus_file(PLUGIN_CONFIG) + + return path + func _on_filesystem_changed(): if refresher: refresher.reload_items() + refresher.select_plugin(get_recent_plugin()) + +func get_recent_plugin(): + if not plugin_config.has_section_key(SETTINGS, SETTING_RECENT): + return null # not saved yet + + var recent = plugin_config.get_value(SETTINGS, SETTING_RECENT) + return recent func _on_request_refresh_plugin(p_name): print("Refreshing plugin: ", p_name) + + assert(not p_name.empty()) + get_editor_interface().set_plugin_enabled(p_name, false) - get_editor_interface().set_plugin_enabled(p_name, true) \ No newline at end of file + get_editor_interface().set_plugin_enabled(p_name, true) + + plugin_config.set_value(SETTINGS, SETTING_RECENT, p_name) + _save_settings() diff --git a/icon.png.import b/icon.png.import index 0041ef8..96cbf46 100644 --- a/icon.png.import +++ b/icon.png.import @@ -3,6 +3,9 @@ importer="texture" type="StreamTexture" path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} [deps] @@ -14,6 +17,7 @@ dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] compress/mode=0 compress/lossy_quality=0.7 compress/hdr_mode=0 +compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 flags/filter=true @@ -23,6 +27,7 @@ flags/srgb=2 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 diff --git a/project.godot b/project.godot index 242173a..91fcf80 100644 --- a/project.godot +++ b/project.godot @@ -8,6 +8,11 @@ config_version=4 +_global_script_classes=[ ] +_global_script_class_icons={ + +} + [application] config/name="Godot Plugin Refresher" @@ -15,7 +20,7 @@ config/icon="res://icon.png" [editor_plugins] -enabled=PoolStringArray( "godot-plugin", "godot-plugin-refresher" ) +enabled=PoolStringArray( "godot-plugin-refresher" ) [input]