Merge branch 'feat/godot' of https://github.com/monkeyx-net/RetroDECK_UK into feat/godot

modified:   tools/configurator/scripts/class_functions.gd
This commit is contained in:
Rekku 2024-10-22 09:27:43 +01:00
commit f338293365

View file

@ -50,7 +50,7 @@ var current_progress: ProgressBar = null
var current_state: String = ""
func _ready():
read_values_states()
read_values_states()
func read_values_states() -> void:
var config = data_handler.parse_config_to_json(config_file_path)
@ -110,40 +110,58 @@ func logger_godot(log_type: String, log_text: String) -> void:
var log_path: String = '/var/config/retrodeck/logs/gd_logs.log'
var log_dir: DirAccess = DirAccess.open(log_dir_path)
var log_file: FileAccess = FileAccess.open(log_path, FileAccess.READ_WRITE)
var log_file: FileAccess
var log_header: String = " GD "
var datetime: Dictionary = Time.get_datetime_dict_from_system()
var unixtime: float = Time.get_unix_time_from_system()
var msec: int = (unixtime - floor(unixtime)) * 1000 # finally, real ms! Thanks, monkeyx
var timestamp: String = "[%d-%02d-%02d %02d:%02d:%02d.%03d]" % [
datetime.year, datetime.month, datetime.day,
datetime.hour, datetime.minute, datetime.second, msec] # real ms!!
var log_line: String = timestamp + log_header
var log_line: String = "GD "
match log_type:
'w':
log_line += "Warning "
#print("Warning, mate")
log_line += "[Warning] "
# print("Warning, mate")
'e':
log_line += "Error "
#print("Error, mate")
log_line += "[Error] "
# print("Error, mate")
'i':
log_line += "Info "
#print("Info, mate")
log_line += "[Info] "
# print("Info, mate")
'd':
log_line += "Debug "
#print("Debug, mate")
#_:
#print("No idea, mate")
log_line += "[Debug] "
# print("Debug, mate")
_:
log_line += " "
print("No idea, mate")
log_line += log_text
#print(log_line)
# print(log_line)
if not log_dir:
log_dir = DirAccess.open("res://") #open something valid to create an instance
print(log_dir.make_dir_recursive(log_dir_path))
if log_dir.make_dir_recursive(log_dir_path) != OK:
print("Something wrong with log directory")
return
if not FileAccess.open(log_path, FileAccess.READ):
log_file = FileAccess.open(log_path, FileAccess.WRITE_READ) # to create a file if not there
else:
log_file = FileAccess.open(log_path, FileAccess.READ_WRITE) # to not truncate
if log_file:
log_file.seek_end()
log_file.store_line(log_line)
log_file.close()
else:
print("Something wrong with log file")
func array_to_string(arr: Array) -> String:
var text: String
for line in arr: