From d292ce389aa84f43a55bc543451667168e66e6ce Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Mon, 30 Jan 2023 15:00:29 +0800 Subject: [PATCH] [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. --- .../UTILS_icons_manager.py | 79 ++++++++++++------ ballance_blender_plugin/icons/Empty.png | Bin 0 -> 785 bytes .../icons/group/SoundID_01.png | Bin 0 -> 2221 bytes .../icons/group/SoundID_02.png | Bin 0 -> 2523 bytes .../icons/group/SoundID_03.png | Bin 0 -> 251 bytes 5 files changed, 54 insertions(+), 25 deletions(-) create mode 100644 ballance_blender_plugin/icons/Empty.png create mode 100644 ballance_blender_plugin/icons/group/SoundID_01.png create mode 100644 ballance_blender_plugin/icons/group/SoundID_02.png create mode 100644 ballance_blender_plugin/icons/group/SoundID_03.png diff --git a/ballance_blender_plugin/UTILS_icons_manager.py b/ballance_blender_plugin/UTILS_icons_manager.py index 3d5c500..8c4681a 100644 --- a/ballance_blender_plugin/UTILS_icons_manager.py +++ b/ballance_blender_plugin/UTILS_icons_manager.py @@ -7,62 +7,91 @@ blender_info_icon = 'INFO' blender_warning_icon = 'ERROR' blender_error_icon = 'CANCEL' -# ImagePreviewCollection ccreated by Blender -floor_icons = None +# universal icon loader, all icon are stored in this preview collection +universal_icons = None + +# empty icon for placeholder +empty_icon_id = 0 + # a map. key is block name, value is loaded icon id floor_icons_map: dict = {} - -element_icons = None element_icons_map: dict = {} +groupext_icons_map: dict = {} -group_map_to_element: dict = { +group_name_conv_map: dict = { "PS_Levelstart": "PS_FourFlames", "PE_Levelende": "PE_Balloon", "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(): - global floor_icons, floor_icons_map - global element_icons, element_icons_map + global universal_icons + 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") + 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(): 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 + universal_icons.load(blockIconName, os.path.join(icon_path, "floor", value["BindingDisplayTexture"]), 'IMAGE') + 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: 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 + universal_icons.load(blockIconName, os.path.join(icon_path, "element", elename + '.png'), 'IMAGE') + 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(): - global floor_icons, floor_icons_map - global element_icons, element_icons_map + global universal_icons + 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() - bpy.utils.previews.remove(element_icons) element_icons_map.clear() + groupext_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) + # default return empty icon + return floor_icons_map.get(floor_blk_name, empty_icon_id) def get_element_icon(element_name: str): - global element_icons_map - # default return 0 - return element_icons_map.get(element_name, 0) + # default return empty icon + return element_icons_map.get(element_name, empty_icon_id) 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)) + 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 # and no unregister call diff --git a/ballance_blender_plugin/icons/Empty.png b/ballance_blender_plugin/icons/Empty.png new file mode 100644 index 0000000000000000000000000000000000000000..285ac3073c986ed3df671fa1ca4d8441f33b1b34 GIT binary patch literal 785 zcmV+s1Md8ZP)2!K_MG5EWfIULA5q}XAguH&EkwLT&Pn|0YVK^BK(Hj_7 zLL40o1|px&3-tY$>i7FaI-O?!wqY12oM6iR?awHg!6A85McL)T@}g#m<%z#U9T1i0d@=h*Z8c_XqXQ8d_Hz< zA@`+S0Zx`cW#bzTC=?1}IHW;4S3DkP;eJ)JBL|j=VD_`6AY86Dt&hcGw11?6^SNsW z0RM{oQ;Xn{NQBx~53B&dUqJjEKf7+XJLAZi&*9vPKR7AC?GoJW^?IUOt(uHrFev75 z_MLYEUu6kSRw@;f;q`j0d&D=)zIR{+!2a75rvuXZXf$f_06*gt?$&`d8-UhXK&Q}M zW8uP2%V9(|AG#KFlL+c-OA#O4XzWW4inz2dLOLRVezDAcg!Ws6@~3?fLpuqeK7`h+ zCm_q|XairtbDha(ZN-3JC!E`_Jbn?@YPIBV!4n<0o6qpF0-!Y^Hw8RnQYw`)&wsq< z63h=D+79SC#skNF#CXp>z<*Q{+G0r1ehDQ6K%TdF80Fr-EX>4Tx04R}tkv&MmP!xqvQ?()$2Rn#}W~fdU#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)M^qI!NP-5i z8{I_`pwSu)P?f)X%+w8DI|k5Az^RAzVW`yTG*4)x47vIR4f z8e&TXs_JY?GozWRX*M%SX7#?Ey83FhoPM8*>u;{(81vJ1;Vx(y1H!&<5n-z6=} z($#h7*!FPm+oNf(3@%(=TQpduWA zyH_UtOj8tceoGX zytu3-sHNJ&J|%S6@Fnc-y!)Gjp{nQ;-A_=2mJD z5plK<=}xFsRZ?{e0Hmr?D@L3neY10Y`trwDM|=17=Jr27U7UWamV1~7NJ-{Kf}oLR z4nS%&)UDsK4w2_qn$cr~x{Xeu5St~1H-iWNEpp%XSqqZ z#~GY+&KP4XOI88!F#x)`$3V@Vd%U`SdGPu?dFe*-T#Y$*5Mx=-Kz4JZ0C+@IS7ldL zrY)Y89?{h!hKJ|2xrczue8B19G$Y>M+@xo;TD_3NkWj#$=lB6F%TE0fCraXuhUr$^F&l3eP!?*OY3WOoi< zGN*kJy=)nkv#SM|`L#cOet-A&u539R-R+lMX0|MgAa^r&p#YeBjHN08dW6s*mt~C@ zgyD;S-8>{opt*z?<6{Eh7Z*#sdwcU5A71!HR_@#8w$8mlngxJ!EtWXv4uQtX$z|1f z9%SxjzHg_9H8V3)Qf1C3FJHWQcK`l1mf_*YN3G^gV@nY>Vtlzf>7WRjc~y4SvL3n{ vQg=p-mTJycXJ*$IinRLe&E4IH51INO=${Q&)5V`R00000NkvXXu0mjf5}!R) literal 0 HcmV?d00001 diff --git a/ballance_blender_plugin/icons/group/SoundID_02.png b/ballance_blender_plugin/icons/group/SoundID_02.png new file mode 100644 index 0000000000000000000000000000000000000000..3079b7da3df2a82cc876acd3b860049cc45a5a5a GIT binary patch literal 2523 zcmV<12_*K3P)EX>4Tx04R}tkv&MmP!xqvQ?()$2Rn#}W~fdU#ELjd6^me@v=v%)FnQ^Z(4-+r zad8w}3l9D)RvlcNb#-tR1i>E=R~IKm7b)?+q|hS93y=44-aUu+?gNB+nW<*S1fXh` zk&4H}Y;HviyuycJbYTQhiJ5vLy^w)tece+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