diff --git a/ballance_blender_plugin/OBJS_add_components.py b/ballance_blender_plugin/OBJS_add_components.py index 42363bd..906eb40 100644 --- a/ballance_blender_plugin/OBJS_add_components.py +++ b/ballance_blender_plugin/OBJS_add_components.py @@ -1,5 +1,5 @@ import bpy, mathutils -from . import UTILS_constants, UTILS_functions +from . import UTILS_constants, UTILS_functions, UTILS_icons_manager # ================================================= actual add @@ -12,7 +12,12 @@ class BALLANCE_OT_add_components(bpy.types.Operator): elements_type: bpy.props.EnumProperty( name="Type", description="This element type", - items=tuple(map(lambda x: (x, x, ""), UTILS_constants.bmfile_componentList)), + #items=tuple(map(lambda x: (x, x, ""), UTILS_constants.bmfile_componentList)), + items=tuple( + # token, display name, descriptions, icon, index + (blk, blk, "", UTILS_icons_manager.get_element_icon(blk), idx) + for idx, blk in enumerate(UTILS_constants.bmfile_componentList) + ), ) attentionElements = ("PC_TwoFlames", "PR_Resetpoint") diff --git a/ballance_blender_plugin/OBJS_add_floors.py b/ballance_blender_plugin/OBJS_add_floors.py index fe0bc03..fe18870 100644 --- a/ballance_blender_plugin/OBJS_add_floors.py +++ b/ballance_blender_plugin/OBJS_add_floors.py @@ -15,16 +15,16 @@ class BALLANCE_OT_add_floors(bpy.types.Operator): floor_type: bpy.props.EnumProperty( name="Type", description="Floor type", - items=tuple( - # token, display name, descriptions - (blk, blk, "") - for blk in UTILS_constants.floor_blockDict.keys() - ), #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()) + # # token, display name, descriptions + # (blk, blk, "") + # for blk in UTILS_constants.floor_blockDict.keys() #), + 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()) + ), ) diff --git a/ballance_blender_plugin/UTILS_icons_manager.py b/ballance_blender_plugin/UTILS_icons_manager.py index 7531762..3d5c500 100644 --- a/ballance_blender_plugin/UTILS_icons_manager.py +++ b/ballance_blender_plugin/UTILS_icons_manager.py @@ -15,6 +15,13 @@ floor_icons_map: dict = {} element_icons = None element_icons_map: dict = {} +group_map_to_element: dict = { + "PS_Levelstart": "PS_FourFlames", + "PE_Levelende": "PE_Balloon", + "PC_Checkpoints": "PC_TwoFlames", + "PR_Resetpoints": "PR_Resetpoint" +} + def register_icons(): global floor_icons, floor_icons_map global element_icons, element_icons_map @@ -51,3 +58,12 @@ def get_element_icon(element_name: str): global element_icons_map # default return 0 return element_icons_map.get(element_name, 0) + +def get_group_icon(group_name: str): + # try parse string + # if not found, return self + return get_element_icon(group_map_to_element.get(group_name, group_name)) + +# no matter how, register icon always +# and no unregister call +register_icons() diff --git a/ballance_blender_plugin/UTILS_virtools_prop.py b/ballance_blender_plugin/UTILS_virtools_prop.py index c881c88..5493edd 100644 --- a/ballance_blender_plugin/UTILS_virtools_prop.py +++ b/ballance_blender_plugin/UTILS_virtools_prop.py @@ -1,5 +1,5 @@ import bpy -from . import UTILS_constants, UTILS_functions +from . import UTILS_constants, UTILS_functions, UTILS_icons_manager class BALLANCE_PG_virtools_material(bpy.types.PropertyGroup): enable_virtools_material: bpy.props.BoolProperty( @@ -92,7 +92,12 @@ class common_group_name_props(bpy.types.Operator): group_name: bpy.props.EnumProperty( name="Group Name", description="Pick vanilla Ballance group name.", - items=tuple((x, x, "") for x in UTILS_constants.propsVtGroups_availableGroups), + #items=tuple((x, x, "") for x in UTILS_constants.propsVtGroups_availableGroups), + items=tuple( + # token, display name, descriptions, icon, index + (grp, grp, "", UTILS_icons_manager.get_group_icon(grp), idx) + for idx, grp in enumerate(UTILS_constants.propsVtGroups_availableGroups) + ), ) custom_group_name: bpy.props.StringProperty( diff --git a/ballance_blender_plugin/__init__.py b/ballance_blender_plugin/__init__.py index fba29e4..12e1935 100644 --- a/ballance_blender_plugin/__init__.py +++ b/ballance_blender_plugin/__init__.py @@ -223,7 +223,7 @@ def menu_func_ballance_grouping(self, context): def register(): # we need init all icon first - UTILS_icons_manager.register_icons() + #UTILS_icons_manager.register_icons() for cls in classes: bpy.utils.register_class(cls) @@ -264,7 +264,7 @@ def unregister(): bpy.utils.unregister_class(cls) # we need uninstall all icon after all classes unregister - UTILS_icons_manager.unregister_icons() + #UTILS_icons_manager.unregister_icons() if __name__=="__main__": register() \ No newline at end of file diff --git a/ballance_blender_plugin/icons/element/PC_TwoFlames.png b/ballance_blender_plugin/icons/element/PC_TwoFlames.png new file mode 100644 index 0000000..a323bd1 Binary files /dev/null and b/ballance_blender_plugin/icons/element/PC_TwoFlames.png differ diff --git a/ballance_blender_plugin/icons/element/PE_Balloon.png b/ballance_blender_plugin/icons/element/PE_Balloon.png new file mode 100644 index 0000000..4ddb83c Binary files /dev/null and b/ballance_blender_plugin/icons/element/PE_Balloon.png differ diff --git a/ballance_blender_plugin/icons/element/PR_Resetpoint.png b/ballance_blender_plugin/icons/element/PR_Resetpoint.png new file mode 100644 index 0000000..ad0ef4f Binary files /dev/null and b/ballance_blender_plugin/icons/element/PR_Resetpoint.png differ diff --git a/ballance_blender_plugin/icons/element/PS_FourFlames.png b/ballance_blender_plugin/icons/element/PS_FourFlames.png new file mode 100644 index 0000000..fa39256 Binary files /dev/null and b/ballance_blender_plugin/icons/element/PS_FourFlames.png differ diff --git a/ballance_blender_plugin/icons/element/P_Ball_Paper.png b/ballance_blender_plugin/icons/element/P_Ball_Paper.png new file mode 100644 index 0000000..712982d Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Ball_Paper.png differ diff --git a/ballance_blender_plugin/icons/element/P_Ball_Stone.png b/ballance_blender_plugin/icons/element/P_Ball_Stone.png new file mode 100644 index 0000000..b81e83e Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Ball_Stone.png differ diff --git a/ballance_blender_plugin/icons/element/P_Ball_Wood.png b/ballance_blender_plugin/icons/element/P_Ball_Wood.png new file mode 100644 index 0000000..58fad44 Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Ball_Wood.png differ diff --git a/ballance_blender_plugin/icons/element/P_Dome.png b/ballance_blender_plugin/icons/element/P_Dome.png new file mode 100644 index 0000000..0920e3a Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Dome.png differ diff --git a/ballance_blender_plugin/icons/element/P_Extra_Point.png b/ballance_blender_plugin/icons/element/P_Extra_Point.png index 7c82a04..24ce625 100644 Binary files a/ballance_blender_plugin/icons/element/P_Extra_Point.png and b/ballance_blender_plugin/icons/element/P_Extra_Point.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_19.png b/ballance_blender_plugin/icons/element/P_Modul_19.png new file mode 100644 index 0000000..c0b7e2c Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Modul_19.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_26.png b/ballance_blender_plugin/icons/element/P_Modul_26.png index de45c23..49525cc 100644 Binary files a/ballance_blender_plugin/icons/element/P_Modul_26.png 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 index 0a5fae6..012c7fb 100644 Binary files a/ballance_blender_plugin/icons/element/P_Modul_29.png and b/ballance_blender_plugin/icons/element/P_Modul_29.png differ diff --git a/ballance_blender_plugin/icons/element/P_Modul_41.png b/ballance_blender_plugin/icons/element/P_Modul_41.png new file mode 100644 index 0000000..804fef2 Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Modul_41.png differ diff --git a/ballance_blender_plugin/icons/element/P_Trafo_Paper.png b/ballance_blender_plugin/icons/element/P_Trafo_Paper.png new file mode 100644 index 0000000..55f263a Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Trafo_Paper.png differ diff --git a/ballance_blender_plugin/icons/element/P_Trafo_Stone.png b/ballance_blender_plugin/icons/element/P_Trafo_Stone.png new file mode 100644 index 0000000..b3373fa Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Trafo_Stone.png differ diff --git a/ballance_blender_plugin/icons/element/P_Trafo_Wood.png b/ballance_blender_plugin/icons/element/P_Trafo_Wood.png new file mode 100644 index 0000000..5a87a7b Binary files /dev/null and b/ballance_blender_plugin/icons/element/P_Trafo_Wood.png differ