From 3ca4514d2133786be2317c949406b485ff12cc7e Mon Sep 17 00:00:00 2001 From: def Date: Fri, 31 Jan 2014 01:41:57 +0100 Subject: [PATCH] Fix: Editor, Debug mode always open immediately --- src/engine/client/client.cpp | 25 +++++++++++++++++++++---- src/engine/client/client.h | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 63bd7b056..06e5f99e1 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1930,6 +1930,11 @@ void CClient::Run() // process pending commands m_pConsole->StoreCommands(false); + bool LastD = false; + bool LastQ = false; + bool LastE = false; + bool LastG = false; + while (1) { // @@ -1980,19 +1985,19 @@ void CClient::Run() } // panic quit button - if(Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyPressed('q')) + if(CtrlShiftKey('q', LastQ)) { Quit(); break; } - if(Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown('d')) + if(CtrlShiftKey('d', LastD)) g_Config.m_Debug ^= 1; - if(Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown('g')) + if(CtrlShiftKey('g', LastG)) g_Config.m_DbgGraphs ^= 1; - if(Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown('e')) + if(CtrlShiftKey('e', LastE)) { g_Config.m_ClEditor = g_Config.m_ClEditor^1; Input()->MouseModeRelative(); @@ -2113,6 +2118,18 @@ void CClient::Run() } } +bool CClient::CtrlShiftKey(int Key, bool &Last) +{ + if(Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && !Last && Input()->KeyPressed(Key)) + { + Last = true; + return true; + } + else if (Last && !Input()->KeyPressed(Key)) + Last = false; + + return false; +} void CClient::Con_Connect(IConsole::IResult *pResult, void *pUserData) { diff --git a/src/engine/client/client.h b/src/engine/client/client.h index ad4796f60..45b4f60ae 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -274,6 +274,7 @@ public: void Run(); + bool CtrlShiftKey(int Key, bool &Last); static void Con_Connect(IConsole::IResult *pResult, void *pUserData); static void Con_Disconnect(IConsole::IResult *pResult, void *pUserData);