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,12 @@
extends PopupDialog
signal confirm_yes
func _on_no_pressed():
hide()
func _on_yes_pressed():
emit_signal("confirm_yes")
hide()

View File

@@ -0,0 +1,67 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/overwrite_confirm_popup.gd" type="Script" id=2]
[node name="overwrite_confirm_popup" type="PopupDialog"]
visible = true
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
custom_constants/margin_right = 30
custom_constants/margin_top = 30
custom_constants/margin_left = 30
custom_constants/margin_bottom = 30
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
margin_left = 30.0
margin_top = 423.0
margin_right = 1250.0
margin_bottom = 477.0
size_flags_vertical = 4
custom_constants/separation = 20
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
margin_right = 1220.0
margin_bottom = 14.0
text = "CONFIRM_OVERWRITE"
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
margin_top = 34.0
margin_right = 1220.0
margin_bottom = 54.0
custom_constants/separation = 10
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="yes" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
margin_left = 1144.0
margin_right = 1177.0
margin_bottom = 20.0
text = "YES"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="no" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
margin_left = 1187.0
margin_right = 1220.0
margin_bottom = 20.0
text = "NO"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/yes" to="." method="_on_yes_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/no" to="." method="_on_no_pressed"]

View File

@@ -0,0 +1,75 @@
# A container for saving to 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
# The slot that was pressed
var _slot_pressed = null
# Load the savegames when loaded
func _ready():
refresh_savegames()
# A slot was pressed, save the game
func _on_slot_pressed(p_slot_n: int):
_slot_pressed = p_slot_n
if escoria.save_manager.save_game_exists(p_slot_n):
$overwrite_confirm_popup.popup_centered_ratio(.3)
else:
$save_name_popup.popup_centered_ratio(.3)
# Create the slots from the list of savegames
func refresh_savegames():
var _slots = $VBoxContainer/ScrollContainer/slots
for slot in _slots.get_children():
_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()
_slots.add_child(new_slot)
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])
var datetime = OS.get_datetime()
var datetime_string = "%02d/%02d/%02d %02d:%02d" % [
datetime["day"],
datetime["month"],
datetime["year"],
datetime["hour"],
datetime["minute"],
]
var new_slot = slot_ui_scene.instance()
_slots.add_child(new_slot)
new_slot.set_slot_name_date(tr("New save"), datetime_string)
new_slot.connect("pressed", self, "_on_slot_pressed", [saves_list.size()+1])
# The back button was pressed
func _on_back_pressed():
emit_signal("back_button_pressed")
# The name for the save game was given, save the game.
#
# #### Parameters
# - p_savename: The name of the savegame entered
func _on_save_name_popup_savegame_name_ok(p_savename: String):
escoria.save_manager.save_game(_slot_pressed, p_savename)
refresh_savegames()
_slot_pressed = null
# Overwriting the savegame was confirmed, show the save name popup
func _on_overwrite_confirm_popup_confirm_yes():
$save_name_popup.popup_centered_ratio(.3)

View File

@@ -0,0 +1,72 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load_save_slot/load_save_slot.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/save_game.gd" type="Script" id=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/save_name_popup.tscn" type="PackedScene" id=4]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/overwrite_confirm_popup.tscn" type="PackedScene" id=5]
[node name="save_game" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
slot_ui_scene = ExtResource( 1 )
[node name="Panel" type="Panel" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = -1.0
margin_bottom = -1.0
__meta__ = {
"_editor_description_": ""
}
[node name="save_name_popup" parent="." instance=ExtResource( 4 )]
visible = false
[node name="overwrite_confirm_popup" parent="." instance=ExtResource( 5 )]
visible = false
[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="savegame_name_ok" from="save_name_popup" to="." method="_on_save_name_popup_savegame_name_ok"]
[connection signal="confirm_yes" from="overwrite_confirm_popup" to="." method="_on_overwrite_confirm_popup_confirm_yes"]
[connection signal="pressed" from="VBoxContainer/back" to="." method="_on_back_pressed"]

View File

@@ -0,0 +1,14 @@
extends PopupDialog
signal savegame_name_ok(savegame_name)
signal savegame_cancel
func _on_cancel_pressed():
emit_signal("savegame_cancel")
hide()
func _on_ok_pressed():
if not $MarginContainer/VBoxContainer/LineEdit.text.empty():
emit_signal("savegame_name_ok", $MarginContainer/VBoxContainer/LineEdit.text)
$MarginContainer/VBoxContainer/LineEdit.clear()
hide()

View File

@@ -0,0 +1,72 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/save_name_popup.gd" type="Script" id=2]
[node name="save_name_popup" type="PopupDialog"]
visible = true
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
custom_constants/margin_right = 30
custom_constants/margin_top = 30
custom_constants/margin_left = 30
custom_constants/margin_bottom = 30
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
margin_left = 30.0
margin_top = 401.0
margin_right = 1250.0
margin_bottom = 499.0
size_flags_vertical = 4
custom_constants/separation = 20
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
margin_right = 1220.0
margin_bottom = 14.0
text = "ENTER_SAVE_NAME"
[node name="LineEdit" type="LineEdit" parent="MarginContainer/VBoxContainer"]
margin_top = 34.0
margin_right = 1220.0
margin_bottom = 58.0
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
margin_top = 78.0
margin_right = 1220.0
margin_bottom = 98.0
custom_constants/separation = 10
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="cancel" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
margin_left = 1118.0
margin_right = 1179.0
margin_bottom = 20.0
text = "CANCEL"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ok" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
margin_left = 1189.0
margin_right = 1220.0
margin_bottom = 20.0
text = "OK"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/cancel" to="." method="_on_cancel_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/ok" to="." method="_on_ok_pressed"]