xiandie/scene/ux/panel/ux_panel.gd

45 lines
1.3 KiB
GDScript3
Raw Normal View History

2025-06-27 14:52:46 +00:00
extends CanvasLayer
2025-06-27 15:23:48 +00:00
# 继续 笔记 设置 返回主菜单 退出游戏
@onready var continue_btn = %"继续" as Button
@onready var note_btn = %"笔记" as Button
@onready var settings_btn = %"设置" as Button
@onready var main_menu_btn = %"返回主菜单" as Button
@onready var quit_btn = %"退出游戏" as Button
2025-06-27 14:52:46 +00:00
func _ready() -> void:
2025-06-27 15:23:48 +00:00
$SfxOpen.play()
2025-06-27 14:52:46 +00:00
layer = GlobalConfig.CANVAS_LAYER_UX_PANEL
SceneManager.toggle_pause_counter(true)
2025-06-30 10:33:40 +00:00
continue_btn.pressed.connect(_continue)
2025-06-27 15:23:48 +00:00
note_btn.pressed.connect(SceneManager.show_note)
settings_btn.pressed.connect(SceneManager.show_settings)
2025-06-30 10:33:40 +00:00
main_menu_btn.pressed.connect(_index_menu)
2025-06-27 15:23:48 +00:00
quit_btn.pressed.connect(_quit_game)
func _quit_game() -> void:
# 从 ArchiveManager 处理退出信号
ArchiveManager.notification(NOTIFICATION_WM_CLOSE_REQUEST)
# 退出游戏过程隐藏界面
# 隐藏 panel
2025-06-30 10:33:40 +00:00
_continue()
2025-06-27 15:23:48 +00:00
2025-06-30 10:33:40 +00:00
func _continue():
$SfxClose.global_play()
2025-06-27 15:23:48 +00:00
SceneManager.toggle_pause_counter(false)
queue_free()
2025-06-27 14:52:46 +00:00
2025-06-30 10:33:40 +00:00
func _index_menu():
SceneManager.checkout_index_page()
# 允许 ground loader 运行 transition
_continue()
2025-06-27 14:52:46 +00:00
func _unhandled_input(event: InputEvent) -> void:
# panel 界面接受所有输入事件
get_viewport().set_input_as_handled()
2025-06-27 15:23:48 +00:00
if event.is_action_pressed("cancel") or event.is_action_pressed("escape"):
2025-06-30 10:33:40 +00:00
_continue()