First commit 🎉
This commit is contained in:
commit
43ea213f9b
728 changed files with 37080 additions and 0 deletions
|
@ -0,0 +1,134 @@
|
|||
@tool
|
||||
extends PopochiuPopup
|
||||
|
||||
signal slot_selected
|
||||
|
||||
const SELECTION_COLOR := Color("edf171")
|
||||
const OVERWRITE_COLOR := Color("c46c71")
|
||||
|
||||
var _current_slot: Button = null
|
||||
var _slot_name := ""
|
||||
var _prev_text := ""
|
||||
var _slot := 0
|
||||
|
||||
@onready var slots: VBoxContainer = %Slots
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
super()
|
||||
|
||||
if Engine.is_editor_hint(): return
|
||||
|
||||
btn_ok.disabled = true
|
||||
|
||||
var saves: Dictionary = PopochiuUtils.e.get_saves_descriptions()
|
||||
|
||||
for btn: Button in slots.get_children():
|
||||
btn.set_meta("has_save", false)
|
||||
|
||||
if saves.has(btn.get_index() + 1):
|
||||
btn.text = saves[btn.get_index() + 1]
|
||||
btn.set_meta("has_save", true)
|
||||
else:
|
||||
btn.disabled = true
|
||||
|
||||
btn.pressed.connect(_select_slot.bind(btn))
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Virtual ####################################################################################
|
||||
func _open() -> void:
|
||||
btn_ok.disabled = true
|
||||
_slot = 0
|
||||
|
||||
if _current_slot:
|
||||
_current_slot.text = _prev_text
|
||||
_current_slot.button_pressed = false
|
||||
|
||||
_current_slot = null
|
||||
_prev_text = ""
|
||||
|
||||
|
||||
func _close() -> void:
|
||||
if not _slot: return
|
||||
|
||||
slot_selected.emit()
|
||||
|
||||
if _slot_name:
|
||||
PopochiuUtils.e.save_game(_slot, _slot_name)
|
||||
else:
|
||||
PopochiuUtils.e.load_game(_slot)
|
||||
|
||||
|
||||
func _on_ok() -> void:
|
||||
_slot = _current_slot.get_index() + 1
|
||||
|
||||
if _slot_name:
|
||||
_prev_text = _current_slot.text
|
||||
_current_slot.set_meta("has_save", true)
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public #####################################################################################
|
||||
func open_save() -> void:
|
||||
_show_save()
|
||||
|
||||
|
||||
func open_load() -> void:
|
||||
_show_load()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _show_save(slot_text := "") -> void:
|
||||
lbl_title.text = "Choose a slot to save the game"
|
||||
_slot_name = slot_text
|
||||
|
||||
if _slot_name.is_empty():
|
||||
_slot_name = _format_date(Time.get_datetime_dict_from_system())
|
||||
|
||||
for btn in slots.get_children():
|
||||
btn.disabled = false
|
||||
|
||||
open()
|
||||
|
||||
|
||||
func _show_load() -> void:
|
||||
lbl_title.text = "Choose the slot to load"
|
||||
_slot_name = ""
|
||||
|
||||
for btn in slots.get_children():
|
||||
btn.disabled = !(btn as Button).get_meta("has_save")
|
||||
|
||||
open()
|
||||
|
||||
|
||||
func _select_slot(btn: Button) -> void:
|
||||
if _slot_name:
|
||||
if _current_slot:
|
||||
_current_slot.text = _prev_text
|
||||
_current_slot.button_pressed = false
|
||||
|
||||
_current_slot = btn
|
||||
_prev_text = _current_slot.text
|
||||
_current_slot.text = _slot_name
|
||||
else:
|
||||
if _current_slot:
|
||||
_current_slot.button_pressed = false
|
||||
|
||||
_current_slot = btn
|
||||
_prev_text = _current_slot.text
|
||||
|
||||
btn_ok.disabled = false
|
||||
|
||||
|
||||
func _format_date(date: Dictionary) -> String:
|
||||
return "%d/%02d/%02d %02d:%02d:%02d" % [
|
||||
date.year, date.month, date.day, date.hour, date.minute, date.second
|
||||
]
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://5wnpp5td5dcx
|
|
@ -0,0 +1,100 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://tgyca2usqnn1"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://djl1xk7jgyvpp" path="res://game/gui/resources/gui_theme.tres" id="1_vmhif"]
|
||||
[ext_resource type="Script" uid="uid://c30sbvthxnrr0" path="res://game/gui/components/popups/save_and_load_popup/save_and_load_popup_custom.gd" id="2_mh08k"]
|
||||
[ext_resource type="StyleBox" uid="uid://ue48aimeiar7" path="res://game/gui/components/popups/popochiu_popup_panel_container.tres" id="3_3nj74"]
|
||||
[ext_resource type="Texture2D" uid="uid://d127ve13o2kpl" path="res://game/gui/resources/images/close.png" id="4_sf4bt"]
|
||||
[ext_resource type="Texture2D" uid="uid://b3q226w2e3giu" path="res://game/gui/resources/images/close_highlight.png" id="5_xdowh"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_yg86r"]
|
||||
|
||||
[node name="SaveAndLoadPopup" type="Control" groups=["popochiu_gui_popup"]]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_vmhif")
|
||||
script = ExtResource("2_mh08k")
|
||||
script_name = &"SaveAndLoadPopup"
|
||||
|
||||
[node name="Overlay" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_yg86r")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Overlay"]
|
||||
custom_minimum_size = Vector2(192, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
theme_override_styles/panel = ExtResource("3_3nj74")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Overlay/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HeaderContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="Label" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Choose a slot to..."
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Close" type="TextureButton" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
texture_normal = ExtResource("4_sf4bt")
|
||||
texture_pressed = ExtResource("5_xdowh")
|
||||
texture_hover = ExtResource("5_xdowh")
|
||||
|
||||
[node name="Slots" type="VBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
alignment = 1
|
||||
|
||||
[node name="BtnSlot1" type="Button" parent="Overlay/PanelContainer/VBoxContainer/Slots"]
|
||||
layout_mode = 2
|
||||
toggle_mode = true
|
||||
text = "slot 1"
|
||||
|
||||
[node name="BtnSlot2" type="Button" parent="Overlay/PanelContainer/VBoxContainer/Slots"]
|
||||
layout_mode = 2
|
||||
toggle_mode = true
|
||||
text = "slot 2"
|
||||
|
||||
[node name="BtnSlot3" type="Button" parent="Overlay/PanelContainer/VBoxContainer/Slots"]
|
||||
layout_mode = 2
|
||||
toggle_mode = true
|
||||
text = "slot 3"
|
||||
|
||||
[node name="BtnSlot4" type="Button" parent="Overlay/PanelContainer/VBoxContainer/Slots"]
|
||||
layout_mode = 2
|
||||
toggle_mode = true
|
||||
text = "slot 4"
|
||||
|
||||
[node name="FooterContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
alignment = 1
|
||||
|
||||
[node name="Ok" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "OK"
|
||||
|
||||
[node name="Cancel" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Cancel"
|
|
@ -0,0 +1,2 @@
|
|||
@tool
|
||||
extends "save_and_load_popup.gd"
|
|
@ -0,0 +1 @@
|
|||
uid://c30sbvthxnrr0
|
Loading…
Add table
Add a link
Reference in a new issue