From d26d195a85e1b1b20f170bd8fc93535b09500d02 Mon Sep 17 00:00:00 2001 From: Colin Basnett Date: Wed, 10 Jul 2024 01:30:45 -0700 Subject: [PATCH] PSA export dialog now uses inline panels --- io_scene_psk_psa/psa/export/operators.py | 133 ++++++++++++---------- io_scene_psk_psa/psa/export/properties.py | 2 +- 2 files changed, 75 insertions(+), 60 deletions(-) diff --git a/io_scene_psk_psa/psa/export/operators.py b/io_scene_psk_psa/psa/export/operators.py index b7c970b..6617271 100644 --- a/io_scene_psk_psa/psa/export/operators.py +++ b/io_scene_psk_psa/psa/export/operators.py @@ -239,79 +239,94 @@ class PSA_OT_export(Operator, ExportHelper): layout = self.layout pg = getattr(context.scene, 'psa_export') - # FPS - layout.prop(pg, 'fps_source', text='FPS') - if pg.fps_source == 'CUSTOM': - layout.prop(pg, 'fps_custom', text='Custom') + sequences_header, sequences_panel = layout.panel('Sequences', default_closed=False) + sequences_header.label(text='Sequences', icon='ACTION') - # SOURCE - layout.prop(pg, 'sequence_source', text='Source') - - if pg.sequence_source in {'TIMELINE_MARKERS', 'NLA_TRACK_STRIPS'}: - # ANIMDATA SOURCE - layout.prop(pg, 'should_override_animation_data') - if pg.should_override_animation_data: - layout.prop(pg, 'animation_data_override', text='') - - if pg.sequence_source == 'NLA_TRACK_STRIPS': - flow = layout.grid_flow() + if sequences_panel: + flow = sequences_panel.grid_flow() flow.use_property_split = True flow.use_property_decorate = False - flow.prop(pg, 'nla_track') + flow.prop(pg, 'sequence_source', text='Source') - # SELECT ALL/NONE - row = layout.row(align=True) - row.label(text='Select') - row.operator(PSA_OT_export_actions_select_all.bl_idname, text='All', icon='CHECKBOX_HLT') - row.operator(PSA_OT_export_actions_deselect_all.bl_idname, text='None', icon='CHECKBOX_DEHLT') + if pg.sequence_source in {'TIMELINE_MARKERS', 'NLA_TRACK_STRIPS'}: + # ANIMDATA SOURCE + flow.prop(pg, 'should_override_animation_data') + if pg.should_override_animation_data: + flow.prop(pg, 'animation_data_override', text=' ') - # ACTIONS - if pg.sequence_source == 'ACTIONS': - rows = max(3, min(len(pg.action_list), 10)) - layout.template_list('PSA_UL_export_sequences', '', pg, 'action_list', pg, 'action_list_index', rows=rows) - elif pg.sequence_source == 'TIMELINE_MARKERS': - rows = max(3, min(len(pg.marker_list), 10)) - layout.template_list('PSA_UL_export_sequences', '', pg, 'marker_list', pg, 'marker_list_index', rows=rows) - elif pg.sequence_source == 'NLA_TRACK_STRIPS': - rows = max(3, min(len(pg.nla_strip_list), 10)) - layout.template_list('PSA_UL_export_sequences', '', pg, 'nla_strip_list', pg, 'nla_strip_list_index', rows=rows) + if pg.sequence_source == 'NLA_TRACK_STRIPS': + flow = sequences_panel.grid_flow() + flow.use_property_split = True + flow.use_property_decorate = False + flow.prop(pg, 'nla_track') - col = layout.column() - col.use_property_split = True - col.use_property_decorate = False - col.prop(pg, 'sequence_name_prefix') - col.prop(pg, 'sequence_name_suffix') + # SELECT ALL/NONE + row = sequences_panel.row(align=True) + row.label(text='Select') + row.operator(PSA_OT_export_actions_select_all.bl_idname, text='All', icon='CHECKBOX_HLT') + row.operator(PSA_OT_export_actions_deselect_all.bl_idname, text='None', icon='CHECKBOX_DEHLT') - # Determine if there is going to be a naming conflict and display an error, if so. - selected_items = [x for x in pg.action_list if x.is_selected] - action_names = [x.name for x in selected_items] - action_name_counts = Counter(action_names) - for action_name, count in action_name_counts.items(): - if count > 1: - layout.label(text=f'Duplicate action: {action_name}', icon='ERROR') - break + # ACTIONS + if pg.sequence_source == 'ACTIONS': + rows = max(3, min(len(pg.action_list), 10)) + sequences_panel.template_list('PSA_UL_export_sequences', '', pg, 'action_list', pg, 'action_list_index', rows=rows) + elif pg.sequence_source == 'TIMELINE_MARKERS': + rows = max(3, min(len(pg.marker_list), 10)) + sequences_panel.template_list('PSA_UL_export_sequences', '', pg, 'marker_list', pg, 'marker_list_index', rows=rows) + elif pg.sequence_source == 'NLA_TRACK_STRIPS': + rows = max(3, min(len(pg.nla_strip_list), 10)) + sequences_panel.template_list('PSA_UL_export_sequences', '', pg, 'nla_strip_list', pg, 'nla_strip_list_index', rows=rows) - layout.separator() + flow = sequences_panel.grid_flow() + flow.use_property_split = True + flow.use_property_decorate = False + flow.prop(pg, 'sequence_name_prefix', text='Name Prefix') + flow.prop(pg, 'sequence_name_suffix') + + # Determine if there is going to be a naming conflict and display an error, if so. + selected_items = [x for x in pg.action_list if x.is_selected] + action_names = [x.name for x in selected_items] + action_name_counts = Counter(action_names) + for action_name, count in action_name_counts.items(): + if count > 1: + layout.label(text=f'Duplicate action: {action_name}', icon='ERROR') + break + + # FPS + flow.prop(pg, 'fps_source') + if pg.fps_source == 'CUSTOM': + flow.prop(pg, 'fps_custom', text='Custom') # BONES - row = layout.row(align=True) - row.prop(pg, 'bone_filter_mode', text='Bones') + bones_header, bones_panel = layout.panel('Bones', default_closed=False) + bones_header.label(text='Bones', icon='BONE_DATA') + if bones_panel: + row = bones_panel.row(align=True) + row.prop(pg, 'bone_filter_mode', text='Bones') - if pg.bone_filter_mode == 'BONE_COLLECTIONS': - row = layout.row(align=True) - row.label(text='Select') - row.operator(PSA_OT_export_bone_collections_select_all.bl_idname, text='All', icon='CHECKBOX_HLT') - row.operator(PSA_OT_export_bone_collections_deselect_all.bl_idname, text='None', icon='CHECKBOX_DEHLT') - rows = max(3, min(len(pg.bone_collection_list), 10)) - layout.template_list('PSX_UL_bone_collection_list', '', pg, 'bone_collection_list', pg, 'bone_collection_list_index', - rows=rows) + if pg.bone_filter_mode == 'BONE_COLLECTIONS': + row = bones_panel.row(align=True) + row.label(text='Select') + row.operator(PSA_OT_export_bone_collections_select_all.bl_idname, text='All', icon='CHECKBOX_HLT') + row.operator(PSA_OT_export_bone_collections_deselect_all.bl_idname, text='None', icon='CHECKBOX_DEHLT') + rows = max(3, min(len(pg.bone_collection_list), 10)) + bones_panel.template_list('PSX_UL_bone_collection_list', '', pg, 'bone_collection_list', pg, 'bone_collection_list_index', + rows=rows) - layout.prop(pg, 'should_enforce_bone_name_restrictions') + flow = bones_panel.grid_flow() + flow.use_property_split = True + flow.use_property_decorate = False + flow.prop(pg, 'should_enforce_bone_name_restrictions') - layout.separator() + # ADVANCED + advanced_header, advanced_panel = layout.panel('Advanced', default_closed=False) + advanced_header.label(text='Advanced') - # ROOT MOTION - layout.prop(pg, 'root_motion', text='Root Motion') + if advanced_panel: + flow = advanced_panel.grid_flow() + flow.use_property_split = True + flow.use_property_decorate = False + flow.prop(pg, 'root_motion', text='Root Motion') @classmethod def _check_context(cls, context): diff --git a/io_scene_psk_psa/psa/export/properties.py b/io_scene_psk_psa/psa/export/properties.py index 22e6824..3efd072 100644 --- a/io_scene_psk_psa/psa/export/properties.py +++ b/io_scene_psk_psa/psa/export/properties.py @@ -125,7 +125,7 @@ class PSA_PG_export(PropertyGroup): description='', items=( ('SCENE', 'Scene', '', 'SCENE_DATA', 0), - ('ACTION_METADATA', 'Action Metadata', 'The frame rate will be determined by action\'s FPS property found in the PSA Export panel.\n\nIf the Sequence Source is Timeline Markers, the lowest value of all contributing actions will be used', 'PROPERTIES', 1), + ('ACTION_METADATA', 'Action Metadata', 'The frame rate will be determined by action\'s FPS property found in the PSA Export panel.\n\nIf the Sequence Source is Timeline Markers, the lowest value of all contributing actions will be used', 'ACTION', 1), ('CUSTOM', 'Custom', '', 2) ) )