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.

158 lines
5.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Holds XP source data
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_SURVEY_QUESTIONS_H
  8. #define TF_SURVEY_QUESTIONS_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tf_gcmessages.h"
  13. #ifdef CLIENT_DLL
  14. #include "vgui_controls/EditablePanel.h"
  15. #endif
  16. #ifdef GC
  17. #include "tf_gc.h"
  18. #endif
  19. #ifdef CLIENT_DLL
  20. using namespace vgui;
  21. #endif
  22. //-----------------------------------------------------------------------------
  23. // Purpose: The definition of a survey question.
  24. //
  25. // m_eType : The type of the survey question
  26. // m_pszSurveyQuestionName: Name of the survey type. Mostly for debugging
  27. // m_flWeight: The weight used when randomly choosing which survey question
  28. // to ask a user
  29. // m_pFnSurveyValidForPlayer: Survey specific function to determine if player
  30. // meets criteria to receive survey
  31. // m_bIsActive: Is the survey currently active (asked of players)
  32. //-----------------------------------------------------------------------------
  33. struct SurveyQuestion_t
  34. {
  35. SurveyQuestionType m_eType;
  36. const char* m_pszSurveyQuestionName;
  37. float m_flWeight;
  38. bool ( *m_pFnSurveyValidForPlayer ) ( const CMsgGC_Match_Result& msgMatchResult , uint32 nPlayerIndex );
  39. bool m_bIsActive;
  40. };
  41. #define UNASWERED_SURVEY_QUESTION ( (int16) -1 )
  42. #define SEEN_BUT_UNANSWERED_SURVEY_QUESTION ( (int16) -2 )
  43. #define SEEN_AND_DISMISSED_SURVEY_QUESTION ( (int16) -3 )
  44. extern const SurveyQuestion_t g_SurveyQuestions[ SurveyQuestionType_ARRAYSIZE ];
  45. #ifdef CLIENT_DLL
  46. //-----------------------------------------------------------------------------
  47. // Purpose: Use CreateSurveyQuestionPanel to create the panel you want
  48. //-----------------------------------------------------------------------------
  49. class CSurveyQuestionPanel* CreateSurveyQuestionPanel( Panel* pParent, const CMsgGCSurveyRequest& msgSurveyQuestion );
  50. //-----------------------------------------------------------------------------
  51. // Purpose: Base, abstract survey panel to handle common functionality
  52. //-----------------------------------------------------------------------------
  53. class CSurveyQuestionPanel : public EditablePanel, public CGameEventListener
  54. {
  55. public:
  56. DECLARE_CLASS_SIMPLE( CSurveyQuestionPanel, EditablePanel );
  57. CSurveyQuestionPanel( Panel* pParent, CMsgGCSurveyRequest msgSurveyQuestion );
  58. ~CSurveyQuestionPanel();
  59. virtual void OnCommand( const char *command ) OVERRIDE;
  60. virtual void FireGameEvent( IGameEvent *event ) OVERRIDE;
  61. virtual void ApplySchemeSettings( IScheme *pScheme ) OVERRIDE;
  62. private:
  63. virtual void Submit() = 0;
  64. virtual const char* GetResFile() const = 0;
  65. bool m_bResponded;
  66. CMsgGCSurveyRequest m_msgRequest;
  67. };
  68. //-----------------------------------------------------------------------------
  69. // Purpose: Base class for multiple choice surveys
  70. //-----------------------------------------------------------------------------
  71. class CMultipleChoiceSurveyQuestionPanel : public CSurveyQuestionPanel
  72. {
  73. public:
  74. DECLARE_CLASS_SIMPLE( CMultipleChoiceSurveyQuestionPanel, CSurveyQuestionPanel );
  75. CMultipleChoiceSurveyQuestionPanel( Panel* pParent, CMsgGCSurveyRequest msgSurveyQuestion, uint16 nSurveyResponses );
  76. private:
  77. virtual void Think() OVERRIDE;
  78. virtual void Submit() OVERRIDE;
  79. uint16 m_nSurveyResponses;
  80. };
  81. //-----------------------------------------------------------------------------
  82. // Purpose: Match quality survey. Users can rate the quality of their match
  83. // with a score of 0 - 4. Score is marked through radio buttons.
  84. //-----------------------------------------------------------------------------
  85. class CMatchQualitySurvey : public CMultipleChoiceSurveyQuestionPanel
  86. {
  87. public:
  88. CMatchQualitySurvey( Panel* pParent, CMsgGCSurveyRequest msgSurveyQuestion ) : CMultipleChoiceSurveyQuestionPanel( pParent, msgSurveyQuestion, 5 ) {}
  89. virtual const char* GetResFile() const OVERRIDE
  90. {
  91. return "resource/ui/SurveyPanel_MatchQuality.res";
  92. }
  93. };
  94. //-----------------------------------------------------------------------------
  95. // Purpose: Map quality survey. Users can rate the quality of the map played
  96. // with a score of 0 - 4. Score is marked through radio buttons.
  97. //-----------------------------------------------------------------------------
  98. class CMapQualitySurvey : public CMultipleChoiceSurveyQuestionPanel
  99. {
  100. public:
  101. CMapQualitySurvey( Panel* pParent, CMsgGCSurveyRequest msgSurveyQuestion ) : CMultipleChoiceSurveyQuestionPanel( pParent, msgSurveyQuestion, 5 ) {}
  102. virtual const char* GetResFile() const OVERRIDE
  103. {
  104. return "resource/ui/SurveyPanel_MapQuality.res";
  105. }
  106. virtual void PerformLayout() OVERRIDE;
  107. };
  108. //-----------------------------------------------------------------------------
  109. // Purpose: Survey casual mode players to see why they're not playing competitive
  110. //-----------------------------------------------------------------------------
  111. class CCompInquirySurvey : public CMultipleChoiceSurveyQuestionPanel
  112. {
  113. public:
  114. CCompInquirySurvey( Panel* pParent, CMsgGCSurveyRequest msgSurveyQuestion ) : CMultipleChoiceSurveyQuestionPanel( pParent, msgSurveyQuestion, 6 ) {}
  115. virtual const char* GetResFile() const OVERRIDE
  116. {
  117. return "resource/ui/SurveyPanel_CompInquiry.res";
  118. }
  119. };
  120. //-----------------------------------------------------------------------------
  121. // Purpose: Survey competitive mode players to see why they're not playing casual
  122. //-----------------------------------------------------------------------------
  123. class CCasualInquirySurvey : public CMultipleChoiceSurveyQuestionPanel
  124. {
  125. public:
  126. CCasualInquirySurvey( Panel* pParent, CMsgGCSurveyRequest msgSurveyQuestion ) : CMultipleChoiceSurveyQuestionPanel( pParent, msgSurveyQuestion, 6 ) {}
  127. virtual const char* GetResFile() const OVERRIDE
  128. {
  129. return "resource/ui/SurveyPanel_CasualInquiry.res";
  130. }
  131. };
  132. #endif
  133. #endif // TF_SURVEY_QUESTIONS_H