Blender 2.8 - 4.5 Support
This commit is contained in:
@ -3,6 +3,14 @@ from bpy.props import *
|
||||
|
||||
__all__ = ['LnxTraitPropWarning', 'LnxTraitPropListItem', 'LNX_UL_PropList']
|
||||
|
||||
# Helper function to handle version compatibility
|
||||
def compatible_prop(prop_func, **kwargs):
|
||||
"""Create properties compatible with both Blender 2.83 and newer versions."""
|
||||
if bpy.app.version < (2, 90, 0):
|
||||
# Remove override parameter for Blender 2.83
|
||||
kwargs.pop('override', None)
|
||||
return prop_func(**kwargs)
|
||||
|
||||
PROP_TYPE_ICONS = {
|
||||
"String": "SORTALPHA",
|
||||
"Int": "CHECKBOX_DEHLT",
|
||||
@ -35,18 +43,19 @@ def filter_objects(item, b_object):
|
||||
|
||||
|
||||
class LnxTraitPropWarning(bpy.types.PropertyGroup):
|
||||
propName: StringProperty(name="Property Name")
|
||||
warning: StringProperty(name="Warning")
|
||||
propName = compatible_prop(StringProperty, name="Property Name", override={"LIBRARY_OVERRIDABLE"})
|
||||
warning = compatible_prop(StringProperty, name="Warning", override={"LIBRARY_OVERRIDABLE"})
|
||||
|
||||
|
||||
class LnxTraitPropListItem(bpy.types.PropertyGroup):
|
||||
"""Group of properties representing an item in the list."""
|
||||
name: StringProperty(
|
||||
name = compatible_prop(StringProperty,
|
||||
name="Name",
|
||||
description="The name of this property",
|
||||
default="Untitled")
|
||||
default="Untitled",
|
||||
override={"LIBRARY_OVERRIDABLE"})
|
||||
|
||||
type: EnumProperty(
|
||||
type = compatible_prop(EnumProperty,
|
||||
items=(
|
||||
# (Haxe Type, Display Name, Description)
|
||||
("String", "String", "String Type"),
|
||||
@ -69,18 +78,18 @@ class LnxTraitPropListItem(bpy.types.PropertyGroup):
|
||||
)
|
||||
|
||||
# === VALUES ===
|
||||
value_string: StringProperty(name="Value", default="", override={"LIBRARY_OVERRIDABLE"})
|
||||
value_int: IntProperty(name="Value", default=0, override={"LIBRARY_OVERRIDABLE"})
|
||||
value_float: FloatProperty(name="Value", default=0.0, override={"LIBRARY_OVERRIDABLE"})
|
||||
value_bool: BoolProperty(name="Value", default=False, override={"LIBRARY_OVERRIDABLE"})
|
||||
value_vec2: FloatVectorProperty(name="Value", size=2, override={"LIBRARY_OVERRIDABLE"})
|
||||
value_vec3: FloatVectorProperty(name="Value", size=3, override={"LIBRARY_OVERRIDABLE"})
|
||||
value_vec4: FloatVectorProperty(name="Value", size=4, override={"LIBRARY_OVERRIDABLE"})
|
||||
value_object: PointerProperty(
|
||||
value_string = compatible_prop(StringProperty, name="Value", default="", override={"LIBRARY_OVERRIDABLE"})
|
||||
value_int = compatible_prop(IntProperty, name="Value", default=0, override={"LIBRARY_OVERRIDABLE"})
|
||||
value_float = compatible_prop(FloatProperty, name="Value", default=0.0, override={"LIBRARY_OVERRIDABLE"})
|
||||
value_bool = compatible_prop(BoolProperty, name="Value", default=False, override={"LIBRARY_OVERRIDABLE"})
|
||||
value_vec2 = compatible_prop(FloatVectorProperty, name="Value", size=2, override={"LIBRARY_OVERRIDABLE"})
|
||||
value_vec3 = compatible_prop(FloatVectorProperty, name="Value", size=3, override={"LIBRARY_OVERRIDABLE"})
|
||||
value_vec4 = compatible_prop(FloatVectorProperty, name="Value", size=4, override={"LIBRARY_OVERRIDABLE"})
|
||||
value_object = compatible_prop(PointerProperty,
|
||||
name="Value", type=bpy.types.Object, poll=filter_objects,
|
||||
override={"LIBRARY_OVERRIDABLE"}
|
||||
)
|
||||
value_scene: PointerProperty(name="Value", type=bpy.types.Scene, override={"LIBRARY_OVERRIDABLE"})
|
||||
value_scene = compatible_prop(PointerProperty, name="Value", type=bpy.types.Scene, override={"LIBRARY_OVERRIDABLE"})
|
||||
|
||||
def set_value(self, val):
|
||||
# Would require way too much effort, so it's out of scope here.
|
||||
|
Reference in New Issue
Block a user