On branch feat/godot-configurator

Changes to be committed:
 modified:   tools/configurator/data_list.json
	modified:   tools/configurator/export/configurator.pck
	deleted:    tools/configurator/export/tk_about.txt
	modified:   tools/configurator/main.gd
	modified:   tools/configurator/project.godot
	modified:   tools/configurator/res/pixel_ui_theme/RetroDECKTheme.tres
	modified:   tools/configurator/scripts/data_handler.gd
	modified:   tools/configurator/scripts/emulator_property.gd
	modified:   tools/configurator/tk_about.gd

	tools/configurator/export/data_list.json
This commit is contained in:
monkeyx-net 2024-08-01 17:03:20 +01:00
parent 058fe166c5
commit ec5059b6ea
9 changed files with 500 additions and 425 deletions

View file

@ -1,45 +1,50 @@
{ {
"about_links": { "about_links": {
"rd_web": { "example_site": {
"name": "Website", "description": "An example description.",
"url": "https://retrodeck.net/", "name": "Example Site",
"description": "Opens the RetroDECK Website in your default browser" "url": "https://example.com"
}, },
"rd_changelog": { "rd_changelog": {
"description": "Opens the RetroDECK change log in your default browser",
"name": "Changelog", "name": "Changelog",
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_rd_versions/version-history/", "url": "https://retrodeck.readthedocs.io/en/latest/wiki_rd_versions/version-history/"
"description": "Opens the RetroDECK change log in your default browser"
},
"rd_wiki":{
"name": "Wiki",
"url": "https://retrodeck.readthedocs.io/en/latest/",
"description": "Opens the RetroDECK Wiki in your default browser"
},
"rd_credits": {
"name": "Credits",
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/",
"description": "Opens the RetroDECK Credits in your default browser"
},
"rd_donate": {
"name": "Donate",
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/",
"description": "Opens Donations page in your default browser"
}, },
"rd_contactus": { "rd_contactus": {
"description": "Opens the RetroDECK contact us section in your default browser",
"name": "Contact us", "name": "Contact us",
"url": "https://github.com/XargonWan/RetroDECK", "url": "https://github.com/XargonWan/RetroDECK"
"description": "Opens the RetroDECK contact us section in your default browser" },
"rd_credits": {
"description": "Opens the RetroDECK Credits in your default browser",
"name": "Credits",
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/"
},
"rd_donate": {
"description": "Opens Donations page in your default browser",
"name": "Donate",
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/"
}, },
"rd_licenses": { "rd_licenses": {
"description": "Opens the RetroDECK licenses in your default browser",
"name": "Licences", "name": "Licences",
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/", "url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/"
"description": "Opens the RetroDECK licenses in your default browser" },
"rd_web": {
"description": "Opens the RetroDECK Website in your default browser",
"name": "Website",
"url": "https://retrodeck.net/"
},
"rd_wiki": {
"description": "Opens the RetroDECK Wiki in your default browser",
"name": "Wiki",
"url": "https://retrodeck.readthedocs.io/en/latest/"
} }
}, },
"emulators": { "emulators": {
"cemu": { "cemu": {
"name": "Cemu",
"description": "Wii U emulator", "description": "Wii U emulator",
"name": "Cemu",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -57,8 +62,8 @@
] ]
}, },
"citra": { "citra": {
"name": "Citra",
"description": "N3DS emulator", "description": "N3DS emulator",
"name": "Citra",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -76,8 +81,8 @@
] ]
}, },
"dolphin": { "dolphin": {
"name": "Dolphin",
"description": "Wii/GameCube emulator", "description": "Wii/GameCube emulator",
"name": "Dolphin",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -95,8 +100,8 @@
] ]
}, },
"duckstation": { "duckstation": {
"name": "Duckstation",
"description": "PSX emulator", "description": "PSX emulator",
"name": "Duckstation",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -113,9 +118,26 @@
} }
] ]
}, },
"example_emulator": {
"description": "An example emulator.",
"name": "Example Emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"abxy_button": {
"status": false
},
"standalone": true
}
]
},
"gzdoom": { "gzdoom": {
"name": "GZDoom",
"description": "Doom engine", "description": "Doom engine",
"name": "GZDoom",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -133,8 +155,8 @@
] ]
}, },
"mame": { "mame": {
"name": "MAME",
"description": "Multiple Arcade Machine Emulator", "description": "Multiple Arcade Machine Emulator",
"name": "MAME",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -152,8 +174,8 @@
] ]
}, },
"melonds": { "melonds": {
"name": "MelonDS",
"description": "NDS emulator", "description": "NDS emulator",
"name": "MelonDS",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -171,8 +193,8 @@
] ]
}, },
"pcsx2": { "pcsx2": {
"name": "PCSX2",
"description": "PS2 emulator", "description": "PS2 emulator",
"name": "PCSX2",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -190,8 +212,8 @@
] ]
}, },
"ppsspp": { "ppsspp": {
"name": "PPSSPP",
"description": "PSP emulator", "description": "PSP emulator",
"name": "PPSSPP",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -209,8 +231,8 @@
] ]
}, },
"primehack": { "primehack": {
"name": "Primehack",
"description": "Metroid Prime emulator", "description": "Metroid Prime emulator",
"name": "Primehack",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -228,8 +250,8 @@
] ]
}, },
"rpcs3": { "rpcs3": {
"name": "RPCS3",
"description": "PS3 emulator", "description": "PS3 emulator",
"name": "RPCS3",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -247,8 +269,8 @@
] ]
}, },
"ryujinx": { "ryujinx": {
"name": "Ryujinx",
"description": "Switch emulator", "description": "Switch emulator",
"name": "Ryujinx",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -266,8 +288,8 @@
] ]
}, },
"vita3k": { "vita3k": {
"name": "Vita3k",
"description": "PS Vita emulator", "description": "PS Vita emulator",
"name": "Vita3k",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -285,8 +307,8 @@
] ]
}, },
"xemu": { "xemu": {
"name": "XEMU",
"description": "XBOX emulator", "description": "XBOX emulator",
"name": "XEMU",
"options": [ "options": [
{ {
"resettable": true "resettable": true
@ -304,8 +326,8 @@
] ]
}, },
"yuzu": { "yuzu": {
"name": "Yuzu",
"description": "Switch emulator", "description": "Switch emulator",
"name": "Yuzu",
"options": [ "options": [
{ {
"resettable": true "resettable": true

View file

@ -1,8 +0,0 @@
ID,URL,Description
rd_web,https://retrodeck.net/,Opens the RetroDECK Website in your default browser
rd_changelog,https://retrodeck.readthedocs.io/en/latest/wiki_rd_versions/version-history/,Opens the RetroDECK change log in your default browser
rd_wiki,https://retrodeck.readthedocs.io/en/latest/,Opens the RetroDECK Wiki in your default browser
rd_credits,https://retrodeck.readthedocs.io/en/latest/,Opens the RetroDECK Credits in your default browser
rd_donate,https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/,Opens Donations in your default browser
rd_contactus,https://github.com/XargonWan/RetroDECK,Opens the RetroDECK contact us section in your default browser
rd_licenses,https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/,Opens the RetroDECK licenses in your default browser

View file

@ -15,16 +15,41 @@ var emu_pick_option: OptionButton
var tab_container: TabContainer var tab_container: TabContainer
var anim_logo: AnimatedSprite2D var anim_logo: AnimatedSprite2D
var anim_rekku: AnimatedSprite2D var anim_rekku: AnimatedSprite2D
#var data_handler: DataHandler
var player =[] var app_data = AppData.new()
func _ready(): func _ready():
_get_nodes() _get_nodes()
_connect_signals() _connect_signals()
_play_main_animations() _play_main_animations()
#print(save_manager.data)#["name"]["unlock_goal"]) #print(save_manager.data["about_links"]["rd_web"]["name"], " ", save_manager.data["about_links"]["rd_web"]["url"])
print(save_manager.data["about_links"]["rd_web"]["name"], " ", save_manager.data["about_links"]["rd_web"]["url"]) #print(save_manager.data["emulators"]["mame"]["name"], " ", save_manager.data["emulators"]["mame"]["description"])
print(save_manager.data["emulators"]["mame"]["name"], " ", save_manager.data["emulators"]["mame"]["description"])
# Populate app_data with some test data
var link = Link.new()
link.name = "Example Site"
link.url = "https://example.com"
link.description = "An example description."
app_data.about_links["example_site"] = link
var emulator = Emulator.new()
emulator.name = "Example Emulator"
emulator.description = "An example emulator."
var option = EmulatorOption.new()
option.resettable = true
emulator.options.append(option)
var property = EmulatorProperty.new()
property.standalone = true
property.abxy_button_status = false
emulator.properties.append(property)
app_data.emulators["example_emulator"] = emulator
data_handler.save_data(app_data)
var app_data = data_handler.load_data()
if app_data:
var website_link = app_data.about_links["rd_web"]
print (website_link.name,"-",website_link.url,"-",website_link.description)
var emulator_list = class_functions.get_text_file_from_system_path("../../tools/configurator.sh","sed -n '/local emulator_list=(/,/)/{s/.*local emulator_list=\\(.*\\)/\\1/; /)/q; p}' ","emulist") var emulator_list = class_functions.get_text_file_from_system_path("../../tools/configurator.sh","sed -n '/local emulator_list=(/,/)/{s/.*local emulator_list=\\(.*\\)/\\1/; /)/q; p}' ","emulist")
#print (emulator_list) #print (emulator_list)

View file

@ -21,6 +21,7 @@ config/icon="res://icon.svg"
class_functions="*res://scripts/class_functions.gd" class_functions="*res://scripts/class_functions.gd"
save_manager="*res://scripts/save_manager.gd" save_manager="*res://scripts/save_manager.gd"
data_handler="*res://scripts/data_handler.gd"
[display] [display]

File diff suppressed because one or more lines are too long

View file

@ -2,7 +2,7 @@ extends Node
class_name DataHandler class_name DataHandler
var data_file_path = "res://data.json" var data_file_path = "res://data_list.json"
var app_data: AppData var app_data: AppData
func _ready(): func _ready():
@ -14,11 +14,11 @@ func load_data() -> AppData:
if file: if file:
var json_data = file.get_as_text() var json_data = file.get_as_text()
file.close() file.close()
var json = JSON.new() var json = JSON.new()
var parsed_data = json.parse(json_data) var parsed_data = json.parse_string(json_data)
if parsed_data.error == OK: #if parsed_data.error == OK:
var data_dict = parsed_data.result if parsed_data:
var data_dict = parsed_data
var about_links = {} var about_links = {}
for key in data_dict["about_links"].keys(): for key in data_dict["about_links"].keys():
@ -36,16 +36,17 @@ func load_data() -> AppData:
emulator.name = emulator_data["name"] emulator.name = emulator_data["name"]
emulator.description = emulator_data["description"] emulator.description = emulator_data["description"]
emulator.options = [] #emulator.options = []
#emulator.properties = []
for option_data in emulator_data["options"]: for option_data in emulator_data["options"]:
var option = EmulatorOption.new() var option = EmulatorOption.new()
option.resettable = option_data["resettable"] option.resettable = option_data["resettable"]
emulator.options.append(option) emulator.options.append(option)
emulator.properties = []
for property_data in emulator_data["properties"]: for property_data in emulator_data["properties"]:
var property = EmulatorProperty.new() var property = EmulatorProperty.new()
property.standalone = property_data["standalone"] property.standalone = property_data.get("standalone", false)
property.abxy_button_status = property_data.get("abxy_button", {}).get("status", false) property.abxy_button_status = property_data.get("abxy_button", {}).get("status", false)
emulator.properties.append(property) emulator.properties.append(property)
@ -63,10 +64,16 @@ func load_data() -> AppData:
return null return null
func save_data(app_data: AppData): func save_data(app_data: AppData):
var file = FileAccess.open(data_file_path, FileAccess.WRITE) var file = FileAccess.open(data_file_path, FileAccess.READ)
var existing_data = {}
if file: if file:
var data_dict = {} var json = JSON.new()
var error = json.parse(file.get_as_text())
if error == OK:
existing_data = json.get_data()
file.close()
else:
print("File not found. Creating a new one.")
var about_links = {} var about_links = {}
for key in app_data.about_links.keys(): for key in app_data.about_links.keys():
var link = app_data.about_links[key] var link = app_data.about_links[key]
@ -76,6 +83,18 @@ func save_data(app_data: AppData):
"description": link.description "description": link.description
} }
var new_data_dict = {}
# Convert about_links to a dictionary
var about_links = {}
for key in app_data.about_links.keys():
var link = app_data.about_links[key]
about_links[key] = {
"name": link.name,
"url": link.url,
"description": link.description
}
# Convert emulators to a dictionary
var emulators = {} var emulators = {}
for key in app_data.emulators.keys(): for key in app_data.emulators.keys():
var emulator = app_data.emulators[key] var emulator = app_data.emulators[key]
@ -99,10 +118,26 @@ func save_data(app_data: AppData):
"properties": properties "properties": properties
} }
data_dict["about_links"] = about_links new_data_dict["about_links"] = about_links
data_dict["emulators"] = emulators new_data_dict["emulators"] = emulators
var json = JSON.new() # Merge existing data with new data
var json_text = json.print(data_dict) for key in new_data_dict.keys():
if existing_data.has(key):
var existing_dict = existing_data[key]
var new_dict = new_data_dict[key]
# Merge dictionaries
for sub_key in new_dict.keys():
existing_dict[sub_key] = new_dict[sub_key]
else:
existing_data[key] = new_data_dict[key]
# Serialize the combined data to JSON
var json_text = JSON.new().stringify(existing_data, "\t")
# Open the file in append mode and write the new JSON data
file = FileAccess.open(data_file_path, FileAccess.WRITE)
file.store_string(json_text) file.store_string(json_text)
file.close() file.close()
print("Data appended successfully")

View file

@ -1,5 +1,5 @@
extends Resource extends Resource
class_name EmulatorProperty class_name EmulatorProperty
@export var standalone: bool @export var standalone: bool
@export var abxy_button_status: bool = false @export var abxy_button_status: bool

View file

@ -16,7 +16,7 @@ func _ready():
#class_functions = ClassFunctions.new() #class_functions = ClassFunctions.new()
#tk_about = class_functions._import_data_lists("res://tk_about.txt") #tk_about = class_functions._import_data_lists("res://tk_about.txt")
tk_about = class_functions.import_csv_data("tk_about.txt") tk_about = class_functions.import_csv_data("res://tk_about.txt")
_get_nodes() _get_nodes()
_connect_signals() _connect_signals()