explain an item wherever the UI names one
Every display naming an item now shows that item's production tooltip, not only the selection panel's chips: the header block stock, the total cost of a building multi-selection, the remaining scrap of a debris selection, the icons of every recipe summary, and a blueprint card's cost. ItemTooltip moves out of the selection panel and takes an ItemTooltipContext of its own -- an item is named all over the UI, and the panel's context carries visuals and a debug flag no tooltip reads. A recipe line wraps each icon with its amount so the pair can be pointed at as one statement, and attaches tooltips only where asked: a module button and the item tooltip itself draw the same line and stay silent. Hover only wherever the display sits on something the player clicks, whose click is not free to explain. Note that a recipe line on an option button can no longer be transparent to the mouse -- Qt never looks inside a transparent widget for the cursor -- so it relies on press propagation to keep picking the option. The header block stock loses world.building_blocks_tooltip, showing what every other block icon shows instead. The Expand button keeps no tooltip: its cost is painted into its face with nowhere to hang one, and the button is due to be removed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ne3mejABZoLWKLh8fgpM3x
This commit is contained in:
@@ -8,7 +8,9 @@
|
||||
#include <QWidget>
|
||||
|
||||
#include "BuildingType.h"
|
||||
#include "ItemTooltipContext.h"
|
||||
#include "RecipesConfig.h"
|
||||
#include "TooltipTrigger.h"
|
||||
|
||||
class BuildingIconCache;
|
||||
class ItemIconCache;
|
||||
@@ -104,9 +106,24 @@ public:
|
||||
// by what holds it.
|
||||
void setCardChrome(bool enabled);
|
||||
|
||||
// Lets every amount on the line explain the item it names, the number and the icon
|
||||
// together as one target (REQ-UI-ITEM-VALUE-TOOLTIP). Off by default, because the
|
||||
// line is silent wherever what holds it carries a tooltip of its own -- a module
|
||||
// button (REQ-MOD-UI-MODULE-TOOLTIP) -- or is itself a tooltip (REQ-UI-ITEM-TOOLTIP).
|
||||
// HoverOnly where the line sits on something the player clicks, whose click is not
|
||||
// free to explain (REQ-UI-TOOLTIP-TRIGGER).
|
||||
//
|
||||
// Call before the first setLine(): the tooltips are attached as the line is built,
|
||||
// and an unchanged spec is not rebuilt.
|
||||
void setItemTooltips(const ItemTooltipContext& context,
|
||||
TooltipTrigger::Trigger trigger);
|
||||
|
||||
private:
|
||||
void rebuild(const Spec& spec);
|
||||
void addAmounts(const std::vector<Amount>& amounts);
|
||||
// The icon and the number of one item, side by side in a widget of their own so the
|
||||
// pair can be pointed at as one thing (REQ-UI-ITEM-VALUE-TOOLTIP).
|
||||
void addAmount(const Amount& entry);
|
||||
|
||||
ItemIconCache* m_itemIcons;
|
||||
BuildingIconCache* m_buildingIcons;
|
||||
@@ -121,4 +138,8 @@ private:
|
||||
// What the row currently shows, so a refresh at tick rate rebuilds it only when the
|
||||
// recipe actually changed.
|
||||
Spec m_spec;
|
||||
// Unset on a line whose items say nothing, which is most of them.
|
||||
std::optional<ItemTooltipContext> m_tooltipContext;
|
||||
TooltipTrigger::Trigger m_tooltipTrigger =
|
||||
TooltipTrigger::Trigger::HoverOnly;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user