From 54f5b8b0edc7aff46718c153e45df80c9a1e803e Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Sat, 19 Mar 2022 20:16:24 -0400 Subject: [PATCH] Add Callback EnumProperty to sound message node. --- korman/nodes/node_messages.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/korman/nodes/node_messages.py b/korman/nodes/node_messages.py index a42196c..c0e67d0 100644 --- a/korman/nodes/node_messages.py +++ b/korman/nodes/node_messages.py @@ -774,12 +774,18 @@ class PlasmaSoundMsgNode(idprops.IDPropObjectMixin, PlasmaMessageWithCallbacksNo min=0, max=100, default=100, options=set(), subtype="PERCENTAGE") + event = EnumProperty(name="Callback", + description="Event upon which to callback the Responder", + items=[("kEnd", "End", "When the action ends"), + ("NONE", "(None)", "Don't notify the Responder at all"), + ("kStop", "Stop", "When the action is stopped by a message")], + default="NONE") def convert_callback_message(self, exporter, so, msg, target, wait): assert not self.is_random_sound, "Callbacks are not available for random sounds" cb = plEventCallbackMsg() cb.addReceiver(target) - cb.event = kEnd + cb.event = globals()[self.event] cb.user = wait msg.addCallback(cb) msg.setCmd(plSoundMsg.kAddCallbacks) @@ -880,10 +886,13 @@ class PlasmaSoundMsgNode(idprops.IDPropObjectMixin, PlasmaMessageWithCallbacksNo if not random: layout.prop(self, "looping") layout.prop(self, "volume") + if not random: + layout.prop(self, "event") @property def has_callbacks(self): - return not self.is_random_sound + if not self.is_random_sound: + return self.event != "NONE" @classmethod def _idprop_mapping(cls):