diff --git a/.gitattributes b/.gitattributes index 38a628f..78f607a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,5 @@ +# all png are binary +*.png binary # our generated mesh should be save as binary *.bin binary # json is data and not good for human reading(althought I edit it on my own hand.) diff --git a/ballance_blender_plugin/OBJS_add_floors.py b/ballance_blender_plugin/OBJS_add_floors.py index 5f348ff..fe0bc03 100644 --- a/ballance_blender_plugin/OBJS_add_floors.py +++ b/ballance_blender_plugin/OBJS_add_floors.py @@ -174,7 +174,8 @@ class BALLANCE_OT_add_floors(bpy.types.Operator): col.prop(self, "expand_length_2") col.label(text="Unit size: " + floor_prototype['UnitSize']) 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.label(text=UTILS_constants.floor_expandDirectionMap[floor_prototype['InitColumnDirection']][floor_prototype['ExpandType']][0]) grids.separator() @@ -193,7 +194,8 @@ class BALLANCE_OT_add_floors(bpy.types.Operator): col.separator() 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.prop(self, "use_2d_top") grids.separator() diff --git a/ballance_blender_plugin/UTILS_icons_manager.py b/ballance_blender_plugin/UTILS_icons_manager.py index fc43646..7531762 100644 --- a/ballance_blender_plugin/UTILS_icons_manager.py +++ b/ballance_blender_plugin/UTILS_icons_manager.py @@ -12,23 +12,42 @@ floor_icons = None # a map. key is block name, value is loaded icon id floor_icons_map: dict = {} +element_icons = None +element_icons_map: dict = {} + def register_icons(): global floor_icons, floor_icons_map + global element_icons, element_icons_map icon_path = os.path.join(os.path.dirname(__file__), "icons") + floor_icons = bpy.utils.previews.new() 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_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(): global floor_icons, floor_icons_map + global element_icons, element_icons_map bpy.utils.previews.remove(floor_icons) floor_icons_map.clear() + bpy.utils.previews.remove(element_icons) + element_icons_map.clear() def get_floor_icon(floor_blk_name: str): 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) diff --git a/ballance_blender_plugin/__init__.py b/ballance_blender_plugin/__init__.py index bc88e55..fba29e4 100644 --- a/ballance_blender_plugin/__init__.py +++ b/ballance_blender_plugin/__init__.py @@ -87,7 +87,7 @@ class BALLANCE_MT_ThreeDViewerMenu(bpy.types.Menu): layout.operator(MODS_flatten_uv.BALLANCE_OT_flatten_uv.bl_idname) class BALLANCE_MT_AddFloorMenu(bpy.types.Menu): - """Add Ballance floor""" + """Add Ballance Floor""" bl_idname = "BALLANCE_MT_AddFloorMenu" bl_label = "Floors" @@ -110,7 +110,7 @@ class BALLANCE_MT_AddFloorMenu(bpy.types.Menu): cop.floor_type = item class BALLANCE_MT_AddRailMenu(bpy.types.Menu): - """Add Ballance rail""" + """Add Ballance Rail""" bl_idname = "BALLANCE_MT_AddRailMenu" 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_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 @@ -141,6 +154,7 @@ classes = ( OBJS_add_floors.BALLANCE_OT_add_floors, BALLANCE_MT_AddFloorMenu, BALLANCE_MT_AddRailMenu, + BALLANCE_MT_AddElementsMenu, NAMES_rename_system.BALLANCE_OT_rename_by_group, NAMES_rename_system.BALLANCE_OT_convert_name, @@ -178,9 +192,10 @@ def menu_func_ballance_add(self, context): layout.label(text="Ballance") layout.menu(BALLANCE_MT_AddFloorMenu.bl_idname, icon='MESH_CUBE') layout.menu(BALLANCE_MT_AddRailMenu.bl_idname, icon='MESH_CIRCLE') - layout.operator_menu_enum( - OBJS_add_components.BALLANCE_OT_add_components.bl_idname, - "elements_type", icon='MESH_ICOSPHERE', text="Elements") + layout.menu(BALLANCE_MT_AddElementsMenu.bl_idname, icon='MESH_ICOSPHERE') + #layout.operator_menu_enum( + # OBJS_add_components.BALLANCE_OT_add_components.bl_idname, + # "elements_type", icon='MESH_ICOSPHERE', text="Elements") def menu_func_ballance_rename(self, context): layout = self.layout layout.separator() diff --git a/ballance_blender_plugin/icons/element/P_Box.png b/ballance_blender_plugin/icons/element/P_Box.png new file mode 100644 index 0000000..2230dea Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Box.png differ diff --git a/ballance_blender_plugin/icons/element/P_Extra_Life.png b/ballance_blender_plugin/icons/element/P_Extra_Life.png new file mode 100644 index 0000000..7364b36 Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Extra_Life.png differ diff --git a/ballance_blender_plugin/icons/element/P_Extra_Point.png b/ballance_blender_plugin/icons/element/P_Extra_Point.png new file mode 100644 index 0000000..7c82a04 Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Extra_Point.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_01.png b/ballance_blender_plugin/icons/element/P_Modul_01.png new file mode 100644 index 0000000..ec76cd3 Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Modul_01.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_03.png b/ballance_blender_plugin/icons/element/P_Modul_03.png new file mode 100644 index 0000000..4c856a7 Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Modul_03.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_08.png b/ballance_blender_plugin/icons/element/P_Modul_08.png new file mode 100644 index 0000000..9052491 Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Modul_08.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_17.png b/ballance_blender_plugin/icons/element/P_Modul_17.png new file mode 100644 index 0000000..ff2fd7e Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Modul_17.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_18.png b/ballance_blender_plugin/icons/element/P_Modul_18.png new file mode 100644 index 0000000..05cf95d Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Modul_18.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_25.png b/ballance_blender_plugin/icons/element/P_Modul_25.png new file mode 100644 index 0000000..c539e26 Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Modul_25.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_26.png b/ballance_blender_plugin/icons/element/P_Modul_26.png new file mode 100644 index 0000000..de45c23 Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Modul_26.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_29.png b/ballance_blender_plugin/icons/element/P_Modul_29.png new file mode 100644 index 0000000..0a5fae6 Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Modul_29.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_30.png b/ballance_blender_plugin/icons/element/P_Modul_30.png new file mode 100644 index 0000000..7bb4356 Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Modul_30.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_34.png b/ballance_blender_plugin/icons/element/P_Modul_34.png new file mode 100644 index 0000000..b696f7d Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Modul_34.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_37.png b/ballance_blender_plugin/icons/element/P_Modul_37.png new file mode 100644 index 0000000..dbd12f7 Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Modul_37.png differ