浏览代码

fixed bug with save and load not restoring all slider values, check buttons and option buttons

Jonathan Higgins 6 月之前
父节点
当前提交
19c49b2fd3
共有 2 个文件被更改,包括 33 次插入2 次删除
  1. 9 0
      scenes/main/scripts/graph_edit.gd
  2. 24 2
      scenes/main/scripts/save_load.gd

+ 9 - 0
scenes/main/scripts/graph_edit.gd

@@ -138,6 +138,9 @@ func _make_node(command: String, skip_undo_redo := false) -> GraphNode:
 						var slider_label = param_data.get("paramname", "")
 						var slider_tooltip  = param_data.get("paramdescription", "")
 						
+						#name slider
+						slider.name = slider_label.replace(" ", "")
+						
 						#get slider properties
 						var brk = param_data.get("automatable", false)
 						var time = param_data.get("time", false)
@@ -193,6 +196,9 @@ func _make_node(command: String, skip_undo_redo := false) -> GraphNode:
 						var checkbutton_label = param_data.get("paramname", "")
 						var checkbutton_tooltip  = param_data.get("paramdescription", "")
 						
+						#name checkbutton
+						checkbutton.name = checkbutton_label.replace(" ", "")
+						
 						#get checkbutton properties
 						var flag = param_data.get("flag", "")
 						
@@ -218,6 +224,9 @@ func _make_node(command: String, skip_undo_redo := false) -> GraphNode:
 						var optionbutton_label = param_data.get("paramname", "")
 						var optionbutton_tooltip  = param_data.get("paramdescription", "")
 						
+						#name optionbutton
+						optionbutton.name = optionbutton_label.replace(" ", "")
+						
 						#get optionbutton properties
 						var options = JSON.parse_string(param_data.get("step", ""))
 						var value = param_data.get("value", 1)

+ 24 - 2
scenes/main/scripts/save_load.gd

@@ -44,7 +44,9 @@ func save_graph_edit(path: String):
 				"command": node.get_meta("command"),
 				"offset": { "x": offset.x, "y": offset.y },
 				"slider_values": {},
-				"notes": {}
+				"notes": {},
+				"checkbutton_states": {},
+				"optionbutton_values": {}
 			}
 
 			# Save slider values and metadata
@@ -63,7 +65,15 @@ func save_graph_edit(path: String):
 			# Save notes from CodeEdit children
 			for child in node.find_children("*", "CodeEdit", true, false):
 				node_data["notes"][child.name] = child.text
-
+			
+			#save checkbutton states
+			for child in node.find_children("*", "CheckButton", true, false):
+				node_data["checkbutton_states"][child.name] = child.button_pressed
+			
+			#save optionbutton states
+			for child in node.find_children("*", "OptionButton", true, false):
+				node_data["optionbutton_values"][child.name] = child.selected
+				
 			node_data_list.append(node_data)
 			node_id += 1
 
@@ -168,6 +178,18 @@ func load_graph_edit(path: String):
 			var codeedit = new_node.find_child(codeedit_name, true, false)
 			if codeedit and (codeedit is CodeEdit):
 				codeedit.text = node_data["notes"][codeedit_name]
+				
+		# Restore check buttons
+		for checkbutton_name in node_data["checkbutton_states"]:
+			var checkbutton = new_node.find_child(checkbutton_name, true, false)
+			if checkbutton and (checkbutton is CheckButton):
+				checkbutton.button_pressed = node_data["checkbutton_states"][checkbutton_name]
+					
+		# Restore option buttons
+		for optionbutton_name in node_data["optionbutton_values"]:
+			var optionbutton = new_node.find_child(optionbutton_name, true, false)
+			if optionbutton and (optionbutton is OptionButton):
+				optionbutton.selected = node_data["optionbutton_values"][optionbutton_name]
 
 		register_input.call(new_node)