From 09d19ca44685bb96e3e3a8fc1e597620ded9e1a5 Mon Sep 17 00:00:00 2001 From: Yusuf Umar Date: Tue, 12 Nov 2024 15:34:24 +0700 Subject: [PATCH] Fix: Blender 2.80+ use wrong icons for channel selection on new layer popup --- Bake.py | 12 ++++-------- Layer.py | 14 ++++---------- Root.py | 16 ---------------- lib.py | 6 ------ ui.py | 2 -- 5 files changed, 8 insertions(+), 42 deletions(-) diff --git a/Bake.py b/Bake.py index f53bb784..1dd014cc 100644 --- a/Bake.py +++ b/Bake.py @@ -1192,10 +1192,8 @@ def bake_vcol_channel_items(self, context): # Add two spaces to prevent text from being translated text_ch_name = ch.name + ' ' # Index plus one, minus one when read - if hasattr(lib, 'custom_icons'): - icon_name = lib.channel_custom_icon_dict[ch.type] - items.append((str(i + 2), text_ch_name, '', lib.get_icon(icon_name), i + 2)) - else: items.append((str(i + 2), text_ch_name, '', lib.channel_icon_dict[ch.type], i + 2)) + icon_name = lib.channel_custom_icon_dict[ch.type] + items.append((str(i + 2), text_ch_name, '', lib.get_icon(icon_name), i + 2)) return items @@ -2012,10 +2010,8 @@ def merge_channel_items(self, context): counter = 0 for i, ch in enumerate(yp.channels): if not layer.channels[i].enable: continue - if hasattr(lib, 'custom_icons'): - icon_name = lib.channel_custom_icon_dict[ch.type] - items.append((str(i), ch.name, '', lib.get_icon(icon_name), counter)) - else: items.append((str(i), ch.name, '', lib.channel_icon_dict[ch.type], counter)) + icon_name = lib.channel_custom_icon_dict[ch.type] + items.append((str(i), ch.name, '', lib.get_icon(icon_name), counter)) counter += 1 return items diff --git a/Layer.py b/Layer.py index 346c50b3..a776758b 100644 --- a/Layer.py +++ b/Layer.py @@ -20,18 +20,12 @@ def channel_items(self, context): items = [] for i, ch in enumerate(yp.channels): - #if hasattr(lib, 'custom_icons'): # Add two spaces to prevent text from being translated text_ch_name = ch.name + ' ' - if not is_bl_newer_than(2, 80): - icon_name = lib.channel_custom_icon_dict[ch.type] - items.append((str(i), text_ch_name, '', lib.get_icon(icon_name), i)) - else: items.append((str(i), text_ch_name, '', lib.channel_icon_dict[ch.type], i)) - - #if hasattr(lib, 'custom_icons'): - if not is_bl_newer_than(2, 80): - items.append(('-1', 'All Channels', '', lib.get_icon('channels'), len(items))) - else: items.append(('-1', 'All Channels', '', 'GROUP_VERTEX', len(items))) + icon_name = lib.channel_custom_icon_dict[ch.type] + items.append((str(i), text_ch_name, '', lib.get_icon(icon_name), i)) + + items.append(('-1', 'All Channels', '', lib.get_icon('channels'), len(items))) return items diff --git a/Root.py b/Root.py index 561a3131..aeb97eca 100644 --- a/Root.py +++ b/Root.py @@ -2561,27 +2561,11 @@ def remove_preview(mat, advanced=False): # pass def layer_preview_mode_type_items(self, context): - #node = get_active_ypaint_node() - #yp = node.node_tree.yp - items = ( ('LAYER', 'Layer', '', lib.get_icon('texture'), 0), ('MASK', 'Mask', '', lib.get_icon('mask'), 1), ('SPECIFIC_MASK', 'Specific Mask', '', lib.get_icon('mask'), 2) ) - - #for i, ch in enumerate(yp.channels): - # #if hasattr(lib, 'custom_icons'): - # if not is_bl_newer_than(2, 80): - # icon_name = lib.channel_custom_icon_dict[ch.type] - # items.append((str(i), ch.name, '', lib.custom_icons[icon_name].icon_id, i)) - # else: items.append((str(i), ch.name, '', lib.channel_icon_dict[ch.type], i)) - - ##if hasattr(lib, 'custom_icons'): - #if not is_bl_newer_than(2, 80): - # items.append(('-1', 'All Channels', '', lib.custom_icons['channels'].icon_id, len(items))) - #else: items.append(('-1', 'All Channels', '', 'GROUP_VERTEX', len(items))) - return items def update_layer_preview_mode(self, context): diff --git a/lib.py b/lib.py index 34ac0acd..77b8f7c4 100644 --- a/lib.py +++ b/lib.py @@ -229,12 +229,6 @@ 'NORMAL' : 'vector_channel', } -channel_icon_dict = { - 'RGB' : 'KEYTYPE_KEYFRAME_VEC', - 'VALUE' : 'HANDLETYPE_FREE_VEC', - 'NORMAL' : 'KEYTYPE_BREAKDOWN_VEC', -} - def get_icon_folder(): if not is_bl_newer_than(2, 80): icon_set = 'legacy' diff --git a/ui.py b/ui.py index 99642fa0..15f41ade 100644 --- a/ui.py +++ b/ui.py @@ -953,8 +953,6 @@ def draw_root_channels_ui(context, layout, node): else: icon_name = 'collapsed_' + icon_name icon_value = lib.get_icon(icon_name) row.prop(chui, 'expand_content', text='', emboss=False, icon_value=icon_value) - #else: - # row.prop(chui, 'expand_content', text='', emboss=True, icon=lib.channel_icon_dict[channel.type]) row.label(text=channel.name + ' ' + pgettext_iface('Channel'))