fix: 装备属性面板避让逻辑 + 多项功能更新

- item_tooltip_view.gd: 新增 avoid_rect 属性,tooltip 与装备窗口重叠时自动推到左侧
- inventory_ui.gd: 悬停装备时传入窗口矩形作为避让区域
- 包含其他累积的功能开发和测试文件
This commit is contained in:
shen
2026-09-21 16:38:59 -07:00
parent 1522a8a1a1
commit c93894313a
5498 changed files with 4558004 additions and 1442 deletions
+18 -3
View File
@@ -10,10 +10,13 @@
extends Node
const ItemTooltip = preload("res://ui/item_tooltip.gd")
const ItemTooltipBridge = preload("res://ui/item_tooltip_bridge.gd")
var client: Node
var proto: Node
var _tooltip_builder: RefCounted
var _tooltip_bridge: RefCounted
var ui: CanvasLayer
var _root: Control
var _self_box: VBoxContainer
var _peer_box: VBoxContainer
@@ -52,8 +55,11 @@ var _end_note_timer: Timer
func setup(m2client: Node, parent: Node, proto_node: Node = null) -> void:
client = m2client
proto = proto_node
ui = parent as CanvasLayer
_tooltip_builder = ItemTooltip.new()
_tooltip_builder.setup(AssetRoot.path(), "en", proto)
_tooltip_bridge = ItemTooltipBridge.new()
_tooltip_bridge.setup(parent, proto, AssetRoot.path())
_build(parent)
if client.has_signal("exchange_changed"):
client.exchange_changed.connect(refresh)
@@ -71,6 +77,8 @@ func set_mobile_mode(enabled: bool) -> void:
_refresh_mobile_inventory()
func close() -> void:
if _tooltip_bridge:
_tooltip_bridge.hide()
if item_mouse and item_mouse.has_method("unregister_owner"):
item_mouse.unregister_owner(self)
if item_mouse.has_method("is_attached") and item_mouse.is_attached():
@@ -237,7 +245,8 @@ func _refresh_mobile_inventory() -> void:
button.alignment = HORIZONTAL_ALIGNMENT_LEFT
button.text = "%s ×%d · 点按加入" % [_name_of(vnum), int(item.get("count", 1))]
button.custom_minimum_size = Vector2(214, 34)
button.tooltip_text = _tooltip_for(item)
if _tooltip_bridge:
_tooltip_bridge.bind(button, func() -> Dictionary: return item.duplicate(true))
var captured_cell := cell
button.pressed.connect(func() -> void: offer(INVENTORY_WINDOW, captured_cell))
_mobile_inventory_list.add_child(button)
@@ -281,6 +290,7 @@ func _render_self_grid(rows: Array) -> void:
var cell: Button = _exchange_cells[pos]
cell.text = ""
cell.tooltip_text = ""
cell.set_meta("tooltip_item", {})
cell.set_meta("vnum", 0)
cell.set_meta("count", 0)
for row in rows:
@@ -291,7 +301,8 @@ func _render_self_grid(rows: Array) -> void:
var count := int(row.get("count", 1))
var cell: Button = _exchange_cells[pos]
cell.text = "%s%s" % [_name_of(vnum).substr(0, 6), (" ×%d" % count) if count > 1 else ""]
cell.tooltip_text = _tooltip_for(row)
cell.tooltip_text = ""
cell.set_meta("tooltip_item", row.duplicate(true))
cell.set_meta("vnum", vnum)
cell.set_meta("count", count)
@@ -337,7 +348,8 @@ func _fill(box: VBoxContainer, rows: Array) -> void:
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.tooltip_text = _tooltip_for(r)
if _tooltip_bridge:
_tooltip_bridge.bind(l, func() -> Dictionary: return r.duplicate(true))
l.add_theme_font_size_override("font_size", 12)
box.add_child(l)
@@ -448,6 +460,9 @@ func _build(parent: Node) -> void:
cell.add_theme_font_size_override("font_size", 8)
_self_grid.add_child(cell)
_exchange_cells[pos] = cell
if _tooltip_bridge:
cell.mouse_entered.connect(func(): _tooltip_bridge.show_item(cell.get_meta("tooltip_item", {})))
cell.mouse_exited.connect(func(): _tooltip_bridge.hide())
if item_mouse and item_mouse.has_method("register_target"):
item_mouse.register_target(cell,
func(payload: Dictionary): return _drop_to_slot(payload, pos), self)