- 修复欢迎板和通知板当前被ChatUI 抢占鼠标问题,通过设置启动弹窗时ChatUI 根节点 mouse_filter 临时改为 IGNORE来实现 - ToDo: 后续统一规划事件逻辑
50 lines
1.3 KiB
GDScript
50 lines
1.3 KiB
GDScript
extends CanvasLayer
|
|
|
|
var _chat_ui: Control
|
|
var _chat_ui_prev_mouse_filter: int = Control.MOUSE_FILTER_STOP
|
|
var _chat_ui_mouse_disabled: bool = false
|
|
|
|
func _ready():
|
|
_disable_chat_ui_mouse_input()
|
|
|
|
# Connect close button (X)
|
|
var header_close = find_child("CloseButton", true, false)
|
|
if header_close:
|
|
header_close.pressed.connect(_on_close_pressed)
|
|
|
|
# Connect Start button
|
|
var start_btn = find_child("StartButton", true, false)
|
|
if start_btn:
|
|
start_btn.pressed.connect(_on_close_pressed)
|
|
|
|
func _exit_tree():
|
|
_restore_chat_ui_mouse_input()
|
|
|
|
func _on_close_pressed():
|
|
queue_free()
|
|
|
|
func _input(event):
|
|
# Allow ESC to close
|
|
if event.is_action_pressed("ui_cancel"):
|
|
queue_free()
|
|
|
|
func _disable_chat_ui_mouse_input():
|
|
var current_scene = get_tree().current_scene
|
|
if current_scene:
|
|
_chat_ui = current_scene.get_node_or_null("UILayer/ChatUI") as Control
|
|
|
|
if _chat_ui == null:
|
|
_chat_ui = get_tree().root.find_child("ChatUI", true, false) as Control
|
|
|
|
if _chat_ui:
|
|
_chat_ui_prev_mouse_filter = _chat_ui.mouse_filter
|
|
_chat_ui.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
_chat_ui_mouse_disabled = true
|
|
|
|
func _restore_chat_ui_mouse_input():
|
|
if _chat_ui_mouse_disabled and is_instance_valid(_chat_ui):
|
|
_chat_ui.mouse_filter = _chat_ui_prev_mouse_filter
|
|
|
|
_chat_ui_mouse_disabled = false
|
|
_chat_ui = null
|