mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
14deb2de71
修复TipBox销毁时的动画冲突问题 重构游戏重启逻辑以包含库存保存 移除GameOver面板中的重复库存保存代码 优化UIState中的字段显示控制和提示清除功能
44 lines
1.1 KiB
GDScript
44 lines
1.1 KiB
GDScript
@tool
|
|
extends PanelContainer
|
|
class_name TipBox
|
|
|
|
enum MessageType {
|
|
INFO,
|
|
WARNING,
|
|
ERROR,
|
|
CONGRATULATION,
|
|
}
|
|
|
|
@export var text: String = "nothing"
|
|
@export var messageType: MessageType = MessageType.INFO
|
|
@export var colorMap = {
|
|
MessageType.INFO: Color.BLACK,
|
|
MessageType.WARNING: Color.BLACK,
|
|
MessageType.ERROR: Color.BLACK,
|
|
MessageType.CONGRATULATION: Color.BLACK,
|
|
}
|
|
|
|
@onready var label: RichTextLabel = $%label
|
|
@onready var animator: AnimationPlayer = $%animator
|
|
|
|
func _ready():
|
|
label.text = text
|
|
animator.play("show")
|
|
var styleBox = get_theme_stylebox("panel").duplicate() as StyleBoxFlat
|
|
styleBox.bg_color = colorMap[messageType]
|
|
add_theme_stylebox_override("panel", styleBox)
|
|
func _process(_delta):
|
|
label.text = text
|
|
|
|
func destroy():
|
|
if animator.is_playing(): return
|
|
animator.play("hide")
|
|
await animator.animation_finished
|
|
queue_free()
|
|
|
|
static func create(applyText: String, applyMessageType: MessageType = MessageType.INFO) -> TipBox:
|
|
var box = ComponentManager.getUIComponent("TipBox").instantiate()
|
|
box.text = applyText
|
|
box.messageType = applyMessageType
|
|
return box
|