summaryrefslogtreecommitdiff
path: root/tools/commedit/dmecommentarynodeentity.h
blob: 00c7aac0bdcce63b3e37f75c7430070e6555d6ed (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Represents an entity in a VMF
//
//=============================================================================

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

#include "toolutils/dmemdlrenderable.h"
#include "datamodel/dmelement.h"
#include "toolframework/itoolentity.h"
#include "materialsystem/MaterialSystemUtil.h"


//-----------------------------------------------------------------------------
// Represents an editable entity; draws its helpers
//-----------------------------------------------------------------------------
class CDmeCommentaryNodeEntity : public CDmeMdlRenderable<CDmElement>
{
	DEFINE_ELEMENT( CDmeCommentaryNodeEntity, CDmeMdlRenderable<CDmElement> );

public:
	// Inherited from CDmElement
	virtual	void	OnAttributeChanged( CDmAttribute *pAttribute );

public:
	// Inherited from DmeRenderable
	virtual const Vector &GetRenderOrigin( void );
	virtual const QAngle &GetRenderAngles( void );
	virtual int		DrawModel( int flags );
	virtual void	GetRenderBounds( Vector& mins, Vector& maxs );
	virtual bool	IsTransparent( void ); 

public:
	int GetEntityId() const;

	const char *GetClassName() const;
	const char *GetTargetName() const;

	bool IsPlaceholder() const;

	// Entity Key iteration
	CDmAttribute *FirstEntityKey();
	CDmAttribute *NextEntityKey( CDmAttribute *pEntityKey );

	// Attach/detach from an engine entity with the same editor index
	void AttachToEngineEntity( HTOOLHANDLE hToolHandle );

	void SetRenderOrigin( const Vector &vecOrigin );
	void SetRenderAngles( const QAngle &angles );

	void MarkDirty( bool bDirty = true );

private:
	bool IsEntityKey( CDmAttribute *pEntityKey );

	// Draws the helper for the entity
	void DrawSprite( IMaterial *pMaterial );

	CDmaVar<Vector> m_vecLocalOrigin;
	CDmaVar<Vector> m_vecLocalAngles;

	CDmaString m_ClassName;
	CDmaString m_TargetName;
	CDmaVar<bool> m_bIsPlaceholder;

	bool m_bInfoTarget;
	bool m_bIsDirty;

	// The entity it's connected to in the engine
	HTOOLHANDLE	m_hEngineEntity;

	CMaterialReference m_SelectedInfoTarget;
	CMaterialReference m_InfoTargetSprite;
};


//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
inline const char *CDmeCommentaryNodeEntity::GetClassName() const
{
	return m_ClassName;
}

inline const char *CDmeCommentaryNodeEntity::GetTargetName() const
{
	return m_TargetName;
}

inline bool CDmeCommentaryNodeEntity::IsPlaceholder() const
{
	return m_bIsPlaceholder;
}

#endif // DMEVMFENTITY_H