Update leenkx/blender/lnx/props_traits.py
This commit is contained in:
@ -13,13 +13,6 @@ import lnx.make as make
|
|||||||
from lnx.props_traits_props import *
|
from lnx.props_traits_props import *
|
||||||
import lnx.ui_icons as ui_icons
|
import lnx.ui_icons as ui_icons
|
||||||
|
|
||||||
def compatible_prop(property_func, **kwargs):
|
|
||||||
"""Create properties compatible with different Blender versions."""
|
|
||||||
if bpy.app.version < (2, 90, 0):
|
|
||||||
# Remove override parameter for Blender 2.83
|
|
||||||
kwargs.pop('override', None)
|
|
||||||
return property_func(**kwargs)
|
|
||||||
|
|
||||||
import lnx.utils
|
import lnx.utils
|
||||||
import lnx.write_data as write_data
|
import lnx.write_data as write_data
|
||||||
|
|
||||||
@ -100,20 +93,31 @@ class LnxTraitListItem(bpy.types.PropertyGroup):
|
|||||||
"""Ensure that only logic node trees show up as node traits"""
|
"""Ensure that only logic node trees show up as node traits"""
|
||||||
return tree.bl_idname == 'LnxLogicTreeType'
|
return tree.bl_idname == 'LnxLogicTreeType'
|
||||||
|
|
||||||
name = compatible_prop(StringProperty, name="Name", description="The name of the trait", default="", override={"LIBRARY_OVERRIDABLE"})
|
if bpy.app.version < (2, 90, 0):
|
||||||
enabled_prop = compatible_prop(BoolProperty, name="", description="Whether this trait is enabled", default=True, update=trigger_recompile, override={"LIBRARY_OVERRIDABLE"})
|
name: StringProperty(name="Name", description="The name of the trait", default="")
|
||||||
is_object = BoolProperty(name="", default=True)
|
enabled_prop: BoolProperty(name="", description="Whether this trait is enabled", default=True, update=trigger_recompile)
|
||||||
fake_user = compatible_prop(BoolProperty, name="Fake User", description="Export this trait even if it is deactivated", default=False, override={"LIBRARY_OVERRIDABLE"})
|
fake_user: BoolProperty(name="Fake User", description="Export this trait even if it is deactivated", default=False)
|
||||||
type_prop = EnumProperty(name="Type", items=PROP_TYPES_ENUM)
|
class_name_prop: StringProperty(name="Class", description="A name for this item", default="", update=update_trait_group)
|
||||||
|
canvas_name_prop: StringProperty(name="Canvas", description="A name for this item", default="", update=update_trait_group)
|
||||||
|
webassembly_prop: StringProperty(name="Module", description="A name for this item", default="", update=update_trait_group)
|
||||||
|
node_tree_prop: PointerProperty(type=NodeTree, update=update_trait_group, poll=poll_node_trees)
|
||||||
|
lnx_traitpropslist_index: IntProperty(name="Index for my_list", default=0, options={"LIBRARY_EDITABLE"})
|
||||||
|
else:
|
||||||
|
name: StringProperty(name="Name", description="The name of the trait", default="", override={"LIBRARY_OVERRIDABLE"})
|
||||||
|
enabled_prop: BoolProperty(name="", description="Whether this trait is enabled", default=True, update=trigger_recompile, override={"LIBRARY_OVERRIDABLE"})
|
||||||
|
fake_user: BoolProperty(name="Fake User", description="Export this trait even if it is deactivated", default=False, override={"LIBRARY_OVERRIDABLE"})
|
||||||
|
class_name_prop: StringProperty(name="Class", description="A name for this item", default="", update=update_trait_group, override={"LIBRARY_OVERRIDABLE"})
|
||||||
|
canvas_name_prop: StringProperty(name="Canvas", description="A name for this item", default="", update=update_trait_group, override={"LIBRARY_OVERRIDABLE"})
|
||||||
|
webassembly_prop: StringProperty(name="Module", description="A name for this item", default="", update=update_trait_group, override={"LIBRARY_OVERRIDABLE"})
|
||||||
|
node_tree_prop: PointerProperty(type=NodeTree, update=update_trait_group, override={"LIBRARY_OVERRIDABLE"}, poll=poll_node_trees)
|
||||||
|
lnx_traitpropslist_index: IntProperty(name="Index for my_list", default=0, options={"LIBRARY_EDITABLE"}, override={"LIBRARY_OVERRIDABLE"})
|
||||||
|
|
||||||
class_name_prop = compatible_prop(StringProperty, name="Class", description="A name for this item", default="", update=update_trait_group, override={"LIBRARY_OVERRIDABLE"})
|
is_object: BoolProperty(name="", default=True)
|
||||||
canvas_name_prop = compatible_prop(StringProperty, name="Canvas", description="A name for this item", default="", update=update_trait_group, override={"LIBRARY_OVERRIDABLE"})
|
type_prop: EnumProperty(name="Type", items=PROP_TYPES_ENUM)
|
||||||
webassembly_prop = compatible_prop(StringProperty, name="Module", description="A name for this item", default="", update=update_trait_group, override={"LIBRARY_OVERRIDABLE"})
|
|
||||||
node_tree_prop = compatible_prop(PointerProperty, type=NodeTree, update=update_trait_group, override={"LIBRARY_OVERRIDABLE"}, poll=poll_node_trees)
|
|
||||||
|
|
||||||
lnx_traitpropslist = CollectionProperty(type=LnxTraitPropListItem)
|
|
||||||
lnx_traitpropslist_index = compatible_prop(IntProperty, name="Index for my_list", default=0, options={"LIBRARY_EDITABLE"}, override={"LIBRARY_OVERRIDABLE"})
|
lnx_traitpropslist: CollectionProperty(type=LnxTraitPropListItem)
|
||||||
lnx_traitpropswarnings = CollectionProperty(type=LnxTraitPropWarning)
|
lnx_traitpropswarnings: CollectionProperty(type=LnxTraitPropWarning)
|
||||||
|
|
||||||
class LNX_UL_TraitList(bpy.types.UIList):
|
class LNX_UL_TraitList(bpy.types.UIList):
|
||||||
"""List of traits."""
|
"""List of traits."""
|
||||||
@ -1077,7 +1081,14 @@ __reg_classes, unregister = bpy.utils.register_classes_factory(__REG_CLASSES)
|
|||||||
def register():
|
def register():
|
||||||
__reg_classes()
|
__reg_classes()
|
||||||
|
|
||||||
bpy.types.Object.lnx_traitlist = compatible_prop(CollectionProperty, type=LnxTraitListItem)
|
if bpy.app.version < (2, 90, 0):
|
||||||
bpy.types.Object.lnx_traitlist_index = compatible_prop(IntProperty, name="Index for lnx_traitlist", default=0)
|
bpy.types.Object.lnx_traitlist = CollectionProperty(type=LnxTraitListItem)
|
||||||
bpy.types.Scene.lnx_traitlist = compatible_prop(CollectionProperty, type=LnxTraitListItem)
|
bpy.types.Object.lnx_traitlist_index = IntProperty(name="Index for lnx_traitlist", default=0, options={"LIBRARY_EDITABLE"})
|
||||||
bpy.types.Scene.lnx_traitlist_index = compatible_prop(IntProperty, name="Index for lnx_traitlist", default=0)
|
bpy.types.Scene.lnx_traitlist = CollectionProperty(type=LnxTraitListItem)
|
||||||
|
bpy.types.Scene.lnx_traitlist_index = IntProperty(name="Index for lnx_traitlist", default=0, options={"LIBRARY_EDITABLE"})
|
||||||
|
else:
|
||||||
|
bpy.types.Object.lnx_traitlist = CollectionProperty(type=LnxTraitListItem, override={"LIBRARY_OVERRIDABLE", "USE_INSERTION"})
|
||||||
|
bpy.types.Object.lnx_traitlist_index = IntProperty(name="Index for lnx_traitlist", default=0, options={"LIBRARY_EDITABLE"}, override={"LIBRARY_OVERRIDABLE"})
|
||||||
|
bpy.types.Scene.lnx_traitlist = CollectionProperty(type=LnxTraitListItem, override={"LIBRARY_OVERRIDABLE", "USE_INSERTION"})
|
||||||
|
bpy.types.Scene.lnx_traitlist_index = IntProperty(name="Index for lnx_traitlist", default=0, options={"LIBRARY_EDITABLE"}, override={"LIBRARY_OVERRIDABLE"})
|
||||||
|
|
Reference in New Issue
Block a user