diff --git a/io_export_psk_psa/__init__.py b/io_export_psk_psa/__init__.py index e15dcd0..75c0b89 100644 --- a/io_export_psk_psa/__init__.py +++ b/io_export_psk_psa/__init__.py @@ -45,7 +45,7 @@ classes = [ psk_importer.PskImportOperator, psa_importer.PsaImportOperator, psa_importer.PsaImportFileSelectOperator, - psa_importer.PSA_UL_ActionList, + psa_exporter.PSA_UL_ExportActionList, psa_importer.PSA_UL_ImportActionList, psa_importer.PsaImportActionListItem, psa_importer.PsaImportSelectAll, diff --git a/io_export_psk_psa/psa/exporter.py b/io_export_psk_psa/psa/exporter.py index ffd662e..4bab2d7 100644 --- a/io_export_psk_psa/psa/exporter.py +++ b/io_export_psk_psa/psa/exporter.py @@ -1,5 +1,5 @@ import bpy -from bpy.types import Operator, PropertyGroup, Action +from bpy.types import Operator, PropertyGroup, Action, UIList from bpy.props import CollectionProperty, IntProperty, PointerProperty, StringProperty, BoolProperty from bpy_extras.io_utils import ExportHelper from typing import Type @@ -35,6 +35,7 @@ class PsaExporter(object): class PsaExportActionListItem(PropertyGroup): action: PointerProperty(type=Action) + action_name: StringProperty() is_selected: BoolProperty(default=False) @property @@ -70,7 +71,7 @@ class PsaExportOperator(Operator, ExportHelper): box = layout.box() box.label(text='Actions', icon='ACTION') row = box.row() - row.template_list('PSA_UL_ActionList', 'asd', scene.psa_export, 'action_list', scene.psa_export, 'action_list_index', rows=10) + row.template_list('PSA_UL_ExportActionList', 'asd', scene.psa_export, 'action_list', scene.psa_export, 'action_list_index', rows=10) row = box.row() row.operator('psa_export.actions_select_all', text='Select All') row.operator('psa_export.actions_deselect_all', text='Deselect All') @@ -99,6 +100,7 @@ class PsaExportOperator(Operator, ExportHelper): for action in bpy.data.actions: item = context.scene.psa_export.action_list.add() item.action = action + item.action_name = action.name if self.is_action_for_armature(action): item.is_selected = True @@ -125,6 +127,28 @@ class PsaExportOperator(Operator, ExportHelper): return {'FINISHED'} +class PSA_UL_ExportActionList(UIList): + def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): + layout.alignment = 'LEFT' + layout.prop(item, 'is_selected', icon_only=True) + layout.label(text=item.action_name) + + def filter_items(self, context, data, property): + # TODO: returns two lists, apparently + actions = getattr(data, property) + flt_flags = [] + flt_neworder = [] + if self.filter_name: + flt_flags = bpy.types.UI_UL_list.filter_items_by_name( + self.filter_name, + self.bitflag_filter_item, + actions, + 'action_name', + reverse=self.use_filter_invert + ) + return flt_flags, flt_neworder + + class PsaExportSelectAll(bpy.types.Operator): bl_idname = 'psa_export.actions_select_all' bl_label = 'Select All' diff --git a/io_export_psk_psa/psa/importer.py b/io_export_psk_psa/psa/importer.py index e779b27..a3593ca 100644 --- a/io_export_psk_psa/psa/importer.py +++ b/io_export_psk_psa/psa/importer.py @@ -189,7 +189,6 @@ class PSA_UL_ImportActionList(UIList): layout.label(text=item.action_name) def filter_items(self, context, data, property): - # TODO: returns two lists, apparently actions = getattr(data, property) flt_flags = [] flt_neworder = [] @@ -204,22 +203,6 @@ class PSA_UL_ImportActionList(UIList): return flt_flags, flt_neworder -class PSA_UL_ActionList(UIList): - def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): - layout.alignment = 'LEFT' - layout.prop(item, 'is_selected', icon_only=True) - layout.label(text=item.action.name) - - def filter_items(self, context, data, property): - # TODO: returns two lists, apparently - actions = getattr(data, property) - flt_flags = [] - flt_neworder = [] - if self.filter_name: - flt_flags = bpy.types.UI_UL_list.filter_items_by_name(self.filter_name, self.bitflag_filter_item, actions, 'name', reverse=self.use_filter_invert) - return flt_flags, flt_neworder - - class PsaImportSelectAll(bpy.types.Operator): bl_idname = 'psa_import.actions_select_all' bl_label = 'Select All'