Files
dota_factory/src/ui/BlueprintSelectionDialog.h
Malte Langkabel 44ec3c51f1 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
2026-08-18 21:41:34 +02:00

50 lines
1.7 KiB
C++

#pragma once
#include <optional>
#include "ItemTooltipContext.h"
#include "ModalDialog.h"
class BlueprintLibrary;
class ItemIconCache;
class QGridLayout;
class QWidget;
// The blueprint selection dialog (REQ-UI-BLUEPRINT-DIALOG): a modal panel showing every
// saved blueprint as a card in a scrolling two-column grid. The caller pauses the game
// while it is open.
//
// Clicking a card accepts the dialog and reports that blueprint's index; the caller
// enters placement mode afterwards, so the dialog is already closed by then
// (REQ-UI-BLUEPRINT-CARD). Deleting acts on the library immediately and leaves the
// dialog open (REQ-UI-BLUEPRINT-DELETE). Escape, Q, the close button, and a click
// outside dismiss it with no other effect (REQ-UI-DIALOG-DISMISS).
class BlueprintSelectionDialog : public ModalDialog
{
Q_OBJECT
public:
// The context's item cache draws the block icon beside each cost, and the rest of it
// lets that cost explain the item it names (REQ-UI-ITEM-VALUE-TOOLTIP). Neither the
// library nor anything in the context is owned; both outlive the dialog.
BlueprintSelectionDialog(BlueprintLibrary* library,
const ItemTooltipContext& context,
QWidget* parent = nullptr);
std::optional<int> getChosenIndex() const;
bool isDismissible() const override;
private:
void rebuildGrid();
void onCardClicked(int index);
void onDeleteClicked(int index);
BlueprintLibrary* m_library;
ItemTooltipContext m_context;
ItemIconCache* m_itemIcons;
QWidget* m_gridContainer;
QGridLayout* m_grid;
std::optional<int> m_chosenIndex; // nullopt = dismissed without picking
};