[colobot] 253/377: Fix issue #648

Didier Raboud odyx at moszumanska.debian.org
Wed Mar 30 13:34:23 UTC 2016


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 8a0cda1c2a5137db66c2cceabd14a6a3ee1db6ec
Author: Krzysztof Dermont <erihel at gmail.com>
Date:   Wed Feb 10 17:06:02 2016 +0100

    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 228b5e9..9ca2ea4 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 d57dd09..8337591 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 31ae587..059af14 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 a901040..d0fe1de 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<TextInputData>()->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<KeyEventData>();
+
+        if (data->slot == INPUT_SLOT_CMDLINE)
         {
-            Ui::CEdit* pe = static_cast<Ui::CEdit*>(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<Ui::CEdit*>(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);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list