summary refs log tree commit diff stats
path: root/src/input_system.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_system.cpp')
-rw-r--r--src/input_system.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/input_system.cpp b/src/input_system.cpp index 56516ac..0758cda 100644 --- a/src/input_system.cpp +++ b/src/input_system.cpp
@@ -27,6 +27,7 @@ void InputSystem::tick(double dt) {
27 if (e.key.keysym.sym == SDLK_ESCAPE) { 27 if (e.key.keysym.sym == SDLK_ESCAPE) {
28 if (debugConsole_) { 28 if (debugConsole_) {
29 debugConsole_ = false; 29 debugConsole_ = false;
30 debugHistory_.pop_front();
30 game_.unpauseGameplay(); 31 game_.unpauseGameplay();
31 SDL_StopTextInput(); 32 SDL_StopTextInput();
32 debugText_.clear(); 33 debugText_.clear();
@@ -41,6 +42,8 @@ void InputSystem::tick(double dt) {
41#ifdef TANETANE_DEBUG 42#ifdef TANETANE_DEBUG
42 if (!debugConsole_ && !game_.isGameplayPaused()) { 43 if (!debugConsole_ && !game_.isGameplayPaused()) {
43 debugConsole_ = true; 44 debugConsole_ = true;
45 debugHistorySelection_ = 0;
46 debugHistory_.push_front("");
44 game_.pauseGameplay(); 47 game_.pauseGameplay();
45 SDL_StartTextInput(); 48 SDL_StartTextInput();
46 debugText_.clear(); 49 debugText_.clear();
@@ -48,7 +51,10 @@ void InputSystem::tick(double dt) {
48#endif 51#endif
49 } else if (debugConsole_ && e.key.keysym.sym == SDLK_RETURN) { 52 } else if (debugConsole_ && e.key.keysym.sym == SDLK_RETURN) {
50 game_.getSystem<ScriptSystem>().runDebugScript(debugText_); 53 game_.getSystem<ScriptSystem>().runDebugScript(debugText_);
54 debugHistory_[0] = debugText_;
51 debugText_.clear(); 55 debugText_.clear();
56 debugHistorySelection_ = 0;
57 debugHistory_.push_front("");
52 } else if (debugConsole_ && e.key.keysym.sym == SDLK_BACKSPACE) { 58 } else if (debugConsole_ && e.key.keysym.sym == SDLK_BACKSPACE) {
53 // Make sure to keep the backtick/heart. 59 // Make sure to keep the backtick/heart.
54 if (!debugText_.empty()) { 60 if (!debugText_.empty()) {
@@ -141,10 +147,20 @@ void InputSystem::tick(double dt) {
141 game_.getSystem<MessageSystem>().selectSecondChoice(); 147 game_.getSystem<MessageSystem>().selectSecondChoice();
142 } 148 }
143 } else if (e.key.keysym.sym == SDLK_UP) { 149 } else if (e.key.keysym.sym == SDLK_UP) {
150 if (debugConsole_ && debugHistorySelection_ < (debugHistory_.size() - 1)) {
151 debugHistory_[debugHistorySelection_] = debugText_;
152 debugHistorySelection_++;
153 debugText_ = debugHistory_[debugHistorySelection_];
154 }
144 if (game_.getSystem<MenuSystem>().isMenuOpen()) { 155 if (game_.getSystem<MenuSystem>().isMenuOpen()) {
145 game_.getSystem<MenuSystem>().pressedUp(); 156 game_.getSystem<MenuSystem>().pressedUp();
146 } 157 }
147 } else if (e.key.keysym.sym == SDLK_DOWN) { 158 } else if (e.key.keysym.sym == SDLK_DOWN) {
159 if (debugConsole_ && debugHistorySelection_ > 0) {
160 debugHistory_[debugHistorySelection_] = debugText_;
161 debugHistorySelection_--;
162 debugText_ = debugHistory_[debugHistorySelection_];
163 }
148 if (game_.getSystem<MenuSystem>().isMenuOpen()) { 164 if (game_.getSystem<MenuSystem>().isMenuOpen()) {
149 game_.getSystem<MenuSystem>().pressedDown(); 165 game_.getSystem<MenuSystem>().pressedDown();
150 } 166 }