mirror of
https://github.com/DarklightGames/io_scene_psk_psa.git
synced 2025-02-08 06:48:19 +01:00
Added the ability to prefix imported action names.
This commit is contained in:
parent
3932176a57
commit
5a13faeb5e
@ -16,6 +16,7 @@ class PsaImportOptions(object):
|
|||||||
self.should_use_fake_user = False
|
self.should_use_fake_user = False
|
||||||
self.should_stash = False
|
self.should_stash = False
|
||||||
self.sequence_names = []
|
self.sequence_names = []
|
||||||
|
self.action_name_prefix = ''
|
||||||
|
|
||||||
|
|
||||||
class PsaImporter(object):
|
class PsaImporter(object):
|
||||||
@ -115,7 +116,8 @@ class PsaImporter(object):
|
|||||||
actions = []
|
actions = []
|
||||||
for sequence in sequences:
|
for sequence in sequences:
|
||||||
# Add the action.
|
# Add the action.
|
||||||
action = bpy.data.actions.new(name=sequence.name.decode())
|
action_name = options.action_name_prefix + sequence.name.decode('windows-1252')
|
||||||
|
action = bpy.data.actions.new(name=action_name)
|
||||||
action.use_fake_user = options.should_use_fake_user
|
action.use_fake_user = options.should_use_fake_user
|
||||||
|
|
||||||
# Create f-curves for the rotation and location of each bone.
|
# Create f-curves for the rotation and location of each bone.
|
||||||
@ -242,6 +244,7 @@ class PsaImportPropertyGroup(bpy.types.PropertyGroup):
|
|||||||
should_clean_keys: BoolProperty(default=True, name='Clean Keyframes', description='Exclude unnecessary keyframes from being written to the actions.')
|
should_clean_keys: BoolProperty(default=True, name='Clean Keyframes', description='Exclude unnecessary keyframes from being written to the actions.')
|
||||||
should_use_fake_user: BoolProperty(default=True, name='Fake User', description='Assign each imported action a fake user so that the data block is saved even it has no users.')
|
should_use_fake_user: BoolProperty(default=True, name='Fake User', description='Assign each imported action a fake user so that the data block is saved even it has no users.')
|
||||||
should_stash: BoolProperty(default=False, name='Stash', description='Stash each imported action as a strip on a new non-contributing NLA track')
|
should_stash: BoolProperty(default=False, name='Stash', description='Stash each imported action as a strip on a new non-contributing NLA track')
|
||||||
|
action_name_prefix: StringProperty(default='', name='Action Name Prefix')
|
||||||
|
|
||||||
|
|
||||||
class PSA_UL_ImportActionList(UIList):
|
class PSA_UL_ImportActionList(UIList):
|
||||||
@ -349,13 +352,13 @@ class PSA_PT_ImportPanel(Panel):
|
|||||||
row.operator('psa_import.actions_select_all', text='All')
|
row.operator('psa_import.actions_select_all', text='All')
|
||||||
row.operator('psa_import.actions_deselect_all', text='None')
|
row.operator('psa_import.actions_deselect_all', text='None')
|
||||||
|
|
||||||
row = layout.row()
|
col = layout.column(heading="Options")
|
||||||
row.prop(property_group, 'should_clean_keys')
|
col.use_property_split = True
|
||||||
|
col.use_property_decorate = False
|
||||||
# DATA
|
col.prop(property_group, 'should_clean_keys')
|
||||||
row = layout.row()
|
col.prop(property_group, 'should_use_fake_user')
|
||||||
row.prop(property_group, 'should_use_fake_user')
|
col.prop(property_group, 'should_stash')
|
||||||
row.prop(property_group, 'should_stash')
|
col.prop(property_group, 'action_name_prefix')
|
||||||
|
|
||||||
layout.operator('psa_import.import', text=f'Import')
|
layout.operator('psa_import.import', text=f'Import')
|
||||||
|
|
||||||
@ -399,6 +402,7 @@ class PsaImportOperator(Operator):
|
|||||||
options.should_clean_keys = property_group.should_clean_keys
|
options.should_clean_keys = property_group.should_clean_keys
|
||||||
options.should_use_fake_user = property_group.should_use_fake_user
|
options.should_use_fake_user = property_group.should_use_fake_user
|
||||||
options.should_stash = property_group.should_stash
|
options.should_stash = property_group.should_stash
|
||||||
|
options.action_name_prefix = property_group.action_name_prefix
|
||||||
PsaImporter().import_psa(psa_reader, context.view_layer.objects.active, options)
|
PsaImporter().import_psa(psa_reader, context.view_layer.objects.active, options)
|
||||||
self.report({'INFO'}, f'Imported {len(sequence_names)} action(s)')
|
self.report({'INFO'}, f'Imported {len(sequence_names)} action(s)')
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user