Fix memory leak and save file deletion + other stuff

might also be the commit where timer starts only when you move
This commit is contained in:
Taevas 2025-05-03 14:33:49 +02:00
parent 709ce8eea3
commit edf99640cf
Signed by: Taevas
SSH key fingerprint: SHA256:Y5Hv18xwPvUKSlgkx1sPnRO3L2mc03ehC7BzrnZVEyY
6 changed files with 45 additions and 57 deletions

View file

@ -6,7 +6,9 @@ script/source = "extends Control
signal request_start
@onready var label_name = $VBoxContainer/MarginContainer/VBoxContainer/Description/Name
@onready var label_time = $VBoxContainer/MarginContainer/VBoxContainer/Description/Time
func _ready() -> void:
$VBoxContainer/MarginContainer.hide()
## Get the newest \"played_for\" when the main menu appears again
func _enter_tree() -> void:
@ -26,6 +28,8 @@ func _on_save_3_pressed() -> void:
display_file_data(SaveFiles.names[2])
func display_file_data(file_name: String) -> void:
$VBoxContainer/MarginContainer.show()
var label_time := $VBoxContainer/MarginContainer/VBoxContainer/Description/Time
var data = SaveFiles.read(file_name)
$VBoxContainer/MarginContainer.show()
label_time.text = \" | \"
@ -34,14 +38,14 @@ func display_file_data(file_name: String) -> void:
var minutes: int = floor(seconds / 60)
label_time.text += (\"%0*d\" % [2, minutes]) + \":\" + (\"%0*.3f\" % [6, seconds - (minutes * 60)])
else:
label_time.text += \"00:00\"
label_time.text += \"00:00.000\"
func _on_start_pressed() -> void:
request_start.emit()
func _on_delete_pressed() -> void:
SaveFiles.empty(SaveFiles.selected_file)
display_file_data(SaveFiles.read(SaveFiles.selected_file))
display_file_data(SaveFiles.selected_file)
"
[node name="SaveFileManager" type="Control"]