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.

60 lines
2.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef MATERIALPATCH_H
  7. #define MATERIALPATCH_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "utilmatlib.h"
  12. struct MaterialPatchInfo_t
  13. {
  14. const char *m_pKey;
  15. const char *m_pRequiredOriginalValue; // NULL if you don't require one.
  16. const char *m_pValue;
  17. MaterialPatchInfo_t()
  18. {
  19. memset( this, 0, sizeof( *this ) );
  20. }
  21. };
  22. enum MaterialPatchType_t
  23. {
  24. PATCH_INSERT = 0, // Add the key no matter what
  25. PATCH_REPLACE, // Add the key only if it exists
  26. };
  27. void CreateMaterialPatch( const char *pOriginalMaterialName, const char *pNewMaterialName,
  28. const char *pNewKey, const char *pNewValue, MaterialPatchType_t nPatchType );
  29. // A version which allows you to use multiple key values
  30. void CreateMaterialPatch( const char *pOriginalMaterialName, const char *pNewMaterialName,
  31. int nKeys, const MaterialPatchInfo_t *pInfo, MaterialPatchType_t nPatchType );
  32. // This gets a keyvalue from the *unpatched* version of the passed-in material
  33. bool GetValueFromMaterial( const char *pMaterialName, const char *pKey, char *pValue, int len );
  34. // Gets a keyvalue from a *patched* material
  35. bool GetValueFromPatchedMaterial( const char *pMaterialName, const char *pKey, char *pValue, int len );
  36. const char *GetOriginalMaterialNameForPatchedMaterial( const char *pPatchMaterialName );
  37. MaterialSystemMaterial_t FindOriginalMaterial( const char *materialName, bool *pFound, bool bComplain = true );
  38. bool DoesMaterialHaveKeyValuePair( const char *pMaterialName, const char *pKeyName, const char *pSearchValue );
  39. bool DoesMaterialHaveKey( const char *pMaterialName, const char *pKeyName );
  40. enum LoadMaterialKeyValuesFlags_t
  41. {
  42. LOAD_MATERIAL_KEY_VALUES_FLAGS_EXPAND_PATCH = 1,
  43. };
  44. KeyValues *LoadMaterialKeyValues( const char *pMaterialName, unsigned int nFlags );
  45. void WriteMaterialKeyValuesToPak( const char *pMaterialName, KeyValues *kv );
  46. #endif // MATERIALPATCH_H