| 243 | } |
| 244 | |
| 245 | PanePtr InventoryPane::createTooltip(Vec2I const& screenPosition) { |
| 246 | ItemPtr item; |
| 247 | if (auto child = getChildAt(screenPosition)) { |
| 248 | if (auto itemSlot = as<ItemSlotWidget>(child)) { |
| 249 | item = itemSlot->item(); |
| 250 | if (!item) { |
| 251 | auto widgetData = itemSlot->data(); |
| 252 | if (widgetData && widgetData.type() == Json::Type::Object) { |
| 253 | if (auto text = widgetData.optString("tooltipText")) |
| 254 | return SimpleTooltipBuilder::buildTooltip(*text); |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | if (auto itemGrid = as<ItemGridWidget>(child)) |
| 259 | item = itemGrid->itemAt(screenPosition); |
| 260 | } |
| 261 | if (item) |
| 262 | return ItemTooltipBuilder::buildItemTooltip(item, m_player); |
| 263 | |
| 264 | auto techDatabase = Root::singleton().techDatabase(); |
| 265 | for (auto const& p : TechTypeNames) { |
| 266 | if (auto techIcon = fetchChild<ImageWidget>(strf("tech{}", p.second))) { |
| 267 | if (techIcon->screenBoundRect().contains(screenPosition)) { |
| 268 | if (auto techModule = m_player->techs()->equippedTechs().maybe(p.first)) |
| 269 | if (techDatabase->contains(*techModule)) |
| 270 | return SimpleTooltipBuilder::buildTooltip(techDatabase->tech(*techModule).description); |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | return {}; |
| 276 | } |
| 277 | |
| 278 | bool InventoryPane::sendEvent(InputEvent const& event) { |
| 279 | if (m_alwaysDisplayCosmetics) |
nothing calls this directly
no test coverage detected