Browse Source

Remove sound datablock name proxy hack.

The commentary about PointerProps and update callbacks appears to be
incorrect. Maybe it was broken in a beta release of Blender 2.79? Works
fine in Blender 2.79b.
pull/179/head
Adam Johnson 5 years ago
parent
commit
34a945e86c
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 3
      korman/operators/op_sound.py
  2. 22
      korman/properties/modifiers/sound.py
  3. 4
      korman/ui/modifiers/sound.py

3
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):

22
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"})

4
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

Loading…
Cancel
Save