aboutsummaryrefslogtreecommitdiff
path: root/sp/src/utils/vbsp/materialpatch.h
blob: f04a95d938001cd13174f0ecb7a928cf80ed7f4e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#ifndef MATERIALPATCH_H
#define MATERIALPATCH_H
#ifdef _WIN32
#pragma once
#endif

#include "utilmatlib.h"

struct MaterialPatchInfo_t
{
	const char *m_pKey;
	const char *m_pRequiredOriginalValue;  // NULL if you don't require one.
	const char *m_pValue;
	MaterialPatchInfo_t()
	{
		memset( this, 0, sizeof( *this ) );
	}
};

enum MaterialPatchType_t
{
	PATCH_INSERT = 0,	// Add the key no matter what
	PATCH_REPLACE,		// Add the key only if it exists
};

void CreateMaterialPatch( const char *pOriginalMaterialName, const char *pNewMaterialName,
						 const char *pNewKey, const char *pNewValue, MaterialPatchType_t nPatchType );

// A version which allows you to use multiple key values
void CreateMaterialPatch( const char *pOriginalMaterialName, const char *pNewMaterialName,
						 int nKeys, const MaterialPatchInfo_t *pInfo, MaterialPatchType_t nPatchType );

// This gets a keyvalue from the *unpatched* version of the passed-in material
bool GetValueFromMaterial( const char *pMaterialName, const char *pKey, char *pValue, int len );

// Gets a keyvalue from a *patched* material
bool GetValueFromPatchedMaterial( const char *pMaterialName, const char *pKey, char *pValue, int len );

const char *GetOriginalMaterialNameForPatchedMaterial( const char *pPatchMaterialName );

MaterialSystemMaterial_t FindOriginalMaterial( const char *materialName, bool *pFound, bool bComplain = true );

bool DoesMaterialHaveKeyValuePair( const char *pMaterialName, const char *pKeyName, const char *pSearchValue );
bool DoesMaterialHaveKey( const char *pMaterialName, const char *pKeyName );

enum LoadMaterialKeyValuesFlags_t
{
	LOAD_MATERIAL_KEY_VALUES_FLAGS_EXPAND_PATCH = 1,
};

KeyValues *LoadMaterialKeyValues( const char *pMaterialName, unsigned int nFlags );
void WriteMaterialKeyValuesToPak( const char *pMaterialName, KeyValues *kv );

#endif // MATERIALPATCH_H