#pragma once #include #include "ModalDialog.h" #include "SchematicChoiceOption.h" struct RecipesConfig; class BuildingIconCache; class ItemIconCache; // The drop's choice dialog (REQ-DEF-SCHEMATIC-DROP). Unlike every other dialog it cannot // be dismissed: clicking an option is the only way out, so getChosenIndex() always names // an option the player picked, and it only ever finishes Accepted. It inherits the base's // refusal of Q and of a click outside (ModalDialog::isDismissible) and adds the refusal // of Escape below. class SchematicChoiceDialog : public ModalDialog { Q_OBJECT public: // The icon caches draw the recipe lines of the "Unlocks recipes" list // (REQ-DEF-SCHEMATIC-DROP, REQ-UI-ITEM-ICON, REQ-UI-BUILD-ICON). Not owned. SchematicChoiceDialog(const std::vector& options, const RecipesConfig& recipes, ItemIconCache* itemIcons, BuildingIconCache* buildingIcons, QWidget* parent = nullptr); int getChosenIndex() const; public slots: // Refuses the dismissal (REQ-DEF-SCHEMATIC-DROP): the drop is a reward the player // has earned, and leaving without choosing would either forfeit it or award the // option that happens to be first. Escape funnels through QDialog::reject(), so // declining it here turns it away without swallowing keys one at a time. void reject() override; private: void onOptionClicked(int index); int m_chosenIndex; };