Added search filtering for PSA export action list

This commit is contained in:
Colin Basnett
2022-01-17 01:12:06 -08:00
parent 10e02a84f1
commit 78837863e2
3 changed files with 27 additions and 20 deletions

View File

@@ -45,7 +45,7 @@ classes = [
psk_importer.PskImportOperator, psk_importer.PskImportOperator,
psa_importer.PsaImportOperator, psa_importer.PsaImportOperator,
psa_importer.PsaImportFileSelectOperator, psa_importer.PsaImportFileSelectOperator,
psa_importer.PSA_UL_ActionList, psa_exporter.PSA_UL_ExportActionList,
psa_importer.PSA_UL_ImportActionList, psa_importer.PSA_UL_ImportActionList,
psa_importer.PsaImportActionListItem, psa_importer.PsaImportActionListItem,
psa_importer.PsaImportSelectAll, psa_importer.PsaImportSelectAll,

View File

@@ -1,5 +1,5 @@
import bpy 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.props import CollectionProperty, IntProperty, PointerProperty, StringProperty, BoolProperty
from bpy_extras.io_utils import ExportHelper from bpy_extras.io_utils import ExportHelper
from typing import Type from typing import Type
@@ -35,6 +35,7 @@ class PsaExporter(object):
class PsaExportActionListItem(PropertyGroup): class PsaExportActionListItem(PropertyGroup):
action: PointerProperty(type=Action) action: PointerProperty(type=Action)
action_name: StringProperty()
is_selected: BoolProperty(default=False) is_selected: BoolProperty(default=False)
@property @property
@@ -70,7 +71,7 @@ class PsaExportOperator(Operator, ExportHelper):
box = layout.box() box = layout.box()
box.label(text='Actions', icon='ACTION') box.label(text='Actions', icon='ACTION')
row = box.row() 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 = box.row()
row.operator('psa_export.actions_select_all', text='Select All') row.operator('psa_export.actions_select_all', text='Select All')
row.operator('psa_export.actions_deselect_all', text='Deselect 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: for action in bpy.data.actions:
item = context.scene.psa_export.action_list.add() item = context.scene.psa_export.action_list.add()
item.action = action item.action = action
item.action_name = action.name
if self.is_action_for_armature(action): if self.is_action_for_armature(action):
item.is_selected = True item.is_selected = True
@@ -125,6 +127,28 @@ class PsaExportOperator(Operator, ExportHelper):
return {'FINISHED'} 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): class PsaExportSelectAll(bpy.types.Operator):
bl_idname = 'psa_export.actions_select_all' bl_idname = 'psa_export.actions_select_all'
bl_label = 'Select All' bl_label = 'Select All'

View File

@@ -189,7 +189,6 @@ class PSA_UL_ImportActionList(UIList):
layout.label(text=item.action_name) layout.label(text=item.action_name)
def filter_items(self, context, data, property): def filter_items(self, context, data, property):
# TODO: returns two lists, apparently
actions = getattr(data, property) actions = getattr(data, property)
flt_flags = [] flt_flags = []
flt_neworder = [] flt_neworder = []
@@ -204,22 +203,6 @@ class PSA_UL_ImportActionList(UIList):
return flt_flags, flt_neworder 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): class PsaImportSelectAll(bpy.types.Operator):
bl_idname = 'psa_import.actions_select_all' bl_idname = 'psa_import.actions_select_all'
bl_label = 'Select All' bl_label = 'Select All'