fix: 装备属性面板避让逻辑 + 多项功能更新
- item_tooltip_view.gd: 新增 avoid_rect 属性,tooltip 与装备窗口重叠时自动推到左侧 - inventory_ui.gd: 悬停装备时传入窗口矩形作为避让区域 - 包含其他累积的功能开发和测试文件
This commit is contained in:
@@ -18,6 +18,14 @@ func _check(ok: bool, msg: String) -> void:
|
||||
push_error("FAIL: " + msg)
|
||||
print(" [FAIL] " + msg)
|
||||
|
||||
func _node_text(node: Node) -> String:
|
||||
var out := ""
|
||||
if node is Label:
|
||||
out += String((node as Label).text) + "\n"
|
||||
for child in node.get_children():
|
||||
out += _node_text(child)
|
||||
return out
|
||||
|
||||
class MockClient extends Node:
|
||||
signal shop_opened(vid: int)
|
||||
signal shop_closed
|
||||
@@ -289,9 +297,13 @@ func _test_shop_data_and_sockets() -> void:
|
||||
|
||||
var slot_btn: Button = shop._grid.get_child(0)
|
||||
_check(slot_btn != null, "Shop slot 0 created")
|
||||
_check(slot_btn.tooltip_text.contains("最大生命:+500"), "Tooltip contains attribute 1 (MAX_HP +500)")
|
||||
_check(slot_btn.tooltip_text.contains("力量:+12"), "Tooltip contains attribute 2 (STR +12)")
|
||||
_check(slot_btn.tooltip_text.contains("价格:1000"), "Tooltip contains item price")
|
||||
_check(slot_btn.tooltip_text.is_empty(), "Shop item has no native duplicate tooltip panel")
|
||||
slot_btn.mouse_entered.emit()
|
||||
var tooltip_text := _node_text(shop._tooltip_view)
|
||||
_check(shop._tooltip_view.visible, "Hover opens the shared shop ItemTooltipView")
|
||||
_check(tooltip_text.contains("最大生命 +500"), "Shared tooltip contains attribute 1 (MAX_HP +500)")
|
||||
_check(tooltip_text.contains("力量 +12"), "Shared tooltip contains attribute 2 (STR +12)")
|
||||
_check(tooltip_text.contains("价格:1,000 金币"), "Shared tooltip contains item price")
|
||||
|
||||
shop.queue_free()
|
||||
host.queue_free()
|
||||
@@ -389,7 +401,10 @@ func _test_shop_incremental_update() -> void:
|
||||
|
||||
_check(shop._active_tab == 1, "shop_updated did NOT reset _active_tab back to 0")
|
||||
var updated_slot: Button = shop._grid.get_child(1)
|
||||
_check(updated_slot.tooltip_text.contains("价格:350"), "Slot 1 refreshed with updated price 350")
|
||||
_check(updated_slot.tooltip_text.is_empty(), "Refreshed shop item still has no native tooltip")
|
||||
updated_slot.mouse_entered.emit()
|
||||
_check(_node_text(shop._tooltip_view).contains("价格:350 金币"),
|
||||
"Shared tooltip refreshes with updated price 350")
|
||||
|
||||
shop.queue_free()
|
||||
host.queue_free()
|
||||
|
||||
Reference in New Issue
Block a user