Files
dota_factory/src/ui/RecipeSelectionDialog.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

66 lines
2.4 KiB
C++

#pragma once
#include <optional>
#include <string>
#include <vector>
#include <QString>
#include "BuildingType.h"
#include "ItemTooltipContext.h"
#include "ModalDialog.h"
#include "RecipeLineRow.h"
struct GameConfig;
class Simulation;
class QPushButton;
// One selectable entry in the recipe/schematic selection dialog
// (REQ-UI-SELECT-BUTTON). The "(None)" entry uses an empty id.
struct RecipeSelectionOption
{
std::string id;
QString caption;
// What the option makes, drawn beneath its caption on the button
// (REQ-UI-SELECT-OPTIONS). Empty for the "(None)" option, which is a caption alone.
// A ship schematic fills the inputs and the time and leaves the outputs empty: a
// ship is not an item and has no icon, so the caption is what it produces.
RecipeLineRow::Spec line;
};
// Builds the lock-aware list of selectable options for a production building
// of the given type, with display captions and recipe lines
// (REQ-UI-SELECT-BUTTON, REQ-UI-SELECT-OPTIONS). The first entry is always a
// "(None)" option with an empty id. Shared by the selection dialog and the
// panel selection button so both render identical captions, and
// usable for construction sites which have no Building yet (REQ-BLD-SITE-CONFIG).
std::vector<RecipeSelectionOption> buildRecipeSelectionOptions(
BuildingType type, Simulation& sim, const GameConfig& config);
// Modal dialog listing the options in one vertical column (REQ-UI-SELECT-OPTIONS). The
// game is paused by the caller while it is open. Clicking an option selects it and closes
// the dialog; dismissing it (close button, Escape, Q, or a click outside) leaves no
// choice (REQ-UI-DIALOG-DISMISS).
class RecipeSelectionDialog : public ModalDialog
{
Q_OBJECT
public:
// The context's icon caches draw each option's recipe line (REQ-UI-ITEM-ICON), and
// the rest of it lets those items explain themselves (REQ-UI-ITEM-VALUE-TOOLTIP).
// Nothing in it is owned.
RecipeSelectionDialog(const std::vector<RecipeSelectionOption>& options,
const QString& title, const ItemTooltipContext& context,
QWidget* parent = nullptr);
std::optional<std::string> getChosenId() const;
bool isDismissible() const override;
private:
void onOptionClicked(int index);
std::vector<std::string> m_optionIds;
std::optional<std::string> m_chosenId;
};