Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "pch_serverbrowser.h"
  8. using namespace vgui;
  9. //-----------------------------------------------------------------------------
  10. // Purpose: Constructor
  11. //-----------------------------------------------------------------------------
  12. CDialogServerPassword::CDialogServerPassword(vgui::Panel *parent) : Frame(parent, "DialogServerPassword")
  13. {
  14. m_iServerID = -1;
  15. SetSize(320, 240);
  16. SetDeleteSelfOnClose(true);
  17. SetSizeable(false);
  18. m_pInfoLabel = new Label(this, "InfoLabel", "#ServerBrowser_ServerRequiresPassword");
  19. m_pGameLabel = new Label(this, "GameLabel", "<game label>");
  20. m_pPasswordEntry = new TextEntry(this, "PasswordEntry");
  21. m_pConnectButton = new Button(this, "ConnectButton", "#ServerBrowser_Connect");
  22. m_pPasswordEntry->SetTextHidden(true);
  23. LoadControlSettings("Servers/DialogServerPassword.res");
  24. SetTitle("#ServerBrowser_ServerRequiresPasswordTitle", true);
  25. // set our initial position in the middle of the workspace
  26. MoveToCenterOfScreen();
  27. }
  28. //-----------------------------------------------------------------------------
  29. // Purpose: Destructor
  30. //-----------------------------------------------------------------------------
  31. CDialogServerPassword::~CDialogServerPassword()
  32. {
  33. }
  34. //-----------------------------------------------------------------------------
  35. // Purpose: initializes the dialog and brings it to the foreground
  36. //-----------------------------------------------------------------------------
  37. void CDialogServerPassword::Activate(const char *serverName, unsigned int serverID)
  38. {
  39. m_pGameLabel->SetText(serverName);
  40. m_iServerID = serverID;
  41. m_pConnectButton->SetAsDefaultButton(true);
  42. m_pPasswordEntry->RequestFocus();
  43. BaseClass::Activate();
  44. }
  45. //-----------------------------------------------------------------------------
  46. // Purpose:
  47. // Input : *command -
  48. //-----------------------------------------------------------------------------
  49. void CDialogServerPassword::OnCommand(const char *command)
  50. {
  51. bool bClose = false;
  52. if (!Q_stricmp(command, "Connect"))
  53. {
  54. KeyValues *msg = new KeyValues("JoinServerWithPassword");
  55. char buf[64];
  56. m_pPasswordEntry->GetText(buf, sizeof(buf)-1);
  57. msg->SetString("password", buf);
  58. msg->SetInt("serverID", m_iServerID);
  59. PostActionSignal(msg);
  60. bClose = true;
  61. }
  62. else if (!Q_stricmp(command, "Close"))
  63. {
  64. bClose = true;
  65. }
  66. else
  67. {
  68. BaseClass::OnCommand(command);
  69. }
  70. if (bClose)
  71. {
  72. PostMessage(this, new KeyValues("Close"));
  73. }
  74. }