Browse Source

Merge pull request #320 from DoobesURU/SoundMsgCallback

Add Callback EnumProperty to sound message node.
pull/324/head
Adam Johnson 2 years ago committed by GitHub
parent
commit
44a41429c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      korman/nodes/node_messages.py

13
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 sound ends"),
("NONE", "(None)", "Don't notify the Responder at all"),
("kStop", "Stop", "When the sound 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):

Loading…
Cancel
Save