DreamBall/menus/main/save_file_manager.tscn

115 lines
3.8 KiB
Text

[gd_scene load_steps=2 format=3 uid="uid://w5te3qujco7d"]
[sub_resource type="GDScript" id="GDScript_a5kgg"]
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 _on_save_1_pressed() -> void:
label_name.text = $VBoxContainer/Save1.text
display_file_data(SaveFiles.read(SaveFiles.names[0]))
func _on_save_2_pressed() -> void:
label_name.text = $VBoxContainer/Save2.text
display_file_data(SaveFiles.read(SaveFiles.names[1]))
func _on_save_3_pressed() -> void:
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_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_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"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = SubResource("GDScript_a5kgg")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 14
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_top = -50.5
offset_bottom = 50.5
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
alignment = 1
[node name="Save1" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Save file #1"
[node name="Save2" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Save file #2"
[node name="Save3" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Save file #3"
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 30
theme_override_constants/margin_top = 30
theme_override_constants/margin_right = 30
theme_override_constants/margin_bottom = 30
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/MarginContainer"]
layout_mode = 2
[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="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/Buttons"]
layout_mode = 2
size_flags_horizontal = 3
text = "Start"
[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/Buttons/Start" to="." method="_on_start_pressed"]
[connection signal="pressed" from="VBoxContainer/MarginContainer/VBoxContainer/Buttons/Delete" to="." method="_on_delete_pressed"]