DDraceNetwork Docs
CChat Class Reference

#include <chat.h>

Inheritance diagram for CChat:
[legend]
Collaboration diagram for CChat:
[legend]

Classes

struct  CCommand
 
struct  CHistoryEntry
 
struct  CLine
 
struct  CRateablePlayer
 

Public Member Functions

 CChat ()
 
int Sizeof () const override
 
bool IsActive () const
 
void AddLine (int ClientId, int Team, const char *pLine)
 
void EnableMode (int Team)
 
void DisableMode ()
 
void RegisterCommand (const char *pName, const char *pParams, const char *pHelpText)
 
void UnregisterCommand (const char *pName)
 
void Echo (const char *pString)
 
void OnWindowResize () override
 
void OnConsoleInit () override
 
void OnStateChange (int NewState, int OldState) override
 
void OnRefreshSkins () override
 
void OnRender () override
 
void OnPrepareLines (float y)
 
void Reset ()
 
void OnRelease () override
 
void OnMessage (int MsgType, void *pRawMsg) override
 
bool OnInput (const IInput::CEvent &Event) override
 
void OnInit () override
 
void RebuildChat ()
 
void ClearLines ()
 
void EnsureCoherentFontSize () const
 
void EnsureCoherentWidth () const
 
float FontSize () const
 
float MessagePaddingX () const
 
float MessagePaddingY () const
 
float MessageTeeSize () const
 
float MessageRounding () const
 
void SendChat (int Team, const char *pLine)
 
void SendChatQueued (const char *pLine)
 
- Public Member Functions inherited from CComponent
virtual ~CComponent ()
 
virtual int Sizeof () const =0
 
class CGameClientGameClient () const
 
class IClientClient () const
 
virtual void OnStateChange (int NewState, int OldState)
 
virtual void OnConsoleInit ()
 
virtual void OnInit ()
 
virtual void OnShutdown ()
 
virtual void OnReset ()
 
virtual void OnWindowResize ()
 
virtual void OnRefreshSkins ()
 
virtual void OnRender ()
 
virtual void OnNewSnapshot ()
 
virtual void OnRelease ()
 
virtual void OnMapLoad ()
 
virtual void OnMessage (int Msg, void *pRawMsg)
 
virtual bool OnCursorMove (float x, float y, IInput::ECursorType CursorType)
 
virtual bool OnInput (const IInput::CEvent &Event)
 

Static Public Attributes

static constexpr float MESSAGE_TEE_PADDING_RIGHT = 0.5f
 

Private Types

enum  { MAX_LINES = 64 , MAX_LINE_LENGTH = 256 }
 
enum  {
  CLIENT_MSG = -2 , SERVER_MSG = -1 , MODE_NONE = 0 , MODE_ALL ,
  MODE_TEAM , CHAT_SERVER = 0 , CHAT_HIGHLIGHT , CHAT_CLIENT ,
  CHAT_NUM
}
 

Private Member Functions

bool LineShouldHighlight (const char *pLine, const char *pName)
 
void StoreSave (const char *pText)
 

Static Private Member Functions

static void ConSay (IConsole::IResult *pResult, void *pUserData)
 
static void ConSayTeam (IConsole::IResult *pResult, void *pUserData)
 
static void ConChat (IConsole::IResult *pResult, void *pUserData)
 
static void ConShowChat (IConsole::IResult *pResult, void *pUserData)
 
static void ConEcho (IConsole::IResult *pResult, void *pUserData)
 
static void ConClearChat (IConsole::IResult *pResult, void *pUserData)
 
static void ConchainChatOld (IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
 
static void ConchainChatFontSize (IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
 
static void ConchainChatWidth (IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
 

Private Attributes

CLineInputBuffered< MAX_LINE_LENGTHm_Input
 
bool m_PrevScoreBoardShowed
 
bool m_PrevShowChat
 
CLine m_aLines [MAX_LINES]
 
int m_CurrentLine
 
int m_Mode
 
bool m_Show
 
bool m_CompletionUsed
 
int m_CompletionChosen
 
char m_aCompletionBuffer [MAX_LINE_LENGTH]
 
int m_PlaceholderOffset
 
int m_PlaceholderLength
 
CRateablePlayer m_aPlayerCompletionList [MAX_CLIENTS]
 
int m_PlayerCompletionListLength
 
std::vector< CCommandm_vCommands
 
bool m_CommandsNeedSorting
 
CHistoryEntrym_pHistoryEntry
 
CStaticRingBuffer< CHistoryEntry, 64 *1024, CRingBufferBase::FLAG_RECYCLEm_History
 
int m_PendingChatCounter
 
int64_t m_LastChatSend
 
int64_t m_aLastSoundPlayed [CHAT_NUM]
 
bool m_IsInputCensored
 
char m_aCurrentInputText [MAX_LINE_LENGTH]
 
bool m_EditingNewLine
 
bool m_ServerSupportsCommandInfo
 

Static Private Attributes

static constexpr float CHAT_HEIGHT_FULL = 200.0f
 
static constexpr float CHAT_HEIGHT_MIN = 50.0f
 
static constexpr float CHAT_FONTSIZE_WIDTH_RATIO = 2.5f
 
static char ms_aDisplayText [MAX_LINE_LENGTH] = {'\0'}
 

Additional Inherited Members

- Protected Member Functions inherited from CComponent
class IKernelKernel () const
 
class IEngineEngine () const
 
class IGraphicsGraphics () const
 
class ITextRenderTextRender () const
 
class IInputInput () const
 
class IStorageStorage () const
 
class CUiUi () const
 
class ISoundSound () const
 
class CRenderToolsRenderTools () const
 
class IConfigManagerConfigManager () const
 
class CConfigConfig () const
 
class IConsoleConsole () const
 
class IDemoPlayerDemoPlayer () const
 
class IDemoRecorderDemoRecorder (int Recorder) const
 
class IFavoritesFavorites () const
 
class IServerBrowserServerBrowser () const
 
class CLayersLayers () const
 
class CCollisionCollision () const
 
int64_t time () const
 
float LocalTime () const
 
class IHttpHttp () const
 
- Protected Attributes inherited from CComponent
CGameClientm_pClient
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
MAX_LINES 
MAX_LINE_LENGTH 

◆ anonymous enum

anonymous enum
private
Enumerator
CLIENT_MSG 
SERVER_MSG 
MODE_NONE 
MODE_ALL 
MODE_TEAM 
CHAT_SERVER 
CHAT_HIGHLIGHT 
CHAT_CLIENT 
CHAT_NUM 

Constructor & Destructor Documentation

◆ CChat()

CChat::CChat ( )

Member Function Documentation

◆ AddLine()

void CChat::AddLine ( int  ClientId,
int  Team,
const char *  pLine 
)

◆ ClearLines()

void CChat::ClearLines ( )

◆ ConchainChatFontSize()

void CChat::ConchainChatFontSize ( IConsole::IResult pResult,
void *  pUserData,
IConsole::FCommandCallback  pfnCallback,
void *  pCallbackUserData 
)
staticprivate

◆ ConchainChatOld()

void CChat::ConchainChatOld ( IConsole::IResult pResult,
void *  pUserData,
IConsole::FCommandCallback  pfnCallback,
void *  pCallbackUserData 
)
staticprivate

◆ ConchainChatWidth()

void CChat::ConchainChatWidth ( IConsole::IResult pResult,
void *  pUserData,
IConsole::FCommandCallback  pfnCallback,
void *  pCallbackUserData 
)
staticprivate

◆ ConChat()

void CChat::ConChat ( IConsole::IResult pResult,
void *  pUserData 
)
staticprivate

◆ ConClearChat()

void CChat::ConClearChat ( IConsole::IResult pResult,
void *  pUserData 
)
staticprivate

◆ ConEcho()

void CChat::ConEcho ( IConsole::IResult pResult,
void *  pUserData 
)
staticprivate

◆ ConSay()

void CChat::ConSay ( IConsole::IResult pResult,
void *  pUserData 
)
staticprivate

◆ ConSayTeam()

void CChat::ConSayTeam ( IConsole::IResult pResult,
void *  pUserData 
)
staticprivate

◆ ConShowChat()

void CChat::ConShowChat ( IConsole::IResult pResult,
void *  pUserData 
)
staticprivate

◆ DisableMode()

void CChat::DisableMode ( )

◆ Echo()

void CChat::Echo ( const char *  pString)

◆ EnableMode()

void CChat::EnableMode ( int  Team)

◆ EnsureCoherentFontSize()

void CChat::EnsureCoherentFontSize ( ) const

◆ EnsureCoherentWidth()

void CChat::EnsureCoherentWidth ( ) const

◆ FontSize()

float CChat::FontSize ( ) const
inline

◆ IsActive()

bool CChat::IsActive ( ) const
inline

◆ LineShouldHighlight()

bool CChat::LineShouldHighlight ( const char *  pLine,
const char *  pName 
)
private

◆ MessagePaddingX()

float CChat::MessagePaddingX ( ) const
inline

◆ MessagePaddingY()

float CChat::MessagePaddingY ( ) const
inline

◆ MessageRounding()

float CChat::MessageRounding ( ) const
inline

◆ MessageTeeSize()

float CChat::MessageTeeSize ( ) const
inline

◆ OnConsoleInit()

void CChat::OnConsoleInit ( )
overridevirtual

Called to let the components register their console commands.

Reimplemented from CComponent.

◆ OnInit()

void CChat::OnInit ( )
overridevirtual

Called to let the components run initialization code.

Reimplemented from CComponent.

◆ OnInput()

bool CChat::OnInput ( const IInput::CEvent Event)
overridevirtual

Called on a input event.

Parameters
EventThe input event.

Reimplemented from CComponent.

◆ OnMessage()

void CChat::OnMessage ( int  Msg,
void *  pRawMsg 
)
overridevirtual

Called when receiving a network message.

Parameters
MsgThe message type.
pRawMsgThe message data.
See also
NETMSGTYPE_SV_DDRACETIME
CNetMsg_Sv_DDRaceTime

Reimplemented from CComponent.

◆ OnPrepareLines()

void CChat::OnPrepareLines ( float  y)

◆ OnRefreshSkins()

void CChat::OnRefreshSkins ( )
overridevirtual

Called when skins have been invalidated and must be updated.

Reimplemented from CComponent.

◆ OnRelease()

void CChat::OnRelease ( )
overridevirtual

Called when the input gets released, for example when a text box loses focus.

Reimplemented from CComponent.

◆ OnRender()

void CChat::OnRender ( )
overridevirtual

Called when the component should get rendered.

The render order depends on the component insertion order.

Reimplemented from CComponent.

◆ OnStateChange()

void CChat::OnStateChange ( int  NewState,
int  OldState 
)
overridevirtual

This method is called when the client changes state, e.g from offline to online.

See also
IClient::STATE_CONNECTING
IClient::STATE_LOADING
IClient::STATE_ONLINE

Reimplemented from CComponent.

◆ OnWindowResize()

void CChat::OnWindowResize ( )
overridevirtual

Called when the window has been resized.

Reimplemented from CComponent.

◆ RebuildChat()

void CChat::RebuildChat ( )

◆ RegisterCommand()

void CChat::RegisterCommand ( const char *  pName,
const char *  pParams,
const char *  pHelpText 
)

◆ Reset()

void CChat::Reset ( )

◆ SendChat()

void CChat::SendChat ( int  Team,
const char *  pLine 
)

◆ SendChatQueued()

void CChat::SendChatQueued ( const char *  pLine)

◆ Sizeof()

int CChat::Sizeof ( ) const
inlineoverridevirtual

Gets the size of the non-abstract component.

Implements CComponent.

◆ StoreSave()

void CChat::StoreSave ( const char *  pText)
private

◆ UnregisterCommand()

void CChat::UnregisterCommand ( const char *  pName)

Member Data Documentation

◆ CHAT_FONTSIZE_WIDTH_RATIO

constexpr float CChat::CHAT_FONTSIZE_WIDTH_RATIO = 2.5f
staticconstexprprivate

◆ CHAT_HEIGHT_FULL

constexpr float CChat::CHAT_HEIGHT_FULL = 200.0f
staticconstexprprivate

◆ CHAT_HEIGHT_MIN

constexpr float CChat::CHAT_HEIGHT_MIN = 50.0f
staticconstexprprivate

◆ m_aCompletionBuffer

char CChat::m_aCompletionBuffer[MAX_LINE_LENGTH]
private

◆ m_aCurrentInputText

char CChat::m_aCurrentInputText[MAX_LINE_LENGTH]
private

◆ m_aLastSoundPlayed

int64_t CChat::m_aLastSoundPlayed[CHAT_NUM]
private

◆ m_aLines

CLine CChat::m_aLines[MAX_LINES]
private

◆ m_aPlayerCompletionList

CRateablePlayer CChat::m_aPlayerCompletionList[MAX_CLIENTS]
private

◆ m_CommandsNeedSorting

bool CChat::m_CommandsNeedSorting
private

◆ m_CompletionChosen

int CChat::m_CompletionChosen
private

◆ m_CompletionUsed

bool CChat::m_CompletionUsed
private

◆ m_CurrentLine

int CChat::m_CurrentLine
private

◆ m_EditingNewLine

bool CChat::m_EditingNewLine
private

◆ m_History

CStaticRingBuffer<CHistoryEntry, 64 * 1024, CRingBufferBase::FLAG_RECYCLE> CChat::m_History
private

◆ m_Input

CLineInputBuffered<MAX_LINE_LENGTH> CChat::m_Input
private

◆ m_IsInputCensored

bool CChat::m_IsInputCensored
private

◆ m_LastChatSend

int64_t CChat::m_LastChatSend
private

◆ m_Mode

int CChat::m_Mode
private

◆ m_PendingChatCounter

int CChat::m_PendingChatCounter
private

◆ m_pHistoryEntry

CHistoryEntry* CChat::m_pHistoryEntry
private

◆ m_PlaceholderLength

int CChat::m_PlaceholderLength
private

◆ m_PlaceholderOffset

int CChat::m_PlaceholderOffset
private

◆ m_PlayerCompletionListLength

int CChat::m_PlayerCompletionListLength
private

◆ m_PrevScoreBoardShowed

bool CChat::m_PrevScoreBoardShowed
private

◆ m_PrevShowChat

bool CChat::m_PrevShowChat
private

◆ m_ServerSupportsCommandInfo

bool CChat::m_ServerSupportsCommandInfo
private

◆ m_Show

bool CChat::m_Show
private

◆ m_vCommands

std::vector<CCommand> CChat::m_vCommands
private

◆ MESSAGE_TEE_PADDING_RIGHT

constexpr float CChat::MESSAGE_TEE_PADDING_RIGHT = 0.5f
staticconstexpr

◆ ms_aDisplayText

char CChat::ms_aDisplayText = {'\0'}
staticprivate

The documentation for this class was generated from the following files: