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.

130 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include <stdio.h>
  8. #include "DialogKickPlayer.h"
  9. #include <VGUI_Button.h>
  10. #include <VGUI_KeyValues.h>
  11. #include <VGUI_Label.h>
  12. #include <VGUI_TextEntry.h>
  13. #include <VGUI_Controls.h>
  14. #include <VGUI_ISurface.h>
  15. using namespace vgui;
  16. #define max(a,b) (((a) > (b)) ? (a) : (b))
  17. //-----------------------------------------------------------------------------
  18. // Purpose: Constructor
  19. //-----------------------------------------------------------------------------
  20. CDialogKickPlayer::CDialogKickPlayer() : Frame(NULL, "DialogKickPlayer")
  21. {
  22. SetSize(320, 200);
  23. m_pInfoLabel = new Label(this, "InfoLabel", "Kick Player?");
  24. m_pPlayerLabel = new Label(this, "PlayerLabel", "<player name>");
  25. m_pOkayButton = new Button(this, "OkayButton", "&Okay");
  26. LoadControlSettings("Admin\\DialogKickPlayer.res");
  27. SetTitle("Kick/Ban/Status Player", true);
  28. // set our initial position in the middle of the workspace
  29. MoveToCenterOfScreen();
  30. }
  31. //-----------------------------------------------------------------------------
  32. // Purpose: Destructor
  33. //-----------------------------------------------------------------------------
  34. CDialogKickPlayer::~CDialogKickPlayer()
  35. {
  36. }
  37. //-----------------------------------------------------------------------------
  38. // Purpose: initializes the dialog and brings it to the foreground
  39. //-----------------------------------------------------------------------------
  40. void CDialogKickPlayer::Activate(const char *playerName,const char *question,const char *type)
  41. {
  42. m_pPlayerLabel->SetText(playerName);
  43. m_pInfoLabel->SetText(question);
  44. m_pInfoLabel->SizeToContents();
  45. // SetSize(
  46. int wide,tall;
  47. m_pInfoLabel->GetSize(wide,tall);
  48. SetWide(max(wide+50,GetWide()));
  49. m_cType=type;
  50. m_pOkayButton->SetAsDefaultButton(true);
  51. MakePopup();
  52. MoveToFront();
  53. RequestFocus();
  54. }
  55. //-----------------------------------------------------------------------------
  56. // Purpose:
  57. // Input : *command -
  58. //-----------------------------------------------------------------------------
  59. void CDialogKickPlayer::OnCommand(const char *command)
  60. {
  61. bool bClose = false;
  62. if (!stricmp(command, "Okay"))
  63. {
  64. KeyValues *msg = new KeyValues("KickPlayer");
  65. char buf[64];
  66. m_pPlayerLabel->GetText(buf,64);
  67. msg->SetString("player", buf );
  68. msg->SetString("type",m_cType);
  69. PostActionSignal(msg);
  70. bClose = true;
  71. }
  72. else if (!stricmp(command, "Close"))
  73. {
  74. bClose = true;
  75. }
  76. else
  77. {
  78. BaseClass::OnCommand(command);
  79. }
  80. if (bClose)
  81. {
  82. PostMessage(this, new KeyValues("Close"));
  83. MarkForDeletion();
  84. }
  85. }
  86. //-----------------------------------------------------------------------------
  87. // Purpose:
  88. //-----------------------------------------------------------------------------
  89. void CDialogKickPlayer::PerformLayout()
  90. {
  91. BaseClass::PerformLayout();
  92. }
  93. //-----------------------------------------------------------------------------
  94. // Purpose: deletes the dialog on close
  95. //-----------------------------------------------------------------------------
  96. void CDialogKickPlayer::OnClose()
  97. {
  98. BaseClass::OnClose();
  99. MarkForDeletion();
  100. }