Skip to content

Commit

Permalink
fix(split type preset): add default option & use grid_flow (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
NMC-TBone authored Jan 14, 2025
1 parent bba8269 commit c8f42bf
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions addon/i3dio/ui/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,11 @@ def description(cls, _context, properties):
f"Supports wood harvester: {'Yes' if support_harvester else 'No'}")

def execute(self, context):
preset = SPLIT_TYPE_PRESETS.get(self.preset, {})
i3d_attributes = context.object.i3d_attributes
if self.preset == "Default":
i3d_attributes.split_type = i3d_attributes.i3d_map['split_type']['default']
return {'FINISHED'}
preset = SPLIT_TYPE_PRESETS.get(self.preset, {})
i3d_attributes.split_type = preset['split_type']
return {'FINISHED'}

Expand All @@ -521,17 +524,12 @@ class I3D_IO_MT_split_type_presets(bpy.types.Menu):

def draw(self, _context):
layout = self.layout
row = layout.row(align=False)
col1 = row.column(align=True)
col2 = row.column(align=True)
presets = list(SPLIT_TYPE_PRESETS.keys())
middle = len(presets) // 2

for idx, preset in enumerate(presets):
if idx <= middle:
col1.operator(I3D_IO_OT_set_split_type_preset.bl_idname, text=preset).preset = preset
else:
col2.operator(I3D_IO_OT_set_split_type_preset.bl_idname, text=preset).preset = preset
grid = layout.grid_flow(columns=2, even_columns=True, even_rows=True)
for preset in list(SPLIT_TYPE_PRESETS.keys()):
grid.operator(I3D_IO_OT_set_split_type_preset.bl_idname, text=preset).preset = preset

layout.separator()
layout.operator(I3D_IO_OT_set_split_type_preset.bl_idname, text="Default").preset = "Default"


@register
Expand Down

0 comments on commit c8f42bf

Please sign in to comment.