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.

231 lines
6.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef OP_OUTPUT_H
  7. #define OP_OUTPUT_H
  8. #pragma once
  9. #include "ObjectPage.h"
  10. #include "Resource.h"
  11. #include "TargetNameCombo.h"
  12. #include "MapEntity.h"
  13. #include "ToolPickEntity.h"
  14. #include "AutoSelCombo.h"
  15. #include "AnchorMgr.h"
  16. #define OUTPUT_LIST_NUM_COLUMNS 6
  17. class COP_Output;
  18. enum SortDirection_t;
  19. //-----------------------------------------------------------------------------
  20. // Purpose: A little glue object that connects the entity picker tool to our dialog.
  21. //-----------------------------------------------------------------------------
  22. class COP_OutputPickEntityTarget : public IPickEntityTarget
  23. {
  24. public:
  25. void AttachEntityDlg(COP_Output *pDlg) { m_pDlg = pDlg; }
  26. void OnNotifyPickEntity(CToolPickEntity *pTool);
  27. void AttachDlgItem( int nItem ) { m_nDlgItem = nItem; }
  28. private:
  29. int m_nDlgItem;
  30. COP_Output *m_pDlg;
  31. };
  32. //-----------------------------------------------------------------------------
  33. // Purpose: A list of connections and entites that send them.
  34. //-----------------------------------------------------------------------------
  35. class COutputConnection
  36. {
  37. public:
  38. CEntityConnectionList* m_pConnList;
  39. CMapEntityList* m_pEntityList;
  40. bool m_bIsValid;
  41. bool m_bOwnedByAll; // Connection used by all selected entities
  42. };
  43. class COP_Output : public CObjectPage, public CFilteredComboBox::ICallbacks
  44. {
  45. public:
  46. static CImageList *m_pImageList;
  47. static CEntityConnectionList* m_pConnectionBuffer; // Stores connections for copy/pasting
  48. static void EmptyCopyBuffer(void);
  49. public:
  50. DECLARE_DYNCREATE(COP_Output)
  51. // Construction
  52. COP_Output(void);
  53. ~COP_Output(void);
  54. virtual void UpdateData( int Mode, PVOID pData, bool bCanEdit );
  55. void SetSelectedConnection(CEntityConnection *pConnection);
  56. bool ShouldShowHiddenTargets();
  57. protected:
  58. virtual void OnTextChanged( const char *pText );
  59. void AddEntityConnections(CMapEntity *pEntity, bool bFirst);
  60. void AddConnection(CEntityConnection *pConnection);
  61. void RemoveAllEntityConnections(void);
  62. void UpdateConnectionList(void);
  63. void ResizeColumns(void);
  64. void SetSelectedItem(int nItem);
  65. void SetSelectedConnections(CEntityConnectionList &List);
  66. // Validation functions
  67. bool ValidateConnections(COutputConnection *pOutputConn, bool bVisibilityCheck);
  68. void UpdateValidityButton(void);
  69. // Edit controls
  70. void UpdateEditControls(void);
  71. void EnableEditControls(bool bValue = true);
  72. void UpdateItemValidity(int nItem);
  73. void EnableTarget(bool bEnable);
  74. void EnableParam(bool bEnable);
  75. bool bSkipEditControlRefresh;
  76. // Functions for updating edited connections
  77. void UpdateEditedInputs(void);
  78. void UpdateEditedOutputs(void);
  79. void UpdateEditedTargets(void);
  80. void UpdateEditedDelays(void);
  81. void UpdateEditedFireOnce(void);
  82. void UpdateEditedParams(void);
  83. // Fuctions for reacting to combo box changes
  84. void OutputChanged(void);
  85. void InputChanged(void);
  86. void SortListByColumn(int nColumn, SortDirection_t eDirection);
  87. void SetSortColumn(int nColumn, SortDirection_t eDirection);
  88. void UpdateColumnHeaderText(int nColumn, bool bIsSortColumn, SortDirection_t eDirection);
  89. CMapEntityList m_EntityList; // Filtered m_pObjectList that only includes map entities
  90. const CMapEntityList* m_pMapEntityList; // List of all entities in the map.
  91. CEntityConnectionList m_EditList; // List of selected connections being edited
  92. void UpdateEntityList(); // Generates m_EntityList from m_pObjectList
  93. protected:
  94. CAnchorMgr m_AnchorMgr;
  95. CEditGameClass *m_pEditGameClass;
  96. CMapEntity *m_pEntity;
  97. bool m_bNoParamEdit;
  98. //
  99. // Cached data for sorting the list view.
  100. //
  101. int m_nSortColumn; // Current column used for sorting.
  102. SortDirection_t m_eSortDirection[OUTPUT_LIST_NUM_COLUMNS]; // Last sort direction per column.
  103. bool m_bPickingEntities;
  104. // ########################################
  105. // Message editing
  106. // ########################################
  107. void SetConnection(CEntityConnectionList *pConnectionList);
  108. void SetMapEntityList(const CMapEntityList *pMapEntityList);
  109. void AddEntityOutputs(CMapEntity *pEntity);
  110. void FillInputList(void);
  111. void FillOutputList(void);
  112. void FillTargetList(void);
  113. void FilterInputList(void);
  114. void FilterOutputList(void);
  115. void FilterTargetList(void);
  116. void FilterEntityOutputs(CMapEntity *pEntity);
  117. void StopPicking(void);
  118. CClassInput* GetInput(char *szInput, int nSize);
  119. CClassOutput* GetOutput(char *szOutput, int nSize);
  120. CMapEntityList* GetTarget(char *szTarget, int nSize);
  121. void UpdateCombosForSelectedInput(CClassInput *pInput);
  122. void UpdateCombosForSelectedOutput(CClassOutput *pOutput);
  123. // #########################################
  124. //{{AFX_DATA(COP_Output)
  125. enum { IDD = IDD_OBJPAGE_OUTPUT };
  126. CListCtrl m_ListCtrl;
  127. CAutoSelComboBox m_ComboOutput;
  128. CTargetNameComboBox m_ComboTarget;
  129. CAutoSelComboBox m_ComboInput;
  130. CButton m_CheckBoxFireOnce;
  131. CButton m_ctlShowHiddenTargetsAsBroken;
  132. CButton m_AddControl;
  133. CButton m_PasteControl;
  134. CButton m_DeleteControl;
  135. CString m_strOutput;
  136. CString m_strTarget;
  137. CString m_strInput;
  138. CString m_strParam;
  139. float m_fDelay;
  140. BOOL m_bFireOnce;
  141. //}}AFX_DATA
  142. // ClassWizard generate virtual function overrides
  143. //{{AFX_VIRTUAL(COP_Output)
  144. virtual void DoDataExchange(CDataExchange* pDX);
  145. virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT *pResult);
  146. virtual BOOL OnInitDialog(void);
  147. virtual void OnDestroy(void);
  148. //}}AFX_VIRTUAL
  149. // Generated message map functions
  150. //{{AFX_MSG(COP_Output)
  151. afx_msg void OnAdd(void);
  152. afx_msg void OnCopy(void);
  153. afx_msg void OnPaste(void);
  154. afx_msg void OnSize( UINT nType, int cx, int cy );
  155. afx_msg void OnDelete(void);
  156. afx_msg void OnMark(void);
  157. afx_msg void OnPickEntity(void);
  158. afx_msg void OnPickEntityParam(void);
  159. afx_msg void OnSelChangeInput(void);
  160. afx_msg void OnEditUpdateInput(void);
  161. afx_msg void OnSelChangeOutput(void);
  162. afx_msg void OnEditUpdateOutput(void);
  163. afx_msg void OnSelChangeParam(void);
  164. afx_msg void OnEditUpdateParam(void);
  165. afx_msg void OnEditDelay(void);
  166. afx_msg void OnFireOnce(void);
  167. afx_msg void OnShowHiddenTargetsAsBroken();
  168. //}}AFX_MSG
  169. DECLARE_MESSAGE_MAP()
  170. private:
  171. bool m_bEntityParamTarget;
  172. COP_OutputPickEntityTarget m_PickEntityTarget;
  173. CString m_strLastParam;
  174. bool m_bIgnoreTextChanged;
  175. friend class COP_OutputPickEntityTarget;
  176. public:
  177. };
  178. #endif // OP_OUTPUT_H