From 423ed95f02763c17d87dd02d5800ea72e33d92e5 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 30 Mar 2025 08:26:08 +0200 Subject: [PATCH] =?UTF-8?q?Information=20de=20date=20de=20derni=C3=A8re=20?= =?UTF-8?q?sauvegarde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UI/men3FD6.tmp | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ UI/menu.gd | 18 ++++++++++-- UI/menu.tscn | 21 ++++++++++---- 3 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 UI/men3FD6.tmp diff --git a/UI/men3FD6.tmp b/UI/men3FD6.tmp new file mode 100644 index 0000000..1a44d6a --- /dev/null +++ b/UI/men3FD6.tmp @@ -0,0 +1,78 @@ +[gd_scene load_steps=6 format=3 uid="uid://44wla7mlivqm"] + +[ext_resource type="Script" path="res://UI/menu.gd" id="1_30mo7"] +[ext_resource type="FontFile" uid="uid://c1lnxul6k2adw" path="res://assest/font/vhs-gothic.ttf" id="2_6inip"] +[ext_resource type="Theme" uid="uid://bn1flbuijm27d" path="res://UI/menu_button.tres" id="3_feq31"] + +[sub_resource type="LabelSettings" id="LabelSettings_q3w7i"] +line_spacing = 45.0 +font = ExtResource("2_6inip") +font_size = 60 + +[sub_resource type="LabelSettings" id="LabelSettings_i5c8e"] +font_size = 30 + +[node name="Menu" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_30mo7") + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Panel" type="Panel" parent="MarginContainer"] +layout_mode = 2 +size_flags_stretch_ratio = 1.37 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/Panel"] +layout_mode = 2 +offset_right = 1920.0 +offset_bottom = 1080.0 + +[node name="Label" type="Label" parent="MarginContainer/Panel/VBoxContainer"] +layout_mode = 2 +text = " +Chaussette sale, le jeu! + +" +label_settings = SubResource("LabelSettings_q3w7i") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="HSeparator" type="HSeparator" parent="MarginContainer/Panel/VBoxContainer"] +layout_mode = 2 + +[node name="Start" type="Button" parent="MarginContainer/Panel/VBoxContainer"] +layout_mode = 2 +theme = ExtResource("3_feq31") +text = "Démarrer une nouvelle partie" + +[node name="Save" type="Button" parent="MarginContainer/Panel/VBoxContainer"] +layout_mode = 2 +theme = ExtResource("3_feq31") +disabled = true +text = "Sauvegarder" + +[node name="Load" type="Button" parent="MarginContainer/Panel/VBoxContainer"] +layout_mode = 2 +theme = ExtResource("3_feq31") +text = "Charger" + +[node name="LastSaveInfo" type="Label" parent="MarginContainer/Panel/VBoxContainer"] +layout_mode = 2 +text = "Last save" +label_settings = SubResource("LabelSettings_i5c8e") +horizontal_alignment = 1 + +[connection signal="pressed" from="MarginContainer/Panel/VBoxContainer/Start" to="." method="_on_button_pressed"] +[connection signal="pressed" from="MarginContainer/Panel/VBoxContainer/Save" to="." method="_on_save_pressed"] +[connection signal="pressed" from="MarginContainer/Panel/VBoxContainer/Load" to="." method="_on_load_pressed"] diff --git a/UI/menu.gd b/UI/menu.gd index ddf84f9..6d8da75 100644 --- a/UI/menu.gd +++ b/UI/menu.gd @@ -10,8 +10,22 @@ signal load var instanciated_destinations = {} +func set_last_save_info(): + if FileAccess.file_exists("user://savegame.save"): + $MarginContainer/Panel/VBoxContainer/Load.disabled = false + $MarginContainer/Panel/VBoxContainer/LastSaveInfo.text = "Dernière sauvegarde: "+str( + Time.get_datetime_string_from_unix_time( + FileAccess.get_modified_time( + "user://savegame.save" + ) + ) + ) + else: + $MarginContainer/Panel/VBoxContainer/Load.disabled = true + + func _ready() -> void: - $MarginContainer/Panel/VBoxContainer/Load.disabled = not FileAccess.file_exists("user://savegame.save") + set_last_save_info() func _on_button_pressed() -> void: emit_signal("start") @@ -20,7 +34,7 @@ func _on_button_pressed() -> void: func _on_save_pressed() -> void: emit_signal("save") - $MarginContainer/Panel/VBoxContainer/Load.disabled = not FileAccess.file_exists("user://savegame.save") + set_last_save_info() func _on_load_pressed() -> void: diff --git a/UI/menu.tscn b/UI/menu.tscn index 5a883ec..ed24429 100644 --- a/UI/menu.tscn +++ b/UI/menu.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=5 format=3 uid="uid://44wla7mlivqm"] +[gd_scene load_steps=6 format=3 uid="uid://44wla7mlivqm"] [ext_resource type="Script" path="res://UI/menu.gd" id="1_30mo7"] [ext_resource type="FontFile" uid="uid://c1lnxul6k2adw" path="res://assest/font/vhs-gothic.ttf" id="2_6inip"] @@ -9,6 +9,9 @@ line_spacing = 45.0 font = ExtResource("2_6inip") font_size = 60 +[sub_resource type="LabelSettings" id="LabelSettings_i5c8e"] +font_size = 30 + [node name="Menu" type="Control"] layout_mode = 3 anchors_preset = 15 @@ -53,17 +56,23 @@ layout_mode = 2 theme = ExtResource("3_feq31") text = "Démarrer une nouvelle partie" -[node name="Save" type="Button" parent="MarginContainer/Panel/VBoxContainer"] +[node name="LastSaveInfo" type="Label" parent="MarginContainer/Panel/VBoxContainer"] layout_mode = 2 -theme = ExtResource("3_feq31") -disabled = true -text = "Sauvegarder" +text = "Last save" +label_settings = SubResource("LabelSettings_i5c8e") +horizontal_alignment = 1 [node name="Load" type="Button" parent="MarginContainer/Panel/VBoxContainer"] layout_mode = 2 theme = ExtResource("3_feq31") text = "Charger" +[node name="Save" type="Button" parent="MarginContainer/Panel/VBoxContainer"] +layout_mode = 2 +theme = ExtResource("3_feq31") +disabled = true +text = "Sauvegarder" + [connection signal="pressed" from="MarginContainer/Panel/VBoxContainer/Start" to="." method="_on_button_pressed"] -[connection signal="pressed" from="MarginContainer/Panel/VBoxContainer/Save" to="." method="_on_save_pressed"] [connection signal="pressed" from="MarginContainer/Panel/VBoxContainer/Load" to="." method="_on_load_pressed"] +[connection signal="pressed" from="MarginContainer/Panel/VBoxContainer/Save" to="." method="_on_save_pressed"]