Replace recipe/schematic dropdowns with button and selection dialog

This commit is contained in:
2026-06-22 12:17:42 +02:00
parent c43225b6fa
commit c7218c7c1e
10 changed files with 318 additions and 50 deletions

View File

@@ -0,0 +1,50 @@
#pragma once
#include <optional>
#include <string>
#include <vector>
#include <QDialog>
#include <QString>
struct Building;
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;
QString tooltip;
};
// Builds the lock-aware list of selectable options for a production building,
// with display captions and info tooltips (REQ-UI-SELECT-BUTTON,
// REQ-UI-SELECT-TOOLTIP). 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 tooltips.
std::vector<RecipeSelectionOption> buildRecipeSelectionOptions(
const Building& building, Simulation& sim, const GameConfig& config);
// Modal dialog showing a grid of option buttons (REQ-UI-SELECT-BUTTON). The
// game is paused by the caller while it is open. Clicking an option selects it
// and closes the dialog; dismissing it (close/Esc) leaves no choice.
class RecipeSelectionDialog : public QDialog
{
Q_OBJECT
public:
RecipeSelectionDialog(const std::vector<RecipeSelectionOption>& options,
const QString& title, QWidget* parent = nullptr);
std::optional<std::string> getChosenId() const;
private:
void onOptionClicked(int index);
std::vector<std::string> m_optionIds;
std::optional<std::string> m_chosenId;
};