Add a window-wide semi-transparent black scrim drawn over the entire game window (header bar, game world view, side panel column) while any auto-pausing modal or end-game screen is open, behind that modal. - New ModalDimOverlay widget: a full-window, mouse-transparent child of MainWindow that paints the dim color. Visibility is reference-counted (pushModal/popModal) so nested or back-to-back modals show a single dim, not stacked layers; a ModalDimScope RAII guard drives it. - Wire a guard around every modal opened from MainWindow: schematic choice, escape menu, layout dialog, recipe/schematic selection (spanning the auto-opened layout dialog), game-over, and win. The nested Create Blueprint dialog is covered by the layout-dialog dim. - Config-driven color via visuals.toml [overlays].modal_dim, following the existing OverlayVisuals/parseColor pattern; refreshed on the Restart config-reload paths (REQ-CFG-RELOAD). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DZR44tA8sn4dPqDzAVXyps
85 lines
3.1 KiB
C++
85 lines
3.1 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <QWidget>
|
|
|
|
#include "BuildingBlocksChangedEvent.h"
|
|
#include "BuildingId.h"
|
|
#include "EscapeMenuRequestedEvent.h"
|
|
#include "EventHandler.h"
|
|
#include "GameOverEvent.h"
|
|
#include "LayoutDialogRequestedEvent.h"
|
|
#include "ModalDimOverlay.h"
|
|
#include "WinEvent.h"
|
|
#include "RecipeSelectionRequestedEvent.h"
|
|
#include "SchematicChoicesAvailableEvent.h"
|
|
#include "ShipLayout.h"
|
|
#include "ShipLayoutBlueprint.h"
|
|
#include "Tick.h"
|
|
#include "VisualsConfig.h"
|
|
|
|
struct ParsedReplay;
|
|
class Simulation;
|
|
class GameWorldView;
|
|
class HeaderBar;
|
|
class SelectedBuildingPanel;
|
|
class BuildButtonGrid;
|
|
class BlueprintPanel;
|
|
class QCloseEvent;
|
|
class QResizeEvent;
|
|
|
|
class MainWindow : public QWidget,
|
|
public CombinedEventHandler<BuildingBlocksChangedEvent,
|
|
SchematicChoicesAvailableEvent,
|
|
GameOverEvent,
|
|
WinEvent,
|
|
EscapeMenuRequestedEvent,
|
|
LayoutDialogRequestedEvent,
|
|
RecipeSelectionRequestedEvent>
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
MainWindow(Simulation* sim, const std::string& configDir,
|
|
std::shared_ptr<ParsedReplay> replay = nullptr, QWidget* parent = nullptr);
|
|
~MainWindow() override;
|
|
|
|
protected:
|
|
void resizeEvent(QResizeEvent* event) override;
|
|
void closeEvent(QCloseEvent* event) override;
|
|
|
|
private:
|
|
void handleEvent(std::shared_ptr<const BuildingBlocksChangedEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const SchematicChoicesAvailableEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const GameOverEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const WinEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const EscapeMenuRequestedEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const LayoutDialogRequestedEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const RecipeSelectionRequestedEvent> event) override;
|
|
|
|
// Opens the shipyard layout configuration dialog for the given schematic and
|
|
// current layout, applying the result via SetShipLayoutCommand (REQ-MOD-UI-DIALOG).
|
|
void openShipLayoutDialog(BuildingId shipyardId,
|
|
const std::string& schematicId,
|
|
const ShipLayoutConfig& currentLayout);
|
|
void layoutPanels();
|
|
|
|
private:
|
|
std::string m_configDir;
|
|
VisualsConfig m_visuals;
|
|
Simulation* m_sim;
|
|
GameWorldView* m_gameWorldView;
|
|
HeaderBar* m_headerBar;
|
|
SelectedBuildingPanel* m_selectedBuildingPanel;
|
|
BuildButtonGrid* m_buildButtonGrid;
|
|
BlueprintPanel* m_blueprintPanel;
|
|
QWidget* m_sidePanel;
|
|
ModalDimOverlay* m_dimOverlay = nullptr;
|
|
|
|
std::vector<ShipLayoutBlueprint> m_layoutBlueprints;
|
|
std::shared_ptr<ParsedReplay> m_replay; // non-null => view-only playback
|
|
};
|