forked from datawhale/whale-town-front
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
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
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:
|
||||
@@ -11,6 +17,9 @@ func _ready():
|
||||
if start_btn:
|
||||
start_btn.pressed.connect(_on_close_pressed)
|
||||
|
||||
func _exit_tree():
|
||||
_restore_chat_ui_mouse_input()
|
||||
|
||||
func _on_close_pressed():
|
||||
queue_free()
|
||||
|
||||
@@ -18,3 +27,23 @@ 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://d8mam0n1a3b5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cohijfo0yeo34" path="res://scenes/prefabs/ui/WelcomeDialog.gd" id="1_vs5b1"]
|
||||
[ext_resource type="Script" uid="uid://cohijfo0yeo34" path="res://scenes/ui/WelcomeDialog.gd" id="1_vs5b1"]
|
||||
[ext_resource type="Texture2D" uid="uid://v7loa3smfkrd" path="res://assets/materials/WelcomeBoard.png" id="2_dy5hw"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_card"]
|
||||
|
||||
Reference in New Issue
Block a user