WIP, update some code
This commit is contained in:
		@ -103,7 +103,7 @@ def menu_func_ballance_add(self, context):
 | 
				
			|||||||
    layout.separator()
 | 
					    layout.separator()
 | 
				
			||||||
    layout.label(text="Ballance")
 | 
					    layout.label(text="Ballance")
 | 
				
			||||||
    layout.operator_menu_enum("ballance.add_elements", "elements_type", icon='MESH_ICOSPHERE', text="Elements")
 | 
					    layout.operator_menu_enum("ballance.add_elements", "elements_type", icon='MESH_ICOSPHERE', text="Elements")
 | 
				
			||||||
    layout.operator("ballance.add_rail", icon='MESH_CUBE', text="Rail section")
 | 
					    layout.operator("ballance.add_rail", icon='MESH_CIRCLE', text="Rail section")
 | 
				
			||||||
    layout.menu(BALLANCE_MT_AddFloorMenu.bl_idname, icon='MESH_CUBE')
 | 
					    layout.menu(BALLANCE_MT_AddFloorMenu.bl_idname, icon='MESH_CUBE')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def register():
 | 
					def register():
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
import bpy,mathutils
 | 
					import bpy,mathutils
 | 
				
			||||||
 | 
					import os
 | 
				
			||||||
from . import utils, config
 | 
					from . import utils, config
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class BALLANCE_OT_add_floor(bpy.types.Operator):
 | 
					class BALLANCE_OT_add_floor(bpy.types.Operator):
 | 
				
			||||||
@ -16,18 +17,21 @@ class BALLANCE_OT_add_floor(bpy.types.Operator):
 | 
				
			|||||||
    expand_length_1 : bpy.props.IntProperty(
 | 
					    expand_length_1 : bpy.props.IntProperty(
 | 
				
			||||||
        name="D1 length",
 | 
					        name="D1 length",
 | 
				
			||||||
        description="The length of expand direction 1",
 | 
					        description="The length of expand direction 1",
 | 
				
			||||||
 | 
					        min=0,
 | 
				
			||||||
        default=0,
 | 
					        default=0,
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expand_length_2 : bpy.props.IntProperty(
 | 
					    expand_length_2 : bpy.props.IntProperty(
 | 
				
			||||||
        name="D2 length",
 | 
					        name="D2 length",
 | 
				
			||||||
        description="The length of expand direction 2",
 | 
					        description="The length of expand direction 2",
 | 
				
			||||||
 | 
					        min=0,
 | 
				
			||||||
        default=0,
 | 
					        default=0,
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    height_multiplier : bpy.props.FloatProperty(
 | 
					    height_multiplier : bpy.props.FloatProperty(
 | 
				
			||||||
        name="Height",
 | 
					        name="Height",
 | 
				
			||||||
        description="The multiplier for height. Default height is 5",
 | 
					        description="The multiplier for height. Default height is 5",
 | 
				
			||||||
 | 
					        min=0.0,
 | 
				
			||||||
        default=1.0,
 | 
					        default=1.0,
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -62,6 +66,10 @@ class BALLANCE_OT_add_floor(bpy.types.Operator):
 | 
				
			|||||||
        name="Bottom face"
 | 
					        name="Bottom face"
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @classmethod
 | 
				
			||||||
 | 
					    def poll(self, context):
 | 
				
			||||||
 | 
					        prefs = bpy.context.preferences.addons[__package__].preferences
 | 
				
			||||||
 | 
					        return os.path.isdir(prefs.external_folder)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def execute(self, context):
 | 
					    def execute(self, context):
 | 
				
			||||||
        return {'FINISHED'}
 | 
					        return {'FINISHED'}
 | 
				
			||||||
@ -75,10 +83,23 @@ class BALLANCE_OT_add_floor(bpy.types.Operator):
 | 
				
			|||||||
        col = layout.column()
 | 
					        col = layout.column()
 | 
				
			||||||
        col.label(text="Basic param")
 | 
					        col.label(text="Basic param")
 | 
				
			||||||
        col.prop(self, "floor_type")
 | 
					        col.prop(self, "floor_type")
 | 
				
			||||||
 | 
					        col.prop(self, "rotation_inside_mesh")
 | 
				
			||||||
 | 
					        col.prop(self, "height_multiplier")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        col.separator()
 | 
				
			||||||
 | 
					        col.label(text="Expand")
 | 
				
			||||||
        col.prop(self, "expand_length_1")
 | 
					        col.prop(self, "expand_length_1")
 | 
				
			||||||
        col.prop(self, "expand_length_2")
 | 
					        col.prop(self, "expand_length_2")
 | 
				
			||||||
        col.prop(self, "height_multiplier")
 | 
					        grids = col.grid_flow(columns=3)
 | 
				
			||||||
        col.prop(self, "rotation_inside_mesh")
 | 
					        grids.separator()
 | 
				
			||||||
 | 
					        grids.label(text="X")
 | 
				
			||||||
 | 
					        grids.separator()
 | 
				
			||||||
 | 
					        grids.label(text="X")
 | 
				
			||||||
 | 
					        grids.template_icon(icon_value = config.blenderIcon_floor_dict[self.floor_type])
 | 
				
			||||||
 | 
					        grids.label(text="X")
 | 
				
			||||||
 | 
					        grids.separator()
 | 
				
			||||||
 | 
					        grids.label(text="X")
 | 
				
			||||||
 | 
					        grids.separator()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        col.separator()
 | 
					        col.separator()
 | 
				
			||||||
        col.label(text="Faces")
 | 
					        col.label(text="Faces")
 | 
				
			||||||
@ -88,17 +109,15 @@ class BALLANCE_OT_add_floor(bpy.types.Operator):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        col.separator()
 | 
					        col.separator()
 | 
				
			||||||
        col.label(text="Sides")
 | 
					        col.label(text="Sides")
 | 
				
			||||||
        row = col.row(align=True)
 | 
					        grids = col.grid_flow(columns=3)
 | 
				
			||||||
        row.label(text="")
 | 
					        grids.separator()
 | 
				
			||||||
        row.prop(self, "use_2d_top")
 | 
					        grids.prop(self, "use_2d_top")
 | 
				
			||||||
        row.label(text="")
 | 
					        grids.separator()
 | 
				
			||||||
        row = col.row(align=True)
 | 
					        grids.prop(self, "use_2d_left")
 | 
				
			||||||
        row.prop(self, "use_2d_left")
 | 
					        grids.template_icon(icon_value = config.blenderIcon_floor_dict[self.floor_type])
 | 
				
			||||||
        row.template_icon(icon_value = config.blenderIcon_floor_dict[self.floor_type])
 | 
					        grids.prop(self, "use_2d_right")
 | 
				
			||||||
        row.prop(self, "use_2d_right")
 | 
					        grids.separator()
 | 
				
			||||||
        row = col.row(align=True)
 | 
					        grids.prop(self, "use_2d_bottom")
 | 
				
			||||||
        row.label(text="")
 | 
					        grids.separator()
 | 
				
			||||||
        row.prop(self, "use_2d_bottom")
 | 
					 | 
				
			||||||
        row.label(text="")
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -118,7 +118,7 @@ component_list = [
 | 
				
			|||||||
floor_block_dict = {}
 | 
					floor_block_dict = {}
 | 
				
			||||||
floor_basic_block_list = []
 | 
					floor_basic_block_list = []
 | 
				
			||||||
floor_derived_block_list = []
 | 
					floor_derived_block_list = []
 | 
				
			||||||
with open(os.path.join(os.path.dirname(__file__), "json", "VanillaBlock.json")) as fp:
 | 
					with open(os.path.join(os.path.dirname(__file__), "json", "BasicBlock.json")) as fp:
 | 
				
			||||||
    for item in json.load(fp):
 | 
					    for item in json.load(fp):
 | 
				
			||||||
        floor_basic_block_list.append(item["Type"])
 | 
					        floor_basic_block_list.append(item["Type"])
 | 
				
			||||||
        floor_block_dict[item["Type"]] = item
 | 
					        floor_block_dict[item["Type"]] = item
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,14 @@
 | 
				
			|||||||
        "UnitSize": "Small",
 | 
					        "UnitSize": "Small",
 | 
				
			||||||
        "ExpandType": "Column",
 | 
					        "ExpandType": "Column",
 | 
				
			||||||
        "InitColumnDirection": "PositiveX",
 | 
					        "InitColumnDirection": "PositiveX",
 | 
				
			||||||
 | 
					        "DefaultSideConfig": {
 | 
				
			||||||
 | 
					            "UseTwoDTop": false,
 | 
				
			||||||
 | 
					            "UseTwoDRight": false,
 | 
				
			||||||
 | 
					            "UseTwoDBottom": false,
 | 
				
			||||||
 | 
					            "UseTwoDLeft": true,
 | 
				
			||||||
 | 
					            "UseThreeDTop": true,
 | 
				
			||||||
 | 
					            "UseThreeDBottom": false
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
        "ThreeDTopFace": {
 | 
					        "ThreeDTopFace": {
 | 
				
			||||||
            "Vertices": [
 | 
					            "Vertices": [
 | 
				
			||||||
                "2.5,0,0;+d1;;",
 | 
					                "2.5,0,0;+d1;;",
 | 
				
			||||||
@ -5,7 +5,7 @@ class BallanceBlenderPluginPreferences(bpy.types.AddonPreferences):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    external_folder: bpy.props.StringProperty(
 | 
					    external_folder: bpy.props.StringProperty(
 | 
				
			||||||
        name="External texture folder",
 | 
					        name="External texture folder",
 | 
				
			||||||
        description="The Ballance texture folder which will be used buy this plugin to get external texture.",
 | 
					        description="The Ballance texture folder which will be used by this plugin to get external texture.",
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    no_component_collection: bpy.props.StringProperty(
 | 
					    no_component_collection: bpy.props.StringProperty(
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user