[fix] fix add floor alignment and add some new icons.

- try setting center alignment for add floor popup operator. it is not center alignment now because blender's impl but it is better than previous layout.
- add some components icon for more directly visual.
This commit is contained in:
yyc12345 2023-01-29 21:39:24 +08:00
parent ddf6b7befe
commit 8d7a982e50
18 changed files with 47 additions and 9 deletions

2
.gitattributes vendored
View File

@ -1,3 +1,5 @@
# all png are binary
*.png binary
# our generated mesh should be save as binary # our generated mesh should be save as binary
*.bin binary *.bin binary
# json is data and not good for human reading(althought I edit it on my own hand.) # json is data and not good for human reading(althought I edit it on my own hand.)

View File

@ -174,7 +174,8 @@ class BALLANCE_OT_add_floors(bpy.types.Operator):
col.prop(self, "expand_length_2") col.prop(self, "expand_length_2")
col.label(text="Unit size: " + floor_prototype['UnitSize']) col.label(text="Unit size: " + floor_prototype['UnitSize'])
col.label(text="Expand mode: " + floor_prototype['ExpandType']) col.label(text="Expand mode: " + floor_prototype['ExpandType'])
grids = col.grid_flow(row_major=True, columns=3) grids = col.grid_flow(row_major=True, columns=3, even_columns=True, even_rows=True, align=True)
grids.alignment = 'CENTER'
grids.separator() grids.separator()
grids.label(text=UTILS_constants.floor_expandDirectionMap[floor_prototype['InitColumnDirection']][floor_prototype['ExpandType']][0]) grids.label(text=UTILS_constants.floor_expandDirectionMap[floor_prototype['InitColumnDirection']][floor_prototype['ExpandType']][0])
grids.separator() grids.separator()
@ -193,7 +194,8 @@ class BALLANCE_OT_add_floors(bpy.types.Operator):
col.separator() col.separator()
col.label(text="Sides") col.label(text="Sides")
grids = col.grid_flow(row_major=True, columns=3) grids = col.grid_flow(row_major=True, columns=3, even_columns=True, even_rows=True, align=True)
grids.alignment = 'CENTER'
grids.separator() grids.separator()
grids.prop(self, "use_2d_top") grids.prop(self, "use_2d_top")
grids.separator() grids.separator()

View File

@ -12,23 +12,42 @@ floor_icons = None
# a map. key is block name, value is loaded icon id # a map. key is block name, value is loaded icon id
floor_icons_map: dict = {} floor_icons_map: dict = {}
element_icons = None
element_icons_map: dict = {}
def register_icons(): def register_icons():
global floor_icons, floor_icons_map global floor_icons, floor_icons_map
global element_icons, element_icons_map
icon_path = os.path.join(os.path.dirname(__file__), "icons") icon_path = os.path.join(os.path.dirname(__file__), "icons")
floor_icons = bpy.utils.previews.new() floor_icons = bpy.utils.previews.new()
for key, value in UTILS_constants.floor_blockDict.items(): for key, value in UTILS_constants.floor_blockDict.items():
blockIconName = "Ballance_FloorIcon_" + key blockIconName = "BlcBldPlg_FloorIcon_" + key
floor_icons.load(blockIconName, os.path.join(icon_path, "floor", value["BindingDisplayTexture"]), 'IMAGE') floor_icons.load(blockIconName, os.path.join(icon_path, "floor", value["BindingDisplayTexture"]), 'IMAGE')
floor_icons_map[key] = floor_icons[blockIconName].icon_id floor_icons_map[key] = floor_icons[blockIconName].icon_id
element_icons = bpy.utils.previews.new()
for elename in UTILS_constants.bmfile_componentList:
blockIconName = "BlcBldPlg_ElementIcon_" + elename
element_icons.load(blockIconName, os.path.join(icon_path, "element", elename + '.png'), 'IMAGE')
element_icons_map[elename] = element_icons[blockIconName].icon_id
def unregister_icons(): def unregister_icons():
global floor_icons, floor_icons_map global floor_icons, floor_icons_map
global element_icons, element_icons_map
bpy.utils.previews.remove(floor_icons) bpy.utils.previews.remove(floor_icons)
floor_icons_map.clear() floor_icons_map.clear()
bpy.utils.previews.remove(element_icons)
element_icons_map.clear()
def get_floor_icon(floor_blk_name: str): def get_floor_icon(floor_blk_name: str):
global floor_icons_map global floor_icons_map
# default return 0
return floor_icons_map.get(floor_blk_name, 0)
return floor_icons_map[floor_blk_name] def get_element_icon(element_name: str):
global element_icons_map
# default return 0
return element_icons_map.get(element_name, 0)

View File

@ -87,7 +87,7 @@ class BALLANCE_MT_ThreeDViewerMenu(bpy.types.Menu):
layout.operator(MODS_flatten_uv.BALLANCE_OT_flatten_uv.bl_idname) layout.operator(MODS_flatten_uv.BALLANCE_OT_flatten_uv.bl_idname)
class BALLANCE_MT_AddFloorMenu(bpy.types.Menu): class BALLANCE_MT_AddFloorMenu(bpy.types.Menu):
"""Add Ballance floor""" """Add Ballance Floor"""
bl_idname = "BALLANCE_MT_AddFloorMenu" bl_idname = "BALLANCE_MT_AddFloorMenu"
bl_label = "Floors" bl_label = "Floors"
@ -110,7 +110,7 @@ class BALLANCE_MT_AddFloorMenu(bpy.types.Menu):
cop.floor_type = item cop.floor_type = item
class BALLANCE_MT_AddRailMenu(bpy.types.Menu): class BALLANCE_MT_AddRailMenu(bpy.types.Menu):
"""Add Ballance rail""" """Add Ballance Rail"""
bl_idname = "BALLANCE_MT_AddRailMenu" bl_idname = "BALLANCE_MT_AddRailMenu"
bl_label = "Rails" bl_label = "Rails"
@ -119,6 +119,19 @@ class BALLANCE_MT_AddRailMenu(bpy.types.Menu):
layout.operator(OBJS_add_rails.BALLANCE_OT_add_rails.bl_idname, text="Rail Section") layout.operator(OBJS_add_rails.BALLANCE_OT_add_rails.bl_idname, text="Rail Section")
layout.operator(OBJS_add_rails.BALLANCE_OT_add_tunnels.bl_idname, text="Tunnel Section") layout.operator(OBJS_add_rails.BALLANCE_OT_add_tunnels.bl_idname, text="Tunnel Section")
class BALLANCE_MT_AddElementsMenu(bpy.types.Menu):
"""Add Ballance Elements"""
bl_idname = "BALLANCE_MT_AddElementsMenu"
bl_label = "Elements"
def draw(self, context):
layout = self.layout
for item in UTILS_constants.bmfile_componentList:
cop = layout.operator(
OBJS_add_components.BALLANCE_OT_add_components.bl_idname,
text=item, icon_value = UTILS_icons_manager.get_element_icon(item))
cop.elements_type = item
# ============================================= # =============================================
# blender call system # blender call system
@ -141,6 +154,7 @@ classes = (
OBJS_add_floors.BALLANCE_OT_add_floors, OBJS_add_floors.BALLANCE_OT_add_floors,
BALLANCE_MT_AddFloorMenu, BALLANCE_MT_AddFloorMenu,
BALLANCE_MT_AddRailMenu, BALLANCE_MT_AddRailMenu,
BALLANCE_MT_AddElementsMenu,
NAMES_rename_system.BALLANCE_OT_rename_by_group, NAMES_rename_system.BALLANCE_OT_rename_by_group,
NAMES_rename_system.BALLANCE_OT_convert_name, NAMES_rename_system.BALLANCE_OT_convert_name,
@ -178,9 +192,10 @@ def menu_func_ballance_add(self, context):
layout.label(text="Ballance") layout.label(text="Ballance")
layout.menu(BALLANCE_MT_AddFloorMenu.bl_idname, icon='MESH_CUBE') layout.menu(BALLANCE_MT_AddFloorMenu.bl_idname, icon='MESH_CUBE')
layout.menu(BALLANCE_MT_AddRailMenu.bl_idname, icon='MESH_CIRCLE') layout.menu(BALLANCE_MT_AddRailMenu.bl_idname, icon='MESH_CIRCLE')
layout.operator_menu_enum( layout.menu(BALLANCE_MT_AddElementsMenu.bl_idname, icon='MESH_ICOSPHERE')
OBJS_add_components.BALLANCE_OT_add_components.bl_idname, #layout.operator_menu_enum(
"elements_type", icon='MESH_ICOSPHERE', text="Elements") # OBJS_add_components.BALLANCE_OT_add_components.bl_idname,
# "elements_type", icon='MESH_ICOSPHERE', text="Elements")
def menu_func_ballance_rename(self, context): def menu_func_ballance_rename(self, context):
layout = self.layout layout = self.layout
layout.separator() layout.separator()

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 695 B