blob: ad53279c13b935a4b2c836d8ac19bff5d562417f (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Contains a bunch of information about editor types
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef DMEEDITORTYPEDICTIONARY_H
#define DMEEDITORTYPEDICTIONARY_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
//-----------------------------------------------------------------------------
// Contains all attributes related to a particular attribute on a particular editor type
//-----------------------------------------------------------------------------
class CDmeEditorAttributeInfo : public CDmElement
{
DEFINE_ELEMENT( CDmeEditorAttributeInfo, CDmElement );
public:
// Returns the attribute name this info is associated with
const char *GetAttributeName() const;
// Returns the widget name to create
const char *GetWidgetName() const;
// Sets the info for an entry in an attribute array
void SetArrayInfo( CDmeEditorAttributeInfo *pInfo );
// Returns the info for a entry in an attribute array, if this attribute is an array type
CDmeEditorAttributeInfo *GetArrayInfo();
// NOTE: The name field of the widget element is the widget type
// The attributes of the widget element are data for the widget to initialize
CDmaString m_Widget;
CDmaVar< bool > m_bIsVisible;
CDmaVar< bool > m_bIsReadOnly;
CDmaVar< bool > m_bHideType;
CDmaVar< bool > m_bHideValue;
CDmaString m_Help;
private:
// If this attribute is an array attribute, how do we edit the array entries?
CDmaElement< CDmeEditorAttributeInfo > m_ArrayEntries;
};
//-----------------------------------------------------------------------------
// Base class for configuration for choices
//-----------------------------------------------------------------------------
class CDmeEditorChoicesInfo : public CDmeEditorAttributeInfo
{
DEFINE_ELEMENT( CDmeEditorChoicesInfo, CDmeEditorAttributeInfo );
public:
void SetChoiceType( const char *pChoiceType );
// Gets the choices
int GetChoiceCount() const;
const char *GetChoiceString( int nIndex ) const;
const char *GetChoiceType() const;
bool HasChoiceType() const;
protected:
CDmElement *CreateChoice( const char *pChoiceString );
CDmaElementArray< CDmElement > m_Choices;
CDmaString m_ChoiceType;
};
//-----------------------------------------------------------------------------
// A single editor type
//-----------------------------------------------------------------------------
class CDmeEditorType : public CDmElement
{
DEFINE_ELEMENT( CDmeEditorType, CDmElement );
public:
// Adds a editor type to be associated with a particular attribute
void AddAttributeInfo( const char *pAttributeName, CDmeEditorAttributeInfo *pInfo );
// Removes a editor type associated with a particular attribute
void RemoveAttributeInfo( const char *pAttributeName );
// Returns the editor info associated with an editor type
CDmeEditorAttributeInfo *GetAttributeInfo( const char *pAttributeName );
// Returns the editor info associated with a single entry in an attribute array
CDmeEditorAttributeInfo *GetAttributeArrayInfo( const char *pAttributeName );
private:
// Computes the actual attribute name stored in the type
const char *GetActualAttributeName( const char *pAttributeName );
};
//-----------------------------------------------------------------------------
// A dictionary of all editor types
//-----------------------------------------------------------------------------
class CDmeEditorTypeDictionary : public CDmElement
{
DEFINE_ELEMENT( CDmeEditorTypeDictionary, CDmElement );
public:
void AddEditorTypesFromFile( const char *pFileName, const char *pPathID );
void AddEditorType( CDmeEditorType *pEditorType );
// Returns the editor info associated with an editor type
CDmeEditorAttributeInfo *GetAttributeInfo( CDmElement *pElement, const char *pAttributeName );
// Returns the editor info associated with a single entry in an attribute array
CDmeEditorAttributeInfo *GetAttributeArrayInfo( CDmElement *pElement, const char *pAttributeName );
private:
// Returns the editor type to use with an element
CDmeEditorType *GetEditorType( CDmElement *pElement );
};
#endif // DMEEDITORTYPEDICTIONARY_H
|