Skip to content

Commit

Permalink
Prepare for Blender v4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
UuuNyaa committed Dec 7, 2023
1 parent 636deb7 commit 0559750
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion mmd_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
bl_info = {
"name": "mmd_tools",
"author": "sugiany",
"version": (2, 10, 0),
"version": (2, 10, 1),
"blender": (2, 93, 0),
"location": "View3D > Sidebar > MMD Tools Panel",
"description": "Utility tools for MMD model editing. (UuuNyaa's forked version)",
Expand Down
28 changes: 16 additions & 12 deletions mmd_tools/operators/addon_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# This file is copied from
# https://github.com/nutti/Screencast-Keys/blob/a16f6c7dd697f6ec7bced5811db4a8144514d320/src/screencast_keys/utils/addon_updater.py

# fmt: off

import datetime
import json
Expand Down Expand Up @@ -176,6 +176,7 @@ def __init__(self):
# If you specify (-1, -1), ignore versions less than current add-on
# version specified in bl_info.
self.min_release_version = (-1, -1)
self.max_release_version = (+999, +999)

# Target add-on path
# {"branch/tag": "add-on path"}
Expand Down Expand Up @@ -268,8 +269,7 @@ def check_update_candidate(self):
releases = _get_all_releases_data(self.__config.owner,
self.__config.repository)
for r in releases:
if _compare_version(_parse_release_version(r["tag_name"]),
self.__config.min_release_version) > 0:
if _compare_version(_parse_release_version(r["tag_name"]), self.__config.min_release_version) > 0 and _compare_version(_parse_release_version(r["tag_name"]), self.__config.max_release_version) < 0:
info = UpdateCandidateInfo()
info.name = r["tag_name"]
info.url = r["assets"][0]["browser_download_url"]
Expand Down Expand Up @@ -377,25 +377,27 @@ def update_ready(self):
def updated(self):
return self.__updated

# fmt: on


class CheckAddonUpdate(bpy.types.Operator):
bl_idname = "mmd_tools.check_addon_update"
bl_label = "Check Update"
bl_description = "Check Add-on Update"
bl_options = {'INTERNAL'}
bl_options = {"INTERNAL"}

def execute(self, context):
updater = AddonUpdaterManager.get_instance()
updater.check_update_candidate()

return {'FINISHED'}
return {"FINISHED"}


class UpdateAddon(bpy.types.Operator):
bl_idname = "mmd_tools.update_addon"
bl_label = "Update"
bl_description = "Update Add-on"
bl_options = {'INTERNAL'}
bl_options = {"INTERNAL"}

branch_name: bpy.props.StringProperty(
name="Branch Name",
Expand All @@ -407,21 +409,23 @@ def execute(self, context):
updater = AddonUpdaterManager.get_instance()
updater.update(self.branch_name)

return {'FINISHED'}
return {"FINISHED"}


def register_updater(bl_info, init_py_file):
config = AddonUpdaterConfig()
config.owner = 'UuuNyaa'
config.repository = 'blender_mmd_tools'
config.owner = "UuuNyaa"
config.repository = "blender_mmd_tools"
config.current_addon_path = os.path.dirname(os.path.realpath(init_py_file))
config.branches = ['main']
config.branches = ["main"]
config.addon_directory = os.path.dirname(config.current_addon_path)
config.min_release_version = (1, 0, 0)
config.default_target_addon_path = 'mmd_tools'
config.max_release_version = (4, 0, 0)
config.default_target_addon_path = "mmd_tools"
config.target_addon_path = {}
updater = AddonUpdaterManager.get_instance()
updater.init(bl_info, config)


def unregister_updater():
pass
pass

0 comments on commit 0559750

Please sign in to comment.