Create UI for saving/loading handling

This commit is contained in:
TheThomaas 2026-10-12 17:17:03 +02:00
parent 53e5ca8f7b
commit c1415f3e43
3 changed files with 41 additions and 0 deletions

29
game/ui/hud/save_hud.gd Normal file
View file

@ -0,0 +1,29 @@
extends CanvasLayer
@onready var panel : PanelContainer = $Panel
@onready var label : Label = $Panel/Label
func _ready() -> void:
panel.visible = false
GameData.save_started.connect(_on_save_started)
GameData.save_finished.connect(_on_save_finished)
func _on_save_started() -> void:
label.text = "Sauvegarde en cours..."
panel.visible = true
panel.modulate.a = 1.0
func _on_save_finished(success : bool) -> void:
label.text = "Sauvegardé !" if success else "Échec de la sauvegarde"
_fade_out()
func _on_load_finished(success : bool) -> void:
label.text = "Chargé !" if success else "Aucune sauvegarde"
_fade_out()
func _fade_out() -> void:
# petit fade out après un court délai
var tween := create_tween()
tween.tween_interval(0.8)
tween.tween_property(panel, "modulate:a", 0.0, 0.3)
tween.tween_callback(func() -> void: panel.visible = false)

View file

@ -0,0 +1 @@
uid://rgm6aitwyxdv

View file

@ -1,6 +1,7 @@
[gd_scene format=3 uid="uid://di22cs2qposdm"]
[ext_resource type="Script" uid="uid://7hglx6nfu063" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_4xhdt"]
[ext_resource type="Script" uid="uid://rgm6aitwyxdv" path="res://game/ui/hud/save_hud.gd" id="1_euh0j"]
[ext_resource type="Script" uid="uid://b3ddqgiawrh5c" path="res://game/ui/hud/team_hud.gd" id="2_lkjh2"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_uyiaf"]
@ -25,6 +26,16 @@ metadata/_custom_type_script = "uid://7hglx6nfu063"
[node name="Ui" type="CanvasLayer" unique_id=1492671226]
[node name="SaveHUD" type="CanvasLayer" parent="." unique_id=319200051]
script = ExtResource("1_euh0j")
[node name="Panel" type="PanelContainer" parent="SaveHUD" unique_id=243494129]
offset_right = 40.0
offset_bottom = 40.0
[node name="Label" type="Label" parent="SaveHUD/Panel" unique_id=42675420]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="." unique_id=38584238]
anchors_preset = 3
anchor_left = 1.0