new timer + save times to save files (#3)
This commit is contained in:
parent
7ae566720c
commit
ac1f29d111
7 changed files with 269 additions and 37 deletions
|
@ -5,33 +5,37 @@ script/source = "extends Control
|
|||
|
||||
signal request_start
|
||||
|
||||
@onready var label = $VBoxContainer/MarginContainer/VBoxContainer/Label
|
||||
@onready var label_name = $VBoxContainer/MarginContainer/VBoxContainer/Description/Name
|
||||
@onready var label_time = $VBoxContainer/MarginContainer/VBoxContainer/Description/Time
|
||||
|
||||
func _on_save_1_pressed() -> void:
|
||||
label.text = $VBoxContainer/Save1.text
|
||||
label_name.text = $VBoxContainer/Save1.text
|
||||
display_file_data(SaveFiles.read(SaveFiles.names[0]))
|
||||
|
||||
func _on_save_2_pressed() -> void:
|
||||
label.text = $VBoxContainer/Save2.text
|
||||
label_name.text = $VBoxContainer/Save2.text
|
||||
display_file_data(SaveFiles.read(SaveFiles.names[1]))
|
||||
|
||||
func _on_save_3_pressed() -> void:
|
||||
label.text = $VBoxContainer/Save3.text
|
||||
label_name.text = $VBoxContainer/Save3.text
|
||||
display_file_data(SaveFiles.read(SaveFiles.names[2]))
|
||||
|
||||
func display_file_data(data: Variant) -> void:
|
||||
$VBoxContainer/MarginContainer.show()
|
||||
label.text += \" | \"
|
||||
if data.has(\"played_for\"):
|
||||
label.text += data.played_for
|
||||
label_time.text = \" | \"
|
||||
if data.has(\"played_for\") and data.played_for is float:
|
||||
var seconds: float = data.played_for
|
||||
var minutes: int = floor(seconds / 60)
|
||||
label_time.text += (\"%0*d\" % [2, minutes]) + \":\" + (\"%0*.3f\" % [6, seconds - (minutes * 60)])
|
||||
else:
|
||||
label.text += \"00:00\"
|
||||
label_time.text += \"00:00\"
|
||||
|
||||
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))
|
||||
"
|
||||
|
||||
[node name="SaveFileManager" type="Control"]
|
||||
|
@ -69,7 +73,6 @@ layout_mode = 2
|
|||
text = "Save file #3"
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 30
|
||||
theme_override_constants/margin_top = 30
|
||||
|
@ -79,27 +82,34 @@ theme_override_constants/margin_bottom = 30
|
|||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/MarginContainer/VBoxContainer"]
|
||||
[node name="Description" type="HBoxContainer" parent="VBoxContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Name" type="Label" parent="VBoxContainer/MarginContainer/VBoxContainer/Description"]
|
||||
layout_mode = 2
|
||||
text = "Save File"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer/VBoxContainer"]
|
||||
[node name="Time" type="Label" parent="VBoxContainer/MarginContainer/VBoxContainer/Description"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Buttons" type="HBoxContainer" parent="VBoxContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 10
|
||||
alignment = 1
|
||||
|
||||
[node name="Start" type="Button" parent="VBoxContainer/MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
[node name="Start" type="Button" parent="VBoxContainer/MarginContainer/VBoxContainer/Buttons"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Start"
|
||||
|
||||
[node name="Delete" type="Button" parent="VBoxContainer/MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
[node name="Delete" type="Button" parent="VBoxContainer/MarginContainer/VBoxContainer/Buttons"]
|
||||
layout_mode = 2
|
||||
text = "Delete"
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/Save1" to="." method="_on_save_1_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/Save2" to="." method="_on_save_2_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/Save3" to="." method="_on_save_3_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/MarginContainer/VBoxContainer/HBoxContainer/Start" to="." method="_on_start_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/MarginContainer/VBoxContainer/HBoxContainer/Delete" to="." method="_on_delete_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/MarginContainer/VBoxContainer/Buttons/Start" to="." method="_on_start_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/MarginContainer/VBoxContainer/Buttons/Delete" to="." method="_on_delete_pressed"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue