feat: complete mobile UI implementation

This commit is contained in:
shenlei
2026-09-04 19:54:33 +09:00
parent 9a4a044da5
commit b19d5b5dd3
132 changed files with 6643 additions and 180 deletions
+26 -2
View File
@@ -5,6 +5,7 @@
extends SceneTree
const PrivateShopUI = preload("res://ui/private_shop_ui.gd")
const MobileWindowHost = preload("res://ui/mobile/mobile_window_host.gd")
class FakeClient extends Node:
signal inventory_changed(window: int, cell: int)
@@ -61,6 +62,8 @@ func _run() -> void:
var pu: Node = PrivateShopUI.new()
get_root().add_child(pu)
pu.setup(fc, ui, fp, assets)
ui.set_mobile_mode(true)
pu.set_mobile_mode(true)
pu.open()
_ck(pu.is_open(), "builder window opened")
if not pu.is_open():
@@ -70,6 +73,7 @@ func _run() -> void:
_ck(pu._inv_list.get_child_count() == 3, "3 inventory candidates")
_ck((pu._inv_list.get_child(0) as Button).has_method("_get_drag_data"),
"inventory candidate supports drag data")
_ck(pu._win["root"].size.x >= 674.0, "mobile builder keeps candidates inside hosted root")
_ck(not pu._drop_mouse_item({"window": 1, "cell": 99, "vnum": 300, "count": 1,
"anti_flags": (1 << 13)}, 2), "ANTIFLAG_GIVE item cannot enter private shop")
_ck(not pu._drop_mouse_item({"window": 1, "cell": 99, "vnum": 301, "count": 1,
@@ -80,10 +84,30 @@ func _run() -> void:
_ck(not _has_call(fc, "open_shop", func(_c): return true), "empty stock → no send")
# 拿起第 1 件(cell 4)→ 落到格 3,价 250000
(pu._inv_list.get_child(0) as Button).pressed.emit()
var first_candidate := pu._inv_list.get_child(0) as Button
MobileWindowHost.wire_buttons(pu._win["root"])
var candidate_down := InputEventScreenTouch.new()
candidate_down.index = 1
candidate_down.pressed = true
candidate_down.position = Vector2(20, 40)
first_candidate.gui_input.emit(candidate_down)
var candidate_up := InputEventScreenTouch.new()
candidate_up.index = 1
candidate_up.pressed = false
candidate_up.position = candidate_down.position
first_candidate.gui_input.emit(candidate_up)
_ck(pu._picked != null and int(pu._picked["cell"]) == 4, "picked inv cell 4")
pu._on_slot_clicked(3)
var mobile_slot_touch := InputEventScreenTouch.new()
mobile_slot_touch.index = 2
mobile_slot_touch.pressed = true
(pu._cells[3] as Panel).gui_input.emit(mobile_slot_touch)
_ck(is_instance_valid(pu._price_dialog), "price dialog opens on empty slot")
_ck(pu._price_dialog.get_node_or_null("PriceInput") is LineEdit,
"mobile price dialog uses a numeric LineEdit")
ui.close_top()
_ck(pu._price_dialog == null, "mobile back closes price dialog and clears owner state")
_ck(pu._picked != null, "closing price dialog keeps selected item for retry")
pu._ask_price(3)
pu._place(3, 250000)
_ck(pu._stock.has(3) and int(pu._stock[3]["price"]) == 250000, "stock[3] placed")
_ck(pu._picked == null, "pick cleared after place")