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.

155 lines
3.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef QCGENERATOR_H
  7. #define QCGENERATOR_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vgui_controls/EditablePanel.h"
  12. #include "vgui_controls/Frame.h"
  13. #include "vgui_controls/Button.h"
  14. #include "tier1/utlstring.h"
  15. #include "vgui_controls/TextEntry.h"
  16. class CQCGenerator;
  17. //-----------------------------------------------------------------------------
  18. // Forward declarations
  19. //-----------------------------------------------------------------------------
  20. namespace vgui
  21. {
  22. class Panel;
  23. }
  24. class CBrowseButton : public vgui::Button
  25. {
  26. DECLARE_CLASS_SIMPLE( CBrowseButton, vgui::Button );
  27. public:
  28. CBrowseButton( vgui::Panel *pParent );
  29. ~CBrowseButton();
  30. void InitBrowseInfo( int x, int y, const char *pszName, const char *pszDir, const char *pszFilter, const char *pszField );
  31. private:
  32. char *pszStartingDirectory;
  33. char *pszFileFilter;
  34. char *pszTargetField;
  35. char **GetStartingDirectory(){ return &pszStartingDirectory; }
  36. char **GetFileFilter(){ return &pszFileFilter; }
  37. char **GetTargetField(){ return &pszTargetField; }
  38. void SetCharVar( char **pVar, const char *pszNewText );
  39. void SetActionMessage();
  40. };
  41. struct LODInfo
  42. {
  43. char pszFilename[MAX_PATH];
  44. int iLOD;
  45. };
  46. struct QCInfo
  47. {
  48. CQCGenerator *pQCGenerator;
  49. char pszSMDPath[MAX_PATH];
  50. char pszCollisionPath[MAX_PATH];
  51. char pszSurfaceProperty[MAX_PATH];
  52. char pszMaterialPath[MAX_PATH];
  53. char pszSceneName[MAX_PATH];
  54. bool bStaticProp;
  55. bool bMostlyOpaque;
  56. bool bDisableCollision;
  57. bool bReferenceAsPhys;
  58. bool bConcave;
  59. bool bAutomass;
  60. bool bNoAnimation;
  61. CUtlVector<LODInfo> LODs;
  62. float fScale;
  63. float fMass;
  64. void Init( CQCGenerator *pPanel )
  65. {
  66. pQCGenerator = pPanel;
  67. V_strcpy_safe( pszSMDPath, "" );
  68. V_strcpy_safe( pszCollisionPath, "" );
  69. V_strcpy_safe( pszSurfaceProperty, "default" );
  70. bStaticProp = false;
  71. bMostlyOpaque = false;
  72. bDisableCollision = false;
  73. bReferenceAsPhys = false;
  74. bConcave = false;
  75. bAutomass = false;
  76. bNoAnimation = true;
  77. fScale = 1.0;
  78. fMass = 10.0;
  79. }
  80. void SyncToControls();
  81. void SyncFromControls();
  82. };
  83. //-----------------------------------------------------------------------------
  84. // Purpose: Base class for generating QC files
  85. //-----------------------------------------------------------------------------
  86. class CQCGenerator : public vgui::EditablePanel
  87. {
  88. DECLARE_CLASS_SIMPLE( CQCGenerator, vgui::EditablePanel );
  89. public:
  90. CQCGenerator( vgui::Panel *pParent, const char *pszPath, const char *pszScene );
  91. ~CQCGenerator();
  92. // overridden frame functions
  93. // virtual void Activate();
  94. virtual void OnCommand( const char *command );
  95. // Purpose:
  96. // virtual void OnKeyCodeTyped( vgui::KeyCode code );
  97. MESSAGE_FUNC( OnNewLODText, "TextNewLine" );
  98. MESSAGE_FUNC_PARAMS( OnBrowse, "browse", data );
  99. MESSAGE_FUNC_PARAMS( OnFileSelected, "FileSelected", data );
  100. MESSAGE_FUNC_PARAMS( OnDirectorySelected, "DirectorySelected", data );
  101. bool GenerateQCFile();
  102. // void BrowseDirectory( KeyValues *data );
  103. void BrowseFile( KeyValues *data );
  104. void DeleteLOD( );
  105. void EditLOD();
  106. virtual void OnKeyCodeTyped( vgui::KeyCode code);
  107. void InitializeSMDPaths( const char *pszPath, const char *pszScene );
  108. protected:
  109. // Creates standard controls. Allows the derived class to
  110. // add these controls to various splitter windows
  111. void CreateStandardControls( vgui::Panel *pParent );
  112. private:
  113. CBrowseButton *m_pCollisionBrowseButton;
  114. char m_szTargetField[MAX_PATH];
  115. vgui::ListPanel *m_pLODPanel;
  116. vgui::TextEntry *m_pLODEdit;
  117. int m_nSelectedSequence;
  118. int m_nSelectedColumn;
  119. QCInfo m_QCInfo_t;
  120. };
  121. #endif // QCGENERATOR_H