mirror of
				https://github.com/RetroDECK/RetroDECK.git
				synced 2025-04-10 19:15:12 +00:00 
			
		
		
		
	Now includes modify json. Need cleaning up!
On branch feat/godot-configurator Changes to be committed: modified: tools/configurator/data_list.json modified: tools/configurator/export/configurator.pck modified: tools/configurator/main.gd modified: tools/configurator/res/pixel_ui_theme/RetroDECKTheme.tres modified: tools/configurator/scripts/data_handler.gd
This commit is contained in:
		
							parent
							
								
									149a725e04
								
							
						
					
					
						commit
						d20b4dbf5d
					
				|  | @ -1,9 +1,9 @@ | |||
| { | ||||
| 	"about_links": { | ||||
| 		"example_site": { | ||||
| 			"description": "An example description.", | ||||
| 			"name": "Example Site", | ||||
| 			"url": "https://example.com" | ||||
| 			"description": "Updated description.", | ||||
| 			"name": "Updated Site", | ||||
| 			"url": "https://updated-example.com" | ||||
| 		}, | ||||
| 		"rd_changelog": { | ||||
| 			"description": "Opens the RetroDECK change log in your default browser", | ||||
|  | @ -52,12 +52,16 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -71,12 +75,16 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -90,12 +98,16 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -109,29 +121,33 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
| 		"example_emulator": { | ||||
| 			"description": "An example emulator.", | ||||
| 			"name": "Example Emulator", | ||||
| 			"description": "Updated description", | ||||
| 			"name": "Updated Emulator", | ||||
| 			"options": [ | ||||
| 				{ | ||||
| 					"resettable": true | ||||
| 					"resettable": false | ||||
| 				} | ||||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 						"status": true | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -145,12 +161,16 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -164,12 +184,16 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -183,12 +207,16 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -202,12 +230,16 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -221,12 +253,16 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -240,12 +276,16 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -259,12 +299,16 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -278,12 +322,16 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -297,12 +345,16 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -316,12 +368,16 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		}, | ||||
|  | @ -335,14 +391,18 @@ | |||
| 			], | ||||
| 			"properties": [ | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					}, | ||||
| 					"standalone": true | ||||
| 				}, | ||||
| 				{ | ||||
| 					"abxy_button": { | ||||
| 						"status": false | ||||
| 					} | ||||
| 					}, | ||||
| 					"standalone": false | ||||
| 				} | ||||
| 			] | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| } | ||||
										
											Binary file not shown.
										
									
								
							|  | @ -45,6 +45,21 @@ func _ready(): | |||
| 	app_data.emulators["example_emulator"] = emulator | ||||
| 
 | ||||
| 	data_handler.save_data(app_data) | ||||
| 	 # Example test cases for modifying data | ||||
| 	data_handler.modify_link("example_site", "Updated Site", "https://updated-example.com", "Updated description.") | ||||
| 
 | ||||
| 	var new_options = [] | ||||
| 	var new_option = EmulatorOption.new() | ||||
| 	new_option.resettable = false | ||||
| 	new_options.append(new_option) | ||||
| 
 | ||||
| 	var new_properties = [] | ||||
| 	var new_property = EmulatorProperty.new() | ||||
| 	new_property.standalone = false | ||||
| 	new_property.abxy_button_status = true | ||||
| 	new_properties.append(new_property) | ||||
| 
 | ||||
| 	data_handler.modify_emulator("example_emulator", "Updated Emulator", "Updated description", new_options, new_properties) | ||||
| 	 | ||||
| 	var app_data = data_handler.load_data() | ||||
| 	if app_data: | ||||
|  |  | |||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							|  | @ -141,3 +141,45 @@ func save_data(app_data: AppData): | |||
| 	file.store_string(json_text) | ||||
| 	file.close() | ||||
| 	print("Data appended successfully") | ||||
| # Function to modify an existing link | ||||
| func modify_link(key: String, new_name: String, new_url: String, new_description: String): | ||||
| 	var app_data = load_data() | ||||
| 	if app_data and app_data.about_links.has(key): | ||||
| 		var link = app_data.about_links[key] | ||||
| 		link.name = new_name | ||||
| 		link.url = new_url | ||||
| 		link.description = new_description | ||||
| 		app_data.about_links[key] = link | ||||
| 		save_data(app_data) | ||||
| 		print("Link modified successfully") | ||||
| 	else: | ||||
| 		print("Link not found") | ||||
| 
 | ||||
| # Function to modify an existing emulator | ||||
| func modify_emulator(key: String, new_name: String, new_description: String, new_options: Array, new_properties: Array): | ||||
| 	var app_data = load_data() | ||||
| 	if app_data and app_data.emulators.has(key): | ||||
| 		var emulator = app_data.emulators[key] | ||||
| 		emulator.name = new_name | ||||
| 		emulator.description = new_description | ||||
| 		 | ||||
| 		# Update options | ||||
| 		emulator.options.clear() | ||||
| 		for option in new_options: | ||||
| 			var new_option = EmulatorOption.new() | ||||
| 			new_option.resettable = option.resettable | ||||
| 			emulator.options.append(new_option) | ||||
| 
 | ||||
| 		# Update properties | ||||
| 		emulator.properties.clear() | ||||
| 		for property in new_properties: | ||||
| 			var new_property = EmulatorProperty.new() | ||||
| 			new_property.standalone = property.standalone | ||||
| 			new_property.abxy_button_status = property.abxy_button_status | ||||
| 			emulator.properties.append(new_property) | ||||
| 
 | ||||
| 		app_data.emulators[key] = emulator | ||||
| 		save_data(app_data) | ||||
| 		print("Emulator modified successfully") | ||||
| 	else: | ||||
| 		print("Emulator not found") | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 monkeyx-net
						monkeyx-net