fix: 修复欢迎板和通知板通知无法关闭问题
- 修复欢迎板和通知板当前被ChatUI 抢占鼠标问题,通过设置启动弹窗时ChatUI 根节点 mouse_filter 临时改为 IGNORE来实现 - ToDo: 后续统一规划事件逻辑
This commit is contained in:
@@ -31,10 +31,14 @@ var pages = [
|
||||
var current_page = 0
|
||||
var tween: Tween
|
||||
var mock_pages = []
|
||||
var _chat_ui: Control
|
||||
var _chat_ui_prev_mouse_filter: int = Control.MOUSE_FILTER_STOP
|
||||
var _chat_ui_mouse_disabled: bool = false
|
||||
|
||||
func _ready():
|
||||
# Pause the game
|
||||
get_tree().paused = true
|
||||
_disable_chat_ui_mouse_input()
|
||||
|
||||
$CenterContainer/PanelContainer/VBoxContainer/Header/RightContainer/CloseButton.pressed.connect(_on_close_pressed)
|
||||
prev_btn.pressed.connect(_on_prev_pressed)
|
||||
@@ -50,6 +54,9 @@ func _ready():
|
||||
_setup_dots()
|
||||
_update_ui(false)
|
||||
|
||||
func _exit_tree():
|
||||
_restore_chat_ui_mouse_input()
|
||||
|
||||
func _on_notices_response(success: bool, data: Dictionary, _error_info: Dictionary):
|
||||
var new_pages = []
|
||||
if success and data.has("data") and data["data"] is Array:
|
||||
@@ -154,3 +161,23 @@ func _on_close_pressed():
|
||||
# Unpause the game
|
||||
get_tree().paused = false
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user