- item_tooltip_view.gd: 新增 avoid_rect 属性,tooltip 与装备窗口重叠时自动推到左侧 - inventory_ui.gd: 悬停装备时传入窗口矩形作为避让区域 - 包含其他累积的功能开发和测试文件
91 lines
2.8 KiB
GDScript
91 lines
2.8 KiB
GDScript
# LoadingScreen (P10) —— 相位驱动的读取遮罩。
|
|
#
|
|
# var ls := preload("res://ui/loading_screen.gd").new()
|
|
# add_child(ls)
|
|
# ls.setup(m2client) # 接 phase_changed;也可手动 show_for("...") / hide()
|
|
#
|
|
# 只有 PHASE = "loading"(载入地图)才铺全屏遮罩;login / select / game 都隐藏
|
|
# —— select 阶段要露出选人界面,login 阶段登录框自己显示进度。
|
|
extends CanvasLayer
|
|
|
|
const HINTS := {
|
|
"loading": "载入地图…",
|
|
}
|
|
|
|
var client: Node
|
|
var _panel: ColorRect
|
|
var _label: Label
|
|
var _spinner: Label
|
|
var _bar: ProgressBar
|
|
var _spin := 0.0
|
|
|
|
func setup(m2client: Node = null) -> void:
|
|
client = m2client
|
|
layer = 60
|
|
_build()
|
|
if client and client.has_signal("phase_changed"):
|
|
client.phase_changed.connect(_on_phase)
|
|
if client and client.has_signal("disconnected"):
|
|
client.disconnected.connect(func(_r): hide_screen())
|
|
|
|
func _on_phase(phase: String) -> void:
|
|
if phase.to_lower() == "loading":
|
|
show_for(String(HINTS.get("loading", "载入地图…")))
|
|
else:
|
|
# ClientVS22 owns the full-screen load window only in
|
|
# SetLoadingPhase(). SetLoginPhase(), SetSelectPhase() and
|
|
# SetGamePhase() all return control to their phase window; keeping the
|
|
# mask for GAME would leave an invisible input blocker over the world.
|
|
hide_screen()
|
|
|
|
func show_for(text: String) -> void:
|
|
_label.text = text
|
|
_bar.visible = false
|
|
_panel.mouse_filter = Control.MOUSE_FILTER_STOP
|
|
_panel.visible = true
|
|
|
|
func set_progress(frac: float) -> void:
|
|
_bar.visible = true
|
|
_bar.value = clampf(frac, 0.0, 1.0) * 100.0
|
|
|
|
func hide_screen() -> void:
|
|
_panel.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
_panel.visible = false
|
|
|
|
func is_showing() -> bool:
|
|
return _panel.visible
|
|
|
|
func _process(dt: float) -> void:
|
|
if _panel.visible:
|
|
_spin += dt * 4.0
|
|
_spinner.text = ["◐", "◓", "◑", "◒"][int(_spin) % 4]
|
|
|
|
func _build() -> void:
|
|
_panel = ColorRect.new()
|
|
_panel.color = Color(0.02, 0.03, 0.05, 0.96)
|
|
_panel.set_anchors_preset(Control.PRESET_FULL_RECT)
|
|
_panel.mouse_filter = Control.MOUSE_FILTER_STOP
|
|
_panel.visible = false
|
|
add_child(_panel)
|
|
var box := VBoxContainer.new()
|
|
box.set_anchors_preset(Control.PRESET_CENTER)
|
|
box.position = Vector2(-120, -50)
|
|
box.custom_minimum_size = Vector2(240, 0)
|
|
box.alignment = BoxContainer.ALIGNMENT_CENTER
|
|
box.add_theme_constant_override("separation", 14)
|
|
_panel.add_child(box)
|
|
_spinner = Label.new()
|
|
_spinner.text = "◐"
|
|
_spinner.add_theme_font_size_override("font_size", 36)
|
|
_spinner.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
box.add_child(_spinner)
|
|
_label = Label.new()
|
|
_label.text = "载入中…"
|
|
_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
box.add_child(_label)
|
|
_bar = ProgressBar.new()
|
|
_bar.custom_minimum_size = Vector2(240, 12)
|
|
_bar.show_percentage = false
|
|
_bar.visible = false
|
|
box.add_child(_bar)
|