2024-08-18 21:42:40 +00:00
|
|
|
#todo
|
|
|
|
# add cores as class/ Like eumlator but one level lower
|
|
|
|
|
2023-09-23 16:24:55 +00:00
|
|
|
extends Control
|
|
|
|
|
2024-03-25 10:22:36 +00:00
|
|
|
var bios_type:int
|
2024-07-28 15:09:37 +00:00
|
|
|
var status_code_label: Label
|
|
|
|
var wrapper_command: String = "../../tools/retrodeck_function_wrapper.sh"
|
2024-08-18 17:31:57 +00:00
|
|
|
var log_text = "gdc_"
|
2024-07-28 15:09:37 +00:00
|
|
|
var log_parameters: Array = ["log", "i", log_text]
|
|
|
|
var log_results: Dictionary
|
2024-07-28 18:44:07 +00:00
|
|
|
var theme_option: OptionButton
|
2024-08-21 15:55:00 +00:00
|
|
|
#signal signal_theme_changed
|
2024-07-28 18:44:07 +00:00
|
|
|
var custom_theme: Theme = $".".theme
|
2024-08-02 20:25:39 +00:00
|
|
|
var log_option: OptionButton
|
2024-07-28 22:19:57 +00:00
|
|
|
var tab_container: TabContainer
|
2024-07-28 23:24:29 +00:00
|
|
|
var anim_logo: AnimatedSprite2D
|
2024-08-04 18:45:51 +00:00
|
|
|
var rd_logs: String
|
2024-08-05 12:37:45 +00:00
|
|
|
var rd_version: String
|
|
|
|
var gc_version: String
|
2024-08-15 20:34:11 +00:00
|
|
|
var l1_button_texture: Texture2D = load("res://assets/icons/kenney_input-prompts-pixel-16/Tiles/tile_0797.png")
|
2024-08-16 13:34:48 +00:00
|
|
|
var r1_button_texture: Texture2D = load("res://assets/icons/kenney_input-prompts-pixel-16/Tiles/tile_0798.png")
|
|
|
|
var a_button_texture: Texture2D = load("res://assets/icons/kenney_input-prompts-pixel-16/Tiles/tile_0042.png")
|
|
|
|
var b_button_texture: Texture2D = load("res://assets/icons/kenney_input-prompts-pixel-16/Tiles/tile_0043.png")
|
2024-03-25 10:22:36 +00:00
|
|
|
|
2024-08-19 11:47:46 +00:00
|
|
|
var app_data := AppData.new()
|
2023-09-23 16:24:55 +00:00
|
|
|
func _ready():
|
2024-07-28 15:09:37 +00:00
|
|
|
_get_nodes()
|
2024-07-28 18:44:07 +00:00
|
|
|
_connect_signals()
|
2024-07-28 23:24:29 +00:00
|
|
|
_play_main_animations()
|
2024-08-16 13:34:48 +00:00
|
|
|
%locale_option.selected = class_functions.map_locale_id(OS.get_locale_language())
|
2024-08-18 21:42:40 +00:00
|
|
|
app_data = data_handler.app_data
|
2024-08-20 20:57:49 +00:00
|
|
|
#data_handler.add_emulator()
|
|
|
|
#data_handler.modify_emulator_test()
|
2024-08-01 16:03:20 +00:00
|
|
|
if app_data:
|
2024-08-18 21:42:40 +00:00
|
|
|
var website_data: Link = app_data.about_links["rd_web"]
|
|
|
|
print (website_data.name,"-",website_data.url,"-",website_data.description,"-",website_data.url)
|
|
|
|
#print (app_data.about_links["rd_web"]["name"])
|
|
|
|
|
|
|
|
for key in app_data.emulators.keys():
|
|
|
|
var emulator = app_data.emulators[key]
|
|
|
|
# Display the properties of each emulator
|
|
|
|
print("Emulator Name: ", emulator.name)
|
|
|
|
print("Description: ", emulator.description)
|
|
|
|
print("Properties:")
|
|
|
|
# Iterate over properties and show each one
|
|
|
|
for property: EmulatorProperty in emulator.properties:
|
|
|
|
print("Cheevos: ", property.cheevos)
|
|
|
|
print("ABXY_button:", property.abxy_button)
|
|
|
|
print("multi_user_config_dir: ", property.multi_user_config_dir)
|
|
|
|
else:
|
|
|
|
print ("No emulators")
|
|
|
|
|
2024-08-04 18:45:51 +00:00
|
|
|
var config_file_path = "/var/config/retrodeck/retrodeck.cfg"
|
|
|
|
var json_file_path = "/var/config/retrodeck/retrodeck.json"
|
|
|
|
var config = data_handler.parse_config_to_json(config_file_path)
|
|
|
|
data_handler.config_save_json(config, json_file_path)
|
|
|
|
rd_logs = config["paths"]["logs_folder"]
|
2024-08-05 12:37:45 +00:00
|
|
|
rd_version = config["version"]
|
|
|
|
gc_version = ProjectSettings.get_setting("application/config/version")
|
2024-08-12 19:09:04 +00:00
|
|
|
%rd_title.text+= "\n " + rd_version + "\nConfigurator\n " + gc_version
|
2024-08-05 12:37:45 +00:00
|
|
|
|
2024-08-04 18:45:51 +00:00
|
|
|
#var log_file = class_functions.import_text_file(rd_logs +"/retrodeck.log")
|
|
|
|
#for id in config.paths:
|
|
|
|
# var path_data = config.paths[id]
|
|
|
|
# print (id)
|
|
|
|
|
|
|
|
# set current startup tab to match IDE
|
2024-08-19 19:07:25 +00:00
|
|
|
tab_container.current_tab = 0
|
2024-08-01 10:47:55 +00:00
|
|
|
#add_child(class_functions) # Needed for threaded results Not need autoload?
|
2023-12-31 07:58:20 +00:00
|
|
|
var children = findElements(self, "Control")
|
2024-02-19 07:15:59 +00:00
|
|
|
for n: Control in children: #iterate the children
|
2024-01-11 07:34:38 +00:00
|
|
|
if (n.focus_mode == FOCUS_ALL):
|
2024-02-19 07:15:59 +00:00
|
|
|
n.mouse_entered.connect(_on_control_mouse_entered.bind(n)) #grab focus on mouse hover
|
|
|
|
if (n.is_class("BaseButton") and n.disabled == true): #if button-like control and disabled
|
|
|
|
n.self_modulate.a = 0.5 #make it half transparent
|
2024-02-13 12:45:30 +00:00
|
|
|
combine_tkeys()
|
2024-03-25 10:22:36 +00:00
|
|
|
|
2024-08-19 19:07:25 +00:00
|
|
|
func _input(event):
|
|
|
|
if Input.is_action_pressed("quit1") and Input.is_action_pressed("quit2"):
|
|
|
|
get_tree().quit()
|
|
|
|
if Input.is_action_pressed("next_tab"):
|
|
|
|
%r1_button.texture_normal = %r1_button.texture_pressed
|
|
|
|
elif Input.is_action_pressed("previous_tab"):
|
|
|
|
%l1_button.texture_normal = %l1_button.texture_pressed
|
|
|
|
elif Input.is_action_pressed("back_button"):
|
|
|
|
%b_button.texture_normal = %b_button.texture_pressed
|
|
|
|
elif Input.is_action_pressed("action_button"):
|
|
|
|
%a_button.texture_normal = %a_button.texture_pressed
|
|
|
|
else:
|
|
|
|
%r1_button.texture_normal = r1_button_texture
|
|
|
|
%l1_button.texture_normal = l1_button_texture
|
|
|
|
%a_button.texture_normal = a_button_texture
|
|
|
|
%b_button.texture_normal = b_button_texture
|
|
|
|
if event.is_action_pressed("quit"):
|
|
|
|
_exit()
|
2024-08-18 21:42:40 +00:00
|
|
|
|
2024-07-28 15:09:37 +00:00
|
|
|
func _get_nodes() -> void:
|
|
|
|
status_code_label = get_node("%status_code_label")
|
2024-07-28 18:44:07 +00:00
|
|
|
theme_option = get_node("%theme_optionbutton")
|
2024-07-28 22:19:57 +00:00
|
|
|
tab_container = get_node("%TabContainer")
|
2024-07-28 23:24:29 +00:00
|
|
|
anim_logo = get_node("%logo_animated")
|
2024-08-02 20:25:39 +00:00
|
|
|
log_option = get_node("%logs_button")
|
|
|
|
|
2024-07-28 18:44:07 +00:00
|
|
|
func _connect_signals() -> void:
|
|
|
|
#signal_theme_changed.connect(_conf_theme)
|
|
|
|
theme_option.item_selected.connect(_conf_theme)
|
2024-08-21 15:55:00 +00:00
|
|
|
#signal_theme_changed.emit(theme_option.item_selected)
|
2024-08-02 20:25:39 +00:00
|
|
|
log_option.item_selected.connect(_load_log)
|
2024-08-20 20:57:49 +00:00
|
|
|
%borders.pressed.connect(_hide_show)
|
2024-07-28 18:44:07 +00:00
|
|
|
|
2024-08-02 20:25:39 +00:00
|
|
|
func _load_log(index: int) -> void:
|
2024-08-04 18:45:51 +00:00
|
|
|
var log_content:String
|
2024-08-02 20:25:39 +00:00
|
|
|
match index:
|
|
|
|
1:
|
2024-08-04 18:45:51 +00:00
|
|
|
log_content = class_functions.import_text_file(rd_logs +"/retrodeck.log")
|
|
|
|
load_popup("RetroDeck Log", "res://components/logs_view/logs_popup_content.tscn", log_content)
|
2024-08-02 20:25:39 +00:00
|
|
|
2:
|
2024-08-04 19:43:16 +00:00
|
|
|
log_content = class_functions.import_text_file(rd_logs +"/ES-DE/es_log.txt")
|
|
|
|
load_popup("ES-DE Log", "res://components/logs_view/logs_popup_content.tscn",log_content)
|
|
|
|
3:
|
|
|
|
log_content = class_functions.import_text_file(rd_logs +"/retroarch/logs/log.txt")
|
|
|
|
load_popup("Retroarch Log", "res://components/logs_view/logs_popup_content.tscn",log_content)
|
2024-08-02 20:25:39 +00:00
|
|
|
|
2024-07-28 23:24:29 +00:00
|
|
|
func _play_main_animations() -> void:
|
|
|
|
anim_logo.play()
|
2024-08-19 19:07:25 +00:00
|
|
|
func _hide_show() -> void:
|
|
|
|
if %borders.button_pressed:
|
|
|
|
%borders_grid_container.visible = true
|
|
|
|
for i in range(%borders_grid_container.get_child_count()):
|
|
|
|
var child = %borders_grid_container.get_child(i)
|
|
|
|
if child is Button:
|
|
|
|
child.button_pressed=true
|
2024-08-20 20:57:49 +00:00
|
|
|
for i in range(%graphics_grid_container.get_child_count()):
|
|
|
|
var child = %graphics_grid_container.get_child(i)
|
|
|
|
if child is Button and child != %borders:
|
|
|
|
child.visible=false
|
|
|
|
%save_button.visible=true
|
|
|
|
elif !%borders.button_pressed:
|
2024-08-19 19:07:25 +00:00
|
|
|
%borders_grid_container.visible = false
|
2024-08-20 20:57:49 +00:00
|
|
|
for i in range(%graphics_grid_container.get_child_count()):
|
|
|
|
var child = %graphics_grid_container.get_child(i)
|
|
|
|
if child is Button:
|
|
|
|
child.visible=true
|
|
|
|
%save_button.visible=false
|
2024-08-19 19:07:25 +00:00
|
|
|
|
2024-07-28 18:44:07 +00:00
|
|
|
func _conf_theme(index: int) -> void:
|
2024-08-21 15:55:00 +00:00
|
|
|
print (index)
|
2024-07-28 18:44:07 +00:00
|
|
|
match index:
|
|
|
|
1:
|
2024-08-19 19:07:25 +00:00
|
|
|
custom_theme = preload("res://res/pixel_ui_theme/RetroDECKTheme.tres")
|
2024-07-28 18:44:07 +00:00
|
|
|
2:
|
|
|
|
custom_theme = preload("res://assets/themes/retro_theme.tres")
|
|
|
|
3:
|
|
|
|
custom_theme = preload("res://assets/themes/modern_theme.tres")
|
|
|
|
4:
|
|
|
|
custom_theme = preload("res://assets/themes/accesible_theme.tres")
|
|
|
|
$".".theme = custom_theme
|
2024-07-28 23:24:29 +00:00
|
|
|
_play_main_animations()
|
2024-07-28 15:09:37 +00:00
|
|
|
|
2023-12-31 07:58:20 +00:00
|
|
|
func findElements(node: Node, className: String, result: Array = []) -> Array:
|
|
|
|
if node.is_class(className):
|
|
|
|
result.push_back(node)
|
|
|
|
for child in node.get_children():
|
|
|
|
result = findElements(child, className, result)
|
|
|
|
return result
|
|
|
|
|
|
|
|
func _on_control_mouse_entered(control: Node):
|
|
|
|
control.grab_focus()
|
2024-01-11 18:19:16 +00:00
|
|
|
|
2024-08-04 18:45:51 +00:00
|
|
|
func load_popup(title:String, content_path:String, display_text: String):
|
2024-01-11 18:19:16 +00:00
|
|
|
var popup = load("res://components/popup.tscn").instantiate() as Control
|
2024-03-25 10:22:36 +00:00
|
|
|
popup.set_title(title)
|
|
|
|
popup.set_content(content_path)
|
2024-08-04 18:45:51 +00:00
|
|
|
popup.set_display_text(display_text)
|
2024-01-11 18:19:16 +00:00
|
|
|
$Background.add_child(popup)
|
2024-01-12 07:37:05 +00:00
|
|
|
|
2024-03-25 10:22:36 +00:00
|
|
|
func _on_quickresume_advanced_pressed():
|
2024-08-04 18:45:51 +00:00
|
|
|
load_popup("Quick Resume Advanced", "res://components/popups_content/popup_content_test.tscn","")
|
2024-03-25 10:22:36 +00:00
|
|
|
|
|
|
|
func _on_bios_button_pressed():
|
2024-07-28 23:24:29 +00:00
|
|
|
_play_main_animations()
|
2024-03-25 10:22:36 +00:00
|
|
|
bios_type = 0
|
2024-07-28 16:06:58 +00:00
|
|
|
log_parameters[2] = log_text + "Bios_Check"
|
2024-07-28 15:09:37 +00:00
|
|
|
log_results = class_functions.execute_command(wrapper_command, log_parameters, false)
|
2024-08-04 18:45:51 +00:00
|
|
|
load_popup("BIOS File Check", "res://components/bios_check/bios_popup_content.tscn","")
|
2024-07-28 15:09:37 +00:00
|
|
|
status_code_label.text = str(log_results["exit_code"])
|
2024-03-25 10:22:36 +00:00
|
|
|
|
|
|
|
func _on_bios_button_expert_pressed():
|
2024-07-28 23:24:29 +00:00
|
|
|
_play_main_animations()
|
2024-03-25 10:22:36 +00:00
|
|
|
bios_type = 1
|
2024-07-28 16:06:58 +00:00
|
|
|
log_parameters[2] = log_text + "Advanced_Bios_Check"
|
2024-07-28 15:09:37 +00:00
|
|
|
log_results = class_functions.execute_command(wrapper_command, log_parameters, false)
|
2024-08-04 18:45:51 +00:00
|
|
|
load_popup("BIOS File Check", "res://components/bios_check/bios_popup_content.tscn","")
|
2024-07-28 15:09:37 +00:00
|
|
|
status_code_label.text = str(log_results["exit_code"])
|
2024-01-12 07:37:05 +00:00
|
|
|
|
|
|
|
func _on_exit_button_pressed():
|
2024-07-28 23:24:29 +00:00
|
|
|
_play_main_animations()
|
2024-07-28 15:39:26 +00:00
|
|
|
log_parameters[2] = log_text + "Exited"
|
2024-07-28 15:09:37 +00:00
|
|
|
log_results = class_functions.execute_command(wrapper_command, log_parameters, false)
|
2024-01-12 07:37:05 +00:00
|
|
|
_exit()
|
|
|
|
|
|
|
|
func _exit():
|
|
|
|
get_tree().root.propagate_notification(NOTIFICATION_WM_CLOSE_REQUEST)
|
|
|
|
get_tree().quit()
|
2024-01-24 17:00:26 +00:00
|
|
|
|
|
|
|
func _on_locale_selected(index):
|
|
|
|
match index:
|
|
|
|
0:
|
|
|
|
TranslationServer.set_locale("en")
|
2024-08-16 13:34:48 +00:00
|
|
|
_:
|
|
|
|
TranslationServer.set_locale("en")
|
|
|
|
combine_tkeys()
|
|
|
|
|
|
|
|
"""
|
2024-01-24 17:00:26 +00:00
|
|
|
1:
|
|
|
|
TranslationServer.set_locale("it")
|
2024-02-11 08:12:01 +00:00
|
|
|
2:
|
|
|
|
TranslationServer.set_locale("de")
|
2024-02-13 12:45:30 +00:00
|
|
|
3:
|
2024-02-16 07:17:39 +00:00
|
|
|
TranslationServer.set_locale("sv")
|
2024-02-18 08:32:34 +00:00
|
|
|
4:
|
|
|
|
TranslationServer.set_locale("ua")
|
|
|
|
5:
|
|
|
|
TranslationServer.set_locale("ja")
|
|
|
|
6:
|
|
|
|
TranslationServer.set_locale("zh")
|
2024-08-16 13:34:48 +00:00
|
|
|
"""
|
|
|
|
|
2024-01-24 17:00:26 +00:00
|
|
|
|
2024-02-13 12:45:30 +00:00
|
|
|
func combine_tkeys(): #More as a test
|
2024-08-15 20:34:11 +00:00
|
|
|
%cheats.text = tr("TK_CHEATS") + " " + tr("TK_SOON") # switched to access as a unique name as easier to refactor
|
2024-08-15 16:10:50 +00:00
|
|
|
#$Background/MarginContainer/TabContainer/TK_SYSTEM/ScrollContainer/VBoxContainer/HBoxContainer/GridContainer/cheats.text = tr("TK_CHEATS") + " " + tr("TK_SOON")
|
2024-08-20 20:57:49 +00:00
|
|
|
#%tate_mode.text = tr("TK_TATE") + " " + tr("TK_SOON")
|
|
|
|
#%hotkey_sound.text = tr("TK_HOTKEYSOUND") + " " + tr("TK_SOON")
|
2024-02-13 12:45:30 +00:00
|
|
|
$Background/MarginContainer/TabContainer/TK_NETWORK/ScrollContainer/VBoxContainer/cheevos_container/cheevos_advanced_container/cheevos_hardcore.text = tr("TK_CHEEVOSHARDCORE") + " " + tr("TK_SOON")
|
|
|
|
$Background/MarginContainer/TabContainer/TK_NETWORK/ScrollContainer/VBoxContainer/data_mng_container/saves_sync.text = tr("TK_SAVESSYNC") + " " + tr("TK_SOON")
|
|
|
|
$Background/MarginContainer/TabContainer/TK_CONFIGURATOR/ScrollContainer/VBoxContainer/system_container/easter_eggs.text = tr("TK_EASTEREGGS") + " " + tr("TK_SOON")
|