Skip to content

Commit

Permalink
fix: fix Blender 4.2 extension compatibility issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm authored May 7, 2024
1 parent b5926b5 commit 08004b7
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 17 deletions.
19 changes: 12 additions & 7 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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("""
███╗ ██╗██████╗
Expand All @@ -635,7 +640,7 @@ def register():
██║ ╚████║██████╔╝
╚═╝ ╚═══╝╚═════╝
HugeMenace — ND Addon v%s
""" % (version));
""" % (version_str));


def unregister():
Expand Down
7 changes: 5 additions & 2 deletions addon-version-updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]})`);
}
2 changes: 1 addition & 1 deletion interface/fast_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion interface/main_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion interface/main_ui_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion interface/packaging_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import bpy
from . import ops
from . common import render_ops
from .. import bl_info
from .. __init__ import bl_info


keys = []
Expand Down
2 changes: 1 addition & 1 deletion interface/sketch_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import bpy
from . import ops
from . common import render_ops
from .. import bl_info
from .. __init__ import bl_info


keys = []
Expand Down
2 changes: 1 addition & 1 deletion interface/utils_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import bpy
from . import ops
from . common import render_ops
from .. import bl_info
from .. __init__ import bl_info


keys = []
Expand Down
2 changes: 1 addition & 1 deletion interface/viewport_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import bpy
from . import ops
from . common import render_ops
from .. import bl_info
from .. __init__ import bl_info


keys = []
Expand Down
12 changes: 11 additions & 1 deletion lib/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 08004b7

Please sign in to comment.