try bme adder
This commit is contained in:
parent
2f123e6a3c
commit
52f3936e42
122
bbp_ng/OP_ADDS_bme.py
Normal file
122
bbp_ng/OP_ADDS_bme.py
Normal file
@ -0,0 +1,122 @@
|
||||
import bpy
|
||||
import typing
|
||||
from . import PROP_preferences, PROP_virtools_mesh, PROP_virtools_group, PROP_bme_material
|
||||
from . import UTIL_functions, UTIL_icons_manager
|
||||
|
||||
#region BME Adder
|
||||
|
||||
class BBP_PG_bme_adder_params(bpy.types.PropertyGroup):
|
||||
prop_int: bpy.props.IntProperty(
|
||||
name = 'Single Int', description = 'Single Int',
|
||||
min = 0, max = 64,
|
||||
soft_min = 0, soft_max = 32,
|
||||
default = 1,
|
||||
)
|
||||
prop_float: bpy.props.FloatProperty(
|
||||
name = 'Single Float', description = 'Single Float',
|
||||
min = 0.0, max = 1024.0,
|
||||
soft_min = 0.0, soft_max = 64.0,
|
||||
default = 5.0,
|
||||
)
|
||||
prop_str: bpy.props.StringProperty(
|
||||
name = 'Single Str', description = 'Single Str',
|
||||
default = ''
|
||||
)
|
||||
prop_bool: bpy.props.BoolProperty(
|
||||
name = 'Single Bool', description = 'Single Bool',
|
||||
default = True
|
||||
)
|
||||
|
||||
class BBP_OT_add_bme_struct(bpy.types.Operator):
|
||||
"""Add BME Struct"""
|
||||
bl_idname = "bbp.dd_bme_struct"
|
||||
bl_label = "Add BME Struct"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
# the updator for default side value
|
||||
def bme_struct_type_updated(self, context):
|
||||
# get floor prototype
|
||||
#floor_prototype = UTILS_constants.floor_blockDict[self.floor_type]
|
||||
|
||||
# try sync default value
|
||||
#default_sides = floor_prototype['DefaultSideConfig']
|
||||
#self.use_2d_top = default_sides['UseTwoDTop']
|
||||
#self.use_2d_right = default_sides['UseTwoDRight']
|
||||
#self.use_2d_bottom = default_sides['UseTwoDBottom']
|
||||
#self.use_2d_left = default_sides['UseTwoDLeft']
|
||||
#self.use_3d_top = default_sides['UseThreeDTop']
|
||||
#self.use_3d_bottom = default_sides['UseThreeDBottom']
|
||||
|
||||
# init data collection
|
||||
# todo: this state will add 32 items in each call.
|
||||
# please clear it or resize it.
|
||||
for i in range(32):
|
||||
item = self.data_floats.add()
|
||||
|
||||
# blender required
|
||||
return None
|
||||
|
||||
bme_struct_type: bpy.props.EnumProperty(
|
||||
name = "Type",
|
||||
description = "BME struct type",
|
||||
items = (
|
||||
('TEST1', 'test1', 'test desc1', UTIL_icons_manager.get_empty_icon(), 1),
|
||||
('TEST2', 'test2', 'test desc2', UTIL_icons_manager.get_empty_icon(), 2),
|
||||
),
|
||||
#items = tuple(
|
||||
# # token, display name, descriptions, icon, index
|
||||
# (blk, blk, "", UTILS_icons_manager.get_floor_icon(blk), idx)
|
||||
# for idx, blk in enumerate(UTILS_constants.floor_blockDict.keys())
|
||||
#),
|
||||
update = bme_struct_type_updated
|
||||
)
|
||||
|
||||
data_floats : bpy.props.CollectionProperty(
|
||||
name = "Floats",
|
||||
description = "Float collection.",
|
||||
type = BBP_PG_bme_adder_params,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def poll(self, context):
|
||||
return PROP_preferences.get_raw_preferences().has_valid_blc_tex_folder()
|
||||
|
||||
def invoke(self, context, event):
|
||||
# trigger default bme struct type updator
|
||||
self.bme_struct_type_updated(context)
|
||||
# run execute() function
|
||||
return self.execute(context)
|
||||
|
||||
def execute(self, context):
|
||||
# todo: call general creator
|
||||
return {'FINISHED'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
# show type
|
||||
for i in self.data_floats:
|
||||
layout.prop(i, 'prop_bool')
|
||||
|
||||
@classmethod
|
||||
def draw_blc_menu(self, layout: bpy.types.UILayout):
|
||||
layout.operator(self.bl_idname)
|
||||
"""
|
||||
for item in PROP_ballance_element.BallanceElementType:
|
||||
item_name: str = PROP_ballance_element.get_ballance_element_name(item)
|
||||
|
||||
cop = layout.operator(
|
||||
self.bl_idname, text = item_name,
|
||||
icon_value = UTIL_icons_manager.get_component_icon(item_name)
|
||||
)
|
||||
cop.component_type = EnumPropHelper.to_selection(item)
|
||||
"""
|
||||
|
||||
#endregion
|
||||
|
||||
def register():
|
||||
bpy.utils.register_class(BBP_PG_bme_adder_params)
|
||||
bpy.utils.register_class(BBP_OT_add_bme_struct)
|
||||
|
||||
def unregister():
|
||||
bpy.utils.unregister_class(BBP_OT_add_bme_struct)
|
||||
bpy.utils.unregister_class(BBP_PG_bme_adder_params)
|
@ -32,7 +32,7 @@ UTIL_icons_manager.register()
|
||||
from . import PROP_preferences, PROP_ptrprop_resolver, PROP_virtools_material, PROP_virtools_texture, PROP_virtools_mesh, PROP_virtools_group, PROP_ballance_element, PROP_bme_material
|
||||
from . import OP_IMPORT_bmfile, OP_EXPORT_bmfile, OP_IMPORT_virtools, OP_EXPORT_virtools
|
||||
from . import OP_UV_flatten_uv, OP_UV_rail_uv
|
||||
from . import OP_ADDS_component
|
||||
from . import OP_ADDS_component, OP_ADDS_bme
|
||||
|
||||
#region Menu
|
||||
|
||||
@ -48,18 +48,15 @@ class BBP_MT_View3DMenu(bpy.types.Menu):
|
||||
layout.operator(OP_UV_flatten_uv.BBP_OT_flatten_uv.bl_idname)
|
||||
layout.operator(OP_UV_rail_uv.BBP_OT_rail_uv.bl_idname)
|
||||
|
||||
class BBP_MT_AddFloorMenu(bpy.types.Menu):
|
||||
class BBP_MT_AddBmeMenu(bpy.types.Menu):
|
||||
"""Add Ballance Floor"""
|
||||
bl_idname = "BBP_MT_AddFloorMenu"
|
||||
bl_idname = "BBP_MT_AddBmeMenu"
|
||||
bl_label = "Floors"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
OP_ADDS_bme.BBP_OT_add_bme_struct.draw_blc_menu(layout)
|
||||
|
||||
layout.label(text="Basic floor")
|
||||
|
||||
layout.separator()
|
||||
layout.label(text="Derived floor")
|
||||
class BBP_MT_AddRailMenu(bpy.types.Menu):
|
||||
"""Add Ballance Rail"""
|
||||
bl_idname = "BBP_MT_AddRailMenu"
|
||||
@ -67,6 +64,7 @@ class BBP_MT_AddRailMenu(bpy.types.Menu):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
class BBP_MT_AddComponentsMenu(bpy.types.Menu):
|
||||
"""Add Ballance Components"""
|
||||
bl_idname = "BBP_MT_AddComponentsMenu"
|
||||
@ -112,19 +110,16 @@ def menu_drawer_add(self, context):
|
||||
layout: bpy.types.UILayout = self.layout
|
||||
layout.separator()
|
||||
layout.label(text="Ballance")
|
||||
layout.menu(BBP_MT_AddFloorMenu.bl_idname, icon='MESH_CUBE')
|
||||
layout.menu(BBP_MT_AddBmeMenu.bl_idname, icon='MESH_CUBE')
|
||||
layout.menu(BBP_MT_AddRailMenu.bl_idname, icon='MESH_CIRCLE')
|
||||
layout.menu(BBP_MT_AddComponentsMenu.bl_idname, icon='MESH_ICOSPHERE')
|
||||
#layout.operator_menu_enum(
|
||||
# OBJS_add_components.BALLANCE_OT_add_components.bl_idname,
|
||||
# "Components_type", icon='MESH_ICOSPHERE', text="Components")
|
||||
#endregion
|
||||
|
||||
#region Register and Unregister.
|
||||
|
||||
g_BldClasses: tuple[typing.Any, ...] = (
|
||||
BBP_MT_View3DMenu,
|
||||
BBP_MT_AddFloorMenu,
|
||||
BBP_MT_AddBmeMenu,
|
||||
BBP_MT_AddRailMenu,
|
||||
BBP_MT_AddComponentsMenu
|
||||
)
|
||||
@ -165,6 +160,7 @@ def register() -> None:
|
||||
OP_UV_rail_uv.register()
|
||||
OP_UV_flatten_uv.register()
|
||||
OP_ADDS_component.register()
|
||||
OP_ADDS_bme.register()
|
||||
|
||||
# register other classes
|
||||
for cls in g_BldClasses:
|
||||
@ -187,6 +183,7 @@ def unregister() -> None:
|
||||
bpy.utils.unregister_class(cls)
|
||||
|
||||
# unregister modules
|
||||
OP_ADDS_bme.unregister()
|
||||
OP_ADDS_component.unregister()
|
||||
OP_UV_flatten_uv.unregister()
|
||||
OP_UV_rail_uv.unregister()
|
||||
|
Loading…
Reference in New Issue
Block a user