feat(ui): 40250 item tooltip parity (thinboard, palette, sockets, stats)
This commit is contained in:
@@ -28,6 +28,7 @@ var context_consumer: Callable = Callable()
|
||||
const UiAssets = preload("res://ui/ui_assets.gd")
|
||||
const EquipRules = preload("res://equip_rules.gd")
|
||||
const ItemTooltip = preload("res://ui/item_tooltip.gd")
|
||||
const ItemTooltipView = preload("res://ui/item_tooltip_view.gd")
|
||||
const ChestSystem = preload("res://chest_system.gd")
|
||||
const ItemAttrSystem = preload("res://item_attr_system.gd")
|
||||
const MetinSocketSystem = preload("res://metin_socket_system.gd")
|
||||
@@ -66,6 +67,7 @@ var uiscript_dir := ""
|
||||
var item_mouse: Node # MouseController(可空,兼容旧测试桩)
|
||||
|
||||
var _win: Dictionary = {} # { root, nodes }
|
||||
var _local_tooltip_view: Control = null
|
||||
var _cells := {} # ui_index:int -> Panel
|
||||
var _drag_from := -1
|
||||
var _combine_from := -1 # Shift 选中的“使用到物品”来源格
|
||||
@@ -122,6 +124,7 @@ func toggle() -> void:
|
||||
else: open()
|
||||
|
||||
func close() -> void:
|
||||
_hide_tooltip()
|
||||
if _mobile_detail_dialog and is_instance_valid(_mobile_detail_dialog) and ui:
|
||||
ui.close(_mobile_detail_dialog)
|
||||
_mobile_detail_dialog = null
|
||||
@@ -259,9 +262,51 @@ func _wire_cells() -> void:
|
||||
var cell: Panel = _cells[idx]
|
||||
var cell_idx: int = int(idx)
|
||||
cell.gui_input.connect(func(e: InputEvent): _on_cell_input(cell_idx, e))
|
||||
cell.mouse_entered.connect(func(): _on_cell_mouse_entered(cell_idx))
|
||||
cell.mouse_exited.connect(func(): _on_cell_mouse_exited(cell_idx))
|
||||
if item_mouse and item_mouse.has_method("register_target"):
|
||||
item_mouse.register_target(cell, func(payload: Dictionary): return _drop_mouse_item(payload, cell_idx), self)
|
||||
|
||||
func _get_tooltip_view() -> Control:
|
||||
if ui and ui.has_method("get_item_tooltip_view"):
|
||||
return ui.get_item_tooltip_view(assets_root, proto, item_list)
|
||||
if _local_tooltip_view == null or not is_instance_valid(_local_tooltip_view):
|
||||
_local_tooltip_view = ItemTooltipView.new()
|
||||
_local_tooltip_view.setup(assets_root, proto, item_list, item_tooltip)
|
||||
_local_tooltip_view.visible = false
|
||||
_local_tooltip_view.z_index = 200
|
||||
if _win.has("root") and is_instance_valid(_win["root"]):
|
||||
_win["root"].add_child(_local_tooltip_view)
|
||||
return _local_tooltip_view
|
||||
|
||||
func _on_cell_mouse_entered(cell_idx: int) -> void:
|
||||
if item_mouse and item_mouse.has_method("is_attached") and item_mouse.is_attached():
|
||||
return
|
||||
var cell: Panel = _cells.get(cell_idx, null)
|
||||
if cell == null:
|
||||
return
|
||||
var vnum := int(cell.get_meta("vnum", 0))
|
||||
if vnum <= 0:
|
||||
return
|
||||
var count := int(cell.get_meta("count", 1))
|
||||
var instance_data: Dictionary = cell.get_meta("item_data", {})
|
||||
var proto_data: Dictionary = proto.item(vnum) if proto and proto.has_method("item") else {}
|
||||
var ctx: Dictionary = _equip_ctx()
|
||||
if ctx.has("race"):
|
||||
ctx["job"] = EquipRules.job_of_race(int(ctx["race"]))
|
||||
ctx["sex"] = EquipRules.sex_of_race(int(ctx["race"]))
|
||||
var tv := _get_tooltip_view()
|
||||
if tv:
|
||||
tv.show_item(vnum, count, proto_data, instance_data, ctx)
|
||||
|
||||
func _on_cell_mouse_exited(_cell_idx: int) -> void:
|
||||
_hide_tooltip()
|
||||
|
||||
func _hide_tooltip() -> void:
|
||||
var tv := _get_tooltip_view()
|
||||
if tv:
|
||||
tv.hide_tooltip()
|
||||
|
||||
func _wire_money() -> void:
|
||||
_money_button = _win.get("nodes", {}).get("Money_Slot", null)
|
||||
if _money_button is BaseButton:
|
||||
|
||||
Reference in New Issue
Block a user