Browse Source

Update anim modifiers to ID props

pull/56/head
Adam Johnson 8 years ago
parent
commit
904f9b8f77
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 6
      korman/idprops.py
  2. 15
      korman/properties/modifiers/anim.py
  3. 6
      korman/ui/modifiers/anim.py

6
korman/idprops.py

@ -118,6 +118,12 @@ class IDPropObjectMixin(IDPropMixin):
return { i: bpy.data.objects for i in idprops.values() }
def poll_animated_objects(self, value):
if value.animation_data is not None:
if value.animation_data.action is not None:
return True
return False
def poll_empty_objects(self, value):
return value.type == "EMPTY"

15
korman/properties/modifiers/anim.py

@ -19,6 +19,7 @@ from PyHSPlasma import *
from .base import PlasmaModifierProperties
from ...exporter import ExportError, utils
from ... import idprops
def _convert_frame_time(frame_num):
fps = bpy.context.scene.render.fps
@ -92,9 +93,15 @@ class PlasmaAnimationModifier(ActionModifier, PlasmaModifierProperties):
atcanim.loopEnd = atcanim.end
class AnimGroupObject(bpy.types.PropertyGroup):
object_name = StringProperty(name="Child Animation",
description="Object whose action is a child animation")
class AnimGroupObject(idprops.IDPropObjectMixin, bpy.types.PropertyGroup):
child_anim = PointerProperty(name="Child Animation",
description="Object whose action is a child animation",
type=bpy.types.Object,
poll=idprops.poll_animated_objects)
@classmethod
def _idprop_mapping(cls):
return {"child_anim": "object_name"}
class PlasmaAnimationGroupModifier(ActionModifier, PlasmaModifierProperties):
@ -123,7 +130,7 @@ class PlasmaAnimationGroupModifier(ActionModifier, PlasmaModifierProperties):
agmaster.msgForwarder = msgfwd.key
agmaster.isGrouped, agmaster.isGroupMaster = True, True
for i in self.children:
child_bo = bpy.data.objects.get(i.object_name, None)
child_bo = i.child_anim
if child_bo is None:
msg = "Animation Group '{}' specifies an invalid object '{}'. Ignoring..."
exporter.report.warn(msg.format(self.key_name, i.object_name), ident=2)

6
korman/ui/modifiers/anim.py

@ -45,8 +45,8 @@ def animation(modifier, layout, context):
class GroupListUI(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_property, index=0, flt_flag=0):
label = item.object_name if item.object_name else "[No Child Specified]"
icon = "ACTION" if item.object_name else "ERROR"
label = item.child_anim.name if item.child_anim is not None else "[No Child Specified]"
icon = "ACTION" if item.child_anim is not None else "ERROR"
layout.label(text=label, icon=icon)
@ -68,7 +68,7 @@ def animation_group(modifier, layout, context):
op.index = modifier.active_child_index
if modifier.children:
layout.prop_search(modifier.children[modifier.active_child_index], "object_name", bpy.data, "objects", icon="ACTION")
layout.prop(modifier.children[modifier.active_child_index], "child_anim", icon="ACTION")
class LoopListUI(bpy.types.UIList):

Loading…
Cancel
Save