fix: 装备属性面板避让逻辑 + 多项功能更新
- item_tooltip_view.gd: 新增 avoid_rect 属性,tooltip 与装备窗口重叠时自动推到左侧 - inventory_ui.gd: 悬停装备时传入窗口矩形作为避让区域 - 包含其他累积的功能开发和测试文件
This commit is contained in:
+16
-1
@@ -8,10 +8,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 _list: VBoxContainer
|
||||
var _title: Label
|
||||
@@ -33,8 +36,11 @@ var _has_open_pos := false
|
||||
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("mall_opened"):
|
||||
client.mall_opened.connect(func(_s): open())
|
||||
@@ -90,6 +96,8 @@ func close() -> void:
|
||||
_close_local()
|
||||
|
||||
func _close_local() -> void:
|
||||
if _tooltip_bridge:
|
||||
_tooltip_bridge.hide()
|
||||
_has_open_pos = false
|
||||
if item_mouse and item_mouse.has_method("unregister_owner"):
|
||||
item_mouse.unregister_owner(self)
|
||||
@@ -156,6 +164,7 @@ func _render_grid() -> void:
|
||||
var cell: Button = _cells[pos]
|
||||
cell.text = ""
|
||||
cell.tooltip_text = ""
|
||||
cell.set_meta("tooltip_item", {})
|
||||
cell.set_meta("vnum", 0)
|
||||
cell.set_meta("count", 0)
|
||||
var items: Array = client.get_mall_items() if client and client.has_method("get_mall_items") else []
|
||||
@@ -168,7 +177,8 @@ func _render_grid() -> void:
|
||||
var count := int(it.get("count", 1))
|
||||
var cell: Button = _cells[pos]
|
||||
cell.text = "%s%s" % [_name_of(vnum).substr(0, 7), (" ×%d" % count) if count > 1 else ""]
|
||||
cell.tooltip_text = _tooltip_for(it)
|
||||
cell.tooltip_text = ""
|
||||
cell.set_meta("tooltip_item", it.duplicate(true))
|
||||
cell.set_meta("vnum", vnum)
|
||||
cell.set_meta("count", count)
|
||||
|
||||
@@ -273,6 +283,8 @@ func _row(it: Dictionary) -> Control:
|
||||
nm.text = "%s ×%d" % [_name_of(vnum), count]
|
||||
nm.custom_minimum_size = Vector2(220, 0)
|
||||
nm.add_theme_font_size_override("font_size", 12)
|
||||
if _tooltip_bridge:
|
||||
_tooltip_bridge.bind(nm, func() -> Dictionary: return it.duplicate(true))
|
||||
row.add_child(nm)
|
||||
if item_mouse:
|
||||
nm.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
@@ -350,6 +362,9 @@ func _build(parent: Node) -> void:
|
||||
cell.add_theme_font_size_override("font_size", 9)
|
||||
cell.gui_input.connect(func(e: InputEvent): _on_grid_input(pos, e))
|
||||
cell.pressed.connect(func(): _on_mobile_grid_tap(pos))
|
||||
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())
|
||||
_grid.add_child(cell)
|
||||
_cells[pos] = cell
|
||||
var close := Button.new()
|
||||
|
||||
Reference in New Issue
Block a user