diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /tracker/AdminServer/ChatPanel.cpp | |
| download | archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip | |
Diffstat (limited to 'tracker/AdminServer/ChatPanel.cpp')
| -rw-r--r-- | tracker/AdminServer/ChatPanel.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/tracker/AdminServer/ChatPanel.cpp b/tracker/AdminServer/ChatPanel.cpp new file mode 100644 index 0000000..343f2d0 --- /dev/null +++ b/tracker/AdminServer/ChatPanel.cpp @@ -0,0 +1,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(""); + } +} |