From 8a0cda1c2a5137db66c2cceabd14a6a3ee1db6ec Mon Sep 17 00:00:00 2001 From: Krzysztof Dermont Date: Wed, 10 Feb 2016 17:06:02 +0100 Subject: [PATCH] Fix issue #648 Should be proper fix --- src/app/input.cpp | 2 ++ src/common/key.h | 1 + src/common/restext.cpp | 1 + src/level/robotmain.cpp | 29 +++++++++++++++++------------ 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/app/input.cpp b/src/app/input.cpp index 228b5e9e..9ca2ea45 100644 --- a/src/app/input.cpp +++ b/src/app/input.cpp @@ -66,6 +66,7 @@ CInput::CInput() { INPUT_SLOT_CAMERA_UP, "camup" }, { INPUT_SLOT_CAMERA_DOWN, "camdown" }, { INPUT_SLOT_PAUSE, "pause" }, + { INPUT_SLOT_CMDLINE, "cmdline" }, }; m_kmodState = 0; @@ -275,6 +276,7 @@ void CInput::SetDefaultInputBindings() m_inputBindings[INPUT_SLOT_CAMERA_DOWN].primary = KEY(PAGEDOWN); m_inputBindings[INPUT_SLOT_PAUSE].primary = KEY(PAUSE); m_inputBindings[INPUT_SLOT_PAUSE].secondary = KEY(p); + m_inputBindings[INPUT_SLOT_CMDLINE].primary = KEY(BACKQUOTE); m_joyAxisBindings[JOY_AXIS_SLOT_X].axis = 0; m_joyAxisBindings[JOY_AXIS_SLOT_Y].axis = 1; diff --git a/src/common/key.h b/src/common/key.h index d57dd098..83375918 100644 --- a/src/common/key.h +++ b/src/common/key.h @@ -105,6 +105,7 @@ enum InputSlot INPUT_SLOT_CAMERA_UP, INPUT_SLOT_CAMERA_DOWN, INPUT_SLOT_PAUSE, + INPUT_SLOT_CMDLINE, INPUT_SLOT_MAX }; diff --git a/src/common/restext.cpp b/src/common/restext.cpp index 31ae5871..059af142 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -239,6 +239,7 @@ void InitializeRestext() stringsEvent[EVENT_INTERFACE_KEY+INPUT_SLOT_CAMERA_UP] = TR("Camera up\\Increase camera angle while visiting message origin"); stringsEvent[EVENT_INTERFACE_KEY+INPUT_SLOT_CAMERA_DOWN] = TR("Camera down\\Decrease camera angle while visiting message origin"); stringsEvent[EVENT_INTERFACE_KEY+INPUT_SLOT_PAUSE] = TR("Pause\\Pause the game without opening menu"); + stringsEvent[EVENT_INTERFACE_KEY+INPUT_SLOT_CMDLINE] = TR("Cheat console\\Show cheat console"); stringsEvent[EVENT_INTERFACE_VOLSOUND] = TR("Sound effects:\\Volume of engines, voice, shooting, etc."); stringsEvent[EVENT_INTERFACE_VOLMUSIC] = TR("Background sound :\\Volume of audio tracks"); diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index a9010405..d0fe1de2 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -715,21 +715,25 @@ bool CRobotMain::ProcessEvent(Event &event) } // Management of the console. - if (event.type == EVENT_TEXT_INPUT && - event.GetData()->text[0] == KEY(BACKQUOTE)) // Pause ? + if (event.type == EVENT_KEY_DOWN) { - if (m_phase != PHASE_PLAYER_SELECT && - !m_movie->IsExist() && - !m_movieLock && !m_editLock && !m_cmdEdit) + auto data = event.GetData(); + + if (data->slot == INPUT_SLOT_CMDLINE) { - Ui::CEdit* pe = static_cast(m_interface->SearchControl(EVENT_CMD)); - if (pe == nullptr) return false; - pe->SetState(Ui::STATE_VISIBLE); - m_interface->SetFocus(pe); - if (m_phase == PHASE_SIMUL) m_cmdEditPause = m_pause->ActivatePause(PAUSE_ENGINE); - m_cmdEdit = true; + if (m_phase != PHASE_PLAYER_SELECT && + !m_movie->IsExist() && + !m_movieLock && !m_editLock && !m_cmdEdit) + { + Ui::CEdit* pe = static_cast(m_interface->SearchControl(EVENT_CMD)); + if (pe == nullptr) return false; + pe->SetState(Ui::STATE_VISIBLE); + m_interface->SetFocus(pe); + if (m_phase == PHASE_SIMUL) m_cmdEditPause = m_pause->ActivatePause(PAUSE_ENGINE); + m_cmdEdit = true; + } + return false; } - return false; } if (event.type == EVENT_KEY_DOWN && @@ -741,6 +745,7 @@ bool CRobotMain::ProcessEvent(Event &event) pe->GetText(cmd, 50); pe->SetText(""); pe->ClearState(Ui::STATE_VISIBLE); + m_interface->SetFocus(nullptr); if (m_phase == PHASE_SIMUL) { m_pause->DeactivatePause(m_cmdEditPause);