Skip to content

Commit ae62e67

Browse files
committed
Remove Malt custom node search
Broken and no longer required.
1 parent 8fd7ef2 commit ae62e67

File tree

1 file changed

+0
-99
lines changed

1 file changed

+0
-99
lines changed

BlenderMalt/MaltNodes/MaltNodeUITools.py

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -344,108 +344,13 @@ def execute(self, context: bpy.types.Context):
344344
return{'FINISHED'}
345345

346346

347-
# Blender 3.4 changed the way add_search works and broke NodeItems searches
348-
# See https://developer.blender.org/T103108
349-
# This is a copy of the 3.3 NODE_OT_add_search operator so we can get the functionality back
350-
from bl_operators.node import *
351-
class NODE_OT_malt_add_search(NodeAddOperator, Operator):
352-
'''Add a node to the active tree'''
353-
bl_idname = "node.malt_add_search"
354-
bl_label = "Search and Add Node"
355-
bl_options = {'REGISTER', 'UNDO'}
356-
bl_property = "node_item"
357-
358-
@classmethod
359-
def poll(cls, context):
360-
return is_malt_tree_context(context)
361-
362-
_enum_item_hack = []
363-
364-
# Create an enum list from node items
365-
def node_enum_items(self, context):
366-
import nodeitems_utils
367-
368-
enum_items = NODE_OT_malt_add_search._enum_item_hack
369-
enum_items.clear()
370-
371-
for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
372-
if isinstance(item, nodeitems_utils.NodeItem):
373-
enum_items.append(
374-
(str(index),
375-
item.label,
376-
"",
377-
index,
378-
))
379-
return enum_items
380-
381-
# Look up the item based on index
382-
def find_node_item(self, context):
383-
import nodeitems_utils
384-
385-
node_item = int(self.node_item)
386-
for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
387-
if index == node_item:
388-
return item
389-
return None
390-
391-
node_item: bpy.props.EnumProperty(
392-
name="Node Type",
393-
description="Node type",
394-
items=node_enum_items,
395-
)
396-
397-
def execute(self, context):
398-
item = self.find_node_item(context)
399-
400-
# no need to keep
401-
self._enum_item_hack.clear()
402-
403-
if item:
404-
# apply settings from the node item
405-
for setting in item.settings.items():
406-
ops = self.settings.add()
407-
ops.name = setting[0]
408-
ops.value = setting[1]
409-
410-
self.create_node(context, item.nodetype)
411-
412-
if self.use_transform:
413-
bpy.ops.node.translate_attach_remove_on_cancel(
414-
'INVOKE_DEFAULT')
415-
416-
return {'FINISHED'}
417-
else:
418-
return {'CANCELLED'}
419-
420-
def invoke(self, context, event):
421-
self.store_mouse_cursor(context, event)
422-
# Delayed execution in the search popup
423-
context.window_manager.invoke_search_popup(self)
424-
return {'CANCELLED'}
425-
426-
def draw_malt_add_search_menu(menu, context):
427-
if context.area.ui_type != 'MaltTree':
428-
return
429-
layout = menu.layout
430-
if is_malt_tree_context(context) == False:
431-
layout.label(text="No node tree selected", icon='ERROR')
432-
elif context.space_data.edit_tree.graph_type == '':
433-
layout.label(text="No node tree type selected", icon='ERROR')
434-
else:
435-
row = layout.row()
436-
row.operator_context = "INVOKE_DEFAULT"
437-
operator = row.operator("node.malt_add_search", text="Search... (Malt)", icon='VIEW_ZOOM')
438-
operator.use_transform = True
439-
440-
441347
classes = [
442348
NodeTreePreview,
443349
OT_MaltEditNodeTree,
444350
OT_MaltSetTreePreview,
445351
OT_MaltConnectTreePreview,
446352
OT_MaltCycleSubCategories,
447353
NODE_OT_add_malt_subcategory_node,
448-
NODE_OT_malt_add_search,
449354
]
450355

451356
class MaltNodeDrawCallbacks:
@@ -553,12 +458,8 @@ def register():
553458
NodeTree.tree_preview = PointerProperty(type=NodeTreePreview, name='Node Tree Preview',
554459
options={'LIBRARY_EDITABLE'}, override={'LIBRARY_OVERRIDABLE'})
555460

556-
bpy.types.NODE_MT_add.prepend(draw_malt_add_search_menu)
557-
558461

559462
def unregister():
560-
bpy.types.NODE_MT_add.remove(draw_malt_add_search_menu)
561-
562463
del NodeTree.tree_preview
563464

564465
for km, kmi in keymaps:

0 commit comments

Comments
 (0)