Captures the uncommitted parallel-development work (increments 46-49) on the
40250 classic client port, folded into docs/CLIENT-GAP.md + CLIENT-GAP-FIX.md.
Increment 49 (W0 interface-freeze batch, Phase 1 prerequisite) lands the
cross-workflow shared-file scaffolding so the 4 Phase 1 workflows can run in
isolated worktrees without contention:
- entity_store.{h,cpp}: Entity gains empire/affect_flags/owner_vid/state_flags;
new mut_spawn_full() (single-shot two-packet merge, §2.3), mut_ownership()
(§2.5), mut_map_bgm() + take_bgm_dirty()/bgm_name()/bgm_volume() (§9.1),
drain_dirty() (§2.1/§2.5 bare-field-update queue); mut_char_info() now stores
empire; reset_for_map_change() clears m_dirty.
- m2_client.cpp: new bgm_changed(name, volume) signal; classic + m2dev pump
loops drain drain_dirty() -> entity_info and take_bgm_dirty() -> bgm_changed;
entity_dict() exposes the 4 new keys.
- classic/classic_parser.{h,cpp}: GC_MAIN_CHARACTER3_BGM /
GC_MAIN_CHARACTER4_BGM_VOL route bgm_name/bgm_volume to mut_map_bgm() (was
discarded); new m_pending_actor staging map (W1 fills §2.2 merge logic).
- project/bgm_director.gd (new) + game_scene.gd: BGM consumption split out of
net_world.gd so W2/W4 don't collide; §8.6/§4.8 keybind convergence (digits
1-4 -> quickslots 0-3, F1-F4 -> quickslots 4-7, Ctrl+1..9 -> _emote()).
Tests: cmake --build build clean; ctest 16/16; 15 GDScript regressions green
(netbridge, gamescene, netplay, p9, p10, p2b, p8, system_menu_ui, skill,
combat_fx, skill_fx, player_motion, char_status_ui, chat, inventory), no skips.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yvAPqPivoY7vmBbzgqK4W
152 lines
4.6 KiB
GDScript
152 lines
4.6 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
|
||
var _status: Label
|
||
var _password_dialog: ConfirmationDialog
|
||
|
||
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)
|
||
if client.has_signal("mall_password_required"):
|
||
client.mall_password_required.connect(_ask_password)
|
||
|
||
func is_open() -> bool:
|
||
return _root != null and _root.visible
|
||
|
||
func close() -> void:
|
||
if _root:
|
||
_root.visible = false
|
||
if is_instance_valid(_password_dialog):
|
||
_password_dialog.queue_free()
|
||
_password_dialog = null
|
||
|
||
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 -1
|
||
|
||
func refresh() -> void:
|
||
if client == null or _root == null:
|
||
return
|
||
_root.visible = client.is_mall_open()
|
||
if not _root.visible:
|
||
return
|
||
_status.text = ""
|
||
_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 _ask_password() -> void:
|
||
if is_instance_valid(_password_dialog):
|
||
_password_dialog.queue_free()
|
||
_password_dialog = ConfirmationDialog.new()
|
||
_password_dialog.title = "商城密码"
|
||
_password_dialog.dialog_text = "请输入 1~6 位密码"
|
||
_password_dialog.ok_button_text = "确认"
|
||
_password_dialog.cancel_button_text = "取消"
|
||
var edit := LineEdit.new()
|
||
edit.secret = true
|
||
edit.max_length = 6
|
||
edit.placeholder_text = "密码"
|
||
edit.custom_minimum_size = Vector2(220, 28)
|
||
_password_dialog.add_child(edit)
|
||
_password_dialog.confirmed.connect(func() -> void:
|
||
if not client.mall_password(edit.text) and is_instance_valid(_status):
|
||
_status.text = "密码格式无效"
|
||
_password_dialog.queue_free()
|
||
_password_dialog = null)
|
||
_password_dialog.canceled.connect(func() -> void:
|
||
_password_dialog.queue_free()
|
||
_password_dialog = null)
|
||
_root.get_parent().add_child(_password_dialog)
|
||
_password_dialog.popup_centered()
|
||
|
||
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:
|
||
var target := _first_free_inv()
|
||
if target < 0:
|
||
_status.text = "背包已满"
|
||
return
|
||
if not client.mall_checkout(cell, 1, target):
|
||
_status.text = "取出请求发送失败")
|
||
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)
|
||
_status = Label.new()
|
||
_status.add_theme_font_size_override("font_size", 11)
|
||
_status.add_theme_color_override("font_color", Color(1, 0.65, 0.55))
|
||
box.add_child(_status)
|
||
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)
|