[fix] add icons for sound hit/roll id group
- add 3 extra icons for groups Sound_(Roll/Hit)ID_(01|02|03). - add a empty placeholder icon to make some UI more clear - finish add group icons.
This commit is contained in:
parent
807e006245
commit
d292ce389a
@ -7,62 +7,91 @@ blender_info_icon = 'INFO'
|
|||||||
blender_warning_icon = 'ERROR'
|
blender_warning_icon = 'ERROR'
|
||||||
blender_error_icon = 'CANCEL'
|
blender_error_icon = 'CANCEL'
|
||||||
|
|
||||||
# ImagePreviewCollection ccreated by Blender
|
# universal icon loader, all icon are stored in this preview collection
|
||||||
floor_icons = None
|
universal_icons = None
|
||||||
|
|
||||||
|
# empty icon for placeholder
|
||||||
|
empty_icon_id = 0
|
||||||
|
|
||||||
# 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 = {}
|
element_icons_map: dict = {}
|
||||||
|
groupext_icons_map: dict = {}
|
||||||
|
|
||||||
group_map_to_element: dict = {
|
group_name_conv_map: dict = {
|
||||||
"PS_Levelstart": "PS_FourFlames",
|
"PS_Levelstart": "PS_FourFlames",
|
||||||
"PE_Levelende": "PE_Balloon",
|
"PE_Levelende": "PE_Balloon",
|
||||||
"PC_Checkpoints": "PC_TwoFlames",
|
"PC_Checkpoints": "PC_TwoFlames",
|
||||||
"PR_Resetpoints": "PR_Resetpoint"
|
"PR_Resetpoints": "PR_Resetpoint",
|
||||||
|
|
||||||
|
"Sound_HitID_01": "SoundID_01",
|
||||||
|
"Sound_RollID_01": "SoundID_01",
|
||||||
|
"Sound_HitID_02": "SoundID_02",
|
||||||
|
"Sound_RollID_02": "SoundID_02",
|
||||||
|
"Sound_HitID_03": "SoundID_03",
|
||||||
|
"Sound_RollID_03": "SoundID_03"
|
||||||
}
|
}
|
||||||
|
|
||||||
def register_icons():
|
def register_icons():
|
||||||
global floor_icons, floor_icons_map
|
global universal_icons
|
||||||
global element_icons, element_icons_map
|
global empty_icon_id
|
||||||
|
global floor_icons_map, element_icons_map, groupext_icons_map
|
||||||
|
|
||||||
|
# create preview collection and get icon folder
|
||||||
icon_path = os.path.join(os.path.dirname(__file__), "icons")
|
icon_path = os.path.join(os.path.dirname(__file__), "icons")
|
||||||
|
universal_icons = bpy.utils.previews.new()
|
||||||
|
|
||||||
floor_icons = bpy.utils.previews.new()
|
# load empty
|
||||||
|
universal_icons.load("BlcBldPlg_EmptyIcon", os.path.join(icon_path, "Empty.png"), 'IMAGE')
|
||||||
|
empty_icon_id = universal_icons["BlcBldPlg_EmptyIcon"].icon_id
|
||||||
|
|
||||||
|
# add floor icon
|
||||||
for key, value in UTILS_constants.floor_blockDict.items():
|
for key, value in UTILS_constants.floor_blockDict.items():
|
||||||
blockIconName = "BlcBldPlg_FloorIcon_" + key
|
blockIconName = "BlcBldPlg_FloorIcon_" + key
|
||||||
floor_icons.load(blockIconName, os.path.join(icon_path, "floor", value["BindingDisplayTexture"]), 'IMAGE')
|
universal_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] = universal_icons[blockIconName].icon_id
|
||||||
|
|
||||||
element_icons = bpy.utils.previews.new()
|
# add elements icon
|
||||||
for elename in UTILS_constants.bmfile_componentList:
|
for elename in UTILS_constants.bmfile_componentList:
|
||||||
blockIconName = "BlcBldPlg_ElementIcon_" + elename
|
blockIconName = "BlcBldPlg_ElementIcon_" + elename
|
||||||
element_icons.load(blockIconName, os.path.join(icon_path, "element", elename + '.png'), 'IMAGE')
|
universal_icons.load(blockIconName, os.path.join(icon_path, "element", elename + '.png'), 'IMAGE')
|
||||||
element_icons_map[elename] = element_icons[blockIconName].icon_id
|
element_icons_map[elename] = universal_icons[blockIconName].icon_id
|
||||||
|
|
||||||
|
# add extra group icon
|
||||||
|
for grp in ("SoundID_01", "SoundID_02", "SoundID_03"):
|
||||||
|
blockIconName = "BlcBldPlg_GroupIcon_" + grp
|
||||||
|
universal_icons.load(blockIconName, os.path.join(icon_path, "group", grp + '.png'), 'IMAGE')
|
||||||
|
groupext_icons_map[grp] = universal_icons[blockIconName].icon_id
|
||||||
|
|
||||||
def unregister_icons():
|
def unregister_icons():
|
||||||
global floor_icons, floor_icons_map
|
global universal_icons
|
||||||
global element_icons, element_icons_map
|
global floor_icons_map, element_icons_map, groupext_icons_map
|
||||||
|
|
||||||
bpy.utils.previews.remove(floor_icons)
|
bpy.utils.previews.remove(universal_icons)
|
||||||
floor_icons_map.clear()
|
floor_icons_map.clear()
|
||||||
bpy.utils.previews.remove(element_icons)
|
|
||||||
element_icons_map.clear()
|
element_icons_map.clear()
|
||||||
|
groupext_icons_map.clear()
|
||||||
|
|
||||||
def get_floor_icon(floor_blk_name: str):
|
def get_floor_icon(floor_blk_name: str):
|
||||||
global floor_icons_map
|
# default return empty icon
|
||||||
# default return 0
|
return floor_icons_map.get(floor_blk_name, empty_icon_id)
|
||||||
return floor_icons_map.get(floor_blk_name, 0)
|
|
||||||
|
|
||||||
def get_element_icon(element_name: str):
|
def get_element_icon(element_name: str):
|
||||||
global element_icons_map
|
# default return empty icon
|
||||||
# default return 0
|
return element_icons_map.get(element_name, empty_icon_id)
|
||||||
return element_icons_map.get(element_name, 0)
|
|
||||||
|
|
||||||
def get_group_icon(group_name: str):
|
def get_group_icon(group_name: str):
|
||||||
# try parse string
|
# try parse string
|
||||||
# if not found, return self
|
# if not found, return self
|
||||||
return get_element_icon(group_map_to_element.get(group_name, group_name))
|
conv_name = group_name_conv_map.get(group_name, group_name)
|
||||||
|
|
||||||
|
# get from extra group icon first
|
||||||
|
idx = groupext_icons_map.get(conv_name, empty_icon_id)
|
||||||
|
if idx != empty_icon_id:
|
||||||
|
return idx
|
||||||
|
|
||||||
|
# if failed, get from element. if still failed, return empty icon
|
||||||
|
return get_element_icon(conv_name)
|
||||||
|
|
||||||
# no matter how, register icon always
|
# no matter how, register icon always
|
||||||
# and no unregister call
|
# and no unregister call
|
||||||
|
BIN
ballance_blender_plugin/icons/Empty.png
Normal file
BIN
ballance_blender_plugin/icons/Empty.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 785 B |
BIN
ballance_blender_plugin/icons/group/SoundID_01.png
Normal file
BIN
ballance_blender_plugin/icons/group/SoundID_01.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
ballance_blender_plugin/icons/group/SoundID_02.png
Normal file
BIN
ballance_blender_plugin/icons/group/SoundID_02.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
BIN
ballance_blender_plugin/icons/group/SoundID_03.png
Normal file
BIN
ballance_blender_plugin/icons/group/SoundID_03.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 251 B |
Loading…
Reference in New Issue
Block a user