| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // ----------------------------------------------------------------
- // From Game Programming in C++ by Sanjay Madhav
- // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
- //
- // Released under the BSD License
- // See LICENSE in root directory for full details.
- // ----------------------------------------------------------------
- #include "PauseMenu.h"
- #include "Game.h"
- #include "DialogBox.h"
- #include <SDL/SDL.h>
- PauseMenu::PauseMenu(Game* game)
- :UIScreen(game)
- {
- mGame->SetState(Game::EPaused);
- SetRelativeMouseMode(false);
- SetTitle("PauseTitle");
- AddButton("ResumeButton", [this]() {
- Close();
- });
- AddButton("QuitButton", [this]() {
- new DialogBox(mGame, "QuitText",
- [this]() {
- mGame->SetState(Game::EQuit);
- });
- });
- }
- PauseMenu::~PauseMenu()
- {
- SetRelativeMouseMode(true);
- mGame->SetState(Game::EGameplay);
- }
- void PauseMenu::HandleKeyPress(int key)
- {
- UIScreen::HandleKeyPress(key);
-
- if (key == SDLK_ESCAPE)
- {
- Close();
- }
- }
|