Parcourir la source

Handle Quotes in overlay

nodespaghetti il y a 4 semaines
Parent
commit
58fac0c637
3 fichiers modifiés avec 35 ajouts et 18 suppressions
  1. 7 1
      execution/readtree.py
  2. 11 0
      utilities/utilities.py
  3. 17 17
      versioning.py

+ 7 - 1
execution/readtree.py

@@ -269,11 +269,17 @@ def node_scan_overlays(node, socket_id,):
                 overlay_keys.add(input.name)
     # sort by reverse length so we find "CatsAndFrogs" before "Cats"
     overlay_keys = sorted(overlay_keys, key= lambda a :-1*len(a))
-    overlay_tries = value.split("$")
+    # First I need to break it into substrings based on quotation marks
+    from ..utilities.utilities import split_quoted_substrings_to_strings
+    quoted_substrings = split_quoted_substrings_to_strings(value)
+    overlay_tries = []
+    for quoted_substring in  quoted_substrings:
+        overlay_tries.extend(quoted_substring.split("$"))
     result = overlay_tries[0] # the 0th element is always before the split character
     # the reason for the difference between overlay_try and key is because
     #  we don't actually know if the $text part has a key in it
     for overlay_try in overlay_tries[1:]:
+        if not overlay_try: continue # some of these are empty
         overlay_resolved_value = "$" + overlay_try
         for key in overlay_keys:
             if key in overlay_try:

+ 11 - 0
utilities/utilities.py

@@ -100,6 +100,17 @@ def tree_from_mantis_node(sig, base_tree):
 def get_ui_node(sig, base_tree):
     return tree_from_mantis_node(sig, base_tree).nodes.get( sig[-1] )
 
+# Function for splitting up 
+def split_quoted_substrings_to_strings(text):
+    import re
+    pattern = r'''(?:"([^"]*)"|'([^']*)'|([^"']+))'''
+    substrings = [
+        next(group for group in match.groups() if group is not None)
+        for match in re.finditer(pattern, text)
+    ]
+    return substrings
+
+
 
 ##################################################################################################
 # groups and changing sockets -- this is used extensively by Schema.

+ 17 - 17
versioning.py

@@ -523,20 +523,20 @@ def add_new_display_features_v0_13_5(*args, **kwargs):
                 node.is_updating = False
         tree.do_live_update = live_updates
 
-def up_0_13_5_modes_for_matrix_from_curve_and_compose_matrix(*args, **kwargs):
-    node = kwargs['node']
-    node.is_updating = True
-    do_live_updates = node.id_data.do_live_updates
-    node.id_data.do_live_updates = False
-    # new re_init keyword should use socket template to automate the update.
-    prGreen("THIS ONE HERE")
-    print (node.id_data.name, node.name)
-    print (node.inputs.keys())
-    if "Mode" not in node.inputs.keys(): # just check here to see if it is needed.
-        prOrange("DOING THE THING BRO")
-        node.init_sockets(node.__class__.socket_templates, re_init=True)
-    node.id_data.do_live_updates = do_live_updates
-    node.is_updating = False
+# def up_0_13_5_modes_for_matrix_from_curve_and_compose_matrix(*args, **kwargs):
+#     node = kwargs['node']
+#     node.is_updating = True
+#     do_live_updates = node.id_data.do_live_updates
+#     node.id_data.do_live_updates = False
+#     # new re_init keyword should use socket template to automate the update.
+#     prGreen("THIS ONE HERE")
+#     print (node.id_data.name, node.name)
+#     print (node.inputs.keys())
+#     if "Mode" not in node.inputs.keys(): # just check here to see if it is needed.
+#         prOrange("DOING THE THING BRO")
+#         node.init_sockets(node.__class__.socket_templates, re_init=True)
+#     node.id_data.do_live_updates = do_live_updates
+#     node.is_updating = False
 
 # versioning tasks that involve Blender versions rather than Mantis versions:
 error_description_4_5_0_LTS = 'There is a bug in Blender 4.5.0 LTS, that is why these sockets are blue.'\
@@ -576,9 +576,9 @@ versioning_tasks = [
            update_fcurve_and_armature_node_to_multi_socket, ['node']),
     (['MantisTree', 'SchemaTree'], fix_bbone_default_scale_in_and_out, ['tree']),
     (['MantisTree', 'SchemaTree'], add_new_display_features_v0_13_5, ['tree']),
-    (['UtilityMatrixFromCurve', 'UtilityMatrixCompose'],
-       up_0_13_5_modes_for_matrix_from_curve_and_compose_matrix,
-     ['node',], ),
+    # (['UtilityMatrixFromCurve', 'UtilityMatrixCompose'],
+    #    up_0_13_5_modes_for_matrix_from_curve_and_compose_matrix,
+    #  ['node',], ),
 ]