Skip to content

Commit c7b3b11

Browse files
committed
refactor(basechat): move function definitions to cpp
1 parent f89154b commit c7b3b11

2 files changed

Lines changed: 67 additions & 61 deletions

File tree

src/game/client/hud_basechat.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,6 +2522,40 @@ void CBaseHudChat::FireGameEvent( IGameEvent *event )
25222522
}
25232523
}
25242524

2525+
void CBaseHudChat::OnKeyCodeTyped(vgui::KeyCode code)
2526+
{
2527+
if (code == KEY_ENTER || code == KEY_PAD_ENTER || code == KEY_ESCAPE)
2528+
{
2529+
if (code != KEY_ESCAPE)
2530+
{
2531+
Send();
2532+
}
2533+
2534+
// End message mode.
2535+
StopMessageMode();
2536+
}
2537+
else
2538+
{
2539+
BaseClass::OnKeyCodeTyped(code);
2540+
}
2541+
}
2542+
2543+
CBaseHudChatEntry::CBaseHudChatEntry( vgui::Panel *parent, char const *panelName, CBaseHudChat *pChat )
2544+
: BaseClass( parent, panelName )
2545+
{
2546+
SetCatchEnterKey( true );
2547+
SetAllowNonAsciiCharacters( true );
2548+
SetDrawLanguageIDAtLeft( true );
2549+
m_pHudChat = pChat;
2550+
}
2551+
2552+
void CBaseHudChatEntry::ApplySchemeSettings( vgui::IScheme *pScheme )
2553+
{
2554+
BaseClass::ApplySchemeSettings(pScheme);
2555+
2556+
SetPaintBorderEnabled( false );
2557+
}
2558+
25252559
// Prevent player from inserting text over utf-8 byte limit
25262560
void CBaseHudChatEntry::InsertChar(wchar_t ch)
25272561
{
@@ -2577,3 +2611,32 @@ void CBaseHudChatEntry::InsertChar(wchar_t ch)
25772611

25782612
return; // do not insert anything
25792613
}
2614+
2615+
void CBaseHudChatEntry::OnKeyCodeTyped(vgui::KeyCode code)
2616+
{
2617+
if ( code == KEY_ENTER || code == KEY_PAD_ENTER || code == KEY_ESCAPE )
2618+
{
2619+
if ( code != KEY_ESCAPE )
2620+
{
2621+
if ( m_pHudChat )
2622+
{
2623+
m_pHudChat->Send();
2624+
}
2625+
}
2626+
2627+
// End message mode.
2628+
if ( m_pHudChat )
2629+
{
2630+
m_pHudChat->StopMessageMode();
2631+
}
2632+
}
2633+
else if ( code == KEY_TAB )
2634+
{
2635+
// Ignore tab, otherwise vgui will screw up the focus.
2636+
return;
2637+
}
2638+
else
2639+
{
2640+
BaseClass::OnKeyCodeTyped( code );
2641+
}
2642+
}

src/game/client/hud_basechat.h

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -276,23 +276,7 @@ class CBaseHudChat : public CHudElement, public vgui::EditablePanel
276276
bool IsVoiceSubtitle( void ) { return m_bEnteringVoice; }
277277
void SetVoiceSubtitleState( bool bState ) { m_bEnteringVoice = bState; }
278278

279-
virtual void OnKeyCodeTyped(vgui::KeyCode code)
280-
{
281-
if (code == KEY_ENTER || code == KEY_PAD_ENTER || code == KEY_ESCAPE)
282-
{
283-
if (code != KEY_ESCAPE)
284-
{
285-
Send();
286-
}
287-
288-
// End message mode.
289-
StopMessageMode();
290-
}
291-
else
292-
{
293-
BaseClass::OnKeyCodeTyped(code);
294-
}
295-
}
279+
virtual void OnKeyCodeTyped(vgui::KeyCode code);
296280

297281
protected:
298282
CBaseHudChatLine *FindUnusedChatLine( void );
@@ -326,52 +310,12 @@ class CBaseHudChatEntry : public vgui::TextEntry
326310
public:
327311
int m_iMaxByteCount = -1; // utf-8 string length
328312

329-
CBaseHudChatEntry( vgui::Panel *parent, char const *panelName, CBaseHudChat *pChat )
330-
: BaseClass( parent, panelName )
331-
{
332-
SetCatchEnterKey( true );
333-
SetAllowNonAsciiCharacters( true );
334-
SetDrawLanguageIDAtLeft( true );
335-
m_pHudChat = pChat;
336-
}
337-
338-
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
339-
{
340-
BaseClass::ApplySchemeSettings(pScheme);
313+
CBaseHudChatEntry( vgui::Panel *parent, char const *panelName, CBaseHudChat *pChat );
341314

342-
SetPaintBorderEnabled( false );
343-
}
315+
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
344316

345317
virtual void InsertChar(wchar_t ch);
346-
347-
virtual void OnKeyCodeTyped(vgui::KeyCode code)
348-
{
349-
if ( code == KEY_ENTER || code == KEY_PAD_ENTER || code == KEY_ESCAPE )
350-
{
351-
if ( code != KEY_ESCAPE )
352-
{
353-
if ( m_pHudChat )
354-
{
355-
m_pHudChat->Send();
356-
}
357-
}
358-
359-
// End message mode.
360-
if ( m_pHudChat )
361-
{
362-
m_pHudChat->StopMessageMode();
363-
}
364-
}
365-
else if ( code == KEY_TAB )
366-
{
367-
// Ignore tab, otherwise vgui will screw up the focus.
368-
return;
369-
}
370-
else
371-
{
372-
BaseClass::OnKeyCodeTyped( code );
373-
}
374-
}
318+
virtual void OnKeyCodeTyped(vgui::KeyCode code);
375319

376320
private:
377321
CBaseHudChat *m_pHudChat;
@@ -417,7 +361,6 @@ class CHudChatFilterPanel : public vgui::EditablePanel
417361
DECLARE_CLASS_SIMPLE( CHudChatFilterPanel, vgui::EditablePanel );
418362

419363
public:
420-
421364
CHudChatFilterPanel( vgui::Panel *pParent, const char *pName );
422365

423366
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );

0 commit comments

Comments
 (0)