Three dialogs take Q as a second way out beside Escape: the recipe/schematic selection dialog and the blueprint selection dialog close outright, and the layout configuration dialog steps out one level per press -- the module being placed, then remove mode, then the session. Both of those mode exits now go through the handler the Remove button uses, extracted from a lambda into onRemoveButtonClicked(), so the key and the button cannot leave different state behind. The schematic choice dialog goes the other way and declines reject(). It had no close button but Escape still closed it, and the caller then applied choiceIndex 0 -- awarding whichever option happened to be first. Refusing reject() covers Escape, Alt+F4, and the window manager together, since all three funnel through it. It is also the only dialog whose dismissal would strand state: the poll that opened it does not reopen it while the choices stay pending, so a drop dismissed is a drop lost. The key itself is spelled once in DialogDismiss.h rather than in three key handlers. It stays out of the ControlAction table on purpose: that table answers what an input does in the player's current situation, and a dialog has none -- it holds focus and takes the key whatever the world is doing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ne3mejABZoLWKLh8fgpM3x
46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <optional>
|
|
|
|
#include <QDialog>
|
|
|
|
class BlueprintLibrary;
|
|
class ItemIconCache;
|
|
class QGridLayout;
|
|
class QWidget;
|
|
|
|
// The blueprint selection dialog (REQ-UI-BLUEPRINT-DIALOG): a frameless modal panel
|
|
// showing every saved blueprint as a card in a scrolling two-column grid. The caller
|
|
// pauses the game and raises the dim overlay 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, and the close button dismiss it
|
|
// with no other effect (REQ-UI-DIALOG-DISMISS).
|
|
class BlueprintSelectionDialog : public QDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
// Neither the library nor the icon cache is owned; both outlive the dialog.
|
|
BlueprintSelectionDialog(BlueprintLibrary* library, ItemIconCache* itemIcons,
|
|
QWidget* parent = nullptr);
|
|
|
|
std::optional<int> getChosenIndex() const;
|
|
|
|
protected:
|
|
void keyPressEvent(QKeyEvent* event) override;
|
|
|
|
private:
|
|
void rebuildGrid();
|
|
void onCardClicked(int index);
|
|
void onDeleteClicked(int index);
|
|
|
|
BlueprintLibrary* m_library;
|
|
ItemIconCache* m_itemIcons;
|
|
QWidget* m_gridContainer;
|
|
QGridLayout* m_grid;
|
|
std::optional<int> m_chosenIndex; // nullopt = dismissed without picking
|
|
};
|