This commit is contained in:
2023-02-07 16:21:22 +01:00
parent 0ba6c3782a
commit 4371d1d386
46 changed files with 1702 additions and 52 deletions

View File

@@ -0,0 +1,46 @@
# A container for loading from a save slot
extends Control
# Emitted when the back button is pressed
signal back_button_pressed
# The scene to display a slot
export(PackedScene) var slot_ui_scene
# Load the savegames when loaded
func _ready():
refresh_savegames()
# A slot was pressed. Load the game
#
# #### Parameters
# - slot_id: The slot that was pressed
func _on_slot_pressed(slot_id: int) -> void:
escoria.save_manager.load_game(slot_id)
# The back button was pressed
func _on_back_pressed():
emit_signal("back_button_pressed")
# Create the slots from the list of savegames
func refresh_savegames():
for slot in $VBoxContainer/ScrollContainer/slots.get_children():
$VBoxContainer/ScrollContainer/slots.remove_child(slot)
var saves_list = escoria.save_manager.get_saves_list()
if not saves_list.empty():
for save_key in saves_list.keys():
var new_slot = slot_ui_scene.instance()
$VBoxContainer/ScrollContainer/slots.add_child(
new_slot
)
# Move newest save to the top of the list
$VBoxContainer/ScrollContainer/slots.move_child(new_slot, 0)
new_slot.set_slot_name_date(saves_list[save_key]["name"], saves_list[save_key]["date"])
new_slot.connect("pressed", self, "_on_slot_pressed", [save_key])

View File

@@ -0,0 +1,60 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load_save_slot/load_save_slot.tscn" type="PackedScene" id=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load/load_game.gd" type="Script" id=3]
[node name="load_game" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
slot_ui_scene = ExtResource( 2 )
[node name="Panel" type="Panel" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_editor_description_": ""
}
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_left = 0.3
anchor_top = 0.3
anchor_right = 0.7
anchor_bottom = 0.7
margin_left = -55.5
margin_right = 55.5
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
margin_right = 623.0
margin_bottom = 336.0
size_flags_vertical = 3
scroll_horizontal_enabled = false
__meta__ = {
"_edit_use_anchors_": false
}
[node name="slots" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"]
margin_right = 623.0
margin_bottom = 336.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="back" type="Button" parent="VBoxContainer"]
margin_top = 340.0
margin_right = 623.0
margin_bottom = 360.0
text = "OPTIONS_BACK"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="VBoxContainer/back" to="." method="_on_back_pressed"]