From 08004b732cb8733ccc52fdf2efc7fb4c6a135172 Mon Sep 17 00:00:00 2001 From: Tristo Date: Tue, 7 May 2024 13:42:13 +1000 Subject: [PATCH] fix: fix Blender 4.2 extension compatibility issues --- __init__.py | 19 ++++++++++++------- addon-version-updater.js | 7 +++++-- interface/fast_menu.py | 2 +- interface/main_menu.py | 2 +- interface/main_ui_panel.py | 2 +- interface/packaging_menu.py | 2 +- interface/sketch_menu.py | 2 +- interface/utils_menu.py | 2 +- interface/viewport_menu.py | 2 +- lib/addons.py | 12 +++++++++++- 10 files changed, 35 insertions(+), 17 deletions(-) diff --git a/__init__.py b/__init__.py index cd94d20..647afd4 100644 --- a/__init__.py +++ b/__init__.py @@ -556,7 +556,9 @@ def draw_keymap(self, box): row = column.row() row.prop(self, pref) - name = "ND v%s" % ('.'.join([str(v) for v in bl_info['version']])) + version = (1, 41, 0) + + name = "ND v%s" % ('.'.join([str(v) for v in version])) wm = bpy.context.window_manager kc = wm.keyconfigs.user @@ -610,22 +612,25 @@ def register(): registerable.reload() registerable.register() - version = '.'.join([str(v) for v in bl_info['version']]) + version = (1, 41, 0) + version_str = '.'.join([str(v) for v in version]) + prefs = lib.preferences.get_preferences() if prefs.enable_update_check: - prefs.update_available = lib.updates.update_available(bl_info['version']) + + prefs.update_available = lib.updates.update_available(version_str) else: prefs.update_available = False - if prefs.local_user_prefs_version != version: - if version.startswith("1.28"): + if prefs.local_user_prefs_version != version_str: + if version_str.startswith("1.28"): prefs.overlay_pin_key = "P" prefs.overlay_pause_key = "BACK_SLASH" prefs.overlay_reset_key = "X" prefs.lock_overlay_pinning = True prefs.enable_mouse_values = True - prefs.local_user_prefs_version = version + prefs.local_user_prefs_version = version_str print(""" ███╗ ██╗██████╗ @@ -635,7 +640,7 @@ def register(): ██║ ╚████║██████╔╝ ╚═╝ ╚═══╝╚═════╝ HugeMenace — ND Addon v%s - """ % (version)); + """ % (version_str)); def unregister(): diff --git a/addon-version-updater.js b/addon-version-updater.js index 21e1b83..90f5b97 100644 --- a/addon-version-updater.js +++ b/addon-version-updater.js @@ -33,8 +33,11 @@ module.exports.readVersion = function (contents) { } module.exports.writeVersion = function (contents, version) { - const regex = /"version": \([0-9]+, [0-9]+, [0-9]+\),/gm; + const objRegex = /"version": \([0-9]+, [0-9]+, [0-9]+\),/gm; + const varRegex = /version = \([0-9]+, [0-9]+, [0-9]+\)/gm; const v = version.split('.'); - return contents.replace(regex, `"version": (${v[0]}, ${v[1]}, ${v[2]}),`); + return contents + .replace(objRegex, `"version": (${v[0]}, ${v[1]}, ${v[2]}),`) + .replace(varRegex, `version = (${v[0]}, ${v[1]}, ${v[2]})`); } \ No newline at end of file diff --git a/interface/fast_menu.py b/interface/fast_menu.py index 3a814d4..f701ae9 100644 --- a/interface/fast_menu.py +++ b/interface/fast_menu.py @@ -27,7 +27,7 @@ import bpy import bmesh -from .. import bl_info +from .. __init__ import bl_info from .. lib.objects import is_planar from . ops import build_icon_lookup_table from .. lib.addons import is_addon_enabled diff --git a/interface/main_menu.py b/interface/main_menu.py index c52c0e6..0092eaf 100644 --- a/interface/main_menu.py +++ b/interface/main_menu.py @@ -28,7 +28,7 @@ import bpy from . import ops from . common import render_ops -from .. import bl_info +from .. __init__ import bl_info from .. import lib diff --git a/interface/main_ui_panel.py b/interface/main_ui_panel.py index d3e7476..cb3b558 100644 --- a/interface/main_ui_panel.py +++ b/interface/main_ui_panel.py @@ -27,7 +27,7 @@ import bpy from bpy.props import BoolProperty, PointerProperty -from .. import bl_info +from .. __init__ import bl_info from .. import lib from . import ops from . common import create_box, render_ops, web_link diff --git a/interface/packaging_menu.py b/interface/packaging_menu.py index 29e2731..63da5e0 100644 --- a/interface/packaging_menu.py +++ b/interface/packaging_menu.py @@ -28,7 +28,7 @@ import bpy from . import ops from . common import render_ops -from .. import bl_info +from .. __init__ import bl_info keys = [] diff --git a/interface/sketch_menu.py b/interface/sketch_menu.py index 9562d88..06b52d2 100644 --- a/interface/sketch_menu.py +++ b/interface/sketch_menu.py @@ -28,7 +28,7 @@ import bpy from . import ops from . common import render_ops -from .. import bl_info +from .. __init__ import bl_info keys = [] diff --git a/interface/utils_menu.py b/interface/utils_menu.py index f3c38d9..2379476 100644 --- a/interface/utils_menu.py +++ b/interface/utils_menu.py @@ -28,7 +28,7 @@ import bpy from . import ops from . common import render_ops -from .. import bl_info +from .. __init__ import bl_info keys = [] diff --git a/interface/viewport_menu.py b/interface/viewport_menu.py index a16be0c..dc04acc 100644 --- a/interface/viewport_menu.py +++ b/interface/viewport_menu.py @@ -28,7 +28,7 @@ import bpy from . import ops from . common import render_ops -from .. import bl_info +from .. __init__ import bl_info keys = [] diff --git a/lib/addons.py b/lib/addons.py index e4ebb37..d64966f 100644 --- a/lib/addons.py +++ b/lib/addons.py @@ -28,8 +28,18 @@ import bpy +def is_extension(): + return __name__.startswith('bl_ext.') + + def get_registered_addon_name(): - return __name__.partition('.')[0] + if is_extension(): + path = __name__.split('.') + extension = path[0:3] + return '.'.join(extension) + + path = __name__.split('.') + return path[0] def is_addon_enabled(addon):