diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2021-03-13 07:45:55 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2021-03-13 15:34:50 -0500 |
| commit | 764efea5a38b970fa57d8c0197673276023b58aa (patch) | |
| tree | 25aebaa5e62147aaabdfcec6c44d36164d9e6fd7 /src/input_system.cpp | |
| parent | 142e00794097dfb78c4b758a2d39d26fae070092 (diff) | |
| download | tanetane-764efea5a38b970fa57d8c0197673276023b58aa.tar.gz tanetane-764efea5a38b970fa57d8c0197673276023b58aa.tar.bz2 tanetane-764efea5a38b970fa57d8c0197673276023b58aa.zip | |
Added pause menu opening and closing animation
#7
Diffstat (limited to 'src/input_system.cpp')
| -rw-r--r-- | src/input_system.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
| diff --git a/src/input_system.cpp b/src/input_system.cpp index c399e91..fd7889d 100644 --- a/src/input_system.cpp +++ b/src/input_system.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "script_system.h" | 5 | #include "script_system.h" |
| 6 | #include "transform_system.h" | 6 | #include "transform_system.h" |
| 7 | #include "animation_system.h" | 7 | #include "animation_system.h" |
| 8 | #include "menu_system.h" | ||
| 8 | 9 | ||
| 9 | struct Input { | 10 | struct Input { |
| 10 | bool left = false; | 11 | bool left = false; |
| @@ -16,25 +17,29 @@ struct Input { | |||
| 16 | void InputSystem::tick(double dt) { | 17 | void InputSystem::tick(double dt) { |
| 17 | SDL_Event e; | 18 | SDL_Event e; |
| 18 | while (SDL_PollEvent(&e)) { | 19 | while (SDL_PollEvent(&e)) { |
| 19 | if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE) { | 20 | if (e.type == SDL_QUIT) { |
| 20 | if (debugConsole_) { | ||
| 21 | debugConsole_ = false; | ||
| 22 | game_.unpauseGameplay(); | ||
| 23 | SDL_StopTextInput(); | ||
| 24 | debugText_.clear(); | ||
| 25 | } else { | ||
| 26 | game_.quit(); | ||
| 27 | } | ||
| 28 | } else if (e.type == SDL_QUIT) { | ||
| 29 | game_.quit(); | 21 | game_.quit(); |
| 30 | 22 | ||
| 31 | return; | 23 | return; |
| 32 | } else if (e.type == SDL_TEXTINPUT) { | 24 | } else if (e.type == SDL_TEXTINPUT) { |
| 33 | debugText_.append(e.text.text); | 25 | debugText_.append(e.text.text); |
| 34 | } else if (e.type == SDL_KEYDOWN) { | 26 | } else if (e.type == SDL_KEYDOWN) { |
| 35 | if (e.key.keysym.sym == SDLK_BACKQUOTE) { | 27 | if (e.key.keysym.sym == SDLK_ESCAPE) { |
| 28 | if (debugConsole_) { | ||
| 29 | debugConsole_ = false; | ||
| 30 | game_.unpauseGameplay(); | ||
| 31 | SDL_StopTextInput(); | ||
| 32 | debugText_.clear(); | ||
| 33 | } else { | ||
| 34 | if (game_.getSystem<MenuSystem>().isMenuOpen()) { | ||
| 35 | game_.getSystem<MenuSystem>().closePauseMenu(); | ||
| 36 | } else if (!game_.isGameplayPaused()) { | ||
| 37 | game_.getSystem<MenuSystem>().openPauseMenu(); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | } else if (e.key.keysym.sym == SDLK_BACKQUOTE) { | ||
| 36 | #ifdef TANETANE_DEBUG | 41 | #ifdef TANETANE_DEBUG |
| 37 | if (!debugConsole_) { | 42 | if (!debugConsole_ && !game_.isGameplayPaused()) { |
| 38 | debugConsole_ = true; | 43 | debugConsole_ = true; |
| 39 | game_.pauseGameplay(); | 44 | game_.pauseGameplay(); |
| 40 | SDL_StartTextInput(); | 45 | SDL_StartTextInput(); |
