1
0
Fork 0
2022-untitled-game/tools/blender/fever_panel.py

90 lines
2.5 KiB
Python
Raw Permalink Normal View History

2022-08-01 23:11:10 +00:00
bl_info = {
'name': 'Fever Data Panel',
'blender': (2, 93, 0),
'category': 'Object'}
import bpy
from bpy.props import BoolProperty, FloatProperty, StringProperty, PointerProperty
class fv_type(bpy.types.PropertyGroup):
@classmethod
def register(cls):
bpy.types.Object.fv_type = PointerProperty(
name = "Fever - Data Type",
description = "Fever - Data Type",
type = cls)
cls.is_audio_source = BoolProperty(
name = "Audio Source",
description = "FV Audio Source",
default = False)
@classmethod
def unregister(cls):
del bpy.types.Object.fv_type
class fv_audio_source(bpy.types.PropertyGroup):
@classmethod
def register(cls):
bpy.types.Object.fv_audio_source = PointerProperty(
name="Fever - Context Data",
description="Fever - Context Data",
type=cls)
cls.file_path = StringProperty(
name="File Path",
subtype="FILE_PATH",
description="Path of the audio WAV file",
default="")
cls.volume = FloatProperty(
name="Volume",
description="Volume of the audio source",
default=1.0)
cls.is_looping = BoolProperty(
name="Is Looping?",
description="Should this audio track loop?",
default=False)
@classmethod
def unregister(cls):
del bpy.types.Object.fv_audio_source
class fv_panel(bpy.types.Panel):
bl_label = "Fever Panel"
bl_idname = "OBJECT_PT_Fever_Panel"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
def draw(self, context):
column = self.layout.column()
row = column.row()
row.prop(context.active_object.fv_type, "is_audio_source")
if context.active_object.fv_type.is_audio_source:
box = self.layout.box()
row = box.row()
row.prop(context.active_object.fv_audio_source, "file_path")
row = box.row()
row.prop(context.active_object.fv_audio_source, "volume")
row = box.row()
row.prop(context.active_object.fv_audio_source, "is_looping")
def register():
bpy.utils.register_class(fv_panel)
bpy.utils.register_class(fv_type)
bpy.utils.register_class(fv_audio_source)
def unregister():
bpy.utils.unregister_class(fv_panel)
bpy.utils.unregister_class(fv_type)
bpy.utils.unregister_class(fv_audio_source)
if __name__ == '__main__':
register()