diff --git a/__init__.py b/__init__.py index bb1b67e..c628dc6 100644 --- a/__init__.py +++ b/__init__.py @@ -7,6 +7,7 @@ if "bpy" not in locals(): from .core.register import __bl_ordered_classes from .core import properties from .core import addon_preferences + from .core.updater import check_for_update_on_start else: import importlib importlib.reload(ui) @@ -33,6 +34,8 @@ def register(): #finally register properties that may use some classes. core.register.register_properties() + bpy.app.handlers.load_post.append(check_for_update_on_start) + from .functions.mesh_tools import AvatarToolkit_OT_ApplyShapeKey bpy.types.MESH_MT_shape_key_context_menu.append((lambda self, context: self.layout.separator())) @@ -41,6 +44,8 @@ def register(): def unregister(): print("Unregistering Avatar Toolkit") # Unregister the UI classes + if check_for_update_on_start in bpy.app.handlers.load_post: + bpy.app.handlers.load_post.remove(check_for_update_on_start) # Iterate over the classes to unregister in reverse order and unregister them for cls in reversed(list(__bl_ordered_classes)): diff --git a/core/updater.py b/core/updater.py index 61cee3c..616f3ad 100644 --- a/core/updater.py +++ b/core/updater.py @@ -6,6 +6,7 @@ import urllib import shutil import pathlib import zipfile +import time from threading import Thread from bpy.app.handlers import persistent from ..functions.translations import t @@ -13,7 +14,7 @@ from .addon_preferences import get_preference, get_current_version, save_prefere from .register import register_wrap from ..ui.panel import AvatarToolKit_PT_AvatarToolkitPanel, CATEGORY_NAME -GITHUB_REPO = "teamneoneko/Avatar-Toolkit" +GITHUB_REPO = "Yusarina/avito" is_checking_for_update = False update_needed = False @@ -292,10 +293,3 @@ def ui_refresh(): for window in windowManager.windows: for area in window.screen.areas: area.tag_redraw() - -def register(): - bpy.app.handlers.load_post.append(check_for_update_on_start) - -def unregister(): - if check_for_update_on_start in bpy.app.handlers.load_post: - bpy.app.handlers.load_post.remove(check_for_update_on_start) diff --git a/resources/translations/en_US.json b/resources/translations/en_US.json index 6c3927c..04fa8e6 100644 --- a/resources/translations/en_US.json +++ b/resources/translations/en_US.json @@ -256,8 +256,14 @@ "Updater.UpdateToLatestButton.label": "Update to {name}", "Updater.UpdateToSelectedButton.label": "Update", "Updater.currentVersion": "Current Version: {name}", - "Scene.avatar_toolkit_updater_version_list.name": "Available Versions", - "Scene.avatar_toolkit_updater_version_list.description": "List of available versions to update to", + "Updater.CheckForUpdateButton.desc": "Check for available updates", + "UpdateToLatestButton.desc": "Update to the latest version", + "UpdateNotificationPopup.label": "Update Notification", + "UpdateNotificationPopup.desc": "Notification about available updates", + "UpdateNotificationPopup.newUpdate": "New update available: {version}", + "RestartBlenderPopup.label": "Restart Blender", + "RestartBlenderPopup.desc": "Restart Blender to complete the update", + "RestartBlenderPopup.message": "Update successful! Please restart Blender.", "check_for_update.cantCheck": "Unable to check for updates", "download_file.cantConnect": "Cannot connect to update server", "download_file.cantFindZip": "Update file not found",