Skip to content

Commit 31bff4b

Browse files
committed
Added ReturnToMainMenuDelegate to GameState and connect it in GameViewContainer
1 parent 8e6a5bb commit 31bff4b

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

appOPHD/States/GameState.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ GameState::~GameState()
8989
}
9090

9191

92+
GameState::ReturnToMainMenuDelegate GameState::onReturnToMainMenuDelegate()
93+
{
94+
return {&mMapViewState, &MapViewState::onGameOver};
95+
}
96+
97+
9298
void GameState::initializeGameState()
9399
{
94100
mMainReportsState.initialize();

appOPHD/States/MapViewState.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ MapViewState::~MapViewState()
251251
eventHandler.windowResized().disconnect({this, &MapViewState::onWindowResized});
252252

253253
NAS2D::Utility<std::map<class MineFacility*, Route>>::get().clear();
254-
255-
mGameOptionsDialog.returnToMainMenuButtonSignal().disconnect({this, &MapViewState::onGameOver});
256254
}
257255

258256

appOPHD/States/MapViewState.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ class MapViewState : public Wrapper
130130

131131
void save(const std::string& filePath);
132132

133+
void onGameOver();
134+
133135
private:
134136
void onDeactivate() override;
135137
void onActivate() override;
@@ -269,8 +271,6 @@ class MapViewState : public Wrapper
269271

270272
void onNotificationClicked(const NotificationArea::Notification&);
271273

272-
void onGameOver();
273-
274274
void onStructuresSelectionChange(const IconGrid::Item*);
275275
void onConnectionsSelectionChange(const IconGrid::Item*);
276276
void onRobotsSelectionChange(const IconGrid::Item*);

appOPHD/States/MapViewStateUi.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ void MapViewState::initUi()
8585
mGameOverDialog.returnToMainMenu().connect({this, &MapViewState::onGameOver});
8686
mGameOverDialog.hide();
8787

88-
mGameOptionsDialog.returnToMainMenuButtonSignal().connect({this, &MapViewState::onGameOver});
89-
9088
mAnnouncement.hide();
9189
mMineOperationsWindow.hide();
9290
mWarehouseInspector.hide();

appOPHD/UI/GameViewContainer.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ GameViewContainer::GameViewContainer(GameState& gameState) :
1111

1212
mGameOptionsDialog.saveGameDialogButtonSignal().connect({this, &GameViewContainer::showSaveDialog});
1313
mGameOptionsDialog.loadGameDialogButtonSignal().connect({this, &GameViewContainer::showLoadDialog});
14+
mGameOptionsDialog.returnToMainMenuButtonSignal().connect(gameState.onReturnToMainMenuDelegate());
1415

1516
mFileIoDialog.hide();
1617
mFileIoDialog.anchored(true);

0 commit comments

Comments
 (0)