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
105 lines
3.1 KiB
GDScript
105 lines
3.1 KiB
GDScript
# MallUI (첫 버전) —— 道具商城仓库窗(창고몰 / item-mall storage)。
|
||
#
|
||
# var mu := preload("res://ui/mall_ui.gd").new()
|
||
# add_child(mu)
|
||
# mu.setup(m2client, canvas_parent, proto) # proto 可空
|
||
#
|
||
# `mall_opened` → 显示;`mall_changed` → 刷新。列出商城道具 + [取出](放进背包第一个空格)。
|
||
extends Node
|
||
|
||
var client: Node
|
||
var proto: Node
|
||
var _root: Control
|
||
var _list: VBoxContainer
|
||
var _title: Label
|
||
|
||
func setup(m2client: Node, parent: Node, proto_node: Node = null) -> void:
|
||
client = m2client
|
||
proto = proto_node
|
||
_build(parent)
|
||
if client.has_signal("mall_opened"):
|
||
client.mall_opened.connect(func(_s): refresh())
|
||
if client.has_signal("mall_changed"):
|
||
client.mall_changed.connect(refresh)
|
||
|
||
func is_open() -> bool:
|
||
return _root != null and _root.visible
|
||
|
||
func _name_of(vnum: int) -> String:
|
||
if proto and proto.has_method("item"):
|
||
var d: Dictionary = proto.item(vnum)
|
||
var n := String(d.get("locale_name", d.get("name", "")))
|
||
if n != "":
|
||
return n
|
||
return "#%d" % vnum
|
||
|
||
func _first_free_inv() -> int:
|
||
var used := {}
|
||
for it in client.get_inventory():
|
||
used[int(it.get("cell", -1))] = true
|
||
for i in range(90):
|
||
if not used.has(i):
|
||
return i
|
||
return 0
|
||
|
||
func refresh() -> void:
|
||
if client == null or _root == null:
|
||
return
|
||
_root.visible = client.is_mall_open()
|
||
if not _root.visible:
|
||
return
|
||
_title.text = "道具商城仓库(%d 格)" % client.get_mall_size()
|
||
for c in _list.get_children():
|
||
c.queue_free()
|
||
var items: Array = client.get_mall_items()
|
||
if items.is_empty():
|
||
var e := Label.new()
|
||
e.text = "(空)"
|
||
_list.add_child(e)
|
||
return
|
||
for it in items:
|
||
_list.add_child(_row(it))
|
||
|
||
func _row(it: Dictionary) -> Control:
|
||
var row := HBoxContainer.new()
|
||
row.custom_minimum_size = Vector2(300, 0)
|
||
var nm := Label.new()
|
||
nm.text = "%s ×%d" % [_name_of(int(it.get("vnum", 0))), int(it.get("count", 1))]
|
||
nm.custom_minimum_size = Vector2(220, 0)
|
||
nm.add_theme_font_size_override("font_size", 12)
|
||
row.add_child(nm)
|
||
var out := Button.new()
|
||
out.text = "取出"
|
||
var cell := int(it.get("cell", 0))
|
||
out.pressed.connect(func() -> void: client.mall_checkout(cell, 1, _first_free_inv()))
|
||
row.add_child(out)
|
||
return row
|
||
|
||
func _build(parent: Node) -> void:
|
||
_root = Panel.new()
|
||
_root.set_anchors_preset(Control.PRESET_CENTER)
|
||
_root.position = Vector2(140, -180)
|
||
_root.custom_minimum_size = Vector2(340, 360)
|
||
_root.size = Vector2(340, 360)
|
||
_root.visible = false
|
||
parent.add_child(_root)
|
||
var box := VBoxContainer.new()
|
||
box.position = Vector2(16, 14)
|
||
box.custom_minimum_size = Vector2(308, 0)
|
||
box.add_theme_constant_override("separation", 6)
|
||
_root.add_child(box)
|
||
_title = Label.new()
|
||
_title.text = "道具商城仓库"
|
||
_title.add_theme_font_size_override("font_size", 16)
|
||
box.add_child(_title)
|
||
var sc := ScrollContainer.new()
|
||
sc.custom_minimum_size = Vector2(308, 280)
|
||
box.add_child(sc)
|
||
_list = VBoxContainer.new()
|
||
_list.add_theme_constant_override("separation", 4)
|
||
sc.add_child(_list)
|
||
var close := Button.new()
|
||
close.text = "关闭"
|
||
close.pressed.connect(func() -> void: _root.visible = false)
|
||
box.add_child(close)
|