fix: 修复欢迎板和通知板通知无法关闭问题
- 修复欢迎板和通知板当前被ChatUI 抢占鼠标问题,通过设置启动弹窗时ChatUI 根节点 mouse_filter 临时改为 IGNORE来实现 - ToDo: 后续统一规划事件逻辑
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=39 format=4 uid="uid://5cc0c6cpnhe8"]
|
[gd_scene load_steps=40 format=4 uid="uid://5cc0c6cpnhe8"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://b43tvo8cykfrq" path="res://scenes/Maps/BaseLevel.gd" id="1_m4als"]
|
[ext_resource type="Script" uid="uid://b43tvo8cykfrq" path="res://scenes/Maps/BaseLevel.gd" id="1_m4als"]
|
||||||
[ext_resource type="Texture2D" uid="uid://baa5wkuyqouh6" path="res://assets/sprites/environment/standard_brick_128_128.jpg" id="1_rb5kq"]
|
[ext_resource type="Texture2D" uid="uid://baa5wkuyqouh6" path="res://assets/sprites/environment/standard_brick_128_128.jpg" id="1_rb5kq"]
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://c7k8yay002w4" path="res://scenes/prefabs/items/welcome_board.tscn" id="16_edt5w"]
|
[ext_resource type="PackedScene" uid="uid://c7k8yay002w4" path="res://scenes/prefabs/items/welcome_board.tscn" id="16_edt5w"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bvfyllcy5fi8o" path="res://scenes/Maps/datawhale_home.tscn" id="16_m4als"]
|
[ext_resource type="PackedScene" uid="uid://bvfyllcy5fi8o" path="res://scenes/Maps/datawhale_home.tscn" id="16_m4als"]
|
||||||
[ext_resource type="PackedScene" uid="uid://rdmrm7j4iokr" path="res://scenes/prefabs/items/notice_board.tscn" id="16_rixdf"]
|
[ext_resource type="PackedScene" uid="uid://rdmrm7j4iokr" path="res://scenes/prefabs/items/notice_board.tscn" id="16_rixdf"]
|
||||||
|
[ext_resource type="Script" uid="uid://d2od22agputjt" path="res://scenes/prefabs/items/WelcomeBoard.gd" id="16_u1t8b"]
|
||||||
[ext_resource type="Script" uid="uid://rlkavptfhr4y" path="res://scenes/Maps/DoorTeleport.gd" id="18_0xqio"]
|
[ext_resource type="Script" uid="uid://rlkavptfhr4y" path="res://scenes/Maps/DoorTeleport.gd" id="18_0xqio"]
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_7nixu"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_7nixu"]
|
||||||
@@ -1086,6 +1087,7 @@ position = Vector2(-184, -76)
|
|||||||
z_index = 1
|
z_index = 1
|
||||||
y_sort_enabled = true
|
y_sort_enabled = true
|
||||||
position = Vector2(128, -80)
|
position = Vector2(128, -80)
|
||||||
|
script = ExtResource("16_u1t8b")
|
||||||
|
|
||||||
[node name="DefaultSpawn" type="Marker2D" parent="."]
|
[node name="DefaultSpawn" type="Marker2D" parent="."]
|
||||||
y_sort_enabled = true
|
y_sort_enabled = true
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://c7k8yay002w4"]
|
[gd_scene load_steps=3 format=3 uid="uid://c7k8yay002w4"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://d2od22agputjt" path="res://scenes/prefabs/items/WelcomeBoard.gd" id="1_script"]
|
|
||||||
[ext_resource type="Texture2D" uid="uid://v7loa3smfkrd" path="res://assets/materials/WelcomeBoard.png" id="2_sprite"]
|
[ext_resource type="Texture2D" uid="uid://v7loa3smfkrd" path="res://assets/materials/WelcomeBoard.png" id="2_sprite"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_board"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_board"]
|
||||||
@@ -8,7 +7,6 @@ size = Vector2(112, 26.5)
|
|||||||
|
|
||||||
[node name="WelcomeBoard" type="StaticBody2D"]
|
[node name="WelcomeBoard" type="StaticBody2D"]
|
||||||
collision_layer = 3
|
collision_layer = 3
|
||||||
script = ExtResource("1_script")
|
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
scale = Vector2(0.25, 0.25)
|
scale = Vector2(0.25, 0.25)
|
||||||
|
|||||||
@@ -31,10 +31,14 @@ var pages = [
|
|||||||
var current_page = 0
|
var current_page = 0
|
||||||
var tween: Tween
|
var tween: Tween
|
||||||
var mock_pages = []
|
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():
|
func _ready():
|
||||||
# Pause the game
|
# Pause the game
|
||||||
get_tree().paused = true
|
get_tree().paused = true
|
||||||
|
_disable_chat_ui_mouse_input()
|
||||||
|
|
||||||
$CenterContainer/PanelContainer/VBoxContainer/Header/RightContainer/CloseButton.pressed.connect(_on_close_pressed)
|
$CenterContainer/PanelContainer/VBoxContainer/Header/RightContainer/CloseButton.pressed.connect(_on_close_pressed)
|
||||||
prev_btn.pressed.connect(_on_prev_pressed)
|
prev_btn.pressed.connect(_on_prev_pressed)
|
||||||
@@ -50,6 +54,9 @@ func _ready():
|
|||||||
_setup_dots()
|
_setup_dots()
|
||||||
_update_ui(false)
|
_update_ui(false)
|
||||||
|
|
||||||
|
func _exit_tree():
|
||||||
|
_restore_chat_ui_mouse_input()
|
||||||
|
|
||||||
func _on_notices_response(success: bool, data: Dictionary, _error_info: Dictionary):
|
func _on_notices_response(success: bool, data: Dictionary, _error_info: Dictionary):
|
||||||
var new_pages = []
|
var new_pages = []
|
||||||
if success and data.has("data") and data["data"] is Array:
|
if success and data.has("data") and data["data"] is Array:
|
||||||
@@ -154,3 +161,23 @@ func _on_close_pressed():
|
|||||||
# Unpause the game
|
# Unpause the game
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
queue_free()
|
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
|
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():
|
func _ready():
|
||||||
|
_disable_chat_ui_mouse_input()
|
||||||
|
|
||||||
# Connect close button (X)
|
# Connect close button (X)
|
||||||
var header_close = find_child("CloseButton", true, false)
|
var header_close = find_child("CloseButton", true, false)
|
||||||
if header_close:
|
if header_close:
|
||||||
@@ -11,6 +17,9 @@ func _ready():
|
|||||||
if start_btn:
|
if start_btn:
|
||||||
start_btn.pressed.connect(_on_close_pressed)
|
start_btn.pressed.connect(_on_close_pressed)
|
||||||
|
|
||||||
|
func _exit_tree():
|
||||||
|
_restore_chat_ui_mouse_input()
|
||||||
|
|
||||||
func _on_close_pressed():
|
func _on_close_pressed():
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
@@ -18,3 +27,23 @@ func _input(event):
|
|||||||
# Allow ESC to close
|
# Allow ESC to close
|
||||||
if event.is_action_pressed("ui_cancel"):
|
if event.is_action_pressed("ui_cancel"):
|
||||||
queue_free()
|
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"]
|
[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"]
|
[ext_resource type="Texture2D" uid="uid://v7loa3smfkrd" path="res://assets/materials/WelcomeBoard.png" id="2_dy5hw"]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_card"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_card"]
|
||||||
|
|||||||
Reference in New Issue
Block a user