Replace recipe/schematic dropdowns with button and selection dialog
This commit is contained in:
50
src/ui/RecipeSelectionDialog.h
Normal file
50
src/ui/RecipeSelectionDialog.h
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user