2010-05-29 07:25:38 +00:00
|
|
|
//#include "gc_console.h"
|
2008-08-30 21:09:13 +00:00
|
|
|
#include <math.h>
|
2010-06-20 12:12:59 +00:00
|
|
|
#include <time.h>
|
2008-08-30 21:09:13 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/generated/client_data.h>
|
2008-01-16 22:14:06 +00:00
|
|
|
|
2008-08-14 17:19:13 +00:00
|
|
|
#include <base/system.h>
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/shared/ringbuffer.h>
|
|
|
|
#include <engine/shared/config.h>
|
|
|
|
#include <engine/graphics.h>
|
|
|
|
#include <engine/textrender.h>
|
2010-06-20 12:12:59 +00:00
|
|
|
#include <engine/storage.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/keys.h>
|
|
|
|
#include <engine/console.h>
|
2008-01-16 22:14:06 +00:00
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <cstdio>
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/ui.h>
|
2008-01-16 22:14:06 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/version.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/lineinput.h>
|
|
|
|
#include <game/client/render.h>
|
2010-05-31 21:40:40 +00:00
|
|
|
#include <game/client/components/controls.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/components/menus.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include "console.h"
|
2008-01-30 13:15:58 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CONSOLE_CLOSED,
|
|
|
|
CONSOLE_OPENING,
|
|
|
|
CONSOLE_OPEN,
|
|
|
|
CONSOLE_CLOSING,
|
|
|
|
};
|
|
|
|
|
2010-06-05 11:38:08 +00:00
|
|
|
CGameConsole::CInstance::CInstance(int Type)
|
2008-03-01 14:36:36 +00:00
|
|
|
{
|
2008-08-27 15:48:50 +00:00
|
|
|
// init ringbuffers
|
2009-10-27 14:38:53 +00:00
|
|
|
//history = ringbuf_init(history_data, sizeof(history_data), RINGBUF_FLAG_RECYCLE);
|
|
|
|
//backlog = ringbuf_init(backlog_data, sizeof(backlog_data), RINGBUF_FLAG_RECYCLE);
|
2008-03-01 14:36:36 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
m_pHistoryEntry = 0x0;
|
2008-03-01 14:36:36 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Type = Type;
|
2009-01-24 12:16:02 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Type == 0)
|
|
|
|
m_CompletionFlagmask = CFGFLAG_CLIENT;
|
2009-01-24 12:16:02 +00:00
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
m_CompletionFlagmask = CFGFLAG_SERVER;
|
2009-01-24 12:16:02 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
m_aCompletionBuffer[0] = 0;
|
|
|
|
m_CompletionChosen = -1;
|
2010-06-19 11:48:01 +00:00
|
|
|
m_CompletionRenderOffset = 0.0f;
|
2009-01-24 13:12:04 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
m_pCommand = 0x0;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-06-05 11:38:08 +00:00
|
|
|
void CGameConsole::CInstance::Init(CGameConsole *pGameConsole)
|
|
|
|
{
|
|
|
|
m_pGameConsole = pGameConsole;
|
|
|
|
};
|
|
|
|
|
2010-06-19 18:51:54 +00:00
|
|
|
void CGameConsole::CInstance::ClearBacklog()
|
|
|
|
{
|
|
|
|
m_Backlog.Init();
|
|
|
|
m_BacklogActPage = 0;
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::CInstance::ExecuteLine(const char *pLine)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_Type == 0)
|
|
|
|
m_pGameConsole->m_pConsole->ExecuteLine(pLine);
|
2008-08-27 15:48:50 +00:00
|
|
|
else
|
2008-03-01 14:36:36 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_pGameConsole->Client()->RconAuthed())
|
|
|
|
m_pGameConsole->Client()->Rcon(pLine);
|
2008-03-01 14:36:36 +00:00
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
m_pGameConsole->Client()->RconAuth("", pLine);
|
2008-03-01 14:36:36 +00:00
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::CInstance::PossibleCommandsCompleteCallback(const char *pStr, void *pUser)
|
2009-01-24 12:16:02 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CGameConsole::CInstance *pInstance = (CGameConsole::CInstance *)pUser;
|
|
|
|
if(pInstance->m_CompletionChosen == pInstance->m_CompletionEnumerationCount)
|
|
|
|
pInstance->m_Input.Set(pStr);
|
|
|
|
pInstance->m_CompletionEnumerationCount++;
|
2009-01-24 12:16:02 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::CInstance::OnInput(IInput::CEvent Event)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
bool Handled = false;
|
2008-03-01 14:36:36 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Event.m_Flags&IInput::FLAG_PRESS)
|
2008-03-01 14:36:36 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Event.m_Key == KEY_RETURN || Event.m_Key == KEY_KP_ENTER)
|
2008-03-01 14:36:36 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_Input.GetString()[0])
|
2008-03-01 14:36:36 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
char *pEntry = m_History.Allocate(m_Input.GetLength()+1);
|
|
|
|
mem_copy(pEntry, m_Input.GetString(), m_Input.GetLength()+1);
|
|
|
|
ExecuteLine(m_Input.GetString());
|
|
|
|
m_Input.Clear();
|
|
|
|
m_pHistoryEntry = 0x0;
|
2008-03-01 14:36:36 +00:00
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
Handled = true;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
else if (Event.m_Key == KEY_UP)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if (m_pHistoryEntry)
|
2008-03-01 14:36:36 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
char *pTest = m_History.Prev(m_pHistoryEntry);
|
2008-03-01 14:36:36 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if (pTest)
|
|
|
|
m_pHistoryEntry = pTest;
|
2008-03-01 20:03:04 +00:00
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
m_pHistoryEntry = m_History.Last();
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if (m_pHistoryEntry)
|
2008-03-01 14:36:36 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
unsigned int Len = str_length(m_pHistoryEntry);
|
|
|
|
if (Len < sizeof(m_Input) - 1) // TODO: WTF?
|
|
|
|
m_Input.Set(m_pHistoryEntry);
|
2008-03-01 14:36:36 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
Handled = true;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
else if (Event.m_Key == KEY_DOWN)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if (m_pHistoryEntry)
|
|
|
|
m_pHistoryEntry = m_History.Next(m_pHistoryEntry);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if (m_pHistoryEntry)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
unsigned int Len = str_length(m_pHistoryEntry);
|
|
|
|
if (Len < sizeof(m_Input) - 1) // TODO: WTF?
|
|
|
|
m_Input.Set(m_pHistoryEntry);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Input.Clear();
|
|
|
|
Handled = true;
|
2008-03-01 20:03:04 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
else if(Event.m_Key == KEY_TAB)
|
2009-01-24 12:16:02 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_Type == 0 || m_pGameConsole->Client()->RconAuthed())
|
2009-01-24 12:16:02 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_CompletionChosen++;
|
|
|
|
m_CompletionEnumerationCount = 0;
|
|
|
|
m_pGameConsole->m_pConsole->PossibleCommands(m_aCompletionBuffer, m_CompletionFlagmask, PossibleCommandsCompleteCallback, this);
|
|
|
|
|
|
|
|
// handle wrapping
|
|
|
|
if(m_CompletionEnumerationCount && m_CompletionChosen >= m_CompletionEnumerationCount)
|
|
|
|
{
|
|
|
|
m_CompletionChosen %= m_CompletionEnumerationCount;
|
|
|
|
m_CompletionEnumerationCount = 0;
|
|
|
|
m_pGameConsole->m_pConsole->PossibleCommands(m_aCompletionBuffer, m_CompletionFlagmask, PossibleCommandsCompleteCallback, this);
|
|
|
|
}
|
2009-01-24 12:16:02 +00:00
|
|
|
}
|
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
else if(Event.m_Key == KEY_PAGEUP)
|
|
|
|
{
|
|
|
|
++m_BacklogActPage;
|
|
|
|
}
|
|
|
|
else if(Event.m_Key == KEY_PAGEDOWN)
|
2009-01-24 12:16:02 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
--m_BacklogActPage;
|
|
|
|
if(m_BacklogActPage < 0)
|
|
|
|
m_BacklogActPage = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!Handled)
|
|
|
|
m_Input.ProcessInput(Event);
|
|
|
|
|
|
|
|
if(Event.m_Flags&IInput::FLAG_PRESS)
|
|
|
|
{
|
|
|
|
if(Event.m_Key != KEY_TAB)
|
|
|
|
{
|
|
|
|
m_CompletionChosen = -1;
|
|
|
|
str_copy(m_aCompletionBuffer, m_Input.GetString(), sizeof(m_aCompletionBuffer));
|
2009-01-24 12:16:02 +00:00
|
|
|
}
|
2009-01-24 13:12:04 +00:00
|
|
|
|
|
|
|
// find the current command
|
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
char aBuf[64] = {0};
|
|
|
|
const char *pSrc = GetString();
|
2009-01-24 13:12:04 +00:00
|
|
|
int i = 0;
|
2010-06-21 11:45:30 +00:00
|
|
|
for(; i < (int)sizeof(aBuf)-1 && *pSrc && *pSrc != ' '; i++, pSrc++)
|
2010-05-29 07:25:38 +00:00
|
|
|
aBuf[i] = *pSrc;
|
|
|
|
aBuf[i] = 0;
|
2009-01-24 13:12:04 +00:00
|
|
|
|
2010-06-18 18:32:52 +00:00
|
|
|
m_pCommand = m_pGameConsole->m_pConsole->GetCommandInfo(aBuf, m_CompletionFlagmask);
|
2009-01-24 13:12:04 +00:00
|
|
|
}
|
2008-03-01 14:36:36 +00:00
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2008-03-01 14:36:36 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::CInstance::PrintLine(const char *pLine)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
int Len = str_length(pLine);
|
2008-03-01 14:36:36 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if (Len > 255)
|
|
|
|
Len = 255;
|
2008-03-01 14:36:36 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
char *pEntry = m_Backlog.Allocate(Len+1);
|
|
|
|
mem_copy(pEntry, pLine, Len);
|
|
|
|
pEntry[Len] = 0;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2008-03-01 14:36:36 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CGameConsole::CGameConsole()
|
2010-06-05 11:38:08 +00:00
|
|
|
: m_LocalConsole(0), m_RemoteConsole(1)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_ConsoleType = 0;
|
|
|
|
m_ConsoleState = CONSOLE_CLOSED;
|
|
|
|
m_StateChangeEnd = 0.0f;
|
|
|
|
m_StateChangeDuration = 0.1f;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2008-01-16 22:14:06 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
float CGameConsole::TimeNow()
|
2008-01-30 13:15:58 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
static long long s_TimeStart = time_get();
|
|
|
|
return float(time_get()-s_TimeStart)/float(time_freq());
|
2008-01-30 13:15:58 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CGameConsole::CInstance *CGameConsole::CurrentConsole()
|
2008-01-16 22:14:06 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_ConsoleType != 0)
|
|
|
|
return &m_RemoteConsole;
|
|
|
|
return &m_LocalConsole;
|
2008-03-01 14:36:36 +00:00
|
|
|
}
|
2008-01-16 22:14:06 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::OnReset()
|
2008-03-01 14:36:36 +00:00
|
|
|
{
|
2008-01-16 22:14:06 +00:00
|
|
|
}
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
// only defined for 0<=t<=1
|
2010-05-29 07:25:38 +00:00
|
|
|
static float ConsoleScaleFunc(float t)
|
2008-03-01 14:36:36 +00:00
|
|
|
{
|
2008-08-27 15:48:50 +00:00
|
|
|
//return t;
|
|
|
|
return sinf(acosf(1.0f-t));
|
2008-03-01 14:36:36 +00:00
|
|
|
}
|
2008-01-18 15:55:03 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
struct CRenderInfo
|
2009-01-24 12:16:02 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CGameConsole *m_pSelf;
|
|
|
|
CTextCursor m_Cursor;
|
|
|
|
const char *m_pCurrentCmd;
|
|
|
|
int m_WantedCompletion;
|
|
|
|
int m_EnumCount;
|
2010-06-19 11:48:01 +00:00
|
|
|
float m_Offset;
|
|
|
|
float m_Width;
|
2009-01-24 12:16:02 +00:00
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::PossibleCommandsRenderCallback(const char *pStr, void *pUser)
|
2009-01-24 12:16:02 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CRenderInfo *pInfo = static_cast<CRenderInfo *>(pUser);
|
2009-01-24 12:16:02 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(pInfo->m_EnumCount == pInfo->m_WantedCompletion)
|
2009-01-24 12:16:02 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
float tw = pInfo->m_pSelf->TextRender()->TextWidth(pInfo->m_Cursor.m_pFont, pInfo->m_Cursor.m_FontSize, pStr, -1);
|
|
|
|
pInfo->m_pSelf->Graphics()->TextureSet(-1);
|
|
|
|
pInfo->m_pSelf->Graphics()->QuadsBegin();
|
|
|
|
pInfo->m_pSelf->Graphics()->SetColor(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,0.85f);
|
|
|
|
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();
|
2009-01-24 12:16:02 +00:00
|
|
|
|
2010-06-19 11:48:01 +00:00
|
|
|
// 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;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
pInfo->m_pSelf->TextRender()->TextColor(0.05f, 0.05f, 0.05f,1);
|
|
|
|
pInfo->m_pSelf->TextRender()->TextEx(&pInfo->m_Cursor, pStr, -1);
|
2009-01-24 12:16:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
const char *pMatchStart = str_find_nocase(pStr, pInfo->m_pCurrentCmd);
|
2009-01-24 12:16:02 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(pMatchStart)
|
2009-01-24 12:16:02 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
pInfo->m_pSelf->TextRender()->TextColor(0.5f,0.5f,0.5f,1);
|
|
|
|
pInfo->m_pSelf->TextRender()->TextEx(&pInfo->m_Cursor, pStr, pMatchStart-pStr);
|
|
|
|
pInfo->m_pSelf->TextRender()->TextColor(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,1);
|
|
|
|
pInfo->m_pSelf->TextRender()->TextEx(&pInfo->m_Cursor, pMatchStart, str_length(pInfo->m_pCurrentCmd));
|
|
|
|
pInfo->m_pSelf->TextRender()->TextColor(0.5f,0.5f,0.5f,1);
|
|
|
|
pInfo->m_pSelf->TextRender()->TextEx(&pInfo->m_Cursor, pMatchStart+str_length(pInfo->m_pCurrentCmd), -1);
|
2009-01-24 12:16:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
pInfo->m_pSelf->TextRender()->TextColor(0.75f,0.75f,0.75f,1);
|
|
|
|
pInfo->m_pSelf->TextRender()->TextEx(&pInfo->m_Cursor, pStr, -1);
|
2009-01-24 12:16:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
pInfo->m_EnumCount++;
|
|
|
|
pInfo->m_Cursor.m_X += 7.0f;
|
2009-01-24 12:16:02 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::OnRender()
|
2008-01-29 21:39:41 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect Screen = *UI()->Screen();
|
|
|
|
float ConsoleMaxHeight = Screen.h*3/5.0f;
|
|
|
|
float ConsoleHeight;
|
2008-02-04 00:13:34 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
float Progress = (TimeNow()-(m_StateChangeEnd-m_StateChangeDuration))/float(m_StateChangeDuration);
|
2008-02-04 00:13:34 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if (Progress >= 1.0f)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if (m_ConsoleState == CONSOLE_CLOSING)
|
|
|
|
m_ConsoleState = CONSOLE_CLOSED;
|
|
|
|
else if (m_ConsoleState == CONSOLE_OPENING)
|
|
|
|
m_ConsoleState = CONSOLE_OPEN;
|
2008-03-18 02:14:35 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
Progress = 1.0f;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2009-05-31 09:44:20 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if (m_ConsoleState == CONSOLE_OPEN && g_Config.m_ClEditor)
|
|
|
|
Toggle(0);
|
2009-05-31 09:44:20 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if (m_ConsoleState == CONSOLE_CLOSED)
|
2008-08-27 15:48:50 +00:00
|
|
|
return;
|
2008-11-01 16:49:05 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if (m_ConsoleState == CONSOLE_OPEN)
|
|
|
|
Input()->MouseModeAbsolute();
|
2008-03-18 02:14:35 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
float ConsoleHeightScale;
|
2008-03-18 02:14:35 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if (m_ConsoleState == CONSOLE_OPENING)
|
|
|
|
ConsoleHeightScale = ConsoleScaleFunc(Progress);
|
|
|
|
else if (m_ConsoleState == CONSOLE_CLOSING)
|
|
|
|
ConsoleHeightScale = ConsoleScaleFunc(1.0f-Progress);
|
2008-08-27 15:48:50 +00:00
|
|
|
else //if (console_state == CONSOLE_OPEN)
|
2010-05-29 07:25:38 +00:00
|
|
|
ConsoleHeightScale = ConsoleScaleFunc(1.0f);
|
2008-03-18 02:14:35 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
ConsoleHeight = ConsoleHeightScale*ConsoleMaxHeight;
|
2008-02-04 00:13:34 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);
|
2008-02-04 00:13:34 +00:00
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
// do console shadow
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->TextureSet(-1);
|
|
|
|
Graphics()->QuadsBegin();
|
2010-05-29 07:25:38 +00:00
|
|
|
IGraphics::CColorVertex Array[4] = {
|
|
|
|
IGraphics::CColorVertex(0, 0,0,0, 0.5f),
|
|
|
|
IGraphics::CColorVertex(1, 0,0,0, 0.5f),
|
|
|
|
IGraphics::CColorVertex(2, 0,0,0, 0.0f),
|
|
|
|
IGraphics::CColorVertex(3, 0,0,0, 0.0f)};
|
|
|
|
Graphics()->SetColorVertex(Array, 4);
|
|
|
|
IGraphics::CQuadItem QuadItem(0, ConsoleHeight, Screen.w, 10.0f);
|
|
|
|
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-03-01 20:03:04 +00:00
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
// do background
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CONSOLE_BG].m_Id);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsBegin();
|
|
|
|
Graphics()->SetColor(0.2f, 0.2f, 0.2f,0.9f);
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_ConsoleType != 0)
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->SetColor(0.4f, 0.2f, 0.2f,0.9f);
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->QuadsSetSubset(0,-ConsoleHeight*0.075f,Screen.w*0.075f*0.5f,0);
|
|
|
|
QuadItem = IGraphics::CQuadItem(0, 0, Screen.w, ConsoleHeight);
|
|
|
|
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-03-01 20:03:04 +00:00
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
// do small bar shadow
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->TextureSet(-1);
|
|
|
|
Graphics()->QuadsBegin();
|
2010-05-29 07:25:38 +00:00
|
|
|
Array[0] = IGraphics::CColorVertex(0, 0,0,0, 0.0f);
|
|
|
|
Array[1] = IGraphics::CColorVertex(1, 0,0,0, 0.0f);
|
|
|
|
Array[2] = IGraphics::CColorVertex(2, 0,0,0, 0.25f);
|
|
|
|
Array[3] = IGraphics::CColorVertex(3, 0,0,0, 0.25f);
|
|
|
|
Graphics()->SetColorVertex(Array, 4);
|
|
|
|
QuadItem = IGraphics::CQuadItem(0, ConsoleHeight-20, Screen.w, 10);
|
|
|
|
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-03-01 20:03:04 +00:00
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
// do the lower bar
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CONSOLE_BAR].m_Id);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsBegin();
|
|
|
|
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.9f);
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->QuadsSetSubset(0,0.1f,Screen.w*0.015f,1-0.1f);
|
|
|
|
QuadItem = IGraphics::CQuadItem(0,ConsoleHeight-10.0f,Screen.w,10.0f);
|
|
|
|
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
ConsoleHeight -= 22.0f;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CInstance *pConsole = CurrentConsole();
|
2008-03-29 15:00:04 +00:00
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
float FontSize = 10.0f;
|
|
|
|
float RowHeight = FontSize*1.25f;
|
2008-08-27 15:48:50 +00:00
|
|
|
float x = 3;
|
2010-05-29 07:25:38 +00:00
|
|
|
float y = ConsoleHeight - RowHeight - 2;
|
2008-03-23 09:22:15 +00:00
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
// render prompt
|
2010-05-29 07:25:38 +00:00
|
|
|
CTextCursor Cursor;
|
|
|
|
TextRender()->SetCursor(&Cursor, x, y, FontSize, TEXTFLAG_RENDER);
|
|
|
|
|
|
|
|
CRenderInfo Info;
|
|
|
|
Info.m_pSelf = this;
|
|
|
|
Info.m_WantedCompletion = pConsole->m_CompletionChosen;
|
|
|
|
Info.m_EnumCount = 0;
|
2010-06-19 11:48:01 +00:00
|
|
|
Info.m_Offset = pConsole->m_CompletionRenderOffset;
|
|
|
|
Info.m_Width = Screen.w;
|
2010-05-29 07:25:38 +00:00
|
|
|
Info.m_pCurrentCmd = pConsole->m_aCompletionBuffer;
|
2010-06-19 11:48:01 +00:00
|
|
|
TextRender()->SetCursor(&Info.m_Cursor, x+Info.m_Offset, y+12.0f, FontSize, TEXTFLAG_RENDER);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
const char *pPrompt = "> ";
|
|
|
|
if(m_ConsoleType)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Client()->State() == IClient::STATE_ONLINE)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Client()->RconAuthed())
|
|
|
|
pPrompt = "rcon> ";
|
2008-08-27 15:48:50 +00:00
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
pPrompt = "ENTER PASSWORD> ";
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
pPrompt = "NOT CONNECTED> ";
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->TextEx(&Cursor, pPrompt, -1);
|
|
|
|
x = Cursor.m_X;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// render version
|
2010-05-29 07:25:38 +00:00
|
|
|
char aBuf[128];
|
|
|
|
str_format(aBuf, sizeof(aBuf), "v%s", GAME_VERSION);
|
|
|
|
float VersionWidth = TextRender()->TextWidth(0, FontSize, aBuf, -1);
|
|
|
|
TextRender()->Text(0, Screen.w-VersionWidth-5, y, FontSize, aBuf, -1);
|
|
|
|
|
|
|
|
// render console input (wrap line)
|
|
|
|
int Lines = TextRender()->TextLineCount(0, FontSize, pConsole->m_Input.GetString(), Screen.w - (VersionWidth + 10 + x));
|
|
|
|
y -= (Lines - 1) * FontSize;
|
|
|
|
TextRender()->SetCursor(&Cursor, x, y, FontSize, TEXTFLAG_RENDER);
|
|
|
|
Cursor.m_LineWidth = Screen.w - (VersionWidth + 10 + x);
|
|
|
|
|
|
|
|
//hide rcon password
|
|
|
|
char aInputString[256];
|
|
|
|
str_copy(aInputString, pConsole->m_Input.GetString(), sizeof(aInputString));
|
|
|
|
if(m_ConsoleType && Client()->State() == IClient::STATE_ONLINE && !Client()->RconAuthed())
|
2009-01-24 13:12:04 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
for(int i = 0; i < pConsole->m_Input.GetLength(); ++i)
|
|
|
|
aInputString[i] = '*';
|
|
|
|
}
|
2009-01-24 13:12:04 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->TextEx(&Cursor, aInputString, pConsole->m_Input.GetCursorOffset());
|
|
|
|
CTextCursor Marker = Cursor;
|
|
|
|
TextRender()->TextEx(&Marker, "|", -1);
|
|
|
|
TextRender()->TextEx(&Cursor, aInputString+pConsole->m_Input.GetCursorOffset(), -1);
|
|
|
|
|
|
|
|
// render possible commands
|
|
|
|
if(m_ConsoleType == 0 || Client()->RconAuthed())
|
|
|
|
{
|
|
|
|
if(pConsole->m_Input.GetString()[0] != 0)
|
2009-01-24 13:12:04 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_pConsole->PossibleCommands(pConsole->m_aCompletionBuffer, pConsole->m_CompletionFlagmask, PossibleCommandsRenderCallback, &Info);
|
2010-06-19 11:48:01 +00:00
|
|
|
pConsole->m_CompletionRenderOffset = Info.m_Offset;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
if(Info.m_EnumCount <= 0)
|
2009-01-24 13:12:04 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(pConsole->m_pCommand)
|
|
|
|
{
|
|
|
|
|
|
|
|
char aBuf[512];
|
|
|
|
str_format(aBuf, sizeof(aBuf), "Help: %s ", pConsole->m_pCommand->m_pHelp);
|
|
|
|
TextRender()->TextEx(&Info.m_Cursor, aBuf, -1);
|
|
|
|
TextRender()->TextColor(0.75f, 0.75f, 0.75f, 1);
|
|
|
|
str_format(aBuf, sizeof(aBuf), "Syntax: %s %s", pConsole->m_pCommand->m_pName, pConsole->m_pCommand->m_pParams);
|
|
|
|
TextRender()->TextEx(&Info.m_Cursor, aBuf, -1);
|
|
|
|
}
|
2009-01-24 13:12:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->TextColor(1,1,1,1);
|
2009-01-24 12:16:02 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// render log (actual page, wrap lines)
|
|
|
|
char *pEntry = pConsole->m_Backlog.Last();
|
|
|
|
for(int Page = 0, Lines = 0; Page <= pConsole->m_BacklogActPage; ++Page, Lines = 0)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
// next page when lines reach the top
|
|
|
|
while(y - Lines * RowHeight > RowHeight && pEntry)
|
|
|
|
{
|
|
|
|
Lines += TextRender()->TextLineCount(0, FontSize, pEntry, Screen.w-10);
|
|
|
|
// just render output from actual backlog page (render bottom up)
|
|
|
|
if(Page == pConsole->m_BacklogActPage)
|
|
|
|
{
|
|
|
|
TextRender()->SetCursor(&Cursor, 0, y - Lines * RowHeight, FontSize, TEXTFLAG_RENDER);
|
|
|
|
Cursor.m_LineWidth = Screen.w-10;
|
|
|
|
TextRender()->TextEx(&Cursor, pEntry, -1);
|
|
|
|
}
|
|
|
|
pEntry = pConsole->m_Backlog.Prev(pEntry);
|
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// actual backlog page number is too high, render last available page (current checked one, render top down)
|
|
|
|
if(!pEntry && Page < pConsole->m_BacklogActPage)
|
|
|
|
{
|
|
|
|
pConsole->m_BacklogActPage = Page;
|
|
|
|
pEntry = pConsole->m_Backlog.First();
|
|
|
|
while(Lines > 0 && pEntry)
|
|
|
|
{
|
|
|
|
TextRender()->SetCursor(&Cursor, 0, y - Lines * RowHeight, FontSize, TEXTFLAG_RENDER);
|
|
|
|
Cursor.m_LineWidth = Screen.w-10;
|
|
|
|
Cursor.m_LineCount = 1;
|
|
|
|
TextRender()->TextEx(&Cursor, pEntry, -1);
|
|
|
|
Lines -= Cursor.m_LineCount;
|
|
|
|
pEntry = pConsole->m_Backlog.Next(pEntry);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-23 09:22:15 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::OnMessage(int MsgType, void *pRawMsg)
|
2008-03-01 20:03:04 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
bool CGameConsole::OnInput(IInput::CEvent Event)
|
2008-03-01 20:03:04 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_ConsoleState == CONSOLE_CLOSED)
|
2008-08-27 16:23:15 +00:00
|
|
|
return false;
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Event.m_Key >= KEY_F1 && Event.m_Key <= KEY_F15)
|
2008-08-27 16:23:15 +00:00
|
|
|
return false;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Event.m_Key == KEY_ESCAPE && (Event.m_Flags&IInput::FLAG_PRESS))
|
|
|
|
Toggle(m_ConsoleType);
|
2008-08-27 16:23:15 +00:00
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
CurrentConsole()->OnInput(Event);
|
2008-08-27 16:23:15 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::Toggle(int Type)
|
2008-08-27 16:23:15 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_ConsoleType != Type && (m_ConsoleState == CONSOLE_OPEN || m_ConsoleState == CONSOLE_OPENING))
|
2008-08-27 16:23:15 +00:00
|
|
|
{
|
|
|
|
// don't toggle console, just switch what console to use
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if (m_ConsoleState == CONSOLE_CLOSED || m_ConsoleState == CONSOLE_OPEN)
|
2008-08-27 16:23:15 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_StateChangeEnd = TimeNow()+m_StateChangeDuration;
|
2008-08-27 16:23:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
float Progress = m_StateChangeEnd-TimeNow();
|
|
|
|
float ReversedProgress = m_StateChangeDuration-Progress;
|
2008-08-27 16:23:15 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
m_StateChangeEnd = TimeNow()+ReversedProgress;
|
2008-08-27 16:23:15 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if (m_ConsoleState == CONSOLE_CLOSED || m_ConsoleState == CONSOLE_CLOSING)
|
2008-10-20 18:12:15 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
Input()->MouseModeAbsolute();
|
|
|
|
m_pClient->m_pMenus->UseMouseButtons(false);
|
|
|
|
m_ConsoleState = CONSOLE_OPENING;
|
2010-05-31 21:40:40 +00:00
|
|
|
// reset controls
|
|
|
|
m_pClient->m_pControls->OnReset();
|
2008-10-20 18:12:15 +00:00
|
|
|
}
|
2008-08-27 16:23:15 +00:00
|
|
|
else
|
2008-10-20 18:12:15 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
Input()->MouseModeRelative();
|
|
|
|
m_pClient->m_pMenus->UseMouseButtons(true);
|
|
|
|
m_ConsoleState = CONSOLE_CLOSING;
|
2008-10-20 18:12:15 +00:00
|
|
|
}
|
2008-08-27 16:23:15 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
m_ConsoleType = Type;
|
2008-08-27 16:23:15 +00:00
|
|
|
}
|
|
|
|
|
2010-06-20 12:12:59 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::ConToggleLocalConsole(IConsole::IResult *pResult, void *pUserData)
|
2008-08-27 16:23:15 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
((CGameConsole *)pUserData)->Toggle(0);
|
2008-08-27 16:23:15 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::ConToggleRemoteConsole(IConsole::IResult *pResult, void *pUserData)
|
2008-08-27 16:23:15 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
((CGameConsole *)pUserData)->Toggle(1);
|
2008-08-27 16:23:15 +00:00
|
|
|
}
|
|
|
|
|
2010-06-19 18:51:54 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2010-06-20 12:12:59 +00:00
|
|
|
void CGameConsole::ConDumpLocalConsole(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
((CGameConsole *)pUserData)->Dump(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGameConsole::ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
((CGameConsole *)pUserData)->Dump(1);
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::ClientConsolePrintCallback(const char *pStr, void *pUserData)
|
2008-08-27 16:23:15 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
((CGameConsole *)pUserData)->m_LocalConsole.PrintLine(pStr);
|
2008-08-27 16:23:15 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::PrintLine(int Type, const char *pLine)
|
2008-08-30 08:01:29 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Type == 0)
|
|
|
|
m_LocalConsole.PrintLine(pLine);
|
|
|
|
else if(Type == 1)
|
|
|
|
m_RemoteConsole.PrintLine(pLine);
|
2008-08-30 08:01:29 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CGameConsole::OnConsoleInit()
|
2008-08-27 16:23:15 +00:00
|
|
|
{
|
2010-06-05 11:38:08 +00:00
|
|
|
// init console instances
|
|
|
|
m_LocalConsole.Init(this);
|
|
|
|
m_RemoteConsole.Init(this);
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
m_pConsole = Kernel()->RequestInterface<IConsole>();
|
|
|
|
|
2008-08-27 16:23:15 +00:00
|
|
|
//
|
2010-05-29 07:25:38 +00:00
|
|
|
Console()->RegisterPrintCallback(ClientConsolePrintCallback, this);
|
2008-08-27 16:23:15 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
Console()->Register("toggle_local_console", "", CFGFLAG_CLIENT, ConToggleLocalConsole, this, "Toggle local console");
|
|
|
|
Console()->Register("toggle_remote_console", "", CFGFLAG_CLIENT, ConToggleRemoteConsole, this, "Toggle remote console");
|
2010-06-19 18:51:54 +00:00
|
|
|
Console()->Register("clear_local_console", "", CFGFLAG_CLIENT, ConClearLocalConsole, this, "Clear local console");
|
|
|
|
Console()->Register("clear_remote_console", "", CFGFLAG_CLIENT, ConClearRemoteConsole, this, "Clear remote console");
|
2010-06-20 12:12:59 +00:00
|
|
|
Console()->Register("dump_local_console", "", CFGFLAG_CLIENT, ConDumpLocalConsole, this, "Dump local console");
|
|
|
|
Console()->Register("dump_remote_console", "", CFGFLAG_CLIENT, ConDumpRemoteConsole, this, "Dump remote console");
|
2008-03-01 20:03:04 +00:00
|
|
|
}
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
/*
|
|
|
|
static void con_team(void *result, void *user_data)
|
2008-03-29 15:00:04 +00:00
|
|
|
{
|
2008-08-27 15:48:50 +00:00
|
|
|
send_switch_team(console_arg_int(result, 0));
|
2008-03-29 15:00:04 +00:00
|
|
|
}
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
static void con_kill(void *result, void *user_data)
|
2008-03-01 20:03:04 +00:00
|
|
|
{
|
2008-08-27 15:48:50 +00:00
|
|
|
send_kill(-1);
|
2008-03-01 20:03:04 +00:00
|
|
|
}
|
|
|
|
|
2008-08-30 08:01:29 +00:00
|
|
|
void send_kill(int client_id);
|
|
|
|
|
2008-03-01 20:03:04 +00:00
|
|
|
static void con_emote(void *result, void *user_data)
|
|
|
|
{
|
2008-03-14 23:39:52 +00:00
|
|
|
send_emoticon(console_arg_int(result, 0));
|
2008-03-01 20:03:04 +00:00
|
|
|
}
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
extern void con_chat(void *result, void *user_data);
|
|
|
|
|
2008-01-16 22:14:06 +00:00
|
|
|
void client_console_init()
|
|
|
|
{
|
2008-03-01 20:03:04 +00:00
|
|
|
//
|
2008-01-29 21:39:41 +00:00
|
|
|
MACRO_REGISTER_COMMAND("team", "i", con_team, 0x0);
|
2008-03-01 14:36:36 +00:00
|
|
|
MACRO_REGISTER_COMMAND("kill", "", con_kill, 0x0);
|
2008-03-01 20:03:04 +00:00
|
|
|
|
|
|
|
// chatting
|
|
|
|
MACRO_REGISTER_COMMAND("emote", "i", con_emote, 0);
|
2008-03-14 23:39:52 +00:00
|
|
|
MACRO_REGISTER_COMMAND("+emote", "", con_key_input_state, &emoticon_selector_active);
|
2008-01-16 22:14:06 +00:00
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
*/
|