update bme

This commit is contained in:
yyc12345 2023-12-17 23:01:45 +08:00
parent 03441c642b
commit 6bc3933291
2 changed files with 81 additions and 41 deletions

View File

@ -18,8 +18,8 @@ class BBP_PG_bme_adder_cfgs(bpy.types.PropertyGroup):
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,
step = 2.5,
soft_min = 0.0, soft_max = 512.0,
step = 50, # Step is in UI, in [1, 100] (WARNING: actual value is /100). So we choose 50, mean 0.5
default = 5.0,
)
prop_bool: bpy.props.BoolProperty(
@ -164,25 +164,30 @@ class BBP_OT_add_bme_struct(bpy.types.Operator):
self.__internal_update_bme_struct_type()
# start drawing
layout = self.layout
layout: bpy.types.UILayout = self.layout
# show type
layout.prop(self, 'bme_struct_type')
# visit cfgs cache list to show cfg
for (cfg, cfg_index) in self.bme_struct_cfg_index_cache:
# draw title first
layout.label(text = cfg.get_title())
# create box for cfgs
box_layout: bpy.types.UILayout = layout.box()
# draw title and description first
box_layout.label(text = cfg.get_title())
box_layout.label(text = cfg.get_desc())
# show prop differently by cfg type
match(cfg.get_type()):
case UTIL_bme.PrototypeShowcaseCfgsTypes.Integer:
layout.prop(self.bme_struct_cfgs[cfg_index], 'prop_int', text = '')
box_layout.prop(self.bme_struct_cfgs[cfg_index], 'prop_int', text = '')
case UTIL_bme.PrototypeShowcaseCfgsTypes.Float:
layout.prop(self.bme_struct_cfgs[cfg_index], 'prop_float', text = '')
box_layout.prop(self.bme_struct_cfgs[cfg_index], 'prop_float', text = '')
case UTIL_bme.PrototypeShowcaseCfgsTypes.Boolean:
layout.prop(self.bme_struct_cfgs[cfg_index], 'prop_bool', text = '')
box_layout.prop(self.bme_struct_cfgs[cfg_index], 'prop_bool', text = '')
case UTIL_bme.PrototypeShowcaseCfgsTypes.Face:
# face will show a special layout (grid view)
grids = layout.grid_flow(
grids = box_layout.grid_flow(
row_major=True, columns=3, even_columns=True, even_rows=True, align=True)
grids.alignment = 'CENTER'
grids.separator()
@ -206,16 +211,6 @@ class BBP_OT_add_bme_struct(bpy.types.Operator):
)
# and assign its init type value
cop.bme_struct_type = _g_EnumHelper_BmeStructType.to_selection(ident)
"""
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

View File

@ -7,12 +7,21 @@
"field": "trafo_texture",
"data": "\"BallWood\""
},
{
"field": "height",
"data": "5.0"
},
{
"field": "face",
"data": "(True, True, True, True, True, True)"
"data": "(True, False, True, True, True, True)"
}
],
"vars": [
{
"field": "uv_height",
"data": "height / 5.0"
}
],
"vars": [],
"vertices": [
{
"skip": "False",
@ -32,19 +41,19 @@
},
{
"skip": "False",
"data": "(0, 0, -5)"
"data": "(0, 0, -height)"
},
{
"skip": "False",
"data": "(5, 0, -5)"
"data": "(5, 0, -height)"
},
{
"skip": "False",
"data": "(5, 5, -5)"
"data": "(5, 5, -height)"
},
{
"skip": "False",
"data": "(0, 5, -5)"
"data": "(0, 5, -height)"
}
],
"faces": [
@ -68,7 +77,7 @@
{
"skip": "not face[1]",
"texture": "trafo_texture",
"indices": [7, 6, 5, 4],
"indices": [5, 4, 7, 6],
"uvs": [
"(0, 0)",
"(1, 0)",
@ -85,12 +94,12 @@
{
"skip": "not face[2]",
"texture": "trafo_texture",
"indices": [0, 3, 7, 4],
"indices": [3, 7, 4, 0],
"uvs": [
"(0, 0)",
"(1, 0)",
"(1, 1)",
"(0, 1)"
"(1, uv_height)",
"(0, uv_height)"
],
"normals": [
"(-1, 0, 0)",
@ -102,12 +111,12 @@
{
"skip": "not face[3]",
"texture": "trafo_texture",
"indices": [5, 6, 2, 1],
"indices": [1, 5, 6, 2],
"uvs": [
"(0, 0)",
"(1, 0)",
"(1, 1)",
"(0, 1)"
"(1, uv_height)",
"(0, uv_height)"
],
"normals": [
"(1, 0, 0)",
@ -119,12 +128,12 @@
{
"skip": "not face[4]",
"texture": "trafo_texture",
"indices": [4, 5, 1, 0],
"indices": [0, 4, 5, 1],
"uvs": [
"(0, 0)",
"(1, 0)",
"(1, 1)",
"(0, 1)"
"(1, uv_height)",
"(0, uv_height)"
],
"normals": [
"(0, -1, 0)",
@ -136,12 +145,12 @@
{
"skip": "not face[5]",
"texture": "trafo_texture",
"indices": [3, 2, 6, 7],
"indices": [2, 6, 7, 3],
"uvs": [
"(0, 0)",
"(1, 0)",
"(1, 1)",
"(0, 1)"
"(1, uv_height)",
"(0, uv_height)"
],
"normals": [
"(1, 0, 0)",
@ -160,16 +169,27 @@
"icon": "WoodTrafo",
"type": "floor",
"cfgs": [
{
"field": "height_",
"type": "float",
"title": "Height",
"desc": "The height of block.",
"default": "5.0"
},
{
"field": "face_",
"type": "face",
"title": "Face",
"desc": "Whether has some faces.",
"default": "(True, True, True, True, True, True)"
"default": "(True, False, True, True, True, True)"
}
]
},
"params": [
{
"field": "height",
"data": "height_"
},
{
"field": "face",
"data": "face_"
@ -184,6 +204,7 @@
"skip": "False",
"params": {
"trafo_texture": "\"BallWood\"",
"height": "height",
"face": "face"
},
"transform": "ident()"
@ -197,16 +218,27 @@
"icon": "StoneTrafo",
"type": "floor",
"cfgs": [
{
"field": "height_",
"type": "float",
"title": "Height",
"desc": "The height of block.",
"default": "5.0"
},
{
"field": "face_",
"type": "face",
"title": "Face",
"desc": "Whether has some faces.",
"default": "(True, True, True, True, True, True)"
"default": "(True, False, True, True, True, True)"
}
]
},
"params": [
{
"field": "height",
"data": "height_"
},
{
"field": "face",
"data": "face_"
@ -221,6 +253,7 @@
"skip": "False",
"params": {
"trafo_texture": "\"BallStone\"",
"height": "height",
"face": "face"
},
"transform": "ident()"
@ -234,16 +267,27 @@
"icon": "PaperTrafo",
"type": "floor",
"cfgs": [
{
"field": "height_",
"type": "float",
"title": "Height",
"desc": "The height of block.",
"default": "5.0"
},
{
"field": "face_",
"type": "face",
"title": "Face",
"desc": "Whether has some faces.",
"default": "(True, True, True, True, True, True)"
"default": "(True, False, True, True, True, True)"
}
]
},
"params": [
{
"field": "height",
"data": "height_"
},
{
"field": "face",
"data": "face_"
@ -258,6 +302,7 @@
"skip": "False",
"params": {
"trafo_texture": "\"BallPaper\"",
"height": "height",
"face": "face"
},
"transform": "ident()"