Networked client on the existing Godot 4.7 + libgr2 renderer:
- net: m2dev wire protocol (libsodium KX + XChaCha20), auth/select/game
phases, EntityStore world model, ~all GC/CG headers. char create/delete,
private shop / mall / cube, SHOP_GC_START_EX, guild, party (+ CG_PARTY_SET_STATE),
quests, dragon soul, refine, safebox, exchange.
- UI: in-game windows migrated 1:1 from the reference uiscript/root .py —
char status (/stat), inventory+equipment, select-item ([SELECT_ITEM] quest
token), system-option + game-option + ESC system menu, private-shop 39-grid,
party info board, shop tabs, atlas, minimap, quickbar, chat, …
- EterGrnLib polish: GR2 material blend/two-sided, LOD crossfade, motion-event
dispatch, contact shadow, ray-AABB picking, weapon grip pre-transform.
Portable asset IO (A1) — all extension/libgr2/formats/mtproto reads routed
through godot::FileAccess (res:// PCK works on iOS/Android); standalone-lib
*_path() kept for the non-Godot CTests. AssetResolver + PropertyRegistry
switched to a baked index (bake_asset_index.gd) instead of std::filesystem.
Mobile builds: build-{android,ios}.sh, export-android.sh, pack-assets.sh,
gen-debug-keystore.sh. Assets ship as a zip mounted at runtime by
project/asset_pack.gd (adb push now; HTTP download is a drop-in later).
ctest 10/10, 34 GDScript suites, macOS/iOS/Android all build.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013EJxkHiNKS4kybHS3XKyAJ
84 lines
2.4 KiB
GDScript
84 lines
2.4 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:
|
|
hide_screen() # login / select / game —— 让位给对应界面
|
|
|
|
func show_for(text: String) -> void:
|
|
_label.text = text
|
|
_bar.visible = false
|
|
_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.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.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)
|