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,326 +1,348 @@
{ {
"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": {
"description": "Opens the RetroDECK change log in your default browser",
"name": "Changelog",
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_rd_versions/version-history/"
},
"rd_contactus": {
"description": "Opens the RetroDECK contact us section in your default browser",
"name": "Contact us",
"url": "https://github.com/XargonWan/RetroDECK"
},
"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": {
"description": "Opens the RetroDECK licenses in your default browser",
"name": "Licences",
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/"
},
"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/"
}
}, },
"rd_changelog": { "emulators": {
"name": "Changelog", "cemu": {
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_rd_versions/version-history/", "description": "Wii U emulator",
"description": "Opens the RetroDECK change log in your default browser" "name": "Cemu",
}, "options": [
"rd_wiki":{ {
"name": "Wiki", "resettable": true
"url": "https://retrodeck.readthedocs.io/en/latest/", }
"description": "Opens the RetroDECK Wiki in your default browser" ],
}, "properties": [
"rd_credits": { {
"name": "Credits", "standalone": true
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/", },
"description": "Opens the RetroDECK Credits in your default browser" {
}, "abxy_button": {
"rd_donate": { "status": false
"name": "Donate", }
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/", }
"description": "Opens Donations page in your default browser" ]
}, },
"rd_contactus": { "citra": {
"name": "Contact us", "description": "N3DS emulator",
"url": "https://github.com/XargonWan/RetroDECK", "name": "Citra",
"description": "Opens the RetroDECK contact us section in your default browser" "options": [
}, {
"rd_licenses": { "resettable": true
"name": "Licences", }
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_credits/donations-licenses/", ],
"description": "Opens the RetroDECK licenses in your default browser" "properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"dolphin": {
"description": "Wii/GameCube emulator",
"name": "Dolphin",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"duckstation": {
"description": "PSX emulator",
"name": "Duckstation",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"example_emulator": {
"description": "An example emulator.",
"name": "Example Emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"abxy_button": {
"status": false
},
"standalone": true
}
]
},
"gzdoom": {
"description": "Doom engine",
"name": "GZDoom",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"mame": {
"description": "Multiple Arcade Machine Emulator",
"name": "MAME",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"melonds": {
"description": "NDS emulator",
"name": "MelonDS",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"pcsx2": {
"description": "PS2 emulator",
"name": "PCSX2",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"ppsspp": {
"description": "PSP emulator",
"name": "PPSSPP",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"primehack": {
"description": "Metroid Prime emulator",
"name": "Primehack",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"rpcs3": {
"description": "PS3 emulator",
"name": "RPCS3",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"ryujinx": {
"description": "Switch emulator",
"name": "Ryujinx",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"vita3k": {
"description": "PS Vita emulator",
"name": "Vita3k",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"xemu": {
"description": "XBOX emulator",
"name": "XEMU",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"yuzu": {
"description": "Switch emulator",
"name": "Yuzu",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
}
} }
},
"emulators": {
"cemu": {
"name": "Cemu",
"description": "Wii U emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"citra": {
"name": "Citra",
"description": "N3DS emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"dolphin": {
"name": "Dolphin",
"description": "Wii/GameCube emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"duckstation": {
"name": "Duckstation",
"description": "PSX emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"gzdoom": {
"name": "GZDoom",
"description": "Doom engine",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"mame": {
"name": "MAME",
"description": "Multiple Arcade Machine Emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"melonds": {
"name": "MelonDS",
"description": "NDS emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"pcsx2": {
"name": "PCSX2",
"description": "PS2 emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"ppsspp": {
"name": "PPSSPP",
"description": "PSP emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"primehack": {
"name": "Primehack",
"description": "Metroid Prime emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"rpcs3": {
"name": "RPCS3",
"description": "PS3 emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"ryujinx": {
"name": "Ryujinx",
"description": "Switch emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"vita3k": {
"name": "Vita3k",
"description": "PS Vita emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"xemu": {
"name": "XEMU",
"description": "XBOX emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
},
"yuzu": {
"name": "Yuzu",
"description": "Switch emulator",
"options": [
{
"resettable": true
}
],
"properties": [
{
"standalone": true
},
{
"abxy_button": {
"status": false
}
}
]
}
}
} }

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,33 +83,61 @@ func save_data(app_data: AppData):
"description": link.description "description": link.description
} }
var emulators = {} var new_data_dict = {}
for key in app_data.emulators.keys(): # Convert about_links to a dictionary
var emulator = app_data.emulators[key] var about_links = {}
var options = [] for key in app_data.about_links.keys():
for option in emulator.options: var link = app_data.about_links[key]
options.append({ about_links[key] = {
"resettable": option.resettable "name": link.name,
}) "url": link.url,
"description": link.description
}
var properties = [] # Convert emulators to a dictionary
for property in emulator.properties: var emulators = {}
properties.append({ for key in app_data.emulators.keys():
"standalone": property.standalone, var emulator = app_data.emulators[key]
"abxy_button": {"status": property.abxy_button_status} var options = []
}) for option in emulator.options:
options.append({
"resettable": option.resettable
})
emulators[key] = { var properties = []
"name": emulator.name, for property in emulator.properties:
"description": emulator.description, properties.append({
"options": options, "standalone": property.standalone,
"properties": properties "abxy_button": {"status": property.abxy_button_status}
} })
data_dict["about_links"] = about_links emulators[key] = {
data_dict["emulators"] = emulators "name": emulator.name,
"description": emulator.description,
"options": options,
"properties": properties
}
var json = JSON.new() new_data_dict["about_links"] = about_links
var json_text = json.print(data_dict) new_data_dict["emulators"] = emulators
file.store_string(json_text)
file.close() # Merge existing data with new data
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.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()