Repe [T3DU] Update - 31f26d171bba0355ce2a77031e3aad4c64dbc7e9

This commit is contained in:
2026-09-04 10:46:13 -07:00
parent c915312901
commit 0460b9d587
482 changed files with 27797 additions and 3226 deletions

View File

@ -18,7 +18,7 @@ class LnxArrayItem(bpy.types.PropertyGroup):
integer_prop: IntProperty(name="Integer", default=0)
float_prop: FloatProperty(name="Float", default=0.0)
boolean_prop: BoolProperty(name="Boolean", default=False)
vector_prop: FloatVectorProperty(name="Vector", size=3, default=[0.0, 0.0, 0.0])
class LnxPropertyListItem(bpy.types.PropertyGroup):
type_prop: EnumProperty(
@ -26,6 +26,7 @@ class LnxPropertyListItem(bpy.types.PropertyGroup):
('integer', 'Integer', 'Integer'),
('float', 'Float', 'Float'),
('boolean', 'Boolean', 'Boolean'),
('vector', 'Vector', 'Vector'),
('array', 'Array', 'Array'),
],
name = "Type")
@ -34,6 +35,7 @@ class LnxPropertyListItem(bpy.types.PropertyGroup):
integer_prop: IntProperty(name="Integer", description="A name for this item", default=0)
float_prop: FloatProperty(name="Float", description="A name for this item", default=0.0)
boolean_prop: BoolProperty(name="Boolean", description="A name for this item", default=False)
vector_prop: FloatVectorProperty(name="Vector", size=3, default=[0.0, 0.0, 0.0])
array_prop: CollectionProperty(type=LnxArrayItem)
array_item_type: EnumProperty(
items = [
@ -41,7 +43,7 @@ class LnxPropertyListItem(bpy.types.PropertyGroup):
('integer', 'Integer', 'Integer'),
('float', 'Float', 'Float'),
('boolean', 'Boolean', 'Boolean'),
# Add more types here as needed
('vector', 'Vector', 'Vector'),
],
name = "New Item Type",
default = 'string'
@ -65,20 +67,26 @@ class LNX_UL_ArrayItemList(bpy.types.UIList):
layout.prop(item, "float_prop", text="")
elif array_type == 'boolean':
layout.prop(item, "boolean_prop", text="")
# Add other types as needed
elif array_type == 'vector':
layout.prop(item, "vector_prop", text="")
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label(text="", icon="OBJECT_DATAMODE")
def get_lnx_target(context):
if context.object is not None and context.object.mode == 'OBJECT':
return context.object
return context.scene
class LnxArrayAddItem(bpy.types.Operator):
bl_idname = "lnx_array.add_item"
bl_label = "Add Array Item"
def execute(self, context):
obj = bpy.context.object
if obj.lnx_propertylist and obj.lnx_propertylist_index < len(obj.lnx_propertylist):
selected_item = obj.lnx_propertylist[obj.lnx_propertylist_index]
target = get_lnx_target(context)
if target.lnx_propertylist and target.lnx_propertylist_index < len(target.lnx_propertylist):
selected_item = target.lnx_propertylist[target.lnx_propertylist_index]
# Create a new item in the array
new_item = selected_item.array_prop.add()
@ -86,13 +94,15 @@ class LnxArrayAddItem(bpy.types.Operator):
# Set the type of the new item based on the selected type
new_item_type = selected_item.array_item_type
if new_item_type == 'string':
new_item.string_prop = "" # Default value for string
new_item.string_prop = ""
elif new_item_type == 'integer':
new_item.integer_prop = 0 # Default value for integer
new_item.integer_prop = 0
elif new_item_type == 'float':
new_item.float_prop = 0.0 # Default value for float
new_item.float_prop = 0.0
elif new_item_type == 'boolean':
new_item.boolean_prop = False # Default value for boolean
new_item.boolean_prop = False
elif new_item_type == 'vector':
new_item.vector_prop = [0.0, 0.0, 0.0]
# Set the index of the new item
new_item_index = len(selected_item.array_prop) - 1
@ -109,9 +119,9 @@ class LnxArrayRemoveItem(bpy.types.Operator):
bl_label = "Remove Array Item"
def execute(self, context):
obj = bpy.context.object
if obj.lnx_propertylist and obj.lnx_propertylist_index < len(obj.lnx_propertylist):
selected_item = obj.lnx_propertylist[obj.lnx_propertylist_index]
target = get_lnx_target(context)
if target.lnx_propertylist and target.lnx_propertylist_index < len(target.lnx_propertylist):
selected_item = target.lnx_propertylist[target.lnx_propertylist_index]
if selected_item.array_prop:
selected_item.array_prop.remove(selected_item.array_index)
if selected_item.array_index > 0:
@ -130,7 +140,6 @@ class LNX_UL_PropertyList(bpy.types.UIList):
layout.label(text="", icon="OBJECT_DATAMODE")
class LnxPropertyListNewItem(bpy.types.Operator):
# Add a new item to the list
bl_idname = "lnx_propertylist.new_item"
bl_label = "New"
@ -139,6 +148,7 @@ class LnxPropertyListNewItem(bpy.types.Operator):
('integer', 'Integer', 'Integer'),
('float', 'Float', 'Float'),
('boolean', 'Boolean', 'Boolean'),
('vector', 'Vector', 'Vector'),
('array', 'Array', 'Array'),
],
@ -153,138 +163,101 @@ class LnxPropertyListNewItem(bpy.types.Operator):
layout.prop(self, "type_prop", expand=True)
def execute(self, context):
obj = bpy.context.object
prop = obj.lnx_propertylist.add()
target = get_lnx_target(context)
prop = target.lnx_propertylist.add()
prop.type_prop = self.type_prop
obj.lnx_propertylist_index = len(obj.lnx_propertylist) - 1
target.lnx_propertylist_index = len(target.lnx_propertylist) - 1
return{'FINISHED'}
class LnxPropertyListDeleteItem(bpy.types.Operator):
# Delete the selected item from the list
bl_idname = "lnx_propertylist.delete_item"
bl_label = "Deletes an item"
@classmethod
def poll(self, context):
""" Enable if there's something in the list """
obj = bpy.context.object
if obj == None:
return False
return len(obj.lnx_propertylist) > 0
target = get_lnx_target(context)
return len(target.lnx_propertylist) > 0
def execute(self, context):
obj = bpy.context.object
lst = obj.lnx_propertylist
index = obj.lnx_propertylist_index
if len(lst) <= index:
return{'FINISHED'}
lst.remove(index)
if index > 0:
index = index - 1
obj.lnx_propertylist_index = index
return{'FINISHED'}
target = get_lnx_target(context)
target.lnx_propertylist.remove(target.lnx_propertylist_index)
target.lnx_propertylist_index = max(0, target.lnx_propertylist_index - 1)
return {'FINISHED'}
class LnxPropertyListMoveItem(bpy.types.Operator):
# Move an item in the list
bl_idname = "lnx_propertylist.move_item"
bl_label = "Move an item in the list"
direction: EnumProperty(
items=(
('UP', 'Up', ""),
('DOWN', 'Down', ""),))
def move_index(self):
obj = bpy.context.object
index = obj.lnx_propertylist_index
list_length = len(obj.lnx_propertylist) - 1
new_index = 0
if self.direction == 'UP':
new_index = index - 1
elif self.direction == 'DOWN':
new_index = index + 1
new_index = max(0, min(new_index, list_length))
obj.lnx_propertylist.move(index, new_index)
obj.lnx_propertylist_index = new_index
bl_label = "Move"
direction: EnumProperty(items=(('UP', 'Up', ""), ('DOWN', 'Down', "")))
def execute(self, context):
obj = bpy.context.object
list = obj.lnx_propertylist
index = obj.lnx_propertylist_index
if self.direction == 'DOWN':
neighbor = index + 1
self.move_index()
elif self.direction == 'UP':
neighbor = index - 1
self.move_index()
else:
return{'CANCELLED'}
return{'FINISHED'}
target = get_lnx_target(context)
idx = target.lnx_propertylist_index
new_idx = idx - 1 if self.direction == 'UP' else idx + 1
if 0 <= new_idx < len(target.lnx_propertylist):
target.lnx_propertylist.move(idx, new_idx)
target.lnx_propertylist_index = new_idx
return {'FINISHED'}
def draw_properties(layout, obj):
layout.label(text="Properties")
# Draw the LNX_UL_PropertyList
rows = 4 if len(obj.lnx_propertylist) > 1 else 2
row = layout.row()
row.template_list("LNX_UL_PropertyList", "The_List", obj, "lnx_propertylist", obj, "lnx_propertylist_index", rows=rows)
# Column for buttons next to LNX_UL_PropertyList
col = row.column(align=True)
col.operator("lnx_propertylist.new_item", icon='ADD', text="")
col.operator("lnx_propertylist.delete_item", icon='REMOVE', text="")
layout.use_property_split = False
main_col = layout.column()
main_col.label(text="Properties")
row = main_col.row()
row.template_list("LNX_UL_PropertyList", "", obj, "lnx_propertylist", obj, "lnx_propertylist_index", rows=4)
btn_col = row.column(align=True)
btn_col.operator("lnx_propertylist.new_item", icon='ADD', text="")
btn_col.operator("lnx_propertylist.delete_item", icon='REMOVE', text="")
if len(obj.lnx_propertylist) > 1:
col.separator()
col.operator("lnx_propertylist.move_item", icon='TRIA_UP', text="").direction = 'UP'
col.operator("lnx_propertylist.move_item", icon='TRIA_DOWN', text="").direction = 'DOWN'
# Draw UI List for array items if the selected property is an array
if obj.lnx_propertylist and obj.lnx_propertylist_index < len(obj.lnx_propertylist):
selected_item = obj.lnx_propertylist[obj.lnx_propertylist_index]
if selected_item.type_prop == 'array':
layout.label(text="Array Items")
# Dropdown to select the type of new array items
layout.prop(selected_item, "array_item_type", text="Array Type")
# Template list for array items
row = layout.row()
row.template_list("LNX_UL_ArrayItemList", "", selected_item, "array_prop", selected_item, "array_index", rows=rows)
# Column for buttons next to the array items list
col = row.column(align=True)
col.operator("lnx_array.add_item", icon='ADD', text="")
col.operator("lnx_array.remove_item", icon='REMOVE', text="")
btn_col.separator()
btn_col.operator("lnx_propertylist.move_item", icon='TRIA_UP', text="").direction = 'UP'
btn_col.operator("lnx_propertylist.move_item", icon='TRIA_DOWN', text="").direction = 'DOWN'
if len(obj.lnx_propertylist) > 0 and obj.lnx_propertylist_index < len(obj.lnx_propertylist):
item = obj.lnx_propertylist[obj.lnx_propertylist_index]
if item.type_prop == 'array':
main_col.separator()
main_col.label(text="Array Items")
main_col.prop(item, "array_item_type", text="Type")
row_arr = main_col.row()
row_arr.template_list("LNX_UL_ArrayItemList", "", item, "array_prop", item, "array_index", rows=4)
btn_arr = row_arr.column(align=True)
btn_arr.operator("lnx_array.add_item", icon='ADD', text="")
btn_arr.operator("lnx_array.remove_item", icon='REMOVE', text="")
class LNX_PT_ObjectPropsPanel(bpy.types.Panel):
bl_label = "Leenkx Props"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
def draw(self, context):
draw_properties(self.layout, context.object)
class LNX_PT_ScenePropsPanel(bpy.types.Panel):
bl_label = "Leenkx Props"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "scene"
def draw(self, context):
draw_properties(self.layout, context.scene)
__REG_CLASSES = (
LnxArrayItem,
LnxPropertyListItem,
LNX_UL_PropertyList,
LNX_UL_ArrayItemList,
LnxPropertyListNewItem,
LnxPropertyListDeleteItem,
LnxPropertyListMoveItem,
LnxArrayAddItem,
LnxArrayRemoveItem,
LnxArrayItem, LnxPropertyListItem, LNX_UL_PropertyList, LNX_UL_ArrayItemList,
LnxPropertyListNewItem, LnxPropertyListDeleteItem, LnxPropertyListMoveItem,
LnxArrayAddItem, LnxArrayRemoveItem, LNX_PT_ObjectPropsPanel, LNX_PT_ScenePropsPanel,
)
__reg_classes, unregister = bpy.utils.register_classes_factory(__REG_CLASSES)
def register():
__reg_classes()
for cls in __REG_CLASSES:
bpy.utils.register_class(cls)
bpy.types.Object.lnx_propertylist = CollectionProperty(type=LnxPropertyListItem)
bpy.types.Object.lnx_propertylist_index = IntProperty(name="Index for lnx_propertylist", default=0)
# New property for tracking the active index in array items
bpy.types.PropertyGroup.array_index = IntProperty(name="Array Index", default=0)
bpy.types.Object.lnx_propertylist_index = IntProperty(name="Index", default=0)
bpy.types.Scene.lnx_propertylist = CollectionProperty(type=LnxPropertyListItem)
bpy.types.Scene.lnx_propertylist_index = IntProperty(name="Index", default=0)
def unregister():
for cls in reversed(__REG_CLASSES):
bpy.utils.unregister_class(cls)
del bpy.types.Object.lnx_propertylist
del bpy.types.Object.lnx_propertylist_index
del bpy.types.Scene.lnx_propertylist
del bpy.types.Scene.lnx_propertylist_index