| 340 | } |
| 341 | |
| 342 | void InventoryPane::update(float dt) { |
| 343 | auto inventory = m_player->inventory(); |
| 344 | auto context = Widget::context(); |
| 345 | |
| 346 | HashSet<ItemPtr> customBarItems; |
| 347 | for (uint8_t i = 0; i < inventory->customBarIndexes(); ++i) { |
| 348 | if (auto primarySlot = inventory->customBarPrimarySlot(i)) { |
| 349 | if (auto primaryItem = inventory->itemsAt(*primarySlot)) |
| 350 | customBarItems.add(primaryItem); |
| 351 | } |
| 352 | if (auto secondarySlot = inventory->customBarSecondarySlot(i)) { |
| 353 | if (auto secondaryItem = inventory->itemsAt(*secondarySlot)) |
| 354 | customBarItems.add(secondaryItem); |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | m_trashSlot->setItem(inventory->itemsAt(TrashSlot())); |
| 359 | m_trashSlot->showLinkIndicator(customBarItems.contains(m_trashSlot->item())); |
| 360 | if (auto trashItem = m_trashSlot->item()) { |
| 361 | if (m_trashBurn.tick(dt) && trashItem->count() > 0) { |
| 362 | m_player->statistics()->recordEvent("trashItem", JsonObject{ |
| 363 | {"itemName", trashItem->name()}, |
| 364 | {"count", trashItem->count()}, |
| 365 | {"category", trashItem->category()} |
| 366 | }); |
| 367 | trashItem->take(trashItem->count()); |
| 368 | } |
| 369 | } else { |
| 370 | m_trashBurn.reset(); |
| 371 | } |
| 372 | m_trashSlot->setProgress(m_trashBurn.timer / m_trashBurn.time); |
| 373 | |
| 374 | for (auto const& p : EquipmentSlotNames) { |
| 375 | if (auto itemSlot = fetchChild<ItemSlotWidget>(p.second)) { |
| 376 | itemSlot->setItem(inventory->itemsAt(p.first)); |
| 377 | itemSlot->showLinkIndicator(customBarItems.contains(itemSlot->item())); |
| 378 | if (auto indicator = itemSlot->findChild<ImageWidget>("hidden")) |
| 379 | indicator->setVisibility(!inventory->equipmentVisibility(p.first)); |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | auto techDatabase = Root::singleton().techDatabase(); |
| 384 | for (auto const& p : TechTypeNames) { |
| 385 | if (auto techIcon = fetchChild<ImageWidget>(strf("tech{}", p.second))) { |
| 386 | if (auto techModule = m_player->techs()->equippedTechs().maybe(p.first)) { |
| 387 | if (techDatabase->contains(*techModule)) { |
| 388 | techIcon->setImage(techDatabase->tech(*techModule).icon); |
| 389 | continue; |
| 390 | } |
| 391 | } |
| 392 | techIcon->setImage(""); |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | if (ItemPtr swapSlot = inventory->swapSlotItem()) { |
| 397 | if (!PlayerInventory::itemAllowedInBag(swapSlot, m_selectedTab)) { |
| 398 | for (auto& pair : m_itemGrids) { |
| 399 | if (pair.first != m_selectedTab && PlayerInventory::itemAllowedInBag(swapSlot, pair.first)) { |
nothing calls this directly
no test coverage detected