From 8a761bfedf0d98a82c193fba362809efaafdb704 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sun, 3 Jun 2018 11:48:08 +0200 Subject: [PATCH] Add commands for switching pages in console For now they were just hardcodet on page up and down keys. The new command allows it to bind it for example on the f-keys for laptop users. --- src/game/client/components/console.cpp | 17 +++++++++++++++++ src/game/client/components/console.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 380463a78..f5b772f03 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -771,6 +771,20 @@ void CGameConsole::ClientConsolePrintCallback(const char *pStr, void *pUserData, ((CGameConsole *)pUserData)->m_LocalConsole.PrintLine(pStr, Highlighted); } +void CGameConsole::ConConsolePageUp(IConsole::IResult *pResult, void *pUserData) +{ + CInstance *pConsole = ((CGameConsole *)pUserData)->CurrentConsole(); + pConsole->m_BacklogActPage++; +} + +void CGameConsole::ConConsolePageDown(IConsole::IResult *pResult, void *pUserData) +{ + CInstance *pConsole = ((CGameConsole *)pUserData)->CurrentConsole(); + --pConsole->m_BacklogActPage; + if(pConsole->m_BacklogActPage < 0) + pConsole->m_BacklogActPage = 0; +} + void CGameConsole::ConchainConsoleOutputLevelUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) { pfnCallback(pResult, pCallbackUserData); @@ -816,6 +830,9 @@ void CGameConsole::OnConsoleInit() Console()->Register("dump_local_console", "", CFGFLAG_CLIENT, ConDumpLocalConsole, this, "Dump local console"); Console()->Register("dump_remote_console", "", CFGFLAG_CLIENT, ConDumpRemoteConsole, this, "Dump remote console"); + Console()->Register("console_page_up", "", CFGFLAG_CLIENT, ConConsolePageUp, this, "Previous page in console"); + Console()->Register("console_page_down", "", CFGFLAG_CLIENT, ConConsolePageDown, this, "Next page in console"); + Console()->Chain("console_output_level", ConchainConsoleOutputLevelUpdate, this); } diff --git a/src/game/client/components/console.h b/src/game/client/components/console.h index ecdb71fc3..d33722f0c 100644 --- a/src/game/client/components/console.h +++ b/src/game/client/components/console.h @@ -92,6 +92,8 @@ class CGameConsole : public CComponent static void ConClearRemoteConsole(IConsole::IResult *pResult, void *pUserData); static void ConDumpLocalConsole(IConsole::IResult *pResult, void *pUserData); static void ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserData); + static void ConConsolePageUp(IConsole::IResult *pResult, void *pUserData); + static void ConConsolePageDown(IConsole::IResult *pResult, void *pUserData); static void ConchainConsoleOutputLevelUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); public: