Add change data for about us section via a csv

On branch feat/godot-configurator
 Changes to be committed:
	new file:   tools/configurator/assets/data_lists/tk_about.Description.translation
	new file:   tools/configurator/assets/data_lists/tk_about.URL.translation
	new file:   tools/configurator/assets/data_lists/tk_about.csv
	new file:   tools/configurator/assets/data_lists/tk_about.csv.import
	modified:   tools/configurator/emu_list.yml
	modified:   tools/configurator/main.tscn
	modified:   tools/configurator/res/pixel_ui_theme/RetroDECKTheme.tres
	modified:   tools/configurator/scripts/class_functions.gd
	new file:   tools/configurator/tk_about.gd
This commit is contained in:
monkeyx-net 2024-07-31 14:57:37 +01:00
parent b1bd8ea9b0
commit f2e00115d7
9 changed files with 206 additions and 49 deletions

View file

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

View file

@ -0,0 +1,17 @@
[remap]
importer="csv_translation"
type="Translation"
uid="uid://bb4q4qm4wqx3b"
[deps]
files=["res://assets/data_lists/tk_about.URL.translation", "res://assets/data_lists/tk_about.Description.translation"]
source_file="res://assets/data_lists/tk_about.csv"
dest_files=["res://assets/data_lists/tk_about.URL.translation", "res://assets/data_lists/tk_about.Description.translation"]
[params]
compress=true
delimiter=0

View file

@ -102,4 +102,4 @@ yuzu:
options:
- resettable: true
properties:
- standalone: true
- standalone: true

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=35 format=3 uid="uid://61f6m4r1mpan"]
[gd_scene load_steps=36 format=3 uid="uid://61f6m4r1mpan"]
[ext_resource type="Texture2D" uid="uid://bv6vh33cnfaw4" path="res://icon.svg" id="1_axfei"]
[ext_resource type="Script" path="res://main.gd" id="1_obpq7"]
@ -6,6 +6,7 @@
[ext_resource type="Script" path="res://TabContainer.gd" id="3_id6l4"]
[ext_resource type="AudioStream" uid="uid://dig4pco500pyt" path="res://res/configurator.mp3" id="3_xivj6"]
[ext_resource type="Texture2D" uid="uid://dx0u5hiwxfgu5" path="res://res/pixel_ui_theme/8x8_ui_elements.png" id="4_2tuu4"]
[ext_resource type="Script" path="res://tk_about.gd" id="4_m4rto"]
[ext_resource type="Script" path="res://Rekku.gd" id="4_nqqx3"]
[ext_resource type="Texture2D" uid="uid://cxyml1owhi6de" path="res://res/pixel_ui_theme/8x8_ui_icons.png" id="4_v1scw"]
[ext_resource type="Texture2D" uid="uid://d2lm4mfx1gt86" path="res://assets/graphics/retrodeck_base_shake0.png" id="5_7rjbt"]
@ -815,6 +816,7 @@ popup/item_4/id = 4
[node name="TK_ABOUT" type="MarginContainer" parent="Background/MarginContainer/TabContainer"]
layout_mode = 2
theme_override_constants/margin_right = 240
script = ExtResource("4_m4rto")
[node name="about_container" type="VBoxContainer" parent="Background/MarginContainer/TabContainer/TK_ABOUT"]
layout_mode = 2
@ -836,31 +838,37 @@ expand_mode = 1
stretch_mode = 4
[node name="website_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/about_container"]
unique_name_in_owner = true
layout_mode = 2
text = "TK_WEBSITE"
[node name="changelog_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/about_container"]
unique_name_in_owner = true
layout_mode = 2
text = "TK_CHANGELOG"
[node name="wiki_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/about_container"]
unique_name_in_owner = true
layout_mode = 2
disabled = true
text = "TK_WIKI"
[node name="credits_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/about_container"]
unique_name_in_owner = true
layout_mode = 2
text = "TK_CREDITS"
[node name="donate_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/about_container"]
unique_name_in_owner = true
layout_mode = 2
text = "TK_DONATE"
[node name="contactus_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/about_container"]
unique_name_in_owner = true
layout_mode = 2
text = "TK_CONTACTUS"
[node name="licenses_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/about_container"]
unique_name_in_owner = true
layout_mode = 2
text = "TK_LICENSES"

File diff suppressed because one or more lines are too long

View file

@ -61,3 +61,33 @@ func process_url_image(body) -> Texture:
func launch_help(url: String) -> void:
OS.shell_open(url)
func import_csv_data(file_path: String) -> Dictionary:
# check if file exists
var data_dict: Dictionary = {}
var file = FileAccess.open(file_path,FileAccess.READ)
if file:
var csv_lines: PackedStringArray = file.get_as_text().strip_edges().split("\n")
for i in range(1, csv_lines.size()): # Start from 1 to skip the header
var line = csv_lines[i]
var columns = line.split(",")
if columns.size() >= 3: # Ensure there are at least 2 elements (URL and Description)
var id = columns[0]
var url = columns[1]
var description = columns[2]
data_dict[id] = {"URL": url, "Description": description}
file.close()
else:
print ("Could not open file: %s", file_path)
return data_dict
func _import_data_lists(file_path: String) -> void:
var tk_about: Dictionary = import_csv_data(file_path)
for key in tk_about.keys():
var entry = tk_about[key]
print("ID: " + key)
print("URL: " + entry["URL"])
print("Description: " + entry["Description"])
print("---")

View file

@ -0,0 +1,94 @@
extends MarginContainer
var class_functions: ClassFunctions
var website_button: Button
var changelog_button: Button
var wiki_button: Button
var credits_button: Button
var donate_button: Button
var contactus_button: Button
var licenses_button: Button
var tk_about: Dictionary
signal signal_theme_changed
func _ready():
class_functions = ClassFunctions.new()
#class_functions._import_data_lists("res://assets/data_lists/tk_about.csv")
tk_about = class_functions.import_csv_data("res://assets/data_lists/tk_about.csv")
_get_nodes()
_connect_signals()
for key in tk_about.keys():
#print("ID: " + key)
#print("URL: " + entry["URL"])
#print("Description: " + entry["Description"])
var entry = tk_about[key]
match key:
"rd_web":
%website_button.tooltip_text = entry["Description"]
%website_button.editor_description = entry["URL"] # hackish?
"rd_changelog":
%changelog_button.tooltip_text = entry["Description"]
%changelog_button.editor_description = entry["URL"]
"rd_wiki":
%wiki_button.tooltip_text = entry["Description"]
%wiki_button.editor_description = entry["URL"]
"rd_credits":
%credits_button.tooltip_text = entry["Description"]
%credits_button.editor_description = entry["URL"]
"rd_donate":
%donate_button.tooltip_text = entry["Description"]
%donate_button.editor_description = entry["URL"]
"rd_contactus":
%contactus_button.tooltip_text = entry["Description"]
%contactus_button.editor_description = entry["URL"]
"rd_licenses":
%licenses_button.tooltip_text = entry["Description"]
%licenses_button.editor_description = entry["URL"]
func _get_nodes() -> void:
website_button = get_node("%website_button")
changelog_button = get_node("%changelog_button")
wiki_button = get_node("%wiki_button")
credits_button = get_node("%credits_button")
donate_button = get_node("%donate_button")
contactus_button = get_node("%contactus_button")
licenses_button = get_node("%licenses_button")
func _connect_signals() -> void:
website_button.pressed.connect(_about_button_pressed.bind("rd_web"))
changelog_button.pressed.connect(_about_button_pressed.bind("rd_changelog"))
wiki_button.pressed.connect(_about_button_pressed.bind("rd_wiki"))
credits_button.pressed.connect(_about_button_pressed.bind("rd_credits"))
donate_button.pressed.connect(_about_button_pressed.bind("rd_donate"))
contactus_button.pressed.connect(_about_button_pressed.bind("rd_contactus"))
licenses_button.pressed.connect(_about_button_pressed.bind("rd_licenses"))
func _about_button_pressed(id: String) -> void:
print (id)
match id:
"rd_web":
var entry = tk_about["rd_web"]
OS.shell_open(%website_button.editor_description)
"rd_changelog":
var entry = tk_about["rd_changelog"]
OS.shell_open(%changelog_button.editor_description)
"rd_wiki":
var entry = tk_about["rd_wiki"]
OS.shell_open(%wiki_button.editor_description)
"rd_credits":
var entry = tk_about["rd_credits"]
OS.shell_open(%credits_button.editor_description)
"rd_donate":
var entry = tk_about["rd_donate"]
OS.shell_open(%donate_button.editor_description)
"rd_contactus":
var entry = tk_about["rd_contactus"]
OS.shell_open(%contactus_button.editor_description)
"rd_licenses":
var entry = tk_about["rd_licenses"]
OS.shell_open(%licenses_button.editor_description)
# print ("ID not found")