| 55 | } |
| 56 | |
| 57 | PanePtr ScriptPane::createTooltip(Vec2I const& screenPosition) { |
| 58 | auto result = m_script.invoke<Json>("createTooltip", screenPosition); |
| 59 | if (result && !result.value().isNull()) { |
| 60 | if (result->type() == Json::Type::String) { |
| 61 | return SimpleTooltipBuilder::buildTooltip(result->toString()); |
| 62 | } else { |
| 63 | PanePtr tooltip = make_shared<Pane>(); |
| 64 | m_reader->construct(*result, tooltip.get()); |
| 65 | return tooltip; |
| 66 | } |
| 67 | } else { |
| 68 | ItemPtr item; |
| 69 | if (auto child = getChildAt(screenPosition)) { |
| 70 | if (auto itemSlot = as<ItemSlotWidget>(child)) |
| 71 | item = itemSlot->item(); |
| 72 | if (auto itemGrid = as<ItemGridWidget>(child)) |
| 73 | item = itemGrid->itemAt(screenPosition); |
| 74 | } |
| 75 | if (item) |
| 76 | return ItemTooltipBuilder::buildItemTooltip(item, m_client->mainPlayer()); |
| 77 | return {}; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | LuaCallbacks ScriptPane::makePaneCallbacks() { |
| 82 | LuaCallbacks callbacks = BaseScriptPane::makePaneCallbacks(); |