diff --git a/.gitignore b/.gitignore index c899fe4..b5c4425 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ # Project specific ignores icon.jpg.import -**/generated/updater/assets/*.import # Godot 4+ specific ignores .godot/ diff --git a/addons/plugin_updater/core/download_update_panel.gd b/addons/plugin_updater/core/download_update_panel.gd index e8238de..d7dff14 100644 --- a/addons/plugin_updater/core/download_update_panel.gd +++ b/addons/plugin_updater/core/download_update_panel.gd @@ -47,10 +47,11 @@ func _check_for_updater(): _latest_version = extract_latest_version(response) var current_version := extract_current_version() - # if the current version is less than the skip version, skip the update - if "ignore_updates_before_version" in config: - var skip_version = SemVer.parse(config.ignore_updates_before_version) - if current_version.is_less_than(skip_version): + # if the current version is less than or equal to the skip version, skip the update + var skip_config = UpdaterConfig.get_skip_config() + if config.plugin_name in skip_config: + var skip_version: SemVer = SemVer.parse(skip_config[config.plugin_name]) + if !_latest_version.is_greater(skip_version): return # if same version exit here no update need @@ -135,9 +136,10 @@ func _colored(message :String, color :Color) -> String: func _skip_update(): # Store a setting in the config. - config.ignore_updates_before_version = str(_latest_version) + var skip_config = UpdaterConfig.get_skip_config() # Read this again in case it was changed + skip_config[config.plugin_name] = str(_latest_version) # Write the config into the addons dir so it gets removed on update - UpdaterConfig.save_user_config(config) + UpdaterConfig.save_skip_config(skip_config) func _on_update_pressed(): hide() diff --git a/addons/plugin_updater/core/plugin-updater.json b/addons/plugin_updater/core/plugin-updater.json new file mode 100644 index 0000000..7a1debe --- /dev/null +++ b/addons/plugin_updater/core/plugin-updater.json @@ -0,0 +1,6 @@ +{ + "plugin_name": "plugin_updater", + "secs_before_check_for_update": 5, + "github_repo": "myyk/godot-plugin-updater", + "editor_plugin_meta": "PluginUpdaterEditorPlugin" +} diff --git a/addons/plugin_updater/core/updater_config.gd b/addons/plugin_updater/core/updater_config.gd index 789abce..7a09238 100644 --- a/addons/plugin_updater/core/updater_config.gd +++ b/addons/plugin_updater/core/updater_config.gd @@ -11,6 +11,7 @@ extends RefCounted static var PLUGIN_NAME: String = "PLUGIN_NAME_PLACEHOLDER" # This is replaced when code is generated const PLUGIN_MAKER_CONFIG_PATH = "res://plugin-updater.json" const PLUGIN_USER_CONFIG_PATH_FORMAT = "res://addons/%s/generated/updater/plugin-updater.json" +const PLUGIN_SKIP_CONFIG_PATH = "res://.godot/plugin-updater-skip.json" static func get_user_config() -> Dictionary: return _get_config(PLUGIN_USER_CONFIG_PATH_FORMAT % PLUGIN_NAME) @@ -31,14 +32,27 @@ static func _get_config(path: String) -> Dictionary: return config -static func save_user_config(config: Dictionary) -> Error: - return _save_config(PLUGIN_USER_CONFIG_PATH_FORMAT % PLUGIN_NAME, config) +# Skip config is a JSON file like: +# { +# "plugin_name_1": "1.0.0" +# "plugin_name_2": "1.2.3" +# } +static func get_skip_config() -> Dictionary: + if !FileAccess.file_exists(PLUGIN_SKIP_CONFIG_PATH): + return {} + + var file: FileAccess = FileAccess.open(PLUGIN_SKIP_CONFIG_PATH, FileAccess.READ) + if file == null: + push_error("plugin-updater: Could not open file at " + PLUGIN_SKIP_CONFIG_PATH) + return {} + return JSON.parse_string(file.get_as_text()) -static func _save_config(path: String, config: Dictionary) -> Error: - var file: FileAccess = FileAccess.open(path, FileAccess.WRITE) +static func save_skip_config(config: Dictionary) -> Error: + var file: FileAccess = FileAccess.open(PLUGIN_SKIP_CONFIG_PATH, FileAccess.WRITE) if file == null: - push_error("plugin-updater: Could not open file at " + path) + push_error("plugin-updater: Could not open file at " + PLUGIN_SKIP_CONFIG_PATH) return FileAccess.get_open_error() - file.store_string(JSON.stringify(config, "\t")) + + file.store_string(JSON.stringify(config)) file.close() return OK diff --git a/addons/plugin_updater/generated/updater/assets/Progress1.svg.import b/addons/plugin_updater/generated/updater/assets/Progress1.svg.import new file mode 100644 index 0000000..50b3910 --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/Progress1.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ddxpytkht0m5p" +path="res://.godot/imported/Progress1.svg-057623bb7fc678c8ebfd7e6825cd98b4.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/Progress1.svg" +dest_files=["res://.godot/imported/Progress1.svg-057623bb7fc678c8ebfd7e6825cd98b4.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=true diff --git a/addons/plugin_updater/generated/updater/assets/Progress2.svg.import b/addons/plugin_updater/generated/updater/assets/Progress2.svg.import new file mode 100644 index 0000000..a5281c6 --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/Progress2.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dowca7ike2thl" +path="res://.godot/imported/Progress2.svg-7068e980fabe92b28e1325b5f6d00641.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/Progress2.svg" +dest_files=["res://.godot/imported/Progress2.svg-7068e980fabe92b28e1325b5f6d00641.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=true diff --git a/addons/plugin_updater/generated/updater/assets/Progress3.svg.import b/addons/plugin_updater/generated/updater/assets/Progress3.svg.import new file mode 100644 index 0000000..7b9bdf6 --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/Progress3.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cwh8md6qipmdw" +path="res://.godot/imported/Progress3.svg-3e76719e48627b96c22a3596f7a8004d.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/Progress3.svg" +dest_files=["res://.godot/imported/Progress3.svg-3e76719e48627b96c22a3596f7a8004d.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=true diff --git a/addons/plugin_updater/generated/updater/assets/Progress4.svg.import b/addons/plugin_updater/generated/updater/assets/Progress4.svg.import new file mode 100644 index 0000000..65f88c2 --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/Progress4.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dm0jpqdjetv2c" +path="res://.godot/imported/Progress4.svg-243be5d576ae8f9e2c9116310ab48f9e.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/Progress4.svg" +dest_files=["res://.godot/imported/Progress4.svg-243be5d576ae8f9e2c9116310ab48f9e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=true diff --git a/addons/plugin_updater/generated/updater/assets/Progress5.svg.import b/addons/plugin_updater/generated/updater/assets/Progress5.svg.import new file mode 100644 index 0000000..cd97f9d --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/Progress5.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bkj6kjyjyi7cd" +path="res://.godot/imported/Progress5.svg-3b103ebc9dd79bfa1e58646d2a7bfb80.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/Progress5.svg" +dest_files=["res://.godot/imported/Progress5.svg-3b103ebc9dd79bfa1e58646d2a7bfb80.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=true diff --git a/addons/plugin_updater/generated/updater/assets/Progress6.svg.import b/addons/plugin_updater/generated/updater/assets/Progress6.svg.import new file mode 100644 index 0000000..756bb55 --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/Progress6.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bsljbs1aiyels" +path="res://.godot/imported/Progress6.svg-96a279f3b31690019bc9305be6572c65.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/Progress6.svg" +dest_files=["res://.godot/imported/Progress6.svg-96a279f3b31690019bc9305be6572c65.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=true diff --git a/addons/plugin_updater/generated/updater/assets/Progress7.svg.import b/addons/plugin_updater/generated/updater/assets/Progress7.svg.import new file mode 100644 index 0000000..c3adfae --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/Progress7.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cct6crbhix7u8" +path="res://.godot/imported/Progress7.svg-d1b3c88fd78d2a2fab65afae59e5a0f0.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/Progress7.svg" +dest_files=["res://.godot/imported/Progress7.svg-d1b3c88fd78d2a2fab65afae59e5a0f0.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=true diff --git a/addons/plugin_updater/generated/updater/assets/Progress8.svg.import b/addons/plugin_updater/generated/updater/assets/Progress8.svg.import new file mode 100644 index 0000000..3c3916e --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/Progress8.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dqc521iq12a7l" +path="res://.godot/imported/Progress8.svg-52faa4c6db33e7240be790d78f9fba49.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/Progress8.svg" +dest_files=["res://.godot/imported/Progress8.svg-52faa4c6db33e7240be790d78f9fba49.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=true diff --git a/addons/plugin_updater/generated/updater/assets/border_bottom.png.import b/addons/plugin_updater/generated/updater/assets/border_bottom.png.import new file mode 100644 index 0000000..649ebd2 --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/border_bottom.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dmv3ld2otx1e2" +path="res://.godot/imported/border_bottom.png-a55228f83e4145118281ff0a8abc1a4b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/border_bottom.png" +dest_files=["res://.godot/imported/border_bottom.png-a55228f83e4145118281ff0a8abc1a4b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/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/addons/plugin_updater/generated/updater/assets/border_top.png.import b/addons/plugin_updater/generated/updater/assets/border_top.png.import new file mode 100644 index 0000000..c0438bc --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/border_top.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b4sio0j5om50s" +path="res://.godot/imported/border_top.png-2ae5e2b555709907a45da1e3c2bd5ad3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/border_top.png" +dest_files=["res://.godot/imported/border_top.png-2ae5e2b555709907a45da1e3c2bd5ad3.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/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/addons/plugin_updater/generated/updater/assets/dot1.png.import b/addons/plugin_updater/generated/updater/assets/dot1.png.import new file mode 100644 index 0000000..6be0455 --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/dot1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ce2eojg0pwpov" +path="res://.godot/imported/dot1.png-5be967c26bec4c7d3c71e73a19164154.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/dot1.png" +dest_files=["res://.godot/imported/dot1.png-5be967c26bec4c7d3c71e73a19164154.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/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/addons/plugin_updater/generated/updater/assets/dot2.png.import b/addons/plugin_updater/generated/updater/assets/dot2.png.import new file mode 100644 index 0000000..6b9fb92 --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/dot2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cvwa5lg3qj0e2" +path="res://.godot/imported/dot2.png-7387b5124b91974576884555be912155.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/dot2.png" +dest_files=["res://.godot/imported/dot2.png-7387b5124b91974576884555be912155.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/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/addons/plugin_updater/generated/updater/assets/embedded.png.import b/addons/plugin_updater/generated/updater/assets/embedded.png.import new file mode 100644 index 0000000..1c5d93d --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/embedded.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://63wk5nib3r7q" +path="res://.godot/imported/embedded.png-f2eb34c16aab4adcbb6cb17408949ff3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/embedded.png" +dest_files=["res://.godot/imported/embedded.png-f2eb34c16aab4adcbb6cb17408949ff3.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/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/addons/plugin_updater/generated/updater/assets/horizontal-line2.png.import b/addons/plugin_updater/generated/updater/assets/horizontal-line2.png.import new file mode 100644 index 0000000..37d9274 --- /dev/null +++ b/addons/plugin_updater/generated/updater/assets/horizontal-line2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dgaa5faajesgv" +path="res://.godot/imported/horizontal-line2.png-70b83d12be46183b3fc4470cb9b3e2ae.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/plugin_updater/generated/updater/assets/horizontal-line2.png" +dest_files=["res://.godot/imported/horizontal-line2.png-70b83d12be46183b3fc4470cb9b3e2ae.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +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/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/addons/plugin_updater/generated/updater/download_update_panel.gd b/addons/plugin_updater/generated/updater/download_update_panel.gd index e8238de..d7dff14 100644 --- a/addons/plugin_updater/generated/updater/download_update_panel.gd +++ b/addons/plugin_updater/generated/updater/download_update_panel.gd @@ -47,10 +47,11 @@ func _check_for_updater(): _latest_version = extract_latest_version(response) var current_version := extract_current_version() - # if the current version is less than the skip version, skip the update - if "ignore_updates_before_version" in config: - var skip_version = SemVer.parse(config.ignore_updates_before_version) - if current_version.is_less_than(skip_version): + # if the current version is less than or equal to the skip version, skip the update + var skip_config = UpdaterConfig.get_skip_config() + if config.plugin_name in skip_config: + var skip_version: SemVer = SemVer.parse(skip_config[config.plugin_name]) + if !_latest_version.is_greater(skip_version): return # if same version exit here no update need @@ -135,9 +136,10 @@ func _colored(message :String, color :Color) -> String: func _skip_update(): # Store a setting in the config. - config.ignore_updates_before_version = str(_latest_version) + var skip_config = UpdaterConfig.get_skip_config() # Read this again in case it was changed + skip_config[config.plugin_name] = str(_latest_version) # Write the config into the addons dir so it gets removed on update - UpdaterConfig.save_user_config(config) + UpdaterConfig.save_skip_config(skip_config) func _on_update_pressed(): hide() diff --git a/addons/plugin_updater/generated/updater/updater_config.gd b/addons/plugin_updater/generated/updater/updater_config.gd index 0e14f4b..5751beb 100644 --- a/addons/plugin_updater/generated/updater/updater_config.gd +++ b/addons/plugin_updater/generated/updater/updater_config.gd @@ -11,6 +11,7 @@ extends RefCounted const PLUGIN_NAME: String = "plugin_updater" # This is replaced when code is generated const PLUGIN_MAKER_CONFIG_PATH = "res://plugin-updater.json" const PLUGIN_USER_CONFIG_PATH_FORMAT = "res://addons/%s/generated/updater/plugin-updater.json" +const PLUGIN_SKIP_CONFIG_PATH = "res://.godot/plugin-updater-skip.json" static func get_user_config() -> Dictionary: return _get_config(PLUGIN_USER_CONFIG_PATH_FORMAT % PLUGIN_NAME) @@ -31,14 +32,27 @@ static func _get_config(path: String) -> Dictionary: return config -static func save_user_config(config: Dictionary) -> Error: - return _save_config(PLUGIN_USER_CONFIG_PATH_FORMAT % PLUGIN_NAME, config) +# Skip config is a JSON file like: +# { +# "plugin_name_1": "1.0.0" +# "plugin_name_2": "1.2.3" +# } +static func get_skip_config() -> Dictionary: + if !FileAccess.file_exists(PLUGIN_SKIP_CONFIG_PATH): + return {} + + var file: FileAccess = FileAccess.open(PLUGIN_SKIP_CONFIG_PATH, FileAccess.READ) + if file == null: + push_error("plugin-updater: Could not open file at " + PLUGIN_SKIP_CONFIG_PATH) + return {} + return JSON.parse_string(file.get_as_text()) -static func _save_config(path: String, config: Dictionary) -> Error: - var file: FileAccess = FileAccess.open(path, FileAccess.WRITE) +static func save_skip_config(config: Dictionary) -> Error: + var file: FileAccess = FileAccess.open(PLUGIN_SKIP_CONFIG_PATH, FileAccess.WRITE) if file == null: - push_error("plugin-updater: Could not open file at " + path) + push_error("plugin-updater: Could not open file at " + PLUGIN_SKIP_CONFIG_PATH) return FileAccess.get_open_error() - file.store_string(JSON.stringify(config, "\t")) + + file.store_string(JSON.stringify(config)) file.close() return OK diff --git a/addons/plugin_updater/plugin.cfg b/addons/plugin_updater/plugin.cfg index 8c18236..3d4ee59 100644 --- a/addons/plugin_updater/plugin.cfg +++ b/addons/plugin_updater/plugin.cfg @@ -3,5 +3,5 @@ name="plugin_updater" description="A plugin for plugin makers to give their plugins an easy in-editor updating." author="myyk" -version="1.1.0" +version="1.1.1" script="plugin_updater.gd" diff --git a/addons/plugin_updater/plugin_updater.gd b/addons/plugin_updater/plugin_updater.gd index 9d13cdd..4c63150 100644 --- a/addons/plugin_updater/plugin_updater.gd +++ b/addons/plugin_updater/plugin_updater.gd @@ -9,10 +9,9 @@ func _enter_tree(): _install_to_plugin(UpdaterConfig.PLUGIN_NAME) # Add auto-update functionality for plugin_updater itself (not the plugin being updated, that needs similar code) - if Engine.is_editor_hint(): - Engine.set_meta("PluginUpdaterEditorPlugin", self) - var update_tool: Node = load("res://addons/plugin_updater/generated/updater/download_update_panel.tscn").instantiate() - Engine.get_main_loop().root.call_deferred("add_child", update_tool) + Engine.set_meta("PluginUpdaterEditorPlugin", self) + var update_tool: Node = load("res://addons/plugin_updater/generated/updater/download_update_panel.tscn").instantiate() + Engine.get_main_loop().root.call_deferred("add_child", update_tool) func _exit_tree(): if Engine.has_meta("PluginUpdaterEditorPlugin"): @@ -38,10 +37,11 @@ func _install_to_plugin(plugin_name: String): if err != OK: push_error("plugin_updater: error copying files, error = " + str(err)) - # Copy the config over - err = DirAccess.copy_absolute(UpdaterConfig.PLUGIN_MAKER_CONFIG_PATH, UpdaterConfig.PLUGIN_USER_CONFIG_PATH_FORMAT % plugin_name) - if err != OK: - push_error("plugin_updater: error copying config file, error = " + str(err)) + # Copy the config over if it matches the plugin_name + if UpdaterConfig.get_repo_config().plugin_name == plugin_name: + err = DirAccess.copy_absolute(UpdaterConfig.PLUGIN_MAKER_CONFIG_PATH, UpdaterConfig.PLUGIN_USER_CONFIG_PATH_FORMAT % plugin_name) + if err != OK: + push_error("plugin_updater: error copying config file, error = " + str(err)) # Copy in plugin name so we can use relative paths replace_string_in_file(target_path + "updater_config.gd", "PLUGIN_NAME_PLACEHOLDER", plugin_name)