mirror of
https://github.com/DarklightGames/io_scene_psk_psa.git
synced 2025-02-21 11:39:37 +01:00
WIP on UI for selecting animations to export in PSA.
This commit is contained in:
parent
1a96d0816e
commit
d13cd881a4
@ -33,10 +33,13 @@ else:
|
||||
from .psa import operator as psa_operator
|
||||
|
||||
import bpy
|
||||
from bpy.props import IntProperty, CollectionProperty
|
||||
|
||||
classes = [
|
||||
psk_operator.PskExportOperator,
|
||||
psa_operator.PsaExportOperator
|
||||
psa_operator.PsaExportOperator,
|
||||
psa_operator.PSA_UL_ActionList,
|
||||
psa_operator.ActionListItem
|
||||
]
|
||||
|
||||
def psk_menu_func(self, context):
|
||||
@ -51,8 +54,12 @@ def register():
|
||||
register_class(cls)
|
||||
bpy.types.TOPBAR_MT_file_export.append(psk_menu_func)
|
||||
bpy.types.TOPBAR_MT_file_export.append(psa_menu_func)
|
||||
bpy.types.Scene.psa_action_list = CollectionProperty(type=psa_operator.ActionListItem)
|
||||
bpy.types.Scene.psa_action_list_index = IntProperty(name='index for list??', default=0)
|
||||
|
||||
def unregister():
|
||||
del bpy.types.Scene.psa_action_list_index
|
||||
del bpy.types.Scene.psa_action_list
|
||||
bpy.types.TOPBAR_MT_file_export.remove(psa_menu_func)
|
||||
bpy.types.TOPBAR_MT_file_export.remove(psk_menu_func)
|
||||
from bpy.utils import unregister_class
|
||||
|
@ -1,8 +1,35 @@
|
||||
from bpy.types import Operator, Action
|
||||
from bpy.types import Operator, Action, UIList, PropertyGroup
|
||||
from bpy_extras.io_utils import ExportHelper
|
||||
from bpy.props import StringProperty, BoolProperty, FloatProperty, CollectionProperty
|
||||
from bpy.props import StringProperty, BoolProperty, FloatProperty, CollectionProperty, PointerProperty
|
||||
from .builder import PsaBuilder
|
||||
from .exporter import PsaExporter
|
||||
import bpy
|
||||
import re
|
||||
|
||||
|
||||
class ActionListItem(PropertyGroup):
|
||||
action: PointerProperty(type=Action)
|
||||
is_selected: BoolProperty(default=False)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.action.name
|
||||
|
||||
|
||||
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, icon='ACTION')
|
||||
|
||||
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 PsaExportOperator(Operator, ExportHelper):
|
||||
@ -11,17 +38,32 @@ class PsaExportOperator(Operator, ExportHelper):
|
||||
__doc__ = 'PSA Exporter (.psa)'
|
||||
filename_ext = '.psa'
|
||||
filter_glob : StringProperty(default='*.psa', options={'HIDDEN'})
|
||||
|
||||
filepath : StringProperty(
|
||||
name='File Path',
|
||||
description='File path used for exporting the PSA file',
|
||||
maxlen=1024,
|
||||
default='')
|
||||
|
||||
actions : CollectionProperty(
|
||||
type=Action,
|
||||
name='Sequences'
|
||||
)
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
scene = context.scene
|
||||
row = layout.row()
|
||||
row.label(text='Actions')
|
||||
row = layout.row()
|
||||
row.template_list('PSA_UL_ActionList', 'asd', scene, 'psa_action_list', scene, 'psa_action_list_index', rows=len(context.scene.psa_action_list))
|
||||
|
||||
def invoke(self, context, event):
|
||||
if context.view_layer.objects.active.type != 'ARMATURE':
|
||||
self.report({'ERROR_INVALID_CONTEXT'}, 'The selected object must be an armature.')
|
||||
return {'CANCELLED'}
|
||||
context.scene.psa_action_list.clear()
|
||||
for action in bpy.data.actions:
|
||||
item = context.scene.psa_action_list.add()
|
||||
item.action = action
|
||||
# TODO: add
|
||||
item.is_selected = True
|
||||
context.window_manager.fileselect_add(self)
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
def execute(self, context):
|
||||
builder = PsaBuilder()
|
||||
|
Loading…
x
Reference in New Issue
Block a user