Browse Source

Fix #178.

This adds a button for packaging/exporting sound files to either the zip
or the game directory.
pull/179/head
Adam Johnson 5 years ago
parent
commit
915fc58e21
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 2
      korman/properties/__init__.py
  2. 21
      korman/properties/modifiers/sound.py
  3. 9
      korman/ui/modifiers/sound.py

2
korman/properties/__init__.py

@ -21,6 +21,7 @@ from .prop_lamp import *
from . import modifiers
from .prop_object import *
from .prop_scene import *
from .prop_sound import *
from .prop_text import *
from .prop_texture import *
from .prop_world import *
@ -33,6 +34,7 @@ def register():
bpy.types.Object.plasma_net = bpy.props.PointerProperty(type=PlasmaNet)
bpy.types.Object.plasma_object = bpy.props.PointerProperty(type=PlasmaObject)
bpy.types.Scene.plasma_scene = bpy.props.PointerProperty(type=PlasmaScene)
bpy.types.Sound.plasma_sound = bpy.props.PointerProperty(type=PlasmaSound)
bpy.types.Text.plasma_text = bpy.props.PointerProperty(type=PlasmaText)
bpy.types.Texture.plasma_layer = bpy.props.PointerProperty(type=PlasmaLayer)
bpy.types.World.plasma_age = bpy.props.PointerProperty(type=PlasmaAge)

21
korman/properties/modifiers/sound.py

@ -154,6 +154,24 @@ class PlasmaSound(idprops.IDPropMixin, bpy.types.PropertyGroup):
fade_in = PointerProperty(type=PlasmaSfxFade, options=set())
fade_out = PointerProperty(type=PlasmaSfxFade, options=set())
def _get_package_value(self):
if self.sound is not None:
self.package_value = self.sound.plasma_sound.package
return self.package_value
def _set_package_value(self, value):
if self.sound is not None:
self.sound.plasma_sound.package = value
# This is really a property of the sound itself, not of this particular emitter instance.
# However, to prevent weird UI inconsistencies where the button might be missing or change
# states when clearing the sound pointer, we'll cache the actual value here.
package = BoolProperty(name="Export",
description="Package this file in the age export",
get=_get_package_value, set=_set_package_value,
options=set())
package_value = BoolProperty(options={"HIDDEN", "SKIP_SAVE"})
@property
def channel_override(self):
if self.is_stereo and len(self.channel) == 1:
@ -166,7 +184,8 @@ class PlasmaSound(idprops.IDPropMixin, bpy.types.PropertyGroup):
length = dataSize / header.avgBytesPerSec
# HAX: Ensure that the sound file is copied to game, if applicable.
exporter.output.add_sfx(self._sound)
if self._sound.plasma_sound.package:
exporter.output.add_sfx(self._sound)
# There is some bug in the MOUL code that causes a crash if this does not match the expected
# result. There's no sense in debugging that though--the user should never specify

9
korman/ui/modifiers/sound.py

@ -40,8 +40,11 @@ def soundemit(modifier, layout, context):
except:
pass
else:
split = layout.split(percentage=0.75)
col = split.column()
# Sound datablock picker
row = layout.row(align=True)
row = col.row(align=True)
row.prop_search(sound, "sound_data_proxy", bpy.data, "sounds", text="")
open_op = row.operator("sound.plasma_open", icon="FILESEL", text="")
open_op.data_path = repr(sound)
@ -55,6 +58,10 @@ def soundemit(modifier, layout, context):
else:
row.operator_menu_enum("sound.plasma_unpack", "method", icon="PACKAGE", text="")
col = split.column()
col.enabled = data is not None
col.prop(sound, "package", text="Export")
# If an invalid sound data block is spec'd, let them know about it.
if data and not sound.is_valid:
layout.label(text="Invalid sound specified", icon="ERROR")

Loading…
Cancel
Save