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
95 lines
3.0 KiB
GDScript
95 lines
3.0 KiB
GDScript
# RefineUI (M4) —— 精炼 / 强化对话框:`refine_ask` 来时弹。
|
||
#
|
||
# var ru := preload("res://ui/refine_ui.gd").new()
|
||
# add_child(ru)
|
||
# ru.setup(m2client, canvas_parent, proto) # proto 可空(出名字)
|
||
#
|
||
# `GC_REFINE_INFORMATION` → `M2Client.refine_ask({type,pos,src_vnum,result_vnum,cost,prob,materials})`。
|
||
# [精炼] → `M2Client.refine(pos, type)`;[取消] 关闭。
|
||
extends Node
|
||
|
||
var client: Node
|
||
var proto: Node
|
||
var _root: Control
|
||
var _text: RichTextLabel
|
||
var _cur := {}
|
||
|
||
func setup(m2client: Node, parent: Node, proto_node: Node = null) -> void:
|
||
client = m2client
|
||
proto = proto_node
|
||
_build(parent)
|
||
if client.has_signal("refine_ask"):
|
||
client.refine_ask.connect(_on_ask)
|
||
|
||
func is_open() -> bool:
|
||
return _root != null and _root.visible
|
||
|
||
func _name_of(vnum: int) -> String:
|
||
if vnum == 0:
|
||
return "-"
|
||
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 _on_ask(info: Dictionary) -> void:
|
||
_cur = info
|
||
var lines := PackedStringArray()
|
||
lines.append("[b]%s[/b] → [b]%s[/b]" % [
|
||
_name_of(int(info.get("src_vnum", 0))), _name_of(int(info.get("result_vnum", 0)))])
|
||
lines.append("成功率 %d%% 费用 %d 金" % [int(info.get("prob", 0)), int(info.get("cost", 0))])
|
||
var mats: Array = info.get("materials", [])
|
||
if not mats.is_empty():
|
||
lines.append("材料:")
|
||
for m in mats:
|
||
lines.append(" %s ×%d" % [_name_of(int(m.get("vnum", 0))), int(m.get("count", 1))])
|
||
_text.text = "\n".join(lines)
|
||
_root.visible = true
|
||
|
||
func _do_refine() -> void:
|
||
if client and client.has_method("refine") and not _cur.is_empty():
|
||
client.refine(int(_cur.get("pos", 0)), int(_cur.get("type", 0)))
|
||
_root.visible = false
|
||
|
||
func _build(parent: Node) -> void:
|
||
_root = Control.new()
|
||
_root.set_anchors_preset(Control.PRESET_CENTER)
|
||
_root.position = Vector2(-160, -130)
|
||
_root.size = Vector2(320, 260)
|
||
_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.09, 0.07, 0.05, 0.98)
|
||
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)
|
||
_text = RichTextLabel.new()
|
||
_text.bbcode_enabled = true
|
||
_text.position = Vector2(14, 34)
|
||
_text.custom_minimum_size = Vector2(292, 160)
|
||
_text.size = Vector2(292, 160)
|
||
_root.add_child(_text)
|
||
var row := HBoxContainer.new()
|
||
row.position = Vector2(14, 208)
|
||
row.add_theme_constant_override("separation", 12)
|
||
_root.add_child(row)
|
||
var ok := Button.new()
|
||
ok.text = "精炼"
|
||
ok.custom_minimum_size = Vector2(120, 30)
|
||
ok.pressed.connect(_do_refine)
|
||
row.add_child(ok)
|
||
var cancel := Button.new()
|
||
cancel.text = "取消"
|
||
cancel.custom_minimum_size = Vector2(120, 30)
|
||
cancel.pressed.connect(func(): _root.visible = false)
|
||
row.add_child(cancel)
|