diff --git a/korman/operators/op_sound.py b/korman/operators/op_sound.py index c61981b..911a562 100644 --- a/korman/operators/op_sound.py +++ b/korman/operators/op_sound.py @@ -44,9 +44,8 @@ class PlasmaSoundOpenOperator(SoundOperator, bpy.types.Operator): sound = bpy.data.sounds.load(self.filepath) # Now do the stanky leg^H^H^H^H^H^H^H^H^H^H deed and put the sound on the mod - # NOTE: must use the name so that the mod can receive update callbacks dest = eval(self.data_path) - setattr(dest, self.sound_property, sound.name) + setattr(dest, self.sound_property, sound) return {"FINISHED"} def invoke(self, context, event): diff --git a/korman/properties/modifiers/sound.py b/korman/properties/modifiers/sound.py index bacfe5c..04c70e1 100644 --- a/korman/properties/modifiers/sound.py +++ b/korman/properties/modifiers/sound.py @@ -39,16 +39,8 @@ class PlasmaSfxFade(bpy.types.PropertyGroup): class PlasmaSound(idprops.IDPropMixin, bpy.types.PropertyGroup): - def _get_name_proxy(self): - if self.sound is not None: - return self.sound.name - return "" - - def _set_name_proxy(self, value): - self.sound = bpy.data.sounds.get(value, None) - - # This is the actual pointer update callback - if not self.sound: + def _update_sound(self, value): + if not value: self.name = "[Empty]" return @@ -73,14 +65,8 @@ class PlasmaSound(idprops.IDPropMixin, bpy.types.PropertyGroup): enabled = BoolProperty(name="Enabled", default=True, options=set()) sound = PointerProperty(name="Sound", description="Sound Datablock", - type=bpy.types.Sound) - - # This is needed because pointer properties do not seem to allow update CBs... Bug? - sound_data_proxy = StringProperty(name="Sound", - description="Name of sound datablock", - get=_get_name_proxy, - set=_set_name_proxy, - options=set()) + type=bpy.types.Sound, + update=_update_sound) is_stereo = BoolProperty(default=True, options={"HIDDEN"}) is_valid = BoolProperty(default=False, options={"HIDDEN"}) diff --git a/korman/ui/modifiers/sound.py b/korman/ui/modifiers/sound.py index af5020a..f80fae6 100644 --- a/korman/ui/modifiers/sound.py +++ b/korman/ui/modifiers/sound.py @@ -45,10 +45,10 @@ def soundemit(modifier, layout, context): # Sound datablock picker row = col.row(align=True) - row.prop_search(sound, "sound_data_proxy", bpy.data, "sounds", text="") + row.prop(sound, "sound", text="") open_op = row.operator("sound.plasma_open", icon="FILESEL", text="") open_op.data_path = repr(sound) - open_op.sound_property = "sound_data_proxy" + open_op.sound_property = "sound" # Pack/Unpack data = sound.sound