blob: 343f2d0a034e9d369a57fc7972be17deefecc9fb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include "ChatPanel.h"
#include "RemoteServer.h"
#include <vgui/IVGui.h>
#include <KeyValues.h>
#include <vgui_controls/TextEntry.h>
#include <vgui_controls/RichText.h>
#include <vgui_controls/Button.h>
#include <vgui_controls/PHandle.h>
#include <stdio.h>
using namespace vgui;
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CChatPanel::CChatPanel(vgui::Panel *parent, const char *name) : PropertyPage(parent, name)
{
m_pServerChatPanel = new RichText(this, "ServerChatText");
m_pServerChatPanel->SetMaximumCharCount(8000);
m_pEnterChatPanel = new TextEntry(this,"ChatMessage");
m_pSendChatButton = new Button(this, "SendChat", "#Chat_Panel_Send");
m_pSendChatButton->SetCommand(new KeyValues("SendChat"));
m_pSendChatButton->SetAsDefaultButton(true);
LoadControlSettings("Admin/ChatPanel.res", "PLATFORM");
}
//-----------------------------------------------------------------------------
// Purpose: Destructor
//-----------------------------------------------------------------------------
CChatPanel::~CChatPanel()
{
}
//-----------------------------------------------------------------------------
// Purpose: Activates the page
//-----------------------------------------------------------------------------
void CChatPanel::OnPageShow()
{
BaseClass::OnPageShow();
}
//-----------------------------------------------------------------------------
// Purpose: Hides the page
//-----------------------------------------------------------------------------
void CChatPanel::OnPageHide()
{
BaseClass::OnPageHide();
}
//-----------------------------------------------------------------------------
// Purpose: inserts a new string into the main chat panel
//-----------------------------------------------------------------------------
void CChatPanel::DoInsertString(const char *str)
{
m_pServerChatPanel->InsertString(str);
}
//-----------------------------------------------------------------------------
// Purpose: run when the send button is pressed, send a rcon "say" to the server
//-----------------------------------------------------------------------------
void CChatPanel::OnSendChat()
{
// build a chat command and send it to the server
char chat_text[512];
strcpy(chat_text, "say ");
m_pEnterChatPanel->GetText(chat_text + 4, sizeof(chat_text) - 4);
if (strlen("say ") != strlen(chat_text))
{
RemoteServer().SendCommand(chat_text);
// the message is sent, zero the text
m_pEnterChatPanel->SetText("");
}
}
|