[feat] add full element icons
- add more element icons. now element icons is not problem. - change icon load strategy. now icon is loaded outside plugin. this operations might slow down blender but now I can apply my custom map to some operators to get better using experience. - use new element icons to decorate some group name to let user know what this group stands for.
@ -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")
|
||||
|
@ -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())
|
||||
),
|
||||
|
||||
)
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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(
|
||||
|
@ -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()
|
BIN
ballance_blender_plugin/icons/element/PC_TwoFlames.png
Normal file
After Width: | Height: | Size: 663 B |
BIN
ballance_blender_plugin/icons/element/PE_Balloon.png
Normal file
After Width: | Height: | Size: 745 B |
BIN
ballance_blender_plugin/icons/element/PR_Resetpoint.png
Normal file
After Width: | Height: | Size: 945 B |
BIN
ballance_blender_plugin/icons/element/PS_FourFlames.png
Normal file
After Width: | Height: | Size: 818 B |
BIN
ballance_blender_plugin/icons/element/P_Ball_Paper.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
ballance_blender_plugin/icons/element/P_Ball_Stone.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
ballance_blender_plugin/icons/element/P_Ball_Wood.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
ballance_blender_plugin/icons/element/P_Dome.png
Normal file
After Width: | Height: | Size: 611 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
BIN
ballance_blender_plugin/icons/element/P_Modul_19.png
Normal file
After Width: | Height: | Size: 992 B |
Before Width: | Height: | Size: 912 B After Width: | Height: | Size: 691 B |
Before Width: | Height: | Size: 904 B After Width: | Height: | Size: 775 B |
BIN
ballance_blender_plugin/icons/element/P_Modul_41.png
Normal file
After Width: | Height: | Size: 550 B |
BIN
ballance_blender_plugin/icons/element/P_Trafo_Paper.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
ballance_blender_plugin/icons/element/P_Trafo_Stone.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
ballance_blender_plugin/icons/element/P_Trafo_Wood.png
Normal file
After Width: | Height: | Size: 1.9 KiB |