1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00

feat(UI): 添加提示框组件及显示功能

实现提示框组件TipBox,包含显示和隐藏动画效果
在UIState中添加showTip方法用于显示提示信息
更新UI场景以包含提示框容器
This commit is contained in:
2026-01-24 15:43:53 +08:00
parent 19384e1c50
commit 6be95a5658
5 changed files with 174 additions and 18 deletions
+13 -7
View File
@@ -1,7 +1,7 @@
[gd_scene load_steps=25 format=3 uid="uid://dfwg750a47ggx"]
[ext_resource type="PackedScene" uid="uid://ofpg5s3j7esv" path="res://components/UI/BossBar.tscn" id="1_2pe58"]
[ext_resource type="Script" path="res://scripts/Statemachine/UIState.gd" id="1_f00a6"]
[ext_resource type="Script" uid="uid://bph6blsdbiklk" path="res://scripts/Statemachine/UIState.gd" id="1_f00a6"]
[ext_resource type="StyleBox" uid="uid://dx0udq8nv2ec0" path="res://styleboxes/topPanel.tres" id="3_kep0k"]
[ext_resource type="PackedScene" uid="uid://bbm8l3hr4ihar" path="res://components/UI/ItemShow.tscn" id="3_o2oi4"]
[ext_resource type="PackedScene" uid="uid://1n28ji5sl6bx" path="res://components/Scenes/FullscreenPanels/MakeFeed.tscn" id="4_kkki3"]
@@ -116,9 +116,9 @@ tracks/1/keys = {
[sub_resource type="AnimationLibrary" id="AnimationLibrary_37e4s"]
_data = {
"RESET": SubResource("Animation_nqiiw"),
"hide": SubResource("Animation_5hjs3"),
"show": SubResource("Animation_2xajo")
&"RESET": SubResource("Animation_nqiiw"),
&"hide": SubResource("Animation_5hjs3"),
&"show": SubResource("Animation_2xajo")
}
[node name="UI" type="CanvasLayer"]
@@ -265,7 +265,7 @@ theme_override_constants/separation = 1
[node name="fieldsAnimator" type="AnimationPlayer" parent="root/fields"]
unique_name_in_owner = true
libraries = {
"": SubResource("AnimationLibrary_37e4s")
&"": SubResource("AnimationLibrary_37e4s")
}
[node name="itemCollect" type="VBoxContainer" parent="root"]
@@ -283,6 +283,14 @@ offset_bottom = 0.400024
grow_vertical = 0
theme_override_constants/separation = 10
[node name="tips" type="VBoxContainer" parent="root"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
grow_vertical = 0
[node name="panels" type="Control" parent="root"]
unique_name_in_owner = true
layout_mode = 1
@@ -310,8 +318,6 @@ layout_mode = 1
[node name="Weapon" parent="root/panels" instance=ExtResource("13_bmc24")]
visible = false
layout_mode = 1
offset_top = 0.0
offset_bottom = 0.0
[node name="Thanks" parent="root/panels" instance=ExtResource("14_gp8lx")]
visible = false
+116
View File
@@ -0,0 +1,116 @@
[gd_scene load_steps=7 format=3 uid="uid://caogpc2fnlrin"]
[ext_resource type="Script" uid="uid://c1gqcwr6say6f" path="res://scripts/Statemachine/TipBox.gd" id="1_7vuk3"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nooq4"]
content_margin_left = 10.0
content_margin_top = 5.0
content_margin_right = 10.0
content_margin_bottom = 5.0
bg_color = Color(1, 0, 0, 1)
corner_radius_top_right = 100
corner_radius_bottom_right = 100
[sub_resource type="Animation" id="Animation_7vuk3"]
length = 0.001
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale:x")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
[sub_resource type="Animation" id="Animation_5pngc"]
resource_name = "show"
length = 0.3
step = 0.01
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale:x")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"handle_modes": PackedInt32Array(0, 0),
"points": PackedFloat32Array(1.0039918, 0, 0, 0.3, 1, 0, 0, 0.205, 0, 0),
"times": PackedFloat32Array(0, 0.3)
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.14, 0.3),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
}
[sub_resource type="Animation" id="Animation_7ishl"]
resource_name = "show"
length = 0.3
step = 0.1
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale:x")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"handle_modes": PackedInt32Array(0, 0),
"points": PackedFloat32Array(0, 0, 0, 0.2, 0, 1, -0.25, 0.5, 0, 0),
"times": PackedFloat32Array(0, 0.3)
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.3),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_uks01"]
_data = {
&"RESET": SubResource("Animation_7vuk3"),
&"hide": SubResource("Animation_5pngc"),
&"show": SubResource("Animation_7ishl")
}
[node name="TipBox" type="PanelContainer"]
theme_override_styles/panel = SubResource("StyleBoxFlat_nooq4")
script = ExtResource("1_7vuk3")
[node name="label" type="Label" parent="."]
unique_name_in_owner = true
layout_mode = 2
text = "nothing"
[node name="animator" type="AnimationPlayer" parent="."]
unique_name_in_owner = true
libraries = {
&"": SubResource("AnimationLibrary_uks01")
}
+24
View File
@@ -0,0 +1,24 @@
@tool
extends PanelContainer
class_name TipBox
@export var text: String = "nothing"
@onready var label: Label = $%label
@onready var animator: AnimationPlayer = $%animator
func _ready():
label.text = text
animator.play("show")
func _process(_delta):
label.text = text
func destroy():
animator.play("hide")
await animator.animation_finished
queue_free()
static func create(applyText: String) -> TipBox:
var box = ComponentManager.getUIComponent("TipBox")
box.text = applyText
return box
+1
View File
@@ -0,0 +1 @@
uid://c1gqcwr6say6f
+20 -11
View File
@@ -1,24 +1,25 @@
extends CanvasLayer
class_name UIState
@onready var items = $"%items"
@onready var fields: VBoxContainer = $"%fields"
@onready var fieldsAnimator: AnimationPlayer = $"%fieldsAnimator"
static var player: EntityBase = null
static var items: PanelContainer
static var fields: VBoxContainer
static var fieldsAnimator: AnimationPlayer
static var player: EntityBase
static var bossbar: EntityStateBar
static var currentPanel: FullscreenPanelBase = null
static var currentPanel: FullscreenPanelBase
static var panels: Control
static var energyPercent: ColorBar
static var itemCollect: VBoxContainer
static var skillIconContainer: VBoxContainer
static var tips: VBoxContainer
func _ready():
bossbar = $"%bossbar"
panels = $"%panels"
energyPercent = $"%percent"
itemCollect = $"%itemCollect"
skillIconContainer = $"%skillContainer"
bossbar = $%bossbar
panels = $%panels
energyPercent = $%percent
itemCollect = $%itemCollect
skillIconContainer = $%skillContainer
tips = $%tips
setPanel("Starter")
func _process(_delta):
bossbar.visible = !!bossbar.entity
@@ -70,3 +71,11 @@ static func setPanel(targetName: String = "", args: Array = []):
panel.hidePanel()
static func closeCurrentPanel():
setPanel()
static func showTip(text: String, destroyAfter: float = -1):
var box = TipBox.create(text)
tips.add_child(box)
if destroyAfter > 0:
await TickTool.millseconds(destroyAfter * 1000)
box.destroy()
else:
return box