From ea64b0d7b361308d3b3737ecbac724856bfddda4 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 18 Jun 2010 20:32:52 +0200 Subject: made the console use the flagmask when looking for command (FindCommand) and removed double "No such command" console message --- src/game/client/components/console.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game/client/components/console.cpp') diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index b323ab48..9e09e6a2 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -184,7 +184,7 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event) aBuf[i] = *pSrc; aBuf[i] = 0; - m_pCommand = m_pGameConsole->m_pConsole->GetCommandInfo(aBuf); + m_pCommand = m_pGameConsole->m_pConsole->GetCommandInfo(aBuf, m_CompletionFlagmask); } } } -- cgit 1.4.1 From b790634a2dc273a506d3373a85e8b11ae9b043da Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 19 Jun 2010 13:48:01 +0200 Subject: scroll the possible commands in the console's tab completion if the wanted one is out of sight. Closes #105 --- src/game/client/components/console.cpp | 14 +++++++++++++- src/game/client/components/console.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src/game/client/components/console.cpp') diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 9e09e6a2..2916606b 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -51,6 +51,7 @@ CGameConsole::CInstance::CInstance(int Type) m_aCompletionBuffer[0] = 0; m_CompletionChosen = -1; + m_CompletionRenderOffset = 0.0f; m_pCommand = 0x0; } @@ -241,6 +242,8 @@ struct CRenderInfo const char *m_pCurrentCmd; int m_WantedCompletion; int m_EnumCount; + float m_Offset; + float m_Width; }; void CGameConsole::PossibleCommandsRenderCallback(const char *pStr, void *pUser) @@ -256,6 +259,12 @@ void CGameConsole::PossibleCommandsRenderCallback(const char *pStr, void *pUser) pInfo->m_pSelf->RenderTools()->DrawRoundRect(pInfo->m_Cursor.m_X-3, pInfo->m_Cursor.m_Y, tw+5, pInfo->m_Cursor.m_FontSize+4, pInfo->m_Cursor.m_FontSize/3); pInfo->m_pSelf->Graphics()->QuadsEnd(); + // scroll when out of sight + if(pInfo->m_Cursor.m_X < 3.0f) + pInfo->m_Offset = 0.0f; + else if(pInfo->m_Cursor.m_X+tw > pInfo->m_Width) + pInfo->m_Offset -= pInfo->m_Width/2; + pInfo->m_pSelf->TextRender()->TextColor(0.05f, 0.05f, 0.05f,1); pInfo->m_pSelf->TextRender()->TextEx(&pInfo->m_Cursor, pStr, -1); } @@ -386,8 +395,10 @@ void CGameConsole::OnRender() Info.m_pSelf = this; Info.m_WantedCompletion = pConsole->m_CompletionChosen; Info.m_EnumCount = 0; + Info.m_Offset = pConsole->m_CompletionRenderOffset; + Info.m_Width = Screen.w; Info.m_pCurrentCmd = pConsole->m_aCompletionBuffer; - TextRender()->SetCursor(&Info.m_Cursor, x, y+12.0f, FontSize, TEXTFLAG_RENDER); + TextRender()->SetCursor(&Info.m_Cursor, x+Info.m_Offset, y+12.0f, FontSize, TEXTFLAG_RENDER); const char *pPrompt = "> "; if(m_ConsoleType) @@ -438,6 +449,7 @@ void CGameConsole::OnRender() if(pConsole->m_Input.GetString()[0] != 0) { m_pConsole->PossibleCommands(pConsole->m_aCompletionBuffer, pConsole->m_CompletionFlagmask, PossibleCommandsRenderCallback, &Info); + pConsole->m_CompletionRenderOffset = Info.m_Offset; if(Info.m_EnumCount <= 0) { diff --git a/src/game/client/components/console.h b/src/game/client/components/console.h index d146307f..6d644001 100644 --- a/src/game/client/components/console.h +++ b/src/game/client/components/console.h @@ -24,6 +24,7 @@ class CGameConsole : public CComponent char m_aCompletionBuffer[128]; int m_CompletionChosen; int m_CompletionFlagmask; + float m_CompletionRenderOffset; IConsole::CCommandInfo *m_pCommand; -- cgit 1.4.1 From e2c3f744b2b12c63f3563c79471446ec508929ef Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 19 Jun 2010 20:51:54 +0200 Subject: added commands to clear the consoles. Closes #104 --- src/game/client/components/console.cpp | 18 ++++++++++++++++++ src/game/client/components/console.h | 4 ++++ 2 files changed, 22 insertions(+) (limited to 'src/game/client/components/console.cpp') diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 2916606b..5ffe1efd 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -61,6 +61,12 @@ void CGameConsole::CInstance::Init(CGameConsole *pGameConsole) m_pGameConsole = pGameConsole; }; +void CGameConsole::CInstance::ClearBacklog() +{ + m_Backlog.Init(); + m_BacklogActPage = 0; +} + void CGameConsole::CInstance::ExecuteLine(const char *pLine) { if(m_Type == 0) @@ -574,6 +580,16 @@ void CGameConsole::ConToggleRemoteConsole(IConsole::IResult *pResult, void *pUse ((CGameConsole *)pUserData)->Toggle(1); } +void CGameConsole::ConClearLocalConsole(IConsole::IResult *pResult, void *pUserData) +{ + ((CGameConsole *)pUserData)->m_LocalConsole.ClearBacklog(); +} + +void CGameConsole::ConClearRemoteConsole(IConsole::IResult *pResult, void *pUserData) +{ + ((CGameConsole *)pUserData)->m_RemoteConsole.ClearBacklog(); +} + void CGameConsole::ClientConsolePrintCallback(const char *pStr, void *pUserData) { ((CGameConsole *)pUserData)->m_LocalConsole.PrintLine(pStr); @@ -600,6 +616,8 @@ void CGameConsole::OnConsoleInit() Console()->Register("toggle_local_console", "", CFGFLAG_CLIENT, ConToggleLocalConsole, this, "Toggle local console"); Console()->Register("toggle_remote_console", "", CFGFLAG_CLIENT, ConToggleRemoteConsole, this, "Toggle remote console"); + Console()->Register("clear_local_console", "", CFGFLAG_CLIENT, ConClearLocalConsole, this, "Clear local console"); + Console()->Register("clear_remote_console", "", CFGFLAG_CLIENT, ConClearRemoteConsole, this, "Clear remote console"); } /* diff --git a/src/game/client/components/console.h b/src/game/client/components/console.h index 6d644001..68f3965d 100644 --- a/src/game/client/components/console.h +++ b/src/game/client/components/console.h @@ -31,6 +31,8 @@ class CGameConsole : public CComponent CInstance(int t); void Init(CGameConsole *pGameConsole); + void ClearBacklog(); + void ExecuteLine(const char *pLine); void OnInput(IInput::CEvent Event); @@ -59,6 +61,8 @@ class CGameConsole : public CComponent static void ClientConsolePrintCallback(const char *pStr, void *pUserData); static void ConToggleLocalConsole(IConsole::IResult *pResult, void *pUserData); static void ConToggleRemoteConsole(IConsole::IResult *pResult, void *pUserData); + static void ConClearLocalConsole(IConsole::IResult *pResult, void *pUserData); + static void ConClearRemoteConsole(IConsole::IResult *pResult, void *pUserData); public: CGameConsole(); -- cgit 1.4.1 From a5113c6740e22e633a7fd7d853b81518762e4e21 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 20 Jun 2010 14:12:59 +0200 Subject: added commands to dump the output of the consoles into a file --- src/engine/shared/storage.cpp | 3 +++ src/game/client/components/console.cpp | 49 ++++++++++++++++++++++++++++++++++ src/game/client/components/console.h | 3 +++ 3 files changed, 55 insertions(+) (limited to 'src/game/client/components/console.cpp') diff --git a/src/engine/shared/storage.cpp b/src/engine/shared/storage.cpp index 491795ad..1d0e2f78 100644 --- a/src/engine/shared/storage.cpp +++ b/src/engine/shared/storage.cpp @@ -30,6 +30,9 @@ public: str_format(aPath, sizeof(aPath), "%s/maps", m_aApplicationSavePath); fs_makedir(aPath); + str_format(aPath, sizeof(aPath), "%s/dumps", m_aApplicationSavePath); + fs_makedir(aPath); + str_format(aPath, sizeof(aPath), "%s/downloadedmaps", m_aApplicationSavePath); fs_makedir(aPath); diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 5ffe1efd..433ff409 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -1,5 +1,6 @@ //#include "gc_console.h" #include +#include #include @@ -9,6 +10,7 @@ #include #include #include +#include #include #include @@ -570,6 +572,41 @@ void CGameConsole::Toggle(int Type) m_ConsoleType = Type; } +void CGameConsole::Dump(int Type) +{ + CInstance *pConsole = Type == 1 ? &m_RemoteConsole : &m_LocalConsole; + char aFilename[128]; + time_t Time; + char aDate[20]; + + time(&Time); + tm* TimeInfo = localtime(&Time); + strftime(aDate, sizeof(aDate), "%Y-%m-%d_%I-%M", TimeInfo); + + for(int i = 0; i < 10; i++) + { + IOHANDLE io; + str_format(aFilename, sizeof(aFilename), "dumps/%s_dump%s-%05d.txt", Type==1?"remote_console":"local_console", aDate, i); + io = Storage()->OpenFile(aFilename, IOFLAG_WRITE); + if(io) + { + #if defined(CONF_FAMILY_WINDOWS) + static const char Newline[] = "\r\n"; + #else + static const char Newline[] = "\n"; + #endif + + for(char *pEntry = pConsole->m_Backlog.First(); pEntry; pEntry = pConsole->m_Backlog.Next(pEntry)) + { + io_write(io, pEntry, str_length(pEntry)); + io_write(io, Newline, sizeof(Newline)-1); + } + io_close(io); + break; + } + } +} + void CGameConsole::ConToggleLocalConsole(IConsole::IResult *pResult, void *pUserData) { ((CGameConsole *)pUserData)->Toggle(0); @@ -590,6 +627,16 @@ void CGameConsole::ConClearRemoteConsole(IConsole::IResult *pResult, void *pUser ((CGameConsole *)pUserData)->m_RemoteConsole.ClearBacklog(); } +void CGameConsole::ConDumpLocalConsole(IConsole::IResult *pResult, void *pUserData) +{ + ((CGameConsole *)pUserData)->Dump(0); +} + +void CGameConsole::ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserData) +{ + ((CGameConsole *)pUserData)->Dump(1); +} + void CGameConsole::ClientConsolePrintCallback(const char *pStr, void *pUserData) { ((CGameConsole *)pUserData)->m_LocalConsole.PrintLine(pStr); @@ -618,6 +665,8 @@ void CGameConsole::OnConsoleInit() Console()->Register("toggle_remote_console", "", CFGFLAG_CLIENT, ConToggleRemoteConsole, this, "Toggle remote console"); Console()->Register("clear_local_console", "", CFGFLAG_CLIENT, ConClearLocalConsole, this, "Clear local console"); Console()->Register("clear_remote_console", "", CFGFLAG_CLIENT, ConClearRemoteConsole, this, "Clear remote console"); + Console()->Register("dump_local_console", "", CFGFLAG_CLIENT, ConDumpLocalConsole, this, "Dump local console"); + Console()->Register("dump_remote_console", "", CFGFLAG_CLIENT, ConDumpRemoteConsole, this, "Dump remote console"); } /* diff --git a/src/game/client/components/console.h b/src/game/client/components/console.h index 68f3965d..a4d22790 100644 --- a/src/game/client/components/console.h +++ b/src/game/client/components/console.h @@ -56,6 +56,7 @@ class CGameConsole : public CComponent float m_StateChangeDuration; void Toggle(int Type); + void Dump(int Type); static void PossibleCommandsRenderCallback(const char *pStr, void *pUser); static void ClientConsolePrintCallback(const char *pStr, void *pUserData); @@ -63,6 +64,8 @@ class CGameConsole : public CComponent static void ConToggleRemoteConsole(IConsole::IResult *pResult, void *pUserData); static void ConClearLocalConsole(IConsole::IResult *pResult, void *pUserData); static void ConClearRemoteConsole(IConsole::IResult *pResult, void *pUserData); + static void ConDumpLocalConsole(IConsole::IResult *pResult, void *pUserData); + static void ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserData); public: CGameConsole(); -- cgit 1.4.1 From c40bc9af3e51c98afe68e03a45ba83651bfa0ad0 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 21 Jun 2010 13:45:30 +0200 Subject: fixed a possible crash in the client console --- src/game/client/components/console.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game/client/components/console.cpp') diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 433ff409..cb8c31ce 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -189,7 +189,7 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event) char aBuf[64] = {0}; const char *pSrc = GetString(); int i = 0; - for(; i < (int)sizeof(aBuf) && *pSrc && *pSrc != ' ' && *pSrc != ' '; i++, pSrc++) + for(; i < (int)sizeof(aBuf)-1 && *pSrc && *pSrc != ' '; i++, pSrc++) aBuf[i] = *pSrc; aBuf[i] = 0; -- cgit 1.4.1