Browse Source

Add Sound Export Operator Buttons

Adds buttons to enable and disable export/packaging of sounds (WIP)
pull/211/head
Patrick Dulebohn 4 years ago
parent
commit
b9e8b4434e
  1. 37
      korman/operators/op_toolbox.py
  2. 7
      korman/ui/ui_toolbox.py

37
korman/operators/op_toolbox.py

@ -16,6 +16,7 @@
import bpy import bpy
from bpy.props import * from bpy.props import *
import pickle import pickle
import itertools
class ToolboxOperator: class ToolboxOperator:
@classmethod @classmethod
@ -235,3 +236,39 @@ class PlasmaTogglePlasmaObjectsOperator(ToolboxOperator, bpy.types.Operator):
for i in context.selected_objects: for i in context.selected_objects:
i.plasma_object.enabled = enable i.plasma_object.enabled = enable
return {"FINISHED"} return {"FINISHED"}
class PlasmaToggleSoundExportOperator(ToolboxOperator, bpy.types.Operator):
bl_idname = "object.plasma_toggle_sound_export"
bl_label = "Toggle Sound Export"
bl_description = "Toggles the Export function of all sound emitters' files"
enable = BoolProperty(name="Enable", description="Sound Export Enable")
def execute(self, context):
enable = self.enable
for i in bpy.data.objects:
if i.plasma_modifiers.soundemit is None:
continue
for sound in i.plasma_modifiers.soundemit.sounds:
sound.package = enable
return {"FINISHED"}
class PlasmaToggleSoundExportSelectedOperator(ToolboxOperator, bpy.types.Operator):
bl_idname = "object.plasma_toggle_sound_export_selected"
bl_label = "Toggle Selected Sound Export"
bl_description = "Toggles the Export function of selected sound emitters' files."
@classmethod
def poll(cls, context):
return super().poll(context) and hasattr(bpy.context, "selected_objects")
def execute(self, context):
enable = not all((i.package for i in itertools.chain.from_iterable(i.plasma_modifiers.soundemit.sounds for i in bpy.context.selected_objects)))
for i in context.selected_objects:
if i.plasma_modifiers.soundemit is None:
continue
for sound in i.plasma_modifiers.soundemit.sounds:
sound.package = enable
return {"FINISHED"}

7
korman/ui/ui_toolbox.py

@ -14,6 +14,7 @@
# along with Korman. If not, see <http://www.gnu.org/licenses/>. # along with Korman. If not, see <http://www.gnu.org/licenses/>.
import bpy import bpy
import itertools
class ToolboxPanel: class ToolboxPanel:
bl_category = "Tools" bl_category = "Tools"
@ -45,6 +46,12 @@ class PlasmaToolboxPanel(ToolboxPanel, bpy.types.Panel):
col.operator("object.plasma_move_selection_to_page", icon="BOOKMARKS", text="Move to Page") col.operator("object.plasma_move_selection_to_page", icon="BOOKMARKS", text="Move to Page")
col.operator("object.plasma_select_page_objects", icon="RESTRICT_SELECT_OFF", text="Select Objects") col.operator("object.plasma_select_page_objects", icon="RESTRICT_SELECT_OFF", text="Select Objects")
col.label("Package Sounds:")
col.operator("object.plasma_toggle_sound_export", icon="MUTE_IPO_OFF", text="Enable All").enable = True
all_sounds_export = all((i.package for i in itertools.chain.from_iterable(i.plasma_modifiers.soundemit.sounds for i in bpy.context.selected_objects if i.plasma_modifiers.soundemit.enabled)))
col.operator("object.plasma_toggle_sound_export_selected", icon="OUTLINER_OB_SPEAKER", text="Disable Selection" if all_sounds_export else "Enable Selection")
col.operator("object.plasma_toggle_sound_export", icon="MUTE_IPO_ON", text="Disable All").enable = False
col.label("Textures:") col.label("Textures:")
col.operator("texture.plasma_enable_all_textures", icon="TEXTURE", text="Enable All") col.operator("texture.plasma_enable_all_textures", icon="TEXTURE", text="Enable All")
col.operator("texture.plasma_toggle_environment_maps", icon="IMAGE_RGB", text="Enable All EnvMaps").enable = True col.operator("texture.plasma_toggle_environment_maps", icon="IMAGE_RGB", text="Enable All EnvMaps").enable = True

Loading…
Cancel
Save