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:
2026-08-18 21:41:34 +02:00
parent dcc801f017
commit 44ec3c51f1
34 changed files with 336 additions and 157 deletions

View File

@@ -14,6 +14,7 @@
#include "ExpansionCostChangedEvent.h"
#include "GameConfig.h"
#include "GameSpeedChangedEvent.h"
#include "ItemTooltipContext.h"
#include "Tick.h"
#include "TickAdvancedEvent.h"
@@ -33,11 +34,12 @@ class HeaderBar : public QWidget,
Q_OBJECT
public:
// itemIcons is the window-wide per-item icon cache (REQ-UI-ITEM-ICON); used to
// show the building_block icon in the stock display and expand button
// (REQ-UI-BLOCKS-ICON, REQ-UI-EXPAND-BUTTON). Not owned; must outlive this widget.
HeaderBar(const Simulation* sim, const GameConfig* config,
ItemIconCache* itemIcons, QWidget* parent = nullptr);
// The context carries the simulation the bar reads, the config, and the icon caches
// -- the item cache draws the building_block icon in the stock display and the expand
// button (REQ-UI-BLOCKS-ICON, REQ-UI-EXPAND-BUTTON), and the stock display explains
// that item with the cache's help (REQ-UI-ITEM-VALUE-TOOLTIP). Nothing in it is
// owned; all of it must outlive this widget.
explicit HeaderBar(const ItemTooltipContext& context, QWidget* parent = nullptr);
~HeaderBar() override;
private slots:
@@ -69,11 +71,10 @@ private:
QPushButton* m_expandButton;
std::vector<QPushButton*> m_speedButtons;
ItemIconCache* m_itemIcons; // Not owned; lives in MainWindow.
// The simulation is the single source of truth for everything the header
// displays; the change events are only refresh signals.
const Simulation* m_sim;
// Not owned; all of it lives in MainWindow. The simulation it names is the single
// source of truth for everything the header displays; the change events are only
// refresh signals.
ItemTooltipContext m_context;
static const double kSpeeds[];
static const int kSpeedCount;