initial
This commit is contained in:
18
public/fgdlib/fgdlib.h
Normal file
18
public/fgdlib/fgdlib.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef FGDLIB_H
|
||||
#define FGDLIB_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "helperinfo.h"
|
||||
#include "gamedata.h"
|
||||
#include "gdclass.h"
|
||||
#include "inputoutput.h"
|
||||
|
||||
#endif // FGDLIB_H
|
||||
220
public/fgdlib/gamedata.h
Normal file
220
public/fgdlib/gamedata.h
Normal file
@@ -0,0 +1,220 @@
|
||||
//========= Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef GAMEDATA_H
|
||||
#define GAMEDATA_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier2/tokenreader.h"
|
||||
#include "gdclass.h"
|
||||
#include "inputoutput.h"
|
||||
#include "utlstring.h"
|
||||
#include "utlvector.h"
|
||||
#include "utlmap.h"
|
||||
|
||||
|
||||
class MDkeyvalue;
|
||||
class GameData;
|
||||
class KeyValues;
|
||||
|
||||
//enum TEXTUREFORMAT;
|
||||
|
||||
|
||||
typedef void (*GameDataMessageFunc_t)(int level, const char *fmt, ...);
|
||||
|
||||
// FGD-based AutoMaterialExclusion data
|
||||
|
||||
struct FGDMatExlcusions_s
|
||||
{
|
||||
char szDirectory[MAX_PATH]; // Where we store the material exclusion directories
|
||||
bool bUserGenerated; // If the user specified this ( default: false -- FGD defined )
|
||||
};
|
||||
|
||||
// FGD-based AutoVisGroup data
|
||||
|
||||
struct FGDVisGroupsBaseClass_s
|
||||
{
|
||||
char szClass[MAX_PATH]; // i.e. Scene Logic, Sounds, etc "Custom\Point Entities\Lights"
|
||||
CUtlStringList szEntities; // i.e. func_viscluster
|
||||
};
|
||||
|
||||
struct FGDAutoVisGroups_s
|
||||
{
|
||||
char szParent[MAX_PATH]; // i.e. Custom, SFM, etc
|
||||
CUtlVector< FGDVisGroupsBaseClass_s > m_Classes; // i.e. Scene Logic, Sounds, etc
|
||||
};
|
||||
|
||||
#define MAX_DIRECTORY_SIZE 32
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Contains the set of data that is loaded from a single FGD file.
|
||||
//-----------------------------------------------------------------------------
|
||||
class GameData
|
||||
{
|
||||
public:
|
||||
typedef enum
|
||||
{
|
||||
NAME_FIXUP_PREFIX = 0,
|
||||
NAME_FIXUP_POSTFIX,
|
||||
NAME_FIXUP_NONE
|
||||
} TNameFixup;
|
||||
|
||||
GameData();
|
||||
~GameData();
|
||||
|
||||
BOOL Load(const char *pszFilename);
|
||||
|
||||
GDclass *ClassForName(const char *pszName, int *piIndex = NULL);
|
||||
|
||||
void ClearData();
|
||||
|
||||
inline int GetMaxMapCoord(void);
|
||||
inline int GetMinMapCoord(void);
|
||||
|
||||
inline bool IsGridNavActive(void);
|
||||
inline int GetGridNavEdgeSize(void);
|
||||
inline int GetGridNavOffsetX(void);
|
||||
inline int GetGridNavOffsetY(void);
|
||||
inline int GetTraceHeight(void);
|
||||
|
||||
inline int GetClassCount();
|
||||
inline GDclass *GetClass(int nIndex);
|
||||
|
||||
void BeginInstancing( int nPass );
|
||||
void BeginMapInstance( );
|
||||
GDclass *BeginInstanceRemap( const char *pszClassName, const char *pszInstancePrefix, Vector &Origin, QAngle &Angle );
|
||||
bool RemapKeyValue( const char *pszKey, const char *pszInValue, char *pszOutValue, TNameFixup NameFixup );
|
||||
bool RemapNameField( const char *pszInValue, char *pszOutValue, TNameFixup NameFixup );
|
||||
bool RemapInstanceField( const char *pszInValue, char *pszOutValue, TNameFixup NameFixup );
|
||||
bool LoadFGDMaterialExclusions( TokenReader &tr );
|
||||
bool LoadFGDAutoVisGroups( TokenReader &tr );
|
||||
|
||||
CUtlVector< FGDMatExlcusions_s > m_FGDMaterialExclusions;
|
||||
|
||||
CUtlVector< FGDAutoVisGroups_s > m_FGDAutoVisGroups;
|
||||
|
||||
private:
|
||||
|
||||
bool ParseMapSize(TokenReader &tr);
|
||||
bool ParseGridNav(TokenReader &tr);
|
||||
|
||||
CUtlVector<GDclass *> m_Classes;
|
||||
|
||||
int m_nMinMapCoord; // Min & max map bounds as defined by the FGD.
|
||||
int m_nMaxMapCoord;
|
||||
|
||||
// Grid nav data
|
||||
bool m_bGridNavActive;
|
||||
int m_nGridNavEdgeSize;
|
||||
int m_nGridNavOffsetX;
|
||||
int m_nGridNavOffsetY;
|
||||
int m_nTraceHeight;
|
||||
|
||||
// Instance Remapping
|
||||
int m_nRemapStage;
|
||||
Vector m_InstanceOrigin; // the origin offset of the instance
|
||||
QAngle m_InstanceAngle; // the rotation of the the instance
|
||||
matrix3x4_t m_InstanceMat; // matrix of the origin and rotation of rendering
|
||||
char m_InstancePrefix[ 128 ]; // the prefix used for the instance name remapping
|
||||
GDclass *m_InstanceClass; // the entity class that is being remapped
|
||||
int m_nNextNodeID;
|
||||
CUtlMap< int, int > m_NodeRemap;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
inline int GameData::GetClassCount()
|
||||
{
|
||||
return m_Classes.Count();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
inline GDclass *GameData::GetClass(int nIndex)
|
||||
{
|
||||
if (nIndex >= m_Classes.Count())
|
||||
return NULL;
|
||||
|
||||
return m_Classes.Element(nIndex);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int GameData::GetMinMapCoord(void)
|
||||
{
|
||||
return m_nMinMapCoord;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int GameData::GetMaxMapCoord(void)
|
||||
{
|
||||
return m_nMaxMapCoord;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool GameData::IsGridNavActive(void)
|
||||
{
|
||||
return m_bGridNavActive;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int GameData::GetGridNavEdgeSize(void)
|
||||
{
|
||||
return m_nGridNavEdgeSize;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int GameData::GetGridNavOffsetX(void)
|
||||
{
|
||||
return m_nGridNavOffsetX;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int GameData::GetGridNavOffsetY(void)
|
||||
{
|
||||
return m_nGridNavOffsetY;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int GameData::GetTraceHeight(void)
|
||||
{
|
||||
return m_nTraceHeight;
|
||||
}
|
||||
|
||||
|
||||
void GDSetMessageFunc(GameDataMessageFunc_t pFunc);
|
||||
bool GDError(TokenReader &tr, char *error, ...);
|
||||
bool GDSkipToken(TokenReader &tr, trtoken_t ttexpecting = TOKENNONE, const char *pszExpecting = NULL);
|
||||
bool GDGetToken(TokenReader &tr, char *pszStore, int nSize, trtoken_t ttexpecting = TOKENNONE, const char *pszExpecting = NULL);
|
||||
bool GDGetTokenDynamic(TokenReader &tr, char **pszStore, trtoken_t ttexpecting, const char *pszExpecting = NULL);
|
||||
|
||||
|
||||
#endif // GAMEDATA_H
|
||||
260
public/fgdlib/gdclass.h
Normal file
260
public/fgdlib/gdclass.h
Normal file
@@ -0,0 +1,260 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Defines the interface to a game class as defined by the game data
|
||||
// file (FGD). Each class is type of entity that can be placed in
|
||||
// the editor and has attributes such as: keys that may be set,
|
||||
// the default size and color of the entity, inputs and outputs,
|
||||
// and any default models that are created when the entity is placed.
|
||||
//
|
||||
// The game classes support multiple inheritence through aggregation
|
||||
// of properties.
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef GDCLASS_H
|
||||
#define GDCLASS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "helperinfo.h"
|
||||
#include "tier2/tokenreader.h"
|
||||
#include "gdvar.h"
|
||||
#include "inputoutput.h"
|
||||
#include "mathlib/vector.h"
|
||||
|
||||
class CHelperInfo;
|
||||
class GameData;
|
||||
class GDinputvariable;
|
||||
|
||||
const int GD_MAX_VARIABLES = 128;
|
||||
|
||||
|
||||
class GDclass
|
||||
{
|
||||
public:
|
||||
|
||||
GDclass(void);
|
||||
~GDclass(void);
|
||||
|
||||
//
|
||||
// Interface to class information:
|
||||
//
|
||||
inline const char *GetName(void) { return(m_szName); }
|
||||
inline const char *GetDescription(void);
|
||||
|
||||
//
|
||||
// Reading a class from the game data file:
|
||||
//
|
||||
BOOL InitFromTokens(TokenReader& tr, GameData*);
|
||||
|
||||
//
|
||||
// Interface to variable information (keys):
|
||||
//
|
||||
inline int GetVariableCount(void) { return(m_nVariables); }
|
||||
GDinputvariable *GetVariableAt(int iIndex);
|
||||
void GetHelperForGDVar( GDinputvariable *pVar, CUtlVector<const char *> *helperName );
|
||||
GDinputvariable *VarForName(const char *pszName, int *piIndex = NULL);
|
||||
BOOL AddVariable(GDinputvariable *pVar, GDclass *pBase, int iBaseIndex, int iVarIndex);
|
||||
void AddBase(GDclass *pBase);
|
||||
|
||||
//
|
||||
// Interface to input information:
|
||||
//
|
||||
inline void AddInput(CClassInput *pInput);
|
||||
CClassInput *FindInput(const char *szName);
|
||||
inline int GetInputCount(void) { return(m_Inputs.Count()); }
|
||||
CClassInput *GetInput(int nIndex);
|
||||
|
||||
//
|
||||
// Interface to output information:
|
||||
//
|
||||
inline void AddOutput(CClassOutput *pOutput);
|
||||
CClassOutput *FindOutput(const char *szName);
|
||||
inline int GetOutputCount(void) { return(m_Outputs.Count()); }
|
||||
CClassOutput *GetOutput(int nIndex);
|
||||
|
||||
GameData *Parent;
|
||||
|
||||
//
|
||||
// Interface to class attributes:
|
||||
//
|
||||
inline bool IsClass(const char *pszClass);
|
||||
inline bool IsSolidClass(void) { return(m_bSolid); }
|
||||
inline bool IsBaseClass(void) { return(m_bBase); }
|
||||
inline bool IsMoveClass(void) { return(m_bMove); }
|
||||
inline bool IsKeyFrameClass(void) { return(m_bKeyFrame); }
|
||||
inline bool IsPointClass(void) { return(m_bPoint); }
|
||||
inline bool IsNPCClass(void) { return(m_bNPC); }
|
||||
inline bool IsFilterClass(void) { return(m_bFilter); }
|
||||
inline bool IsNodeClass(void);
|
||||
static inline bool IsNodeClass(const char *pszClassName);
|
||||
|
||||
inline bool ShouldSnapToHalfGrid() { return m_bHalfGridSnap; }
|
||||
|
||||
inline void SetNPCClass(bool bNPC) { m_bNPC = bNPC; }
|
||||
inline void SetFilterClass(bool bFilter) { m_bFilter = bFilter; }
|
||||
inline void SetPointClass(bool bPoint) { m_bPoint = bPoint; }
|
||||
inline void SetSolidClass(bool bSolid) { m_bSolid = bSolid; }
|
||||
inline void SetBaseClass(bool bBase) { m_bBase = bBase; }
|
||||
inline void SetMoveClass(bool bMove) { m_bMove = bMove; }
|
||||
inline void SetKeyFrameClass(bool bKeyFrame) { m_bKeyFrame = bKeyFrame; }
|
||||
|
||||
inline const Vector &GetMins(void) { return(m_bmins); }
|
||||
inline const Vector &GetMaxs(void) { return(m_bmaxs); }
|
||||
|
||||
BOOL GetBoundBox(Vector& pfMins, Vector& pfMaxs);
|
||||
bool HasBoundBox() const { return m_bGotSize; }
|
||||
|
||||
inline color32 GetColor(void);
|
||||
|
||||
//
|
||||
// Interface to helper information:
|
||||
//
|
||||
inline void AddHelper(CHelperInfo *pHelper);
|
||||
inline int GetHelperCount(void) { return(m_Helpers.Count()); }
|
||||
CHelperInfo *GetHelper(int nIndex);
|
||||
|
||||
protected:
|
||||
|
||||
//
|
||||
// Parsing the game data file:
|
||||
//
|
||||
bool ParseInput(TokenReader &tr);
|
||||
bool ParseInputOutput(TokenReader &tr, CClassInputOutputBase *pInputOutput);
|
||||
bool ParseOutput(TokenReader &tr);
|
||||
bool ParseVariable(TokenReader &tr);
|
||||
|
||||
private:
|
||||
|
||||
bool ParseBase(TokenReader &tr);
|
||||
bool ParseColor(TokenReader &tr);
|
||||
bool ParseHelper(TokenReader &tr, char *pszHelperName);
|
||||
bool ParseSize(TokenReader &tr);
|
||||
bool ParseSpecifiers(TokenReader &tr);
|
||||
bool ParseVariables(TokenReader &tr);
|
||||
|
||||
color32 m_rgbColor; // Color of entity.
|
||||
|
||||
bool m_bBase; // Base only - not available to user.
|
||||
bool m_bSolid; // Tied to solids only.
|
||||
bool m_bModel; // Properties of a single model.
|
||||
bool m_bMove; // Animatable
|
||||
bool m_bKeyFrame; // Animation keyframe
|
||||
bool m_bPoint; // Point class, not tied to solids.
|
||||
bool m_bNPC; // NPC class - used for populating lists of NPC classes.
|
||||
bool m_bFilter; // filter class - used for populating lists of filters.
|
||||
bool m_bHalfGridSnap; // Snaps to a 1/2 grid so it can be centered on any geometry. Used for hinges, etc.
|
||||
|
||||
bool m_bGotSize; // Just for loading.
|
||||
bool m_bGotColor;
|
||||
|
||||
char m_szName[MAX_IDENT]; // Name of this class.
|
||||
char *m_pszDescription; // Description of this class, dynamically allocated.
|
||||
|
||||
CUtlVector<GDinputvariable *> m_Variables; // Variables for this class.
|
||||
int m_nVariables; // Count of base & local variables combined.
|
||||
CUtlVector<GDclass *> m_Bases; // List of base classes this class inherits from.
|
||||
|
||||
CClassInputList m_Inputs;
|
||||
CClassOutputList m_Outputs;
|
||||
|
||||
CHelperInfoList m_Helpers; // Helpers for this class.
|
||||
|
||||
//
|
||||
// [0] = base number from Bases, or -1 if not in a base.
|
||||
// [1] = index into base's variables
|
||||
//
|
||||
signed short m_VariableMap[GD_MAX_VARIABLES][2];
|
||||
|
||||
Vector m_bmins; // 3D minima of object (pointclass).
|
||||
Vector m_bmaxs; // 3D maxima of object (pointclass).
|
||||
};
|
||||
|
||||
|
||||
void GDclass::AddInput(CClassInput *pInput)
|
||||
{
|
||||
Assert(pInput != NULL);
|
||||
if (pInput != NULL)
|
||||
{
|
||||
m_Inputs.AddToTail(pInput);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void GDclass::AddOutput(CClassOutput *pOutput)
|
||||
{
|
||||
Assert(pOutput != NULL);
|
||||
if (pOutput != NULL)
|
||||
{
|
||||
m_Outputs.AddToTail(pOutput);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void GDclass::AddHelper(CHelperInfo *pHelper)
|
||||
{
|
||||
Assert(pHelper != NULL);
|
||||
if (pHelper != NULL)
|
||||
{
|
||||
m_Helpers.AddToTail(pHelper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns the render color of this entity class.
|
||||
//-----------------------------------------------------------------------------
|
||||
color32 GDclass::GetColor(void)
|
||||
{
|
||||
return m_rgbColor;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns a description of this entity class, or the entity class name
|
||||
// if no description exists.
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *GDclass::GetDescription(void)
|
||||
{
|
||||
if (m_pszDescription == NULL)
|
||||
{
|
||||
return(m_szName);
|
||||
}
|
||||
|
||||
return(m_pszDescription);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : pszClass -
|
||||
//-----------------------------------------------------------------------------
|
||||
bool GDclass::IsClass(const char *pszClass)
|
||||
{
|
||||
Assert(pszClass != NULL);
|
||||
return(!stricmp(pszClass, m_szName));
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns true if the given classname represents an AI node class, false if not.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool GDclass::IsNodeClass(const char *pszClassName)
|
||||
{
|
||||
return((strnicmp(pszClassName, "info_node", 9) == 0) && (stricmp(pszClassName, "info_node_link") != 0));
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns true if this is an AI node class, false if not.
|
||||
//
|
||||
// HACK: if this is necessary, we should have a new @NodeClass FGD specifier (or something)
|
||||
//-----------------------------------------------------------------------------
|
||||
bool GDclass::IsNodeClass(void)
|
||||
{
|
||||
return(IsNodeClass(m_szName));
|
||||
}
|
||||
|
||||
|
||||
#endif // GDCLASS_H
|
||||
225
public/fgdlib/gdvar.h
Normal file
225
public/fgdlib/gdvar.h
Normal file
@@ -0,0 +1,225 @@
|
||||
//========= Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef GDVAR_H
|
||||
#define GDVAR_H
|
||||
#pragma once
|
||||
|
||||
#include <utlvector.h>
|
||||
#include <tier2/tokenreader.h> // dvs: for MAX_STRING. Fix.
|
||||
|
||||
|
||||
class MDkeyvalue;
|
||||
|
||||
|
||||
enum GDIV_TYPE
|
||||
{
|
||||
ivBadType = -1,
|
||||
ivAngle,
|
||||
ivTargetDest,
|
||||
ivTargetNameOrClass,
|
||||
ivTargetSrc,
|
||||
ivInteger,
|
||||
ivString,
|
||||
ivStringInstanced,
|
||||
ivChoices,
|
||||
ivFlags,
|
||||
ivDecal,
|
||||
ivColor255, // components are 0-255
|
||||
ivColor1, // components are 0-1
|
||||
ivStudioModel,
|
||||
ivSprite,
|
||||
ivSound,
|
||||
ivVector,
|
||||
ivNPCClass,
|
||||
ivFilterClass,
|
||||
ivFloat,
|
||||
ivMaterial,
|
||||
ivScene,
|
||||
ivSide, // One brush face ID.
|
||||
ivSideList, // One or more brush face IDs, space delimited.
|
||||
ivOrigin, // The origin of an entity, in the form "x y z".
|
||||
ivVecLine, // An origin that draws a line back to the parent entity.
|
||||
ivAxis, // The axis of rotation for a rotating entity, in the form "x0 y0 z0, x1 y1 z1".
|
||||
ivPointEntityClass,
|
||||
ivNodeDest,
|
||||
ivScript,
|
||||
ivScriptList,
|
||||
ivParticleSystem,
|
||||
ivInstanceFile, // used for hammer to know this field should display a browse button to find map files
|
||||
ivAngleNegativePitch, // used for instance rotating when just a negative pitch value is present ( light_ pitch fields )
|
||||
ivInstanceVariable, // used for instance variables for easy hammer editing
|
||||
ivInstanceParm, // used for instance parameter declaration
|
||||
ivBoolean,
|
||||
ivNodeID, // used for instance node id remapping
|
||||
|
||||
ivMax // count of types
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Defines an element in a choices/flags list. Choices values are strings;
|
||||
// flags values are integers, hence the iValue and szValue members.
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef struct
|
||||
{
|
||||
unsigned long iValue; // Bitflag value for ivFlags
|
||||
char szValue[MAX_STRING]; // String value for ivChoices
|
||||
char szCaption[MAX_STRING]; // Name of this choice
|
||||
BOOL bDefault; // Flag set by default?
|
||||
} GDIVITEM;
|
||||
|
||||
|
||||
class GDinputvariable
|
||||
{
|
||||
public:
|
||||
|
||||
GDinputvariable();
|
||||
GDinputvariable( const char *szType, const char *szName );
|
||||
~GDinputvariable();
|
||||
|
||||
BOOL InitFromTokens(TokenReader& tr);
|
||||
|
||||
// functions:
|
||||
inline const char *GetName() { return m_szName; }
|
||||
inline const char *GetLongName(void) { return m_szLongName; }
|
||||
inline const char *GetDescription(void);
|
||||
|
||||
inline int GetFlagCount() { return m_Items.Count(); }
|
||||
inline int GetFlagMask(int nFlag);
|
||||
inline const char *GetFlagCaption(int nFlag);
|
||||
|
||||
inline int GetChoiceCount() { return m_Items.Count(); }
|
||||
inline const char *GetChoiceCaption(int nChoice);
|
||||
|
||||
inline GDIV_TYPE GetType() { return m_eType; }
|
||||
const char *GetTypeText(void);
|
||||
|
||||
inline void GetDefault(int *pnStore)
|
||||
{
|
||||
pnStore[0] = m_nDefault;
|
||||
}
|
||||
|
||||
inline void GetDefault(char *pszStore)
|
||||
{
|
||||
strcpy(pszStore, m_szDefault);
|
||||
}
|
||||
|
||||
GDIV_TYPE GetTypeFromToken(const char *pszToken);
|
||||
trtoken_t GetStoreAsFromType(GDIV_TYPE eType);
|
||||
|
||||
const char *ItemStringForValue(const char *szValue);
|
||||
const char *ItemValueForString(const char *szString);
|
||||
|
||||
BOOL IsFlagSet(unsigned int);
|
||||
void SetFlag(unsigned int, BOOL bSet);
|
||||
|
||||
void ResetDefaults();
|
||||
|
||||
void ToKeyValue(MDkeyvalue* pkv);
|
||||
void FromKeyValue(MDkeyvalue* pkv);
|
||||
|
||||
inline bool IsReportable(void);
|
||||
inline bool IsReadOnly(void);
|
||||
|
||||
GDinputvariable &operator =(GDinputvariable &Other);
|
||||
void Merge(GDinputvariable &Other);
|
||||
|
||||
static const char *GetVarTypeName( GDIV_TYPE eType );
|
||||
|
||||
private:
|
||||
|
||||
// for choices/flags:
|
||||
CUtlVector<GDIVITEM> m_Items;
|
||||
|
||||
static char *m_pszEmpty;
|
||||
|
||||
char m_szName[MAX_IDENT];
|
||||
char m_szLongName[MAX_STRING];
|
||||
char *m_pszDescription;
|
||||
|
||||
GDIV_TYPE m_eType;
|
||||
|
||||
int m_nDefault;
|
||||
char m_szDefault[MAX_STRING];
|
||||
|
||||
int m_nValue;
|
||||
char m_szValue[MAX_STRING];
|
||||
|
||||
bool m_bReportable;
|
||||
bool m_bReadOnly;
|
||||
|
||||
friend class GDclass;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *GDinputvariable::GetDescription(void)
|
||||
{
|
||||
if (m_pszDescription != NULL)
|
||||
{
|
||||
return(m_pszDescription);
|
||||
}
|
||||
|
||||
return(m_pszEmpty);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns whether or not this variable is read only. Read only variables
|
||||
// cannot be edited in the Entity Properties dialog.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool GDinputvariable::IsReadOnly(void)
|
||||
{
|
||||
return(m_bReadOnly);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns whether or not this variable should be displayed in the Entity
|
||||
// Report dialog.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool GDinputvariable::IsReportable(void)
|
||||
{
|
||||
return(m_bReportable);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns the flag mask (eg 4096) for the flag at the given index. The
|
||||
// array is packed, so it isn't just 1 >> nFlag.
|
||||
//-----------------------------------------------------------------------------
|
||||
int GDinputvariable::GetFlagMask(int nFlag)
|
||||
{
|
||||
Assert(m_eType == ivFlags);
|
||||
return m_Items.Element(nFlag).iValue;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns the caption text (eg "Only break on trigger") for the flag at the given index.
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *GDinputvariable::GetFlagCaption(int nFlag)
|
||||
{
|
||||
Assert(m_eType == ivFlags);
|
||||
return m_Items.Element(nFlag).szCaption;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns the caption text (eg "Yes") for the choice at the given index.
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *GDinputvariable::GetChoiceCaption(int nChoice)
|
||||
{
|
||||
Assert(m_eType == ivChoices);
|
||||
return m_Items.Element(nChoice).szCaption;
|
||||
}
|
||||
|
||||
|
||||
#endif // GDVAR_H
|
||||
128
public/fgdlib/helperinfo.h
Normal file
128
public/fgdlib/helperinfo.h
Normal file
@@ -0,0 +1,128 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ====
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef HELPERINFO_H
|
||||
#define HELPERINFO_H
|
||||
#pragma once
|
||||
|
||||
#include <tier0/dbg.h>
|
||||
#include <utlvector.h>
|
||||
|
||||
|
||||
#define MAX_HELPER_NAME_LEN 256
|
||||
|
||||
|
||||
typedef CUtlVector<char *> CParameterList;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CHelperInfo
|
||||
{
|
||||
public:
|
||||
|
||||
inline CHelperInfo(void);
|
||||
inline ~CHelperInfo(void);
|
||||
|
||||
inline const char *GetName(void) const { return(m_szName); }
|
||||
inline void SetName(const char *pszName);
|
||||
|
||||
inline bool AddParameter(const char *pszParameter);
|
||||
|
||||
inline int GetParameterCount(void) const { return(m_Parameters.Count()); }
|
||||
inline const char *GetParameter(int nIndex) const;
|
||||
|
||||
protected:
|
||||
|
||||
char m_szName[MAX_HELPER_NAME_LEN];
|
||||
CParameterList m_Parameters;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
inline CHelperInfo::CHelperInfo(void)
|
||||
{
|
||||
m_szName[0] = '\0';
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
inline CHelperInfo::~CHelperInfo(void)
|
||||
{
|
||||
int nCount = m_Parameters.Count();
|
||||
for (int i = 0; i < nCount; i++)
|
||||
{
|
||||
char *pszParam = m_Parameters.Element(i);
|
||||
Assert(pszParam != NULL);
|
||||
if (pszParam != NULL)
|
||||
{
|
||||
delete [] pszParam;
|
||||
}
|
||||
}
|
||||
|
||||
m_Parameters.RemoveAll();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : char *pszParameter -
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
inline bool CHelperInfo::AddParameter(const char *pszParameter)
|
||||
{
|
||||
if ((pszParameter != NULL) && (pszParameter[0] != '\0'))
|
||||
{
|
||||
int nLen = strlen(pszParameter);
|
||||
|
||||
if (nLen > 0)
|
||||
{
|
||||
char *pszNew = new char [nLen + 1];
|
||||
if (pszNew != NULL)
|
||||
{
|
||||
strcpy(pszNew, pszParameter);
|
||||
m_Parameters.AddToTail(pszNew);
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
inline const char *CHelperInfo::GetParameter(int nIndex) const
|
||||
{
|
||||
if (nIndex >= m_Parameters.Count())
|
||||
return NULL;
|
||||
|
||||
return m_Parameters.Element(nIndex);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : char *pszName -
|
||||
//-----------------------------------------------------------------------------
|
||||
inline void CHelperInfo::SetName(const char *pszName)
|
||||
{
|
||||
if (pszName != NULL)
|
||||
{
|
||||
strcpy(m_szName, pszName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef CUtlVector<CHelperInfo *> CHelperInfoList;
|
||||
|
||||
|
||||
#endif // HELPERINFO_H
|
||||
165
public/fgdlib/ieditortexture.h
Normal file
165
public/fgdlib/ieditortexture.h
Normal file
@@ -0,0 +1,165 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ====
|
||||
//
|
||||
// Purpose: Defines the interface a given texture for the 3D renderer. Current
|
||||
// implementations are for world textures (WADTexture.cpp) and sprite
|
||||
// textures (Texture.cpp).
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef IEDITORTEXTURE_H
|
||||
#define IEDITORTEXTURE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <utlvector.h>
|
||||
|
||||
|
||||
class CDC;
|
||||
class CPalette;
|
||||
class IMaterial;
|
||||
|
||||
// FGDLIB:
|
||||
#define DEFAULT_TEXTURE_SCALE 0.25
|
||||
#define DEFAULT_LIGHTMAP_SCALE 16
|
||||
|
||||
|
||||
//
|
||||
// Set your texture ID to this in your implementation's constructor.
|
||||
//
|
||||
#define TEXTURE_ID_NONE -1
|
||||
|
||||
|
||||
//
|
||||
// Texture formats. hack: MUST correlate with radio buttons in IDD_OPTIONS_CONFIGS.
|
||||
//
|
||||
enum TEXTUREFORMAT
|
||||
{
|
||||
tfNone = -1,
|
||||
tfWAD = 0,
|
||||
tfWAL = 1,
|
||||
tfWAD3 = 2,
|
||||
tfWAD4 = 3,
|
||||
tfWAD5 = 4,
|
||||
tfVMT = 5,
|
||||
tfSprite = 6 // dvs: not sure if I want to do it this way
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Flags for DrawTexData_t.
|
||||
//
|
||||
#define drawCaption 0x01
|
||||
#define drawResizeAlways 0x02
|
||||
#define drawIcons 0x04
|
||||
#define drawErrors 0x08
|
||||
#define drawUsageCount 0x10
|
||||
|
||||
|
||||
struct DrawTexData_t
|
||||
{
|
||||
int nFlags;
|
||||
int nUsageCount;
|
||||
};
|
||||
|
||||
|
||||
class IEditorTexture
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~IEditorTexture(void)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// dvs: remove one of these
|
||||
//
|
||||
virtual int GetImageWidth( void ) const = 0;
|
||||
virtual int GetImageHeight( void ) const = 0;
|
||||
|
||||
virtual int GetWidth( void ) const = 0;
|
||||
virtual int GetHeight( void ) const = 0;
|
||||
|
||||
virtual float GetDecalScale( void ) const = 0;
|
||||
|
||||
//
|
||||
// dvs: Try to remove as many of these as possible:
|
||||
//
|
||||
virtual const char *GetName( void ) const = 0;
|
||||
virtual int GetShortName( char *szShortName ) const = 0;
|
||||
virtual int GetKeywords( char *szKeywords ) const = 0;
|
||||
// FGDLIB:
|
||||
//virtual void Draw(CDC *pDC, RECT &rect, int iFontHeight, int iIconHeight, DrawTexData_t &DrawTexData) = 0;
|
||||
virtual TEXTUREFORMAT GetTextureFormat( void ) const = 0;
|
||||
virtual int GetSurfaceAttributes( void ) const = 0;
|
||||
virtual int GetSurfaceContents(void ) const = 0;
|
||||
virtual int GetSurfaceValue( void ) const = 0;
|
||||
virtual CPalette *GetPalette( void ) const = 0;
|
||||
virtual bool HasData( void ) const = 0;
|
||||
virtual bool HasPalette( void ) const = 0;
|
||||
virtual bool Load( void ) = 0; // ensure that texture is loaded. could this be done internally?
|
||||
virtual void Reload( void ) = 0; // The texture changed
|
||||
virtual bool IsLoaded( void ) const = 0;
|
||||
virtual const char *GetFileName( void ) const = 0;
|
||||
|
||||
virtual bool IsWater( void ) const = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : pData -
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
virtual int GetImageDataRGB( void *pData = NULL ) = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : pData -
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
virtual int GetImageDataRGBA( void *pData = NULL ) = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns true if this texture has an alpha component, false if not.
|
||||
//-----------------------------------------------------------------------------
|
||||
virtual bool HasAlpha( void ) const = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns whether this texture is a dummy texture or not. Dummy textures
|
||||
// serve as placeholders for textures that were found in the map, but
|
||||
// not in the WAD (or the materials tree). The dummy texture enables us
|
||||
// to bind the texture, find it by name, etc.
|
||||
//-----------------------------------------------------------------------------
|
||||
virtual bool IsDummy( void ) const = 0; // dvs: perhaps not the best name?
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns the unique texture ID for this texture object. The texture ID
|
||||
// identifies the texture object across all renderers, and is assigned
|
||||
// by the first renderer that actually binds the texture thru BindTexture.
|
||||
//
|
||||
// Only the renderer ever needs to call SetTextureID.
|
||||
//-----------------------------------------------------------------------------
|
||||
virtual int GetTextureID( void ) const = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sets the unique texture ID for this texture object. The texture ID
|
||||
// identifies the texture object across all renderers, and is assigned
|
||||
// by the first renderer that actually binds the texture thru BindTexture.
|
||||
//
|
||||
// Only the renderer should ever call SetTextureID!
|
||||
//-----------------------------------------------------------------------------
|
||||
virtual void SetTextureID( int nTextureID ) = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns the material system material associated with a texture
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
virtual IMaterial* GetMaterial() { return 0; }
|
||||
};
|
||||
|
||||
|
||||
typedef CUtlVector<IEditorTexture *> EditorTextureList_t;
|
||||
|
||||
|
||||
#endif // IEDITORTEXTURE_H
|
||||
106
public/fgdlib/inputoutput.h
Normal file
106
public/fgdlib/inputoutput.h
Normal file
@@ -0,0 +1,106 @@
|
||||
//========= Copyright © 1996-2008, Valve Corporation, All rights reserved. ====
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef INPUTOUTPUT_H
|
||||
#define INPUTOUTPUT_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <utlvector.h>
|
||||
#include "entitydefs.h"
|
||||
|
||||
|
||||
enum InputOutputType_t
|
||||
{
|
||||
iotInvalid = -1,
|
||||
iotVoid,
|
||||
iotInt,
|
||||
iotBool,
|
||||
iotString,
|
||||
iotFloat,
|
||||
iotVector,
|
||||
iotEHandle,
|
||||
iotColor,
|
||||
iotScript,
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CClassInputOutputBase
|
||||
{
|
||||
public:
|
||||
|
||||
CClassInputOutputBase(void);
|
||||
CClassInputOutputBase(const char *pszName, InputOutputType_t eType);
|
||||
virtual ~CClassInputOutputBase(void);
|
||||
|
||||
inline const char *GetName(void) { return(m_szName); }
|
||||
InputOutputType_t GetType(void) { return(m_eType); }
|
||||
const char *GetTypeText(void);
|
||||
inline const char *GetDescription(void);
|
||||
|
||||
inline void SetName(const char *szName) { strcpy(m_szName, szName); }
|
||||
inline void SetType(InputOutputType_t eType) { m_eType = eType; }
|
||||
InputOutputType_t SetType(const char *szType);
|
||||
inline void SetDescription(char *pszDescription) { m_pszDescription = pszDescription; }
|
||||
|
||||
CClassInputOutputBase &operator =(CClassInputOutputBase &);
|
||||
|
||||
protected:
|
||||
|
||||
static char *g_pszEmpty;
|
||||
|
||||
char m_szName[MAX_IO_NAME_LEN];
|
||||
InputOutputType_t m_eType;
|
||||
char *m_pszDescription;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns this I/O's long description.
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CClassInputOutputBase::GetDescription(void)
|
||||
{
|
||||
if (m_pszDescription != NULL)
|
||||
{
|
||||
return(m_pszDescription);
|
||||
}
|
||||
|
||||
return(g_pszEmpty);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CClassInput : public CClassInputOutputBase
|
||||
{
|
||||
public:
|
||||
|
||||
CClassInput(void);
|
||||
CClassInput(const char *pszName, InputOutputType_t eType);
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CClassOutput : public CClassInputOutputBase
|
||||
{
|
||||
public:
|
||||
|
||||
CClassOutput(void);
|
||||
CClassOutput(const char *pszName, InputOutputType_t eType);
|
||||
};
|
||||
|
||||
|
||||
typedef CUtlVector<CClassInput *> CClassInputList;
|
||||
typedef CUtlVector<CClassOutput *> CClassOutputList;
|
||||
|
||||
|
||||
#endif // INPUTOUTPUT_H
|
||||
233
public/fgdlib/wckeyvalues.h
Normal file
233
public/fgdlib/wckeyvalues.h
Normal file
@@ -0,0 +1,233 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef WCKEYVALUES_H
|
||||
#define WCKEYVALUES_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <tier0/dbg.h>
|
||||
#include <utlvector.h>
|
||||
#include <utldict.h>
|
||||
#pragma warning(push, 1)
|
||||
#pragma warning(disable:4701 4702 4530)
|
||||
#include <fstream>
|
||||
#pragma warning(pop)
|
||||
|
||||
|
||||
#define KEYVALUE_MAX_KEY_LENGTH 80
|
||||
#define KEYVALUE_MAX_VALUE_LENGTH 512
|
||||
|
||||
|
||||
class MDkeyvalue
|
||||
{
|
||||
public:
|
||||
|
||||
//
|
||||
// Constructors/Destructor.
|
||||
//
|
||||
inline MDkeyvalue(void);
|
||||
inline MDkeyvalue(const char *pszKey, const char *pszValue);
|
||||
~MDkeyvalue(void);
|
||||
|
||||
MDkeyvalue &operator =(const MDkeyvalue &other);
|
||||
|
||||
inline void Set(const char *pszKey, const char *pszValue);
|
||||
inline const char *Key(void) const;
|
||||
inline const char *Value(void) const;
|
||||
|
||||
//
|
||||
// Serialization functions.
|
||||
//
|
||||
int SerializeRMF(std::fstream &f, BOOL bRMF);
|
||||
int SerializeMAP(std::fstream &f, BOOL bRMF);
|
||||
|
||||
char szKey[KEYVALUE_MAX_KEY_LENGTH]; // The name of this key.
|
||||
char szValue[KEYVALUE_MAX_VALUE_LENGTH]; // The value of this key, stored as a string.
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor.
|
||||
//-----------------------------------------------------------------------------
|
||||
MDkeyvalue::MDkeyvalue(void)
|
||||
{
|
||||
szKey[0] = '\0';
|
||||
szValue[0] = '\0';
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor with assignment.
|
||||
//-----------------------------------------------------------------------------
|
||||
MDkeyvalue::MDkeyvalue(const char *pszKey, const char *pszValue)
|
||||
{
|
||||
szKey[0] = '\0';
|
||||
szValue[0] = '\0';
|
||||
|
||||
Set(pszKey, pszValue);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Assigns a key and value.
|
||||
//-----------------------------------------------------------------------------
|
||||
void MDkeyvalue::Set(const char *pszKey, const char *pszValue)
|
||||
{
|
||||
Assert(pszKey);
|
||||
Assert(pszValue);
|
||||
|
||||
strcpy(szKey, pszKey);
|
||||
strcpy(szValue, pszValue);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns the string keyname.
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *MDkeyvalue::Key(void) const
|
||||
{
|
||||
return szKey;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns the string value of this keyvalue.
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *MDkeyvalue::Value(void) const
|
||||
{
|
||||
return szValue;
|
||||
}
|
||||
|
||||
|
||||
typedef CUtlVector<MDkeyvalue> KeyValueArray;
|
||||
|
||||
|
||||
// Used in cases where there can be duplicate key names.
|
||||
class WCKVBase_Vector
|
||||
{
|
||||
public:
|
||||
|
||||
// Iteration helpers.
|
||||
inline int GetCount() const { return m_KeyValues.Count(); }
|
||||
inline int GetFirst() const { return m_KeyValues.Count() - 1; }
|
||||
inline int GetNext( int i ) const { return i - 1; }
|
||||
static inline int GetInvalidIndex() { return -1; }
|
||||
|
||||
void RemoveKeyAt(int nIndex);
|
||||
int FindByKeyName( const char *pKeyName ) const; // Returns the same value as GetInvalidIndex if not found.
|
||||
|
||||
// Special function used for non-unique keyvalue lists.
|
||||
void AddKeyValue(const char *pszKey, const char *pszValue);
|
||||
|
||||
protected:
|
||||
|
||||
void InsertKeyValue( const MDkeyvalue &kv );
|
||||
|
||||
protected:
|
||||
CUtlVector<MDkeyvalue> m_KeyValues;
|
||||
};
|
||||
|
||||
// Used for most key/value sets because it's fast. Does not allow duplicate key names.
|
||||
class WCKVBase_Dict
|
||||
{
|
||||
public:
|
||||
|
||||
// Iteration helpers. Note that there is no GetCount() because you can't iterate
|
||||
// these by incrementing a counter.
|
||||
inline int GetFirst() const { return m_KeyValues.First(); }
|
||||
inline int GetNext( int i ) const { return m_KeyValues.Next( i ); }
|
||||
static inline int GetInvalidIndex() { return CUtlDict<MDkeyvalue,unsigned short>::InvalidIndex(); }
|
||||
|
||||
int FindByKeyName( const char *pKeyName ) const; // Returns the same value as GetInvalidIndex if not found.
|
||||
void RemoveKeyAt(int nIndex);
|
||||
|
||||
protected:
|
||||
void InsertKeyValue( const MDkeyvalue &kv );
|
||||
|
||||
protected:
|
||||
CUtlDict<MDkeyvalue,unsigned short> m_KeyValues;
|
||||
};
|
||||
|
||||
|
||||
// See below for typedefs of this class you can use.
|
||||
template<class Base>
|
||||
class WCKeyValuesT : public Base
|
||||
{
|
||||
public:
|
||||
|
||||
WCKeyValuesT(void);
|
||||
~WCKeyValuesT(void);
|
||||
|
||||
void RemoveAll(void);
|
||||
void RemoveKey(const char *pszKey);
|
||||
|
||||
void SetValue(const char *pszKey, const char *pszValue);
|
||||
void SetValue(const char *pszKey, int iValue);
|
||||
|
||||
const char *GetKey(int nIndex) const;
|
||||
MDkeyvalue &GetKeyValue(int nIndex);
|
||||
const MDkeyvalue& GetKeyValue(int nIndex) const;
|
||||
const char *GetValue(int nIndex) const;
|
||||
const char *GetValue(const char *pszKey, int *piIndex = NULL) const;
|
||||
};
|
||||
|
||||
|
||||
// These have explicit template instantiations so you can use them.
|
||||
typedef WCKeyValuesT<WCKVBase_Dict> WCKeyValues;
|
||||
typedef WCKeyValuesT<WCKVBase_Vector> WCKeyValuesVector;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : nIndex -
|
||||
//-----------------------------------------------------------------------------
|
||||
template<class Base>
|
||||
inline const char *WCKeyValuesT<Base>::GetKey(int nIndex) const
|
||||
{
|
||||
return(this->m_KeyValues.Element(nIndex).szKey);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : nIndex -
|
||||
// Output : MDKeyValue
|
||||
//-----------------------------------------------------------------------------
|
||||
template<class Base>
|
||||
inline MDkeyvalue &WCKeyValuesT<Base>::GetKeyValue(int nIndex)
|
||||
{
|
||||
return(this->m_KeyValues.Element(nIndex));
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : nIndex -
|
||||
// Output : MDkeyvalue
|
||||
//-----------------------------------------------------------------------------
|
||||
template<class Base>
|
||||
inline const MDkeyvalue& WCKeyValuesT<Base>::GetKeyValue(int nIndex) const
|
||||
{
|
||||
return(this->m_KeyValues.Element(nIndex));
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : nIndex -
|
||||
//-----------------------------------------------------------------------------
|
||||
template<class Base>
|
||||
inline const char *WCKeyValuesT<Base>::GetValue(int nIndex) const
|
||||
{
|
||||
return(this->m_KeyValues.Element(nIndex).szValue);
|
||||
}
|
||||
|
||||
|
||||
void StripEdgeWhiteSpace(char *psz);
|
||||
|
||||
|
||||
#endif // WCKEYVALUES_H
|
||||
Reference in New Issue
Block a user