summaryrefslogtreecommitdiff
path: root/public/dme_controls/inotifyui.h
blob: c21f38dd243bdc21e2438054df100bd9b0aafb94 (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
133
134
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================

#ifndef INOTIFYUI_H
#define INOTIFYUI_H

#ifdef _WIN32
#pragma once
#endif

#include "tier1/utlvector.h"
#include "datamodel/idatamodel.h"


//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;


//-----------------------------------------------------------------------------
// Interface used to allow tools to deal with dynamic choice lists
//-----------------------------------------------------------------------------
struct IntChoice_t
{
	int m_nValue;
	const char *m_pChoiceString;
};

struct StringChoice_t
{
	const char *m_pValue;
	const char *m_pChoiceString;
};

struct ElementChoice_t
{
	ElementChoice_t() {}
	ElementChoice_t( CDmElement *pValue, const char *pChoiceString = NULL ) : m_pValue( pValue ), m_pChoiceString( pChoiceString ) {}
	CDmElement *m_pValue;
	const char *m_pChoiceString;
};

typedef CUtlVector<IntChoice_t> IntChoiceList_t;
typedef CUtlVector<StringChoice_t> StringChoiceList_t;
typedef CUtlVector<ElementChoice_t> ElementChoiceList_t;


//-----------------------------------------------------------------------------
// Interface used to call back out of the element properties panels
// to communicate with external systems
//-----------------------------------------------------------------------------
enum DmeControlsNotifySource_t
{
	NOTIFY_SOURCE_PROPERTIES_TREE = NOTIFY_SOURCE_FIRST_DME_CONTROL_SOURCE,
	NOTIFY_SOURCE_FILE_LIST_MANAGER,
	NOTIFY_SOURCE_PRESET_GROUP_EDITOR,
};


//-----------------------------------------------------------------------------
// Utility scope guards
//-----------------------------------------------------------------------------
DEFINE_SOURCE_UNDO_SCOPE_GUARD( ElementTree, NOTIFY_SOURCE_PROPERTIES_TREE );
DEFINE_SOURCE_NOTIFY_SCOPE_GUARD( ElementTree, NOTIFY_SOURCE_PROPERTIES_TREE );


class IElementPropertiesChoices
{
public:
	// For boolean choice lists. Return false if it's an unknown choice list type
	// Element, attribute specifies the attribute we're editing. 
	// bArray element is true if the attribute is an array attribute and we're editing one of its elements
	virtual bool GetBoolChoiceList( const char *pChoiceListType, CDmElement *pElement, 
		const char *pAttributeName, bool bArrayElement, const char *pChoiceStrings[2] ) = 0;

	// For integer choice lists. Return false if it's an unknown choice list type
	virtual bool GetIntChoiceList( const char *pChoiceListType, CDmElement *pElement, 
		const char *pAttributeName, bool bArrayElement, IntChoiceList_t &list ) = 0;

	// For string choice lists. Return false if it's an unknown choice list type
	virtual bool GetStringChoiceList( const char *pChoiceListType, CDmElement *pElement, 
		const char *pAttributeName, bool bArrayElement, StringChoiceList_t &list ) = 0;

	// For element choice lists. Return false if it's an unknown choice list type
	virtual bool GetElementChoiceList( const char *pChoiceListType, CDmElement *pElement, 
		const char *pAttributeName, bool bArrayElement, ElementChoiceList_t &list ) = 0;

	virtual const char *GetElementChoiceString( const char *pChoiceListType, CDmElement *pElement, 
		const char *pAttributeName, bool bArrayElement, CDmElement *pValue ) = 0;
};


//-----------------------------------------------------------------------------
// Default implementation of IElementPropertiesChoices
//-----------------------------------------------------------------------------
class CBaseElementPropertiesChoices : public IElementPropertiesChoices
{
public:
	virtual bool GetBoolChoiceList( const char *pChoiceListType, CDmElement *pElement, 
		const char *pAttributeName, bool bArrayElement, const char *pChoiceStrings[2] )
	{
		return false;
	}

	virtual bool GetIntChoiceList( const char *pChoiceListType, CDmElement *pElement, 
		const char *pAttributeName, bool bArrayElement, IntChoiceList_t &list )
	{
		return false;
	}

	virtual bool GetStringChoiceList( const char *pChoiceListType, CDmElement *pElement, 
		const char *pAttributeName, bool bArrayElement, StringChoiceList_t &list )
	{
		return false;
	}

	virtual bool GetElementChoiceList( const char *pChoiceListType, CDmElement *pElement, 
		const char *pAttributeName, bool bArrayElement, ElementChoiceList_t &list )
	{
		return false;
	}
	virtual const char *GetElementChoiceString( const char *pChoiceListType, CDmElement *pElement, 
		const char *pAttributeName, bool bArrayElement, CDmElement *pValue )
	{
		return NULL;
	}
};

#endif // INOTIFYUI_H