Brushstroke Tools: Initial Version #328
@ -76,6 +76,7 @@ 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')
|
||||
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.")
|
||||
|
@ -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():
|
||||
|
Loading…
Reference in New Issue
Block a user