MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / createTooltip

Method createTooltip

source/frontend/StarInventory.cpp:245–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245PanePtr 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
278bool InventoryPane::sendEvent(InputEvent const& event) {
279 if (m_alwaysDisplayCosmetics)

Callers

nothing calls this directly

Calls 13

singletonClass · 0.85
strfFunction · 0.85
optStringMethod · 0.80
techDatabaseMethod · 0.80
techsMethod · 0.80
techMethod · 0.80
itemMethod · 0.45
dataMethod · 0.45
typeMethod · 0.45
itemAtMethod · 0.45
containsMethod · 0.45
screenBoundRectMethod · 0.45

Tested by

no test coverage detected