fix: 装备属性面板避让逻辑 + 多项功能更新
- item_tooltip_view.gd: 新增 avoid_rect 属性,tooltip 与装备窗口重叠时自动推到左侧 - inventory_ui.gd: 悬停装备时传入窗口矩形作为避让区域 - 包含其他累积的功能开发和测试文件
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
extends Node
|
||||
|
||||
const ItemTooltip = preload("res://ui/item_tooltip.gd")
|
||||
const ItemTooltipBridge = preload("res://ui/item_tooltip_bridge.gd")
|
||||
const UiKit = preload("res://ui_kit.gd")
|
||||
const UiBuild = preload("res://ui/ui_build.gd")
|
||||
const UiAssets = preload("res://ui/ui_assets.gd")
|
||||
@@ -18,6 +19,7 @@ const UiAssets = preload("res://ui/ui_assets.gd")
|
||||
var client: Node
|
||||
var proto: Node
|
||||
var _tooltip_builder: RefCounted
|
||||
var _tooltip_bridge: RefCounted
|
||||
var _assets_root := ""
|
||||
var _root: Control
|
||||
var _board_panel: Control
|
||||
@@ -58,6 +60,8 @@ func setup(m2client: Node, parent: Node, proto_node: Node = null, assets_overrid
|
||||
_assets_root = assets_override if assets_override != "" else AssetRoot.path()
|
||||
_tooltip_builder = ItemTooltip.new()
|
||||
_tooltip_builder.setup(_assets_root, "en", proto)
|
||||
_tooltip_bridge = ItemTooltipBridge.new()
|
||||
_tooltip_bridge.setup(parent, proto, _assets_root)
|
||||
_build(parent)
|
||||
if client and client.has_signal("safebox_opened"):
|
||||
client.safebox_opened.connect(func(_size): open())
|
||||
@@ -141,6 +145,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)
|
||||
@@ -257,6 +263,7 @@ func _render_grid() -> void:
|
||||
|
||||
func _clear_grid_cell(cell: Control) -> void:
|
||||
cell.tooltip_text = ""
|
||||
cell.set_meta("tooltip_item", {})
|
||||
cell.set_meta("vnum", 0)
|
||||
cell.set_meta("count", 0)
|
||||
for c in cell.get_children():
|
||||
@@ -267,7 +274,8 @@ func _fill_grid_cell(cell: Control, item: Dictionary) -> void:
|
||||
var count := int(item.get("count", 1))
|
||||
cell.set_meta("vnum", vnum)
|
||||
cell.set_meta("count", count)
|
||||
cell.tooltip_text = _tooltip_for(item)
|
||||
cell.tooltip_text = ""
|
||||
cell.set_meta("tooltip_item", item.duplicate(true))
|
||||
|
||||
var tex := _icon(vnum)
|
||||
if tex != null:
|
||||
@@ -438,7 +446,8 @@ func _refresh_inventory_candidates(_w: int = 0, _c: int = 0) -> void:
|
||||
button.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
button.text = "%s ×%d · 点按存入" % [_name_of(vnum), int(item.get("count", 1))]
|
||||
button.custom_minimum_size = Vector2(316, 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: deposit(INVENTORY_WINDOW, captured_cell))
|
||||
_mobile_inventory_list.add_child(button)
|
||||
@@ -550,6 +559,8 @@ func _row(it: Dictionary) -> Control:
|
||||
nm.text = "%s ×%d" % [_name_of(int(it.get("vnum", 0))), int(it.get("count", 1))]
|
||||
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)
|
||||
var out := Button.new()
|
||||
out.text = "取出"
|
||||
@@ -653,6 +664,9 @@ func _build(parent: Node) -> void:
|
||||
cell.add_theme_stylebox_override("panel", sbf)
|
||||
|
||||
cell.gui_input.connect(func(e: InputEvent): _on_cell_input(pos, e))
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user