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.

310 lines
8.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=============================================================================
  4. #ifndef ITEMTEST_CONTROLS_H
  5. #define ITEMTEST_CONTROLS_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. // Valve includes
  10. #include "itemtest/itemtest.h"
  11. #include "tier1/utlstring.h"
  12. #include "vgui_controls/Label.h"
  13. #include "vgui_controls/WizardPanel.h"
  14. #include "vgui_controls/WizardSubPanel.h"
  15. #include "vgui_controls/FileOpenStateMachine.h"
  16. //-----------------------------------------------------------------------------
  17. // Forward declarations
  18. //-----------------------------------------------------------------------------
  19. class vgui::CheckButton;
  20. class vgui::PanelListPanel;
  21. class vgui::TextEntry;
  22. class vgui::ComboBox;
  23. class vgui::TextEntry;
  24. class CDualPanelList;
  25. class CVmtEntry;
  26. //=============================================================================
  27. //
  28. //=============================================================================
  29. class CStatusLabel : public vgui::Label
  30. {
  31. DECLARE_CLASS_SIMPLE( CStatusLabel, vgui::Label );
  32. public:
  33. CStatusLabel( vgui::Panel *pPanel, const char *pszName, bool bValid = false );
  34. // From vgui::Label
  35. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  36. // New functions
  37. virtual void SetValid( bool bValid );
  38. virtual bool GetValid() const;
  39. protected:
  40. bool m_bValid;
  41. Color m_cValid;
  42. Color m_cInvalid;
  43. void UpdateColors();
  44. };
  45. //=============================================================================
  46. //
  47. //=============================================================================
  48. class CItemUploadSubPanel : public vgui::WizardSubPanel
  49. {
  50. DECLARE_CLASS_SIMPLE( CItemUploadSubPanel, vgui::WizardSubPanel );
  51. public:
  52. CItemUploadSubPanel( vgui::Panel *pParent, const char *pszName, const char *pszNextName );
  53. // From vgui::Panel
  54. virtual void PerformLayout();
  55. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  56. // From vgui::WizardSubPanel
  57. virtual void OnDisplay();
  58. virtual vgui::WizardSubPanel *GetNextSubPanel();
  59. // Sucks data from the asset into the GUI
  60. virtual void UpdateGUI()
  61. {
  62. AssertMsg1( 0, "Implement UpdateGUI in base class: %s", GetPanelClassName() );
  63. }
  64. // Sets the status labels
  65. virtual bool UpdateStatus();
  66. protected:
  67. CUtlString m_sNextName; // The name of the next wizard sub panel
  68. vgui::Label *m_pLabel; // Label at the top of the wizard sub panel
  69. vgui::PanelListPanel *m_pPanelListPanel; // Standard list of widgets to set parameters
  70. CStatusLabel *m_pStatusLabel; // Whether the overall panel is valid or not
  71. vgui::Label *m_pStatusText; // The text for the overall status
  72. // New functions
  73. void AddStatusPanels( const char *pszPrefix );
  74. void SetStatus( bool bValid, const char *pszPrefix, const char *pszMessage = NULL, bool bHide = false );
  75. };
  76. //=============================================================================
  77. //
  78. //=============================================================================
  79. class CGlobalSubPanel : public CItemUploadSubPanel
  80. {
  81. DECLARE_CLASS_SIMPLE( CGlobalSubPanel, CItemUploadSubPanel );
  82. public:
  83. CGlobalSubPanel( vgui::Panel *pParent, const char *pszName, const char *pszNextName );
  84. // From CItemUploadSubPanel
  85. virtual void UpdateGUI();
  86. virtual bool UpdateStatus();
  87. MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel );
  88. MESSAGE_FUNC_PTR( OnCheckButtonChecked, "CheckButtonChecked", panel );
  89. protected:
  90. vgui::TextEntry *m_pNameTextEntry;
  91. vgui::ComboBox *m_pClassComboBox;
  92. vgui::TextEntry *m_pSteamTextEntry;
  93. vgui::CheckButton *m_pAutoSkinCheckButton;
  94. };
  95. //=============================================================================
  96. //
  97. //=============================================================================
  98. class CGeometrySubPanel : public CItemUploadSubPanel, public vgui::IFileOpenStateMachineClient
  99. {
  100. DECLARE_CLASS_SIMPLE( CGeometrySubPanel, CItemUploadSubPanel );
  101. public:
  102. CGeometrySubPanel( vgui::Panel *pParent, const char *pszName, const char *pszNextName );
  103. // From CItemUploadSubpanel
  104. virtual void UpdateGUI();
  105. virtual bool UpdateStatus();
  106. // From IFileOpenStateMachineClient
  107. virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog, bool bOpenFile, const char *pszFileFormat, KeyValues *pContextKeyValues );
  108. virtual bool OnReadFileFromDisk( const char *pszFileName, const char *pszFileFormat, KeyValues *pContextKeyValues );
  109. virtual bool OnWriteFileToDisk( const char *pszFileName, const char *pszFileFormat, KeyValues *pContextKeyValues );
  110. MESSAGE_FUNC_INT( OnOpen, "Open", nLodIndex );
  111. MESSAGE_FUNC_INT( OnDelete, "Delete", nLodIndex );
  112. protected:
  113. vgui::FileOpenStateMachine *m_pFileOpenStateMachine;
  114. void AddGeometry();
  115. };
  116. //=============================================================================
  117. //
  118. //=============================================================================
  119. class CMaterialSubPanel : public CItemUploadSubPanel, public vgui::IFileOpenStateMachineClient
  120. {
  121. DECLARE_CLASS_SIMPLE( CMaterialSubPanel, CItemUploadSubPanel );
  122. public:
  123. CMaterialSubPanel( vgui::Panel *pParent, const char *pszName, const char *pszNextName );
  124. // From CItemUploadSubpanel
  125. virtual void InvalidateLayout();
  126. virtual void UpdateGUI();
  127. virtual bool UpdateStatus();
  128. // From IFileOpenStateMachineClient
  129. virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog, bool bOpenFile, const char *pszFileFormat, KeyValues *pContextKeyValues );
  130. virtual bool OnReadFileFromDisk( const char *pszFileName, const char *pszFileFormat, KeyValues *pContextKeyValues );
  131. virtual bool OnWriteFileToDisk( const char *pszFileName, const char *pszFileFormat, KeyValues *pContextKeyValues );
  132. enum Browse_t
  133. {
  134. kCommon,
  135. kRed,
  136. kBlue,
  137. kNormal
  138. };
  139. void Browse( CVmtEntry *pVmtEntry, Browse_t nBrowseType );
  140. CTargetVMT *GetTargetVMT( int nTargetVMTIndex );
  141. protected:
  142. vgui::FileOpenStateMachine *m_pFileOpenStateMachine;
  143. void AddMaterial();
  144. };
  145. //=============================================================================
  146. //
  147. //=============================================================================
  148. class CFinalSubPanel : public CItemUploadSubPanel
  149. {
  150. DECLARE_CLASS_SIMPLE( CFinalSubPanel, CItemUploadSubPanel );
  151. public:
  152. CFinalSubPanel( vgui::Panel *pParent, const char *pszName, const char *pszNextName );
  153. // From CItemUploadSubPanel
  154. virtual void UpdateGUI();
  155. virtual bool UpdateStatus();
  156. virtual void OnCommand( const char *command );
  157. virtual void PerformLayout();
  158. MESSAGE_FUNC( OnQuitApp, "QuitApp" );
  159. void OnZip();
  160. protected:
  161. void OnGather();
  162. void OnStudioMDL();
  163. void OnHlmv();
  164. void OnExplore( bool bMaterial, bool bContent);
  165. bool GetHlmvCmd( CFmtStrMax &sHlmvCmd );
  166. vgui::Button *m_pHLMVButton;
  167. vgui::Label *m_pHLMVLabel;
  168. vgui::Button *m_pExploreMaterialContentButton;
  169. vgui::Label *m_pExploreMaterialContentLabel;
  170. vgui::Button *m_pExploreModelContentButton;
  171. vgui::Label *m_pExploreModelContentLabel;
  172. vgui::Button *m_pExploreMaterialGameButton;
  173. vgui::Label *m_pExploreMaterialGameLabel;
  174. vgui::Button *m_pExploreModelGameButton;
  175. vgui::Label *m_pExploreModelGameLabel;
  176. };
  177. //=============================================================================
  178. //
  179. //=============================================================================
  180. class CItemUploadWizard : public vgui::WizardPanel
  181. {
  182. DECLARE_CLASS_SIMPLE( CItemUploadWizard, vgui::WizardPanel );
  183. public:
  184. CItemUploadWizard( vgui::Panel *pParent, const char *pszName );
  185. virtual ~CItemUploadWizard();
  186. void Run();
  187. void UpdateGUI();
  188. // This should be templatized but this is taking too long to write already...
  189. CAssetTF &Asset() { return m_asset; }
  190. virtual void OnFinishButton();
  191. CItemUploadSubPanel *GetCurrentItemUploadSubPanel()
  192. {
  193. return dynamic_cast< CItemUploadSubPanel * >( GetCurrentSubPanel() );
  194. }
  195. protected:
  196. friend class CItemUploadSubPanel;
  197. CUtlVector< vgui::DHANDLE< vgui::WizardSubPanel > > m_hSubPanelList;
  198. CAssetTF m_asset;
  199. CFinalSubPanel *m_pFinalSubPanel;
  200. };
  201. //=============================================================================
  202. //
  203. //=============================================================================
  204. class CItemUploadDialog : public vgui::Frame
  205. {
  206. DECLARE_CLASS_SIMPLE( CItemUploadDialog, vgui::Frame );
  207. public:
  208. CItemUploadDialog( vgui::Panel *pParent, const char *pszName );
  209. ~CItemUploadDialog();
  210. };
  211. //-----------------------------------------------------------------------------
  212. //
  213. //-----------------------------------------------------------------------------
  214. extern CItemUploadDialog *g_pItemUploadDialog;
  215. #endif // ITEMTEST_CONTROLS_H