Brushstroke Tools: Initial Version #328

Merged
Simon Thommes merged 229 commits from SimonThommes/blender-studio-tools:brushstroke_tools-initial-version into main 2024-11-06 15:03:47 +01:00
2 changed files with 14 additions and 10 deletions
Showing only changes of commit 5120f3d383 - Show all commits

View File

@ -76,13 +76,14 @@ class BSBST_preferences(bpy.types.AddonPreferences):
version_comp = utils.compare_versions(lib_version, utils.addon_version)
if bool(version_comp):
col.label(text=f"Version mismatch: Local Data ({'.'.join([str(i) for i in lib_version])}) {'>' if version_comp>0 else '<'} Addon ({'.'.join([str(i) for i in utils.addon_version])})", icon='ERROR')
split = col.split(factor=0.75)
if version_comp>0:
split.label(text="Consider upgrading the addon or re-copying the data.")
else:
split.label(text="Consider upgrading re-copying the data.")
op = split.operator('brushstroke_tools.copy_resources', icon='IMPORT')
op.update = False
if abs(version_comp) in [1,2]:
split = col.split(factor=0.75)
if version_comp>0:
split.label(text="Consider upgrading the addon or re-copying the data.")
else:
split.label(text="Consider upgrading re-copying the data.")
op = split.operator('brushstroke_tools.copy_resources', icon='IMPORT')
op.update = False
if self.import_method == 'LINK' and not self.resource_path:
col.label(text='Linking the resources from the default addon directory is not recommended.', icon='ERROR')

View File

@ -248,13 +248,16 @@ def copy_resources_to_dir(tgt_dir = ''):
print("Error: % s" % err)
def compare_versions(v1: tuple, v2: tuple):
""" Returns 1 when v1 > v2, 0 when v1 == v2, -1 when v1 < v2.
""" Returns n when v1 > v2, 0 when v1 == v2, -n when v1 < v2, while n = 'Index of first significant version tuple element' + 1.
e.g. (0,2,0), (0,2,1) -> -3
"""
c = 1
for e1, e2 in zip(v1, v2):
if e1 > e2:
return 1
return c
elif e1 < e2:
return -1
return -c
c += 1
return 0
def ensure_resources():