Add PC to pause menu
This commit is contained in:
parent
d4740e818a
commit
7c78f973f1
|
|
@ -5,9 +5,14 @@ extends CanvasLayer
|
|||
@export var click_sound : AudioStream
|
||||
|
||||
@onready var resume_button: Button = $PanelContainer/VBoxContainer/Resume
|
||||
@onready var storage_button: Button = $PanelContainer/VBoxContainer/Storage
|
||||
@onready var save_button: Button = $PanelContainer/VBoxContainer/Save
|
||||
@onready var menu_panel: PanelContainer = $PanelContainer
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
|
||||
var is_transitioning : bool = false
|
||||
var pc_screen : PCScreen = null
|
||||
var save_feedback_active : bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
|
|
@ -15,7 +20,7 @@ func _ready() -> void:
|
|||
animation_player.play("RESET")
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if is_transitioning: return
|
||||
if is_transitioning or pc_screen != null: return #le PC gere ses propres entrees
|
||||
if event.is_action_pressed("pause"):
|
||||
if get_tree().paused:
|
||||
resume()
|
||||
|
|
@ -50,6 +55,37 @@ func resume() -> void:
|
|||
func _on_resume_pressed() -> void:
|
||||
resume()
|
||||
|
||||
func _on_storage_pressed() -> void:
|
||||
if is_transitioning or pc_screen != null: return
|
||||
UiAudio.play(click_sound)
|
||||
|
||||
GameData.player_team.add_pokemon(PokemonInstance.create(Pokedex.get_pokemon("pikachu"), 15))
|
||||
|
||||
pc_screen = PCScreen.new()
|
||||
add_child(pc_screen) #ajoute en dernier : s'affiche au-dessus du menu
|
||||
pc_screen.setup(GameData.player_team, GameData.player_storage)
|
||||
pc_screen.closed.connect(_on_pc_closed)
|
||||
menu_panel.hide() #le flou de fond reste visible derriere le PC
|
||||
|
||||
func _on_pc_closed() -> void:
|
||||
if pc_screen:
|
||||
pc_screen.queue_free()
|
||||
pc_screen = null
|
||||
menu_panel.show()
|
||||
storage_button.grab_focus()
|
||||
|
||||
func _on_save_pressed() -> void:
|
||||
UiAudio.play(click_sound)
|
||||
GameData.save()
|
||||
|
||||
#retour visuel temporaire sur le bouton (le focus reste dessus, pour la manette)
|
||||
if save_feedback_active: return
|
||||
save_feedback_active = true
|
||||
save_button.text = "Sauvegardé !"
|
||||
await get_tree().create_timer(1.5, true).timeout #true = continue meme en pause
|
||||
save_button.text = "Sauvegarder"
|
||||
save_feedback_active = false
|
||||
|
||||
func _on_restart_pressed() -> void:
|
||||
UiAudio.play(click_sound)
|
||||
get_tree().paused = false
|
||||
|
|
|
|||
|
|
@ -162,12 +162,24 @@ alignment = 1
|
|||
|
||||
[node name="Resume" type="Button" parent="PanelContainer/VBoxContainer" unique_id=1186461560]
|
||||
layout_mode = 2
|
||||
focus_neighbor_bottom = NodePath("../Restart")
|
||||
focus_neighbor_bottom = NodePath("../Storage")
|
||||
text = "Resume"
|
||||
|
||||
[node name="Storage" type="Button" parent="PanelContainer/VBoxContainer" unique_id=1204857311]
|
||||
layout_mode = 2
|
||||
focus_neighbor_top = NodePath("../Resume")
|
||||
focus_neighbor_bottom = NodePath("../Save")
|
||||
text = "Pokémon Storage"
|
||||
|
||||
[node name="Save" type="Button" parent="PanelContainer/VBoxContainer" unique_id=1730492856]
|
||||
layout_mode = 2
|
||||
focus_neighbor_top = NodePath("../Storage")
|
||||
focus_neighbor_bottom = NodePath("../Restart")
|
||||
text = "Sauvegarder"
|
||||
|
||||
[node name="Restart" type="Button" parent="PanelContainer/VBoxContainer" unique_id=389396198]
|
||||
layout_mode = 2
|
||||
focus_neighbor_top = NodePath("../Resume")
|
||||
focus_neighbor_top = NodePath("../Save")
|
||||
focus_neighbor_bottom = NodePath("../Quit")
|
||||
text = "Restart"
|
||||
|
||||
|
|
@ -180,5 +192,7 @@ text = "Quit"
|
|||
libraries/ = SubResource("AnimationLibrary_2nc7s")
|
||||
|
||||
[connection signal="pressed" from="PanelContainer/VBoxContainer/Resume" to="." method="_on_resume_pressed"]
|
||||
[connection signal="pressed" from="PanelContainer/VBoxContainer/Storage" to="." method="_on_storage_pressed"]
|
||||
[connection signal="pressed" from="PanelContainer/VBoxContainer/Save" to="." method="_on_save_pressed"]
|
||||
[connection signal="pressed" from="PanelContainer/VBoxContainer/Restart" to="." method="_on_restart_pressed"]
|
||||
[connection signal="pressed" from="PanelContainer/VBoxContainer/Quit" to="." method="_on_quit_pressed"]
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
[ext_resource type="PackedScene" uid="uid://di22cs2qposdm" path="res://game/ui/hud/ui.tscn" id="7_yebv1"]
|
||||
[ext_resource type="PackedScene" uid="uid://d1mcef8gl66j" path="res://game/ui/pause_menu/pause_menu.tscn" id="8_g80jn"]
|
||||
[ext_resource type="PackedScene" uid="uid://dwxpt0s7vn36k" path="res://game/player/player_character.tscn" id="9_42ub6"]
|
||||
[ext_resource type="Script" uid="uid://dmdmxqw3k3ntu" path="res://game/storage/storage.gd" id="10_rr16o"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_tipki"]
|
||||
sky_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
|
||||
|
|
@ -117,6 +116,3 @@ process_mode = 3
|
|||
|
||||
[node name="PlayerCharacter" parent="." unique_id=1830301535 instance=ExtResource("9_42ub6")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.2155721, -0.00040316582, 0.73769236)
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=78269872]
|
||||
script = ExtResource("10_rr16o")
|
||||
|
|
|
|||
Loading…
Reference in a new issue