Counter Strike : Global Offensive Source Code
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.

153 lines
3.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef SCRIPTOBJECT_H
  8. #define SCRIPTOBJECT_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui_controls/Panel.h>
  13. class CPanelListPanel;
  14. #define SCRIPT_VERSION 1.0f
  15. typedef void * FileHandle_t;
  16. enum objtype_t
  17. {
  18. O_BADTYPE,
  19. O_BOOL,
  20. O_NUMBER,
  21. O_LIST,
  22. O_STRING,
  23. O_OBSOLETE,
  24. };
  25. typedef struct
  26. {
  27. objtype_t type;
  28. char szDescription[32];
  29. } objtypedesc_t;
  30. class CScriptListItem
  31. {
  32. public:
  33. CScriptListItem();
  34. CScriptListItem( char const *strItem, char const *strValue );
  35. char szItemText[128];
  36. char szValue[256];
  37. CScriptListItem *pNext;
  38. };
  39. class CScriptObject : public vgui::Panel
  40. {
  41. public:
  42. void AddItem( CScriptListItem *pItem );
  43. CScriptObject( void );
  44. ~CScriptObject();
  45. bool ReadFromBuffer( const char **pBuffer, bool isNewObject );
  46. void WriteToConfig();
  47. void WriteToFile( FileHandle_t fp );
  48. void WriteToScriptFile( FileHandle_t fp );
  49. void SetCurValue( char const *strValue );
  50. objtype_t GetType( char *pszType );
  51. objtype_t type;
  52. char cvarname[64 ];
  53. char prompt[ 256 ];
  54. CScriptListItem *pListItems;
  55. float fMin, fMax;
  56. char defValue[ 128 ]; // Default value string
  57. float fdefValue; // Float version of default value.
  58. char curValue[ 128 ];
  59. float fcurValue;
  60. bool bSetInfo; // Prepend "Setinfo" to keyvalue pair in config?
  61. // Linked list of default list box items.
  62. CScriptObject *pNext;
  63. };
  64. abstract_class CDescription
  65. {
  66. public:
  67. CDescription( CPanelListPanel *panel );
  68. ~CDescription();
  69. bool ReadFromBuffer( const char **pBuffer );
  70. bool InitFromFile( char *pszFileName );
  71. void TransferCurrentValues( const char *pszConfigFile );
  72. void AddObject( CScriptObject *pItem );
  73. void WriteToConfig();
  74. void WriteToFile( FileHandle_t fp );
  75. void WriteToScriptFile( FileHandle_t fp );
  76. virtual void WriteScriptHeader( FileHandle_t fp ) = 0; // Clients must implement this.
  77. virtual void WriteFileHeader( FileHandle_t fp ) = 0; // Clients must implement this.
  78. void setDescription( const char *pszDesc );
  79. void setHint( const char *pszHint );
  80. const char *GetDescription( void ) { return m_pszDescriptionType; };
  81. const char *getHint( void ) { return m_pszHintText; } ;
  82. public:
  83. CScriptObject *pObjList;
  84. private:
  85. CScriptObject * FindObject( const char *pszObjectName );
  86. char *m_pszHintText;
  87. char *m_pszDescriptionType;
  88. CPanelListPanel *m_pListPanel;
  89. };
  90. namespace vgui
  91. {
  92. class Label;
  93. class Panel;
  94. }
  95. class mpcontrol_t : public vgui::Panel
  96. {
  97. public:
  98. mpcontrol_t( vgui::Panel *parent, char const *panelName );
  99. virtual void OnSizeChanged( int wide, int tall );
  100. objtype_t type;
  101. vgui::Panel *pControl;
  102. vgui::Label *pPrompt;
  103. CScriptObject *pScrObj;
  104. mpcontrol_t *next;
  105. };
  106. class CInfoDescription : public CDescription
  107. {
  108. public:
  109. CInfoDescription( CPanelListPanel *panel );
  110. void WriteScriptHeader( FileHandle_t fp );
  111. void WriteFileHeader( FileHandle_t fp );
  112. };
  113. void UTIL_StripInvalidCharacters( char *pszInput, int maxlen );
  114. #endif // SCRIPTOBJECT_H