RetroDECK/tools/configurator/scripts/save_manager.gd
monkeyx-net 058fe166c5 Adding json support and supporting class
On branch feat/godot-configurator
 Changes to be committed:
	deleted:    tools/configurator/basic
	new file:   tools/configurator/data.json
	modified:   tools/configurator/data_list.json
	modified:   tools/configurator/main.gd
	modified:   tools/configurator/project.godot
	modified:   tools/configurator/res/pixel_ui_theme/RetroDECKTheme.tres
	new file:   tools/configurator/scripts/app_data.gd
	modified:   tools/configurator/scripts/class_functions.gd
	new file:   tools/configurator/scripts/data_handler.gd
	new file:   tools/configurator/scripts/emulator.gd
	new file:   tools/configurator/scripts/emulator_option.gd
	new file:   tools/configurator/scripts/emulator_property.gd
	new file:   tools/configurator/scripts/link.gd
	new file:   tools/configurator/scripts/save_manager.gd
2024-08-01 14:33:58 +01:00

31 lines
698 B
GDScript

extends Node
var json: JSON = JSON.new()
#var path: String = "res://data.json"
var path: String = "res://data_list.json"
var data = {}
func write_json(content):
var file = FileAccess.open(path, FileAccess.WRITE)
file.store_string(json.stringify(content))
file.close()
file = null
func read_json():
var file = FileAccess.open(path, FileAccess.READ)
var content = json.parse_string(file.get_as_text())
if data is Dictionary:
return content
else:
print ("Error")
func create_new_json_file():
var file = FileAccess.open("res://test.json",FileAccess.READ)
var content = json.parse_string(file.get_as_text())
data = content
write_json(content)
func _ready ():
data = read_json()