2025-05-08 23:02:22 +02:00
|
|
|
[gd_scene load_steps=4 format=3 uid="uid://w5te3qujco7d"]
|
2025-05-07 19:56:24 +02:00
|
|
|
|
|
|
|
[ext_resource type="Theme" uid="uid://c6ceauyc42c33" path="res://menus/menu.tres" id="1_gc46s"]
|
2025-03-27 16:00:39 +01:00
|
|
|
|
|
|
|
[sub_resource type="GDScript" id="GDScript_a5kgg"]
|
2025-05-07 00:34:45 +02:00
|
|
|
script/source = "extends MainMenuComponent
|
2025-03-27 16:00:39 +01:00
|
|
|
|
2025-04-16 00:16:39 +02:00
|
|
|
signal request_start
|
2025-03-27 16:00:39 +01:00
|
|
|
|
2025-05-07 19:56:24 +02:00
|
|
|
func _init() -> void:
|
|
|
|
self.displayed_name = \"Save files\"
|
|
|
|
|
2025-05-03 14:33:49 +02:00
|
|
|
func _ready() -> void:
|
2025-05-07 19:56:24 +02:00
|
|
|
for child in $ScrollContainer/SaveButtons.get_children(true):
|
|
|
|
child.queue_free()
|
2025-05-08 23:02:22 +02:00
|
|
|
## Get the newest \"played_for\" when the main menu appears again
|
|
|
|
get_parent().connect(\"tree_entered\", func():
|
|
|
|
if SaveFiles.selected_file:
|
|
|
|
display_file_data(SaveFiles.selected_file)
|
|
|
|
)
|
|
|
|
|
|
|
|
var btn_group := ButtonGroup.new()
|
2025-05-07 19:56:24 +02:00
|
|
|
var save_file_names := SaveFiles.get_all_existing_save_file_names()
|
|
|
|
for i in len(save_file_names):
|
|
|
|
var save_file_name := save_file_names[i]
|
2025-05-08 23:02:22 +02:00
|
|
|
var save_name := save_file_name.substr(0, save_file_name.rfind(\".\"))
|
|
|
|
if save_name.is_valid_int():
|
|
|
|
save_name = \"File #\" + save_name
|
|
|
|
|
2025-05-07 19:56:24 +02:00
|
|
|
var button := Button.new()
|
2025-05-08 23:02:22 +02:00
|
|
|
button.toggle_mode = true
|
|
|
|
button.button_group = btn_group
|
2025-05-07 19:56:24 +02:00
|
|
|
button.connect(\"pressed\", func():
|
2025-05-08 23:02:22 +02:00
|
|
|
$VBoxContainer/MarginContainer/VBoxContainer/Description/Name.text = save_name
|
2025-05-07 19:56:24 +02:00
|
|
|
display_file_data(save_file_name)
|
|
|
|
)
|
2025-05-08 23:02:22 +02:00
|
|
|
button.text = save_name
|
2025-05-07 19:56:24 +02:00
|
|
|
|
|
|
|
if i == 0 or i == len(save_file_names) - 1:
|
|
|
|
var margin = MarginContainer.new()
|
|
|
|
if i == 0:
|
|
|
|
margin.add_theme_constant_override(\"margin_left\", 10)
|
|
|
|
elif i == len(save_file_names) - 1:
|
|
|
|
margin.add_theme_constant_override(\"margin_right\", 10)
|
|
|
|
margin.add_child(button)
|
|
|
|
$ScrollContainer/SaveButtons.add_child(margin)
|
|
|
|
else:
|
|
|
|
$ScrollContainer/SaveButtons.add_child(button)
|
2025-05-07 00:34:45 +02:00
|
|
|
super()
|
2025-04-16 00:16:39 +02:00
|
|
|
|
2025-04-29 21:18:04 +02:00
|
|
|
func display_file_data(file_name: String) -> void:
|
2025-05-03 14:33:49 +02:00
|
|
|
var label_time := $VBoxContainer/MarginContainer/VBoxContainer/Description/Time
|
2025-05-08 23:02:22 +02:00
|
|
|
$VBoxContainer/MarginContainer/VBoxContainer/Buttons/Start.disabled = false
|
|
|
|
$VBoxContainer/MarginContainer/VBoxContainer/Buttons/Delete.disabled = false
|
2025-04-29 21:18:04 +02:00
|
|
|
var data = SaveFiles.read(file_name)
|
2025-04-20 23:25:51 +02:00
|
|
|
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)])
|
2025-04-16 00:16:39 +02:00
|
|
|
else:
|
2025-05-03 14:33:49 +02:00
|
|
|
label_time.text += \"00:00.000\"
|
2025-04-16 00:16:39 +02:00
|
|
|
|
|
|
|
func _on_start_pressed() -> void:
|
|
|
|
request_start.emit()
|
|
|
|
|
|
|
|
func _on_delete_pressed() -> void:
|
|
|
|
SaveFiles.empty(SaveFiles.selected_file)
|
2025-05-03 14:33:49 +02:00
|
|
|
display_file_data(SaveFiles.selected_file)
|
2025-03-27 16:00:39 +01:00
|
|
|
"
|
|
|
|
|
2025-05-08 23:02:22 +02:00
|
|
|
[sub_resource type="LabelSettings" id="LabelSettings_gc46s"]
|
|
|
|
font_size = 24
|
|
|
|
|
2025-04-16 00:16:39 +02:00
|
|
|
[node name="SaveFileManager" type="Control"]
|
|
|
|
layout_mode = 3
|
2025-03-27 16:00:39 +01:00
|
|
|
anchors_preset = 15
|
|
|
|
anchor_right = 1.0
|
|
|
|
anchor_bottom = 1.0
|
|
|
|
grow_horizontal = 2
|
|
|
|
grow_vertical = 2
|
2025-05-07 19:56:24 +02:00
|
|
|
theme = ExtResource("1_gc46s")
|
2025-03-27 16:00:39 +01:00
|
|
|
script = SubResource("GDScript_a5kgg")
|
|
|
|
|
2025-05-07 19:56:24 +02:00
|
|
|
[node name="ColorRect" type="ColorRect" parent="."]
|
2025-04-16 00:16:39 +02:00
|
|
|
layout_mode = 1
|
2025-05-07 19:56:24 +02:00
|
|
|
anchors_preset = 15
|
2025-04-16 00:16:39 +02:00
|
|
|
anchor_right = 1.0
|
2025-05-07 19:56:24 +02:00
|
|
|
anchor_bottom = 1.0
|
2025-04-16 00:16:39 +02:00
|
|
|
grow_horizontal = 2
|
|
|
|
grow_vertical = 2
|
2025-05-07 19:56:24 +02:00
|
|
|
color = Color(0.147731, 0.243238, 0.205466, 1)
|
|
|
|
|
|
|
|
[node name="ScrollContainer" type="ScrollContainer" parent="."]
|
|
|
|
layout_mode = 1
|
|
|
|
anchors_preset = 10
|
|
|
|
anchor_right = 1.0
|
|
|
|
grow_horizontal = 2
|
|
|
|
size_flags_vertical = 3
|
2025-05-08 23:02:22 +02:00
|
|
|
follow_focus = true
|
2025-05-07 19:56:24 +02:00
|
|
|
vertical_scroll_mode = 0
|
|
|
|
|
|
|
|
[node name="SaveButtons" type="HBoxContainer" parent="ScrollContainer"]
|
|
|
|
layout_mode = 2
|
2025-04-16 00:16:39 +02:00
|
|
|
size_flags_horizontal = 3
|
2025-05-07 19:56:24 +02:00
|
|
|
size_flags_vertical = 6
|
2025-04-16 00:16:39 +02:00
|
|
|
alignment = 1
|
|
|
|
|
2025-05-07 19:56:24 +02:00
|
|
|
[node name="Placeholder1" type="Button" parent="ScrollContainer/SaveButtons"]
|
2025-03-27 16:00:39 +01:00
|
|
|
layout_mode = 2
|
2025-05-08 23:02:22 +02:00
|
|
|
toggle_mode = true
|
2025-04-16 00:16:39 +02:00
|
|
|
text = "Save file #1"
|
2025-03-27 16:00:39 +01:00
|
|
|
|
2025-05-07 19:56:24 +02:00
|
|
|
[node name="Placeholder2" type="Button" parent="ScrollContainer/SaveButtons"]
|
2025-03-27 16:00:39 +01:00
|
|
|
layout_mode = 2
|
2025-05-08 23:02:22 +02:00
|
|
|
toggle_mode = true
|
2025-04-16 00:16:39 +02:00
|
|
|
text = "Save file #2"
|
2025-03-27 16:00:39 +01:00
|
|
|
|
2025-05-07 19:56:24 +02:00
|
|
|
[node name="Placeholder3" type="Button" parent="ScrollContainer/SaveButtons"]
|
2025-03-27 16:00:39 +01:00
|
|
|
layout_mode = 2
|
2025-05-08 23:02:22 +02:00
|
|
|
toggle_mode = true
|
2025-04-16 00:16:39 +02:00
|
|
|
text = "Save file #3"
|
2025-03-27 16:00:39 +01:00
|
|
|
|
2025-05-07 19:56:24 +02:00
|
|
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
|
|
|
layout_mode = 1
|
|
|
|
anchors_preset = 8
|
|
|
|
anchor_left = 0.5
|
|
|
|
anchor_top = 0.5
|
|
|
|
anchor_right = 0.5
|
|
|
|
anchor_bottom = 0.5
|
2025-05-08 23:02:22 +02:00
|
|
|
offset_left = -243.5
|
2025-05-07 19:56:24 +02:00
|
|
|
offset_top = -157.0
|
2025-05-08 23:02:22 +02:00
|
|
|
offset_right = 243.5
|
2025-05-07 19:56:24 +02:00
|
|
|
offset_bottom = 157.0
|
|
|
|
grow_horizontal = 2
|
|
|
|
grow_vertical = 2
|
|
|
|
size_flags_horizontal = 3
|
2025-05-08 23:02:22 +02:00
|
|
|
mouse_filter = 2
|
2025-05-07 19:56:24 +02:00
|
|
|
alignment = 1
|
|
|
|
|
2025-04-16 00:16:39 +02:00
|
|
|
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"]
|
2025-03-27 16:00:39 +01:00
|
|
|
layout_mode = 2
|
2025-04-16 00:16:39 +02:00
|
|
|
theme_override_constants/margin_left = 30
|
|
|
|
theme_override_constants/margin_top = 30
|
|
|
|
theme_override_constants/margin_right = 30
|
|
|
|
theme_override_constants/margin_bottom = 30
|
2025-03-27 16:00:39 +01:00
|
|
|
|
2025-04-16 00:16:39 +02:00
|
|
|
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/MarginContainer"]
|
2025-03-27 16:00:39 +01:00
|
|
|
layout_mode = 2
|
|
|
|
|
2025-04-20 23:25:51 +02:00
|
|
|
[node name="Description" type="HBoxContainer" parent="VBoxContainer/MarginContainer/VBoxContainer"]
|
|
|
|
layout_mode = 2
|
|
|
|
alignment = 1
|
|
|
|
|
|
|
|
[node name="Name" type="Label" parent="VBoxContainer/MarginContainer/VBoxContainer/Description"]
|
2025-03-27 16:00:39 +01:00
|
|
|
layout_mode = 2
|
2025-05-08 23:02:22 +02:00
|
|
|
text = "Please select a save file!"
|
|
|
|
label_settings = SubResource("LabelSettings_gc46s")
|
2025-04-16 00:16:39 +02:00
|
|
|
horizontal_alignment = 1
|
2025-05-08 23:02:22 +02:00
|
|
|
vertical_alignment = 1
|
2025-03-27 16:00:39 +01:00
|
|
|
|
2025-04-20 23:25:51 +02:00
|
|
|
[node name="Time" type="Label" parent="VBoxContainer/MarginContainer/VBoxContainer/Description"]
|
|
|
|
layout_mode = 2
|
|
|
|
|
|
|
|
[node name="Buttons" type="HBoxContainer" parent="VBoxContainer/MarginContainer/VBoxContainer"]
|
2025-03-27 16:00:39 +01:00
|
|
|
layout_mode = 2
|
2025-04-16 00:16:39 +02:00
|
|
|
alignment = 1
|
2025-03-27 16:00:39 +01:00
|
|
|
|
2025-04-20 23:25:51 +02:00
|
|
|
[node name="Start" type="Button" parent="VBoxContainer/MarginContainer/VBoxContainer/Buttons"]
|
2025-05-07 19:56:24 +02:00
|
|
|
custom_minimum_size = Vector2(300, 0)
|
2025-04-16 00:16:39 +02:00
|
|
|
layout_mode = 2
|
|
|
|
size_flags_horizontal = 3
|
2025-05-08 23:02:22 +02:00
|
|
|
disabled = true
|
2025-04-16 00:16:39 +02:00
|
|
|
text = "Start"
|
|
|
|
|
2025-04-20 23:25:51 +02:00
|
|
|
[node name="Delete" type="Button" parent="VBoxContainer/MarginContainer/VBoxContainer/Buttons"]
|
2025-04-16 00:16:39 +02:00
|
|
|
layout_mode = 2
|
2025-05-08 23:02:22 +02:00
|
|
|
disabled = true
|
2025-04-16 00:16:39 +02:00
|
|
|
text = "Delete"
|
2025-03-27 16:00:39 +01:00
|
|
|
|
2025-04-20 23:25:51 +02:00
|
|
|
[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"]
|