Metin2 game client (P0–P11) + mobile asset pipeline
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
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
# ExchangeUI (P8) —— 交易 / 换货窗。
|
||||
#
|
||||
# var xu := preload("res://ui/exchange_ui.gd").new()
|
||||
# add_child(xu)
|
||||
# xu.setup(m2client, canvas_parent, proto) # proto 可空
|
||||
#
|
||||
# 两栏:我方 / 对方,各列道具行 + 金币。底部:金币输入 + [放金币]、[接受]、[取消]。
|
||||
# `exchange_changed` 刷新(active=false 时自动关闭)。
|
||||
# inventory_ui 在交易开着时右键道具 → 调 xu.offer(win, cell)。
|
||||
extends Node
|
||||
|
||||
var client: Node
|
||||
var proto: Node
|
||||
var _root: Control
|
||||
var _self_box: VBoxContainer
|
||||
var _peer_box: VBoxContainer
|
||||
var _self_gold: Label
|
||||
var _peer_gold: Label
|
||||
var _accept_btn: Button
|
||||
var _gold_input: LineEdit
|
||||
var _next_display := 0
|
||||
|
||||
func setup(m2client: Node, parent: Node, proto_node: Node = null) -> void:
|
||||
client = m2client
|
||||
proto = proto_node
|
||||
_build(parent)
|
||||
if client.has_signal("exchange_changed"):
|
||||
client.exchange_changed.connect(refresh)
|
||||
|
||||
func is_open() -> bool:
|
||||
return _root != null and _root.visible
|
||||
|
||||
func offer(inv_window: int, inv_cell: int) -> void:
|
||||
if is_open():
|
||||
client.exchange_add_item(inv_window, inv_cell, _next_display)
|
||||
_next_display = (_next_display + 1) % 12
|
||||
|
||||
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 refresh() -> void:
|
||||
if client == null:
|
||||
return
|
||||
var x: Dictionary = client.get_exchange()
|
||||
if not x.get("active", false):
|
||||
_root.visible = false
|
||||
_next_display = 0
|
||||
return
|
||||
_root.visible = true
|
||||
_fill(_self_box, x.get("self_items", []))
|
||||
_fill(_peer_box, x.get("peer_items", []))
|
||||
_self_gold.text = "金币: %d" % int(x.get("self_gold", 0))
|
||||
_peer_gold.text = "金币: %d" % int(x.get("peer_gold", 0))
|
||||
var me: bool = x.get("self_accept", false)
|
||||
var peer: bool = x.get("peer_accept", false)
|
||||
_accept_btn.text = "已接受 ✓" if me else "接受"
|
||||
_accept_btn.modulate = Color(0.5, 1, 0.5) if me else Color(1, 1, 1)
|
||||
_root.get_node("PeerAccept").text = "对方: 已接受" if peer else "对方: 未接受"
|
||||
|
||||
func _fill(box: VBoxContainer, rows: Array) -> void:
|
||||
for c in box.get_children():
|
||||
c.queue_free()
|
||||
for r in rows:
|
||||
var l := Label.new()
|
||||
l.text = "%s ×%d" % [_name_of(int(r.get("vnum", 0))), int(r.get("count", 1))]
|
||||
l.add_theme_font_size_override("font_size", 12)
|
||||
box.add_child(l)
|
||||
|
||||
func _on_put_gold() -> void:
|
||||
var g := int(_gold_input.text)
|
||||
if g > 0:
|
||||
client.exchange_add_gold(g)
|
||||
|
||||
func _build(parent: Node) -> void:
|
||||
_root = Control.new()
|
||||
_root.set_anchors_preset(Control.PRESET_CENTER)
|
||||
_root.position = Vector2(-220, -180)
|
||||
_root.size = Vector2(440, 360)
|
||||
_root.visible = false
|
||||
_root.set_meta("is_titlebar", true)
|
||||
parent.add_child(_root)
|
||||
var panel := Panel.new()
|
||||
panel.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
var sb := StyleBoxFlat.new()
|
||||
sb.bg_color = Color(0.07, 0.08, 0.1, 0.97)
|
||||
sb.set_corner_radius_all(4)
|
||||
panel.add_theme_stylebox_override("panel", sb)
|
||||
_root.add_child(panel)
|
||||
var title := Label.new()
|
||||
title.text = "交易"
|
||||
title.position = Vector2(12, 8)
|
||||
_root.add_child(title)
|
||||
|
||||
var sl := Label.new()
|
||||
sl.text = "我方"
|
||||
sl.position = Vector2(20, 34)
|
||||
_root.add_child(sl)
|
||||
_self_box = VBoxContainer.new()
|
||||
_self_box.position = Vector2(20, 56)
|
||||
_self_box.custom_minimum_size = Vector2(200, 0)
|
||||
_root.add_child(_self_box)
|
||||
_self_gold = Label.new()
|
||||
_self_gold.text = "金币: 0"
|
||||
_self_gold.position = Vector2(20, 250)
|
||||
_root.add_child(_self_gold)
|
||||
|
||||
var pl := Label.new()
|
||||
pl.text = "对方"
|
||||
pl.position = Vector2(240, 34)
|
||||
_root.add_child(pl)
|
||||
_peer_box = VBoxContainer.new()
|
||||
_peer_box.position = Vector2(240, 56)
|
||||
_peer_box.custom_minimum_size = Vector2(180, 0)
|
||||
_root.add_child(_peer_box)
|
||||
_peer_gold = Label.new()
|
||||
_peer_gold.text = "金币: 0"
|
||||
_peer_gold.position = Vector2(240, 250)
|
||||
_root.add_child(_peer_gold)
|
||||
|
||||
var pa := Label.new()
|
||||
pa.name = "PeerAccept"
|
||||
pa.text = "对方: 未接受"
|
||||
pa.position = Vector2(240, 272)
|
||||
pa.add_theme_font_size_override("font_size", 12)
|
||||
_root.add_child(pa)
|
||||
|
||||
var bottom := HBoxContainer.new()
|
||||
bottom.position = Vector2(20, 300)
|
||||
_root.add_child(bottom)
|
||||
_gold_input = LineEdit.new()
|
||||
_gold_input.placeholder_text = "金币"
|
||||
_gold_input.custom_minimum_size = Vector2(90, 0)
|
||||
bottom.add_child(_gold_input)
|
||||
var put := Button.new()
|
||||
put.text = "放金币"
|
||||
put.pressed.connect(_on_put_gold)
|
||||
bottom.add_child(put)
|
||||
_accept_btn = Button.new()
|
||||
_accept_btn.text = "接受"
|
||||
_accept_btn.pressed.connect(func() -> void: client.exchange_accept())
|
||||
bottom.add_child(_accept_btn)
|
||||
var cancel := Button.new()
|
||||
cancel.text = "取消"
|
||||
cancel.pressed.connect(func() -> void: client.exchange_cancel())
|
||||
bottom.add_child(cancel)
|
||||
Reference in New Issue
Block a user