mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2025-01-17 22:35:39 +00:00
On branch feat/godot-configurator
Changes to be committed: new file: configurator/scripts/class_functions.gd modified: retrodeck_function_wrapper.sh
This commit is contained in:
parent
16436ea5b6
commit
30d87168e7
|
@ -1,5 +1,6 @@
|
|||
extends Control
|
||||
|
||||
var classFunctions: ClassFunctions
|
||||
var file := FileAccess
|
||||
var bios_tempfile : String
|
||||
var BIOS_COLUMNS_BASIC := ["BIOS File Name", "System", "Found", "Hash Match", "Description"]
|
||||
|
@ -9,11 +10,14 @@ var BIOS_COLUMNS_EXPERT := ["BIOS File Name", "System", "Found", "Hash Match", "
|
|||
func _ready():
|
||||
#Check if XDG_RUNTIME_DIR is set and choose temp file location
|
||||
if OS.has_environment("XDG_RUNTIME_DIR"):
|
||||
bios_tempfile = OS.get_environment("XDG_RUNTIME_DIR") + "/godot_temp/godot_bios_files_checked.tmp"
|
||||
#bios_tempfile = OS.get_environment("XDG_RUNTIME_DIR") + "/godot_temp/godot_bios_files_checked.tmp"
|
||||
bios_tempfile = "/var/config/retrodeck/godot/godot_bios_files_checked.tmp"
|
||||
else:
|
||||
bios_tempfile = "/var/config/retrodeck/godot_temp/godot_bios_files_checked.tmp"
|
||||
|
||||
var table := $Table
|
||||
classFunctions = ClassFunctions.new()
|
||||
add_child(classFunctions)
|
||||
|
||||
if bios_type == 0: #Basic BIOS button pressed
|
||||
table.columns = BIOS_COLUMNS_BASIC.size()
|
||||
|
@ -28,7 +32,16 @@ func _ready():
|
|||
table.hide_root = true
|
||||
|
||||
if bios_type == 0: #Basic BIOS button pressed
|
||||
OS.execute("/app/tools/retrodeck_function_wrapper.sh",["check_bios_files", "basic"])
|
||||
#OS.execute("/app/tools/retrodeck_function_wrapper.sh",["check_bios_files", "basic"])
|
||||
var command = "../../tools/retrodeck_function_wrapper.sh"
|
||||
var parameters = ["log", "i", "Configurator: " + "check_bios_files"]
|
||||
var console = false
|
||||
var result: Dictionary = classFunctions.execute_command(command, parameters, false)
|
||||
parameters = ["check_bios_files"]
|
||||
#result = classFunctions.execute_command(command, parameters, false)
|
||||
#threaded
|
||||
await run_thread_command(command, parameters, console)
|
||||
|
||||
else: #Assume advanced BIOS button pressed
|
||||
OS.execute("/app/tools/retrodeck_function_wrapper.sh",["check_bios_files"])
|
||||
|
||||
|
@ -43,3 +56,9 @@ func _ready():
|
|||
if table_line.get_index() % 2 == 1:
|
||||
table_line.set_custom_bg_color(i,Color(0.15, 0.15, 0.15, 1),false)
|
||||
table_line.set_custom_color(i,Color(1,1,1,1))
|
||||
|
||||
func run_thread_command(command: String, parameters: Array, console: bool) -> void:
|
||||
var result = await classFunctions.run_command_in_thread(command, parameters, console)
|
||||
if result != null:
|
||||
print (result["output"])
|
||||
print ("Exit Code: " + str(result["exit_code"]))
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
63
tools/configurator/scripts/class_functions.gd
Normal file
63
tools/configurator/scripts/class_functions.gd
Normal file
|
@ -0,0 +1,63 @@
|
|||
class_name ClassFunctions extends Control
|
||||
|
||||
# This should be looked at again when GoDot 4.3 ships as has new OS.execute_with_pipe
|
||||
|
||||
func array_to_string(arr: Array) -> String:
|
||||
var text = ""
|
||||
for line in arr:
|
||||
text += line + "\n"
|
||||
return text
|
||||
|
||||
func execute_command(command: String, parameters: Array, console: bool) -> Dictionary:
|
||||
var result = {}
|
||||
var output = []
|
||||
var exit_code = OS.execute(command, parameters, output, console)
|
||||
result["output"] = array_to_string(output)
|
||||
result["exit_code"] = exit_code
|
||||
return result
|
||||
|
||||
func run_command_in_thread(command: String, paramaters: Array, _console: bool) -> Dictionary:
|
||||
var thread = Thread.new()
|
||||
thread.start(execute_command.bind(command,paramaters,false))
|
||||
while thread.is_alive():
|
||||
await get_tree().process_frame
|
||||
var result = thread.wait_to_finish()
|
||||
thread = null
|
||||
return result
|
||||
|
||||
func _threaded_command_execution(command: String, parameters: Array, console: bool) -> Dictionary:
|
||||
var result = execute_command(command, parameters, console)
|
||||
return result
|
||||
|
||||
# Make this generic for command, path and naming
|
||||
func get_text_file_from_system_path(file_path: String, command: String) -> Dictionary:
|
||||
var output = []
|
||||
command += file_path
|
||||
var exit_code = OS.execute("sh", ["-c", command], output)
|
||||
if exit_code == 0:
|
||||
var content = array_to_string(output)
|
||||
return parse_file_list(content)
|
||||
else:
|
||||
print("Error reading file: ", exit_code)
|
||||
return {}
|
||||
|
||||
func parse_file_list(content: String) -> Dictionary:
|
||||
var file_dict = {}
|
||||
var regex = RegEx.new()
|
||||
regex.compile(r'"([^"]+)"\s*"([^"]+)"')
|
||||
var matches = regex.search_all(content)
|
||||
|
||||
for match in matches:
|
||||
var name = match.get_string(1)
|
||||
var description = match.get_string(2)
|
||||
file_dict[name] = description
|
||||
return file_dict
|
||||
|
||||
func process_url_image(body) -> Texture:
|
||||
var image = Image.new()
|
||||
image.load_png_from_buffer(body)
|
||||
var texture = ImageTexture.create_from_image(image)
|
||||
return texture
|
||||
|
||||
func launch_help(url: String) -> void:
|
||||
OS.shell_open(url)
|
0
tools/retrodeck_function_wrapper.sh
Normal file → Executable file
0
tools/retrodeck_function_wrapper.sh
Normal file → Executable file
Loading…
Reference in a new issue