diff --git a/src/game/client/hud_basechat.cpp b/src/game/client/hud_basechat.cpp index daa3446d8..1519628b4 100644 --- a/src/game/client/hud_basechat.cpp +++ b/src/game/client/hud_basechat.cpp @@ -55,8 +55,8 @@ Color g_ColorGrey( 204, 204, 204, 255 ); Color g_ColorPurple( 160, 115, 205, 255 ); static const char *gBugPriorityTable[] = { - "TODAY", - "ASAP", + "TODAY", + "ASAP", "NONE", NULL }; @@ -65,7 +65,7 @@ static const char *gBugTokenTable[] = { "re", "regression", "today", "showstopper", "asap", "showstopper", - "ss", "showstopper", + "ss", "showstopper", "show", "showstopper", // "high", "high", "med", "medium", @@ -210,15 +210,15 @@ static CUtlLinkedList *ParseTokens(char *szString) CUtlLinkedList *tokens = new CUtlLinkedList(); // ensure that the defaults are reset // later tokens should override these values - tokens->AddToHead("NONE"); - tokens->AddToHead("High"); - tokens->AddToHead("triage"); + tokens->AddToHead("NONE"); + tokens->AddToHead("High"); + tokens->AddToHead("triage"); char *pEnd = szString + V_strlen(szString) - 1; while ( pEnd >= szString && (*pEnd == ')' || *pEnd == ' ') ) { if (*pEnd == ')') - { + { char *pToken = NULL; // skip any spaces @@ -233,7 +233,7 @@ static CUtlLinkedList *ParseTokens(char *szString) // skip back to the open paren (if there is one) char *pStart = pEnd; while (pStart > szString && *pStart != '(') pStart--; - if (pStart >= szString) + if (pStart >= szString) { *pStart = '\0'; pToken = pStart+1; @@ -292,7 +292,7 @@ wchar_t* ReadChatTextString( bf_read &msg, wchar_t *pOut, int outSize, bool stri // Input : *parent - // *panelName - //----------------------------------------------------------------------------- -CBaseHudChatLine::CBaseHudChatLine( vgui::Panel *parent, const char *panelName ) : +CBaseHudChatLine::CBaseHudChatLine( vgui::Panel *parent, const char *panelName ) : vgui::MultiFontRichText( parent, panelName ) { m_hFont = m_hFontMarlett = 0; @@ -358,7 +358,7 @@ void CBaseHudChatLine::PerformFadeout( void ) r = r + ( 255 - r ) * frac; g = g + ( 255 - g ) * frac; b = b + ( 255 - b ) * frac; - + // Draw a right facing triangle in red, faded out over time int alpha = 63 + 192 * (1.0f - frac1 ); alpha = clamp( alpha, 0, 255 ); @@ -460,11 +460,11 @@ void CBaseHudChatLine::Expire( void ) //----------------------------------------------------------------------------- // Purpose: The prompt and text entry area for chat messages //----------------------------------------------------------------------------- -CBaseHudChatInputLine::CBaseHudChatInputLine( CBaseHudChat *parent, char const *panelName ) : +CBaseHudChatInputLine::CBaseHudChatInputLine( CBaseHudChat *parent, char const *panelName ) : vgui::Panel( parent, panelName ) { m_pPrompt = new vgui::Label( this, "ChatInputPrompt", L"Enter text:" ); - m_pInput = new CBaseHudChatEntry( this, "ChatInput", parent ); + m_pInput = new CBaseHudChatEntry( this, "ChatInput", parent ); m_pInput->SetMaximumCharCount( 127 ); // Send converts text to utf-8 m_pInput->m_iMaxByteCount = 127; @@ -473,7 +473,7 @@ CBaseHudChatInputLine::CBaseHudChatInputLine( CBaseHudChat *parent, char const * void CBaseHudChatInputLine::ApplySchemeSettings(vgui::IScheme *pScheme) { BaseClass::ApplySchemeSettings(pScheme); - + // FIXME: Outline vgui::HFont hFont = pScheme->GetFont( "ChatFont" ); @@ -527,7 +527,7 @@ void CBaseHudChatInputLine::PerformLayout() GetSize( wide, tall ); int w,h; - m_pPrompt->GetContentSize( w, h); + m_pPrompt->GetContentSize( w, h); m_pPrompt->SetBounds( 0, 0, w, tall ); m_pInput->SetBounds( w + 2, 0, wide - w - 2 , tall ); @@ -538,12 +538,12 @@ vgui::Panel *CBaseHudChatInputLine::GetInputPanel( void ) return m_pInput; } -CHudChatFilterButton::CHudChatFilterButton( vgui::Panel *pParent, const char *pName, const char *pText ) : +CHudChatFilterButton::CHudChatFilterButton( vgui::Panel *pParent, const char *pName, const char *pText ) : BaseClass( pParent, pName, pText ) { } -CHudChatFilterCheckButton::CHudChatFilterCheckButton( vgui::Panel *pParent, const char *pName, const char *pText, int iFlag ) : +CHudChatFilterCheckButton::CHudChatFilterCheckButton( vgui::Panel *pParent, const char *pName, const char *pText, int iFlag ) : BaseClass( pParent, pName, pText ) { m_iFlag = iFlag; @@ -793,7 +793,7 @@ void CBaseHudChat::CreateChatInputLine( void ) void CBaseHudChat::CreateChatLines( void ) { m_ChatLine = new CBaseHudChatLine( this, "ChatLine1" ); - m_ChatLine->SetVisible( false ); + m_ChatLine->SetVisible( false ); } @@ -902,7 +902,7 @@ void CBaseHudChat::MsgFunc_SayText( bf_read &msg ) int CBaseHudChat::GetFilterForString( const char *pString ) { - if ( !Q_stricmp( pString, "#HL_Name_Change" ) ) + if ( !Q_stricmp( pString, "#HL_Name_Change" ) ) { return CHAT_FILTER_NAMECHANGE; } @@ -1109,7 +1109,7 @@ void CBaseHudChat::MsgFunc_VoiceSubtitle( bf_read &msg ) const wchar_t *pVoicePrefix = g_pVGuiLocalize->Find( "#Voice" ); g_pVGuiLocalize->ConvertUnicodeToANSI( pVoicePrefix, szPrefix, sizeof(szPrefix) ); - + ChatPrintf( client, CHAT_FILTER_NONE, "%c(%s) %s%c: %s", COLOR_PLAYERNAME, szPrefix, GetDisplayedSubtitlePlayerName( client ), COLOR_NORMAL, ConvertCRtoNL( szString ) ); SetVoiceSubtitleState( false ); @@ -1274,15 +1274,15 @@ void CBaseHudChat::Printf( int iFilter, const char *fmt, ... ) //----------------------------------------------------------------------------- void CBaseHudChat::StartMessageMode( int iMessageModeType ) { - // reactivedrop: #iss-nohud-hanging if asw_draw_hud is 0 we don't - // show chat input box, because this leads to input being stuck and + // reactivedrop: #iss-nohud-hanging if asw_draw_hud is 0 we don't + // show chat input box, because this leads to input being stuck and // inability of client to open Esc menu or console #ifdef INFESTED_DLL extern ConVar asw_draw_hud; if (!asw_draw_hud.GetBool()) return; #endif // INFESTED_DLL - + m_nMessageMode = iMessageModeType; cl_chat_active.SetValue( m_nMessageMode ); @@ -1292,7 +1292,7 @@ void CBaseHudChat::StartMessageMode( int iMessageModeType ) m_pChatInput->ClearEntry(); SetChatPrompt( iMessageModeType ); - + if ( GetChatHistory() ) { // TERROR: hack to get ChatFont back @@ -1312,7 +1312,7 @@ void CBaseHudChat::StartMessageMode( int iMessageModeType ) SetMouseInputEnabled( true ); m_pChatInput->SetVisible( true ); vgui::surface()->CalculateMouseVisible(); - m_pChatInput->SetPaintBorderEnabled( true ); + m_pChatInput->SetPaintBorderEnabled( true ); m_pChatInput->RequestFocus(); #ifndef INFESTED_DLL @@ -1354,7 +1354,7 @@ void CBaseHudChat::StopMessageMode( bool bFade ) { SetKeyBoardInputEnabled( false ); SetMouseInputEnabled( false ); - + if ( GetChatHistory() ) { GetChatHistory()->SetPaintBorderEnabled( false ); @@ -1394,7 +1394,7 @@ void CBaseHudChat::FadeChatHistory( void ) { return; } - + float frac = ( m_flHistoryFadeTime - gpGlobals->curtime ) * CHAT_HISTORY_ONE_OVER_FADE_TIME; int alpha = frac * CHAT_HISTORY_ALPHA; alpha = clamp( alpha, 0, CHAT_HISTORY_ALPHA ); @@ -1451,7 +1451,7 @@ Color CBaseHudChat::GetTextColorForClient( TextColor colorNum, int clientIndex ) case COLOR_ACHIEVEMENT: { - vgui::IScheme *pSourceScheme = vgui::scheme()->GetIScheme( vgui::scheme()->GetScheme( "SourceScheme" ) ); + vgui::IScheme *pSourceScheme = vgui::scheme()->GetIScheme( vgui::scheme()->GetScheme( "SourceScheme" ) ); if ( pSourceScheme ) { c = pSourceScheme->GetColor( "SteamLightGreen", GetBgColor() ); @@ -1512,7 +1512,7 @@ int CBaseHudChatLine::TranslateChannelRange(byte inputval) //pass float modifier into range 0 - 255 outputMod *= 255.0f; - + return outputMod; } @@ -1584,9 +1584,9 @@ void CBaseHudChatLine::InsertAndColorizeText( wchar_t *buf, int clientIndex ) endIndexPos = diffResult; } - - + + if (endIndexPos > 0) { // save this start @@ -2192,7 +2192,7 @@ void CBaseHudChatLine::Colorize( int alpha ) CBaseHudChat *pChat = dynamic_cast(GetParent() ); if ( pChat && pChat->GetChatHistory() ) - { + { pChat->GetChatHistory()->InsertString( "\n" ); } @@ -2218,7 +2218,7 @@ void CBaseHudChatLine::Colorize( int alpha ) ConColorMsg( color, "%s", szText ); if ( pChat && pChat->GetChatHistory() ) - { + { pChat->GetChatHistory()->InsertColorChange( color ); pChat->GetChatHistory()->InsertFontChange( m_hFont ); pChat->GetChatHistory()->InsertString( wText ); @@ -2257,7 +2257,7 @@ void CBaseHudChat::Send( void ) wchar_t szTextbuf[1024]; m_pChatInput->GetMessageText( szTextbuf, sizeof( szTextbuf ) ); - + char ansi[1024]; g_pVGuiLocalize->ConvertUnicodeToANSI( szTextbuf, ansi, sizeof( ansi ) ); int len = Q_strlen(ansi); @@ -2276,7 +2276,7 @@ void CBaseHudChat::Send( void ) engine->ClientCmd_Unrestricted(szbuf); } - + m_pChatInput->ClearEntry(); m_nMessageMode = MM_NONE; // TERROR cl_chat_active.SetValue( m_nMessageMode ); @@ -2461,12 +2461,12 @@ void CBaseHudChat::ChatPrintf( int iPlayerIndex, int iFilter, const char *fmt, . if ( iPlayerIndex == 0 ) { Q_memset( &sPlayerInfo, 0, sizeof(player_info_t) ); - Q_strncpy( sPlayerInfo.name, "Console", sizeof(sPlayerInfo.name) ); + Q_strncpy( sPlayerInfo.name, "Console", sizeof(sPlayerInfo.name) ); } else { engine->GetPlayerInfo( iPlayerIndex, &sPlayerInfo ); - } + } int bufSize = (strlen( pmsg ) + 1 ) * sizeof(wchar_t); wchar_t *wbuf = static_cast( _alloca( bufSize ) ); @@ -2517,11 +2517,45 @@ void CBaseHudChat::FireGameEvent( IGameEvent *event ) if ( !player ) return; - + ChatPrintf( player->entindex(), CHAT_FILTER_NONE, "(SourceTV) %s", event->GetString( "text" ) ); } } +void CBaseHudChat::OnKeyCodeTyped(vgui::KeyCode code) +{ + if (code == KEY_ENTER || code == KEY_PAD_ENTER || code == KEY_ESCAPE) + { + if (code != KEY_ESCAPE) + { + Send(); + } + + // End message mode. + StopMessageMode(); + } + else + { + BaseClass::OnKeyCodeTyped(code); + } +} + +CBaseHudChatEntry::CBaseHudChatEntry( vgui::Panel *parent, char const *panelName, CBaseHudChat *pChat ) + : BaseClass( parent, panelName ) +{ + SetCatchEnterKey( true ); + SetAllowNonAsciiCharacters( true ); + SetDrawLanguageIDAtLeft( true ); + m_pHudChat = pChat; +} + +void CBaseHudChatEntry::ApplySchemeSettings( vgui::IScheme *pScheme ) +{ + BaseClass::ApplySchemeSettings(pScheme); + + SetPaintBorderEnabled( false ); +} + // Prevent player from inserting text over utf-8 byte limit void CBaseHudChatEntry::InsertChar(wchar_t ch) { @@ -2577,3 +2611,32 @@ void CBaseHudChatEntry::InsertChar(wchar_t ch) return; // do not insert anything } + +void CBaseHudChatEntry::OnKeyCodeTyped(vgui::KeyCode code) +{ + if ( code == KEY_ENTER || code == KEY_PAD_ENTER || code == KEY_ESCAPE ) + { + if ( code != KEY_ESCAPE ) + { + if ( m_pHudChat ) + { + m_pHudChat->Send(); + } + } + + // End message mode. + if ( m_pHudChat ) + { + m_pHudChat->StopMessageMode(); + } + } + else if ( code == KEY_TAB ) + { + // Ignore tab, otherwise vgui will screw up the focus. + return; + } + else + { + BaseClass::OnKeyCodeTyped( code ); + } +} diff --git a/src/game/client/hud_basechat.h b/src/game/client/hud_basechat.h index b74e5f91e..30dcab89a 100644 --- a/src/game/client/hud_basechat.h +++ b/src/game/client/hud_basechat.h @@ -117,7 +117,7 @@ class CBaseHudChatLine : public vgui::MultiFontRichText Color GetTextColor( void ) { return m_clrText; } void SetNameLength( int iLength ) { m_iNameLength = iLength; } void SetNameColor( Color cColor ){ m_clrNameColor = cColor; } - + virtual void PerformFadeout( void ); static int TranslateChannelRange(byte inputval); virtual void InsertAndColorizeText( wchar_t *buf, int clientIndex ); @@ -140,7 +140,7 @@ class CBaseHudChatLine : public vgui::MultiFontRichText friend class CRD_HoIAF_System; int m_iNameStart; - + private: float m_flStartTime; int m_nCount; @@ -214,17 +214,17 @@ class CBaseHudChat : public CHudElement, public vgui::EditablePanel virtual void CreateChatInputLine( void ); virtual void CreateChatLines( void ); - + virtual void Init( void ); void LevelInit( const char *newmap ); void LevelShutdown( void ); void MsgFunc_TextMsg(const char *pszName, int iSize, void *pbuf); - + virtual void Printf( int iFilter, const char *fmt, ... ); virtual void ChatPrintf( int iPlayerIndex, int iFilter, const char *fmt, ... ); - + virtual void StartMessageMode( int iMessageModeType ); virtual void StopMessageMode( bool bFade = true ); int GetMessageMode() { return m_nMessageMode; } @@ -255,7 +255,7 @@ class CBaseHudChat : public CHudElement, public vgui::EditablePanel virtual void MsgFunc_TextMsg( bf_read &msg ); virtual void MsgFunc_VoiceSubtitle( bf_read &msg ); - + CBaseHudChatInputLine *GetChatInput( void ) { return m_pChatInput; } CHudChatFilterPanel *GetChatFilterPanel( void ); @@ -275,24 +275,8 @@ class CBaseHudChat : public CHudElement, public vgui::EditablePanel bool IsVoiceSubtitle( void ) { return m_bEnteringVoice; } void SetVoiceSubtitleState( bool bState ) { m_bEnteringVoice = bState; } - - virtual void OnKeyCodeTyped(vgui::KeyCode code) - { - if (code == KEY_ENTER || code == KEY_PAD_ENTER || code == KEY_ESCAPE) - { - if (code != KEY_ESCAPE) - { - Send(); - } - - // End message mode. - StopMessageMode(); - } - else - { - BaseClass::OnKeyCodeTyped(code); - } - } + + virtual void OnKeyCodeTyped(vgui::KeyCode code); protected: CBaseHudChatLine *FindUnusedChatLine( void ); @@ -307,7 +291,7 @@ class CBaseHudChat : public CHudElement, public vgui::EditablePanel CHudChatFilterButton *m_pFiltersButton; CHudChatFilterPanel *m_pFilterPanel; -private: +private: void Clear( void ); int ComputeBreakChar( int width, const char *text, int textlen ); @@ -326,52 +310,12 @@ class CBaseHudChatEntry : public vgui::TextEntry public: int m_iMaxByteCount = -1; // utf-8 string length - CBaseHudChatEntry( vgui::Panel *parent, char const *panelName, CBaseHudChat *pChat ) - : BaseClass( parent, panelName ) - { - SetCatchEnterKey( true ); - SetAllowNonAsciiCharacters( true ); - SetDrawLanguageIDAtLeft( true ); - m_pHudChat = pChat; - } - - virtual void ApplySchemeSettings( vgui::IScheme *pScheme ) - { - BaseClass::ApplySchemeSettings(pScheme); + CBaseHudChatEntry( vgui::Panel *parent, char const *panelName, CBaseHudChat *pChat ); - SetPaintBorderEnabled( false ); - } + virtual void ApplySchemeSettings( vgui::IScheme *pScheme ); virtual void InsertChar(wchar_t ch); - - virtual void OnKeyCodeTyped(vgui::KeyCode code) - { - if ( code == KEY_ENTER || code == KEY_PAD_ENTER || code == KEY_ESCAPE ) - { - if ( code != KEY_ESCAPE ) - { - if ( m_pHudChat ) - { - m_pHudChat->Send(); - } - } - - // End message mode. - if ( m_pHudChat ) - { - m_pHudChat->StopMessageMode(); - } - } - else if ( code == KEY_TAB ) - { - // Ignore tab, otherwise vgui will screw up the focus. - return; - } - else - { - BaseClass::OnKeyCodeTyped( code ); - } - } + virtual void OnKeyCodeTyped(vgui::KeyCode code); private: CBaseHudChat *m_pHudChat; @@ -384,7 +328,7 @@ class CBaseHudChatEntry : public vgui::TextEntry class CBaseHudChatInputLine : public vgui::Panel { typedef vgui::Panel BaseClass; - + public: CBaseHudChatInputLine( CBaseHudChat *parent, char const *panelName ); @@ -397,7 +341,7 @@ class CBaseHudChatInputLine : public vgui::Panel virtual void ApplySchemeSettings(vgui::IScheme *pScheme); vgui::Panel *GetInputPanel( void ); - virtual vgui::VPANEL GetCurrentKeyFocus() { return m_pInput->GetVPanel(); } + virtual vgui::VPANEL GetCurrentKeyFocus() { return m_pInput->GetVPanel(); } virtual void Paint() { @@ -417,7 +361,6 @@ class CHudChatFilterPanel : public vgui::EditablePanel DECLARE_CLASS_SIMPLE( CHudChatFilterPanel, vgui::EditablePanel ); public: - CHudChatFilterPanel( vgui::Panel *pParent, const char *pName ); virtual void ApplySchemeSettings( vgui::IScheme *pScheme );