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

@@ -60,7 +60,7 @@ MainWindow::MainWindow(Simulation* sim, const std::string& configDir,
m_buildingIcons = std::make_unique<BuildingIconCache>(
QDir::cleanPath(configDirPath + "/../icons/buildings"));
m_headerBar = new HeaderBar(sim, &sim->getConfig(), m_itemIcons.get(), this);
m_headerBar = new HeaderBar(getItemTooltipContext(), this);
m_gameWorldView = new GameWorldView(sim, &sim->getConfig(), &m_visuals, m_configDir,
m_itemIcons.get(), m_replay.get(), this);
@@ -237,7 +237,7 @@ void MainWindow::handleEvent(std::shared_ptr<const SchematicChoicesAvailableEven
ModalPauseScope pause(*m_gameWorldView);
SchematicChoiceDialog dialog(event->choices, m_sim->getConfig().recipes,
m_itemIcons.get(), m_buildingIcons.get(), m_modalLayer);
getItemTooltipContext(), m_modalLayer);
m_modalLayer->execute(dialog);
// The command goes out unconditionally because the dialog cannot be dismissed: it
@@ -330,11 +330,11 @@ void MainWindow::openShipLayoutDialog(BuildingId shipyardId,
}
}
ShipLayoutDialog dialog(&m_sim->getConfig(), schematicId, currentLayout,
ShipLayoutDialog dialog(schematicId, currentLayout,
m_layoutBlueprints,
std::move(unlockedModuleIds),
m_gameWorldView->isDebugDrawEnabled(),
m_itemIcons.get(), m_modalLayer);
getItemTooltipContext(), m_modalLayer);
// Opened from the panel's "Configure" button (REQ-MOD-UI-PREVIEW) or straight after
// a schematic change (REQ-MOD-UI-AUTO-DIALOG), so it opens on the panel either way.
if (m_modalLayer->execute(dialog, getSelectionPanelAnchor()) == QDialog::Accepted
@@ -428,8 +428,8 @@ void MainWindow::handleEvent(std::shared_ptr<const RecipeSelectionRequestedEvent
bool autoOpenLayout = false;
std::string chosenSchematic;
RecipeSelectionDialog dialog(options, title, m_itemIcons.get(),
m_buildingIcons.get(), m_modalLayer);
RecipeSelectionDialog dialog(options, title, getItemTooltipContext(),
m_modalLayer);
if (m_modalLayer->execute(dialog, getSelectionPanelAnchor()) == QDialog::Accepted
&& dialog.getChosenId().has_value())
{
@@ -491,9 +491,15 @@ void MainWindow::handleEvent(std::shared_ptr<const BlueprintSelectionRequestedEv
showBlueprintSelectionDialog();
}
ItemTooltipContext MainWindow::getItemTooltipContext() const
{
return ItemTooltipContext{ m_sim, &m_sim->getConfig(), m_itemIcons.get(),
m_buildingIcons.get() };
}
void MainWindow::showBlueprintSelectionDialog()
{
BlueprintSelectionDialog dialog(m_blueprintLibrary.get(), m_itemIcons.get(),
BlueprintSelectionDialog dialog(m_blueprintLibrary.get(), getItemTooltipContext(),
m_modalLayer);
if (m_modalLayer->execute(dialog) == QDialog::Accepted
&& dialog.getChosenIndex().has_value())