-
Notifications
You must be signed in to change notification settings - Fork 313
Expand file tree
/
Copy pathpause_overlay.gd
More file actions
70 lines (47 loc) · 1.58 KB
/
pause_overlay.gd
File metadata and controls
70 lines (47 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# SPDX-FileCopyrightText: The Threadbare Authors
# SPDX-License-Identifier: MPL-2.0
extends CanvasLayer
@export_file("*.tscn") var title_scene: String
@export_file("*.tscn") var frays_end: String
@onready var pause_menu: Control = %PauseMenu
@onready var resume_button: Button = %ResumeButton
@onready var inventory: Control = %Inventory
@onready var options: Control = %Options
@onready var abandon_quest_button: Button = %AbandonQuestButton
func _ready() -> void:
visible = false
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed(&"pause"):
toggle_pause()
get_viewport().set_input_as_handled()
func toggle_pause() -> void:
var new_state := not get_tree().paused
visible = new_state
get_tree().paused = new_state
if new_state:
abandon_quest_button.visible = GameState.is_on_quest()
pause_menu.show()
resume_button.grab_focus()
func _on_abandon_quest_pressed() -> void:
toggle_pause()
GameState.abandon_quest()
SceneSwitcher.change_to_file_with_transition(
frays_end, ^"", Transition.Effect.FADE, Transition.Effect.FADE
)
func _on_inventory_button_pressed() -> void:
inventory.show()
func _on_inventory_back() -> void:
pause_menu.show()
resume_button.grab_focus()
func _on_options_button_pressed() -> void:
options.show()
func _on_options_back() -> void:
pause_menu.show()
resume_button.grab_focus()
func _on_resume_button_pressed() -> void:
toggle_pause()
func _on_title_screen_button_pressed() -> void:
toggle_pause()
SceneSwitcher.change_to_file_with_transition(
title_scene, ^"", Transition.Effect.FADE, Transition.Effect.FADE
)