#pragma once #include #include "ItemTooltipContext.h" #include "Tooltip.h" #include "TooltipTrigger.h" // The tooltip an item's name carries: the item, and every way the player can currently // produce it, each drawn as a recipe line (REQ-UI-ITEM-TOOLTIP). // // Its content is drawn -- item squares, building chips and all -- rather than written, // which is what it adds to the plain text tooltip it derives from. Rebuilt on every show, // because what produces an item changes as the player unlocks recipes // (REQ-LOCK-UI-RECIPE). class ItemTooltip : public Tooltip { Q_OBJECT public: // Gives one display the tooltip of the item it names (REQ-UI-ITEM-VALUE-TOOLTIP). // The tooltip is parented to the target and dies with it. HoverOnly wherever the // target sits on something the player clicks, whose click is not free to explain. static void attachTo(QWidget& target, const ItemTooltipContext& context, const std::string& itemId, TooltipTrigger::Trigger trigger); ItemTooltip(const ItemTooltipContext& context, const std::string& itemId, QWidget* parent = nullptr); protected: void refreshContent() override; private: ItemTooltipContext m_context; std::string m_itemId; };