summaryrefslogtreecommitdiff
path: root/tools/foundry/foundrydoc.h
blob: 73a51445b8e3a54d7587397df407a3b34b23f8ae (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//
//===========================================================================//

#ifndef FOUNDRYDOC_H
#define FOUNDRYDOC_H

#ifdef _WIN32
#pragma once
#endif


#include "dme_controls/inotifyui.h"
#include "datamodel/dmehandle.h"


//-----------------------------------------------------------------------------
// Forward declarations 
//-----------------------------------------------------------------------------
class IFoundryDocCallback;
class CDmeVMFEntity;


//-----------------------------------------------------------------------------
// Contains all editable state 
//-----------------------------------------------------------------------------
class CFoundryDoc : public IDmNotify
{
public:
	CFoundryDoc( IFoundryDocCallback *pCallback );
	~CFoundryDoc();

	// Inherited from INotifyUI
	virtual void NotifyDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );

	// Sets/Gets the file name
	const char *GetBSPFileName();
	const char *GetVMFFileName();
	void SetVMFFileName( const char *pFileName );

	// Dirty bits (has it changed since the last time it was saved?)
	void	SetDirty( bool bDirty );
	bool	IsDirty() const;

	// Saves/loads from file
	bool	LoadFromFile( const char *pFileName );
	void	SaveToFile( );

	// Returns the root object
	CDmElement *GetRootObject();

	// Called when data changes (see INotifyUI for flags)
	void	OnDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );

	// Create a text block the engine can parse containing the entity data to spawn
	const char* GenerateEntityData( const char *pActualEntityData );

	// Returns the entity list
	CDmAttribute *GetEntityList();

	// Deletes an entity
	void DeleteEntity( CDmeVMFEntity *pEntity );

private:
	// Always copy the worldspawn and other entities that had data built into them by VBSP out
	void AddOriginalEntities( CUtlBuffer &entityBuf, const char *pActualEntityData );

	// Copy in other entities from the editable VMF
	void AddVMFEntities( CUtlBuffer &entityBuf, const char *pActualEntityData );

	IFoundryDocCallback *m_pCallback;
	CDmeHandle< CDmElement > m_hRoot;
	char m_pBSPFileName[512];
	char m_pVMFFileName[512];
	bool m_bDirty;
};


#endif // FOUNDRYDOC_H