- Added an event when switching to another input device. - Added InitialSetupMenu, which shows up when starting the game for the first time. - Updated entrance hall csg. - Added DialogBank for easier localization. - Shaders can now be paused and time scaled. - Added shading the edges of the beating lightbeam shader.
79 lines
1.8 KiB
GDScript
79 lines
1.8 KiB
GDScript
class_name PauseMenu
|
|
extends Control
|
|
|
|
|
|
@export var world: World
|
|
|
|
@onready var continue_button: Button = %ContinueButton
|
|
@onready var settings_button: Button = %SettingsButton
|
|
@onready var main_menu_button: Button = %MainMenuButton
|
|
|
|
@onready var settings_menu: SettingsMenu = %SettingsMenu
|
|
|
|
|
|
func _ready() -> void:
|
|
continue_button.pressed.connect(_on_continue_button_pressed)
|
|
settings_button.pressed.connect(_on_settings_button_pressed)
|
|
main_menu_button.pressed.connect(_on_main_menu_button_pressed)
|
|
|
|
settings_menu.close_request.connect(_on_settings_menu_close_requested)
|
|
|
|
InputManager.input_method_changed.connect(_on_input_method_changed)
|
|
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
if event.is_action_pressed(&"pause"):
|
|
if settings_menu.is_visible_in_tree():
|
|
settings_menu.close()
|
|
else:
|
|
toggle_pause()
|
|
|
|
|
|
func set_paused(value: bool) -> void:
|
|
ShaderGlobals.set_paused(value)
|
|
world.process_mode = Node.PROCESS_MODE_DISABLED if value else Node.PROCESS_MODE_INHERIT
|
|
visible = value
|
|
|
|
if visible:
|
|
_on_input_method_changed(InputManager.using_controller)
|
|
continue_button.grab_focus()
|
|
else:
|
|
InputManager.capture_mouse()
|
|
|
|
|
|
func is_paused() -> bool:
|
|
return world.process_mode == Node.PROCESS_MODE_DISABLED
|
|
|
|
|
|
func toggle_pause() -> void:
|
|
set_paused(not is_paused())
|
|
|
|
|
|
func _on_continue_button_pressed() -> void:
|
|
set_process_input(true)
|
|
set_paused(false)
|
|
|
|
|
|
func _on_settings_button_pressed() -> void:
|
|
settings_menu.show()
|
|
|
|
|
|
func _on_settings_menu_close_requested() -> void:
|
|
settings_menu.hide()
|
|
settings_button.grab_focus()
|
|
|
|
|
|
func _on_main_menu_button_pressed() -> void:
|
|
set_process_input(false)
|
|
world.request_world_unload()
|
|
|
|
|
|
func _on_input_method_changed(is_using_controller: bool) -> void:
|
|
if not is_paused():
|
|
return
|
|
|
|
if is_using_controller:
|
|
InputManager.capture_mouse()
|
|
else:
|
|
InputManager.release_mouse()
|