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
+13 -8
View File
@@ -19,6 +19,7 @@
extends Node
const ItemTooltip = preload("res://ui/item_tooltip.gd")
const ItemTooltipBridge = preload("res://ui/item_tooltip_bridge.gd")
class PrivateShopDragButton extends Button:
var drag_entry: Dictionary = {}
@@ -41,6 +42,7 @@ var client: Node
var ui: CanvasLayer # UiManager
var proto: Node
var _tooltip_builder: RefCounted
var _tooltip_bridge: RefCounted
var assets_root := ""
var uiscript_dir := ""
@@ -66,6 +68,8 @@ func setup(m2client: Node, ui_manager: CanvasLayer, proto_node: Node = null, ass
assets_root = ui.assets_root
_tooltip_builder = ItemTooltip.new()
_tooltip_builder.setup(assets_root if assets_root != "" else AssetRoot.path(), "en", proto)
_tooltip_bridge = ItemTooltipBridge.new()
_tooltip_bridge.setup(ui, proto, assets_root if assets_root != "" else AssetRoot.path())
uiscript_dir = assets_root.path_join("uiscript/uiscript")
if not DirAccess.dir_exists_absolute(uiscript_dir):
uiscript_dir = assets_root.path_join("uiscript")
@@ -95,6 +99,8 @@ func toggle() -> void:
else: open()
func close() -> void:
if _tooltip_bridge:
_tooltip_bridge.hide()
_dismiss_price_dialog()
if item_mouse and item_mouse.has_method("unregister_owner"):
item_mouse.unregister_owner(self)
@@ -148,6 +154,9 @@ func _index_cells(root: Node) -> void:
continue
var slot := int(n.get_meta("slot_index"))
_cells[slot] = n
if _tooltip_bridge:
n.mouse_entered.connect(func(): _tooltip_bridge.show_item(n.get_meta("tooltip_item", {})))
n.mouse_exited.connect(func(): _tooltip_bridge.hide())
var idx := slot
n.gui_input.connect(func(e: InputEvent) -> void:
if e is InputEventMouseButton and e.button_index == MOUSE_BUTTON_LEFT and e.pressed:
@@ -283,9 +292,8 @@ func _refresh_inv() -> void:
var count := int(it.get("count", 1))
var b := PrivateShopDragButton.new()
b.text = "%s ×%d" % [_name_of(vnum), count]
if _tooltip_builder:
var pd: Dictionary = proto.item(vnum) if proto and proto.has_method("item") else {}
b.tooltip_text = _tooltip_builder.format(vnum, count, pd, it)
if _tooltip_bridge:
_tooltip_bridge.bind(b, func() -> Dictionary: return it.duplicate(true))
b.alignment = HORIZONTAL_ALIGNMENT_LEFT
b.custom_minimum_size = Vector2(196, 22)
b.toggle_mode = true
@@ -313,6 +321,7 @@ func _refresh_grid() -> void:
cell.remove_child(ch)
ch.queue_free()
cell.tooltip_text = ""
cell.set_meta("tooltip_item", {})
if _stock.has(slot):
var s: Dictionary = _stock[slot]
var nm := Label.new()
@@ -329,11 +338,7 @@ func _refresh_grid() -> void:
cell.add_child(pr)
var tooltip_item := s.duplicate(true)
tooltip_item["count"] = int(s["count"])
if _tooltip_builder:
var pd: Dictionary = proto.item(int(s["vnum"])) if proto and proto.has_method("item") else {}
cell.tooltip_text = _tooltip_builder.format(int(s["vnum"]), int(s["count"]), pd, tooltip_item)
else:
cell.tooltip_text = "%s ×%d\n%d 냥" % [_name_of(int(s["vnum"])), int(s["count"]), int(s["price"])]
cell.set_meta("tooltip_item", tooltip_item)
cell.modulate = Color(1, 1, 1)
else:
cell.modulate = Color(0.72, 0.72, 0.82) if _picked != null else Color(1, 1, 1)