forked from perilouswithadollarsign/cstrike15_src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapdoc.h
1178 lines (964 loc) · 41.8 KB
/
mapdoc.h
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//========================== Copyright (c) 1996-2009 Valve Corporation. All Rights Reserved. ===========================
//
//
//
//======================================================================================================================
#ifndef MAPDOC_H
#define MAPDOC_H
#ifdef _WIN32
#pragma once
#endif
#include "cordon.h"
#include "MapClass.h"
#include "Selection.h"
#include "MapEntity.h"
#include "GameConfig.h"
#include "filesystem.h"
#include "tier1/utlrbtree.h"
#include "tier1/utlstack.h"
class CToolManager;
class CMapDoc;
class CGameConfig;
class CHistory;
class CMapGroup;
class CMapView;
class CMapView3D;
class CMapView2D;
class IBSPLighting;
class CRender;
class CManifest;
class CFoW;
class CGridNav;
struct FindEntity_t;
struct FindGroup_t;
struct AddNonSelectedInfo_t;
struct AssetUsageInfo_t;
enum SelectionHandleMode_t;
enum MAPFORMAT;
enum ToolID_t;
enum
{
// hints what recently changed
MAPVIEW_UPDATE_OBJECTS = 0x001, // a world object has changed (pos, size etc)
MAPVIEW_UPDATE_ANIMATION = 0x002, // an object animation has been changed
MAPVIEW_UPDATE_COLOR = 0x004, // an object color has been changed
MAPVIEW_UPDATE_SELECTION = 0x008, // the current selection has changed
MAPVIEW_UPDATE_TOOL = 0x010, // the current tool has been changed
// what views should be updated
MAPVIEW_UPDATE_ONLY_2D = 0x020, // update only 2D views for some reason
MAPVIEW_UPDATE_ONLY_3D = 0x040, // update only 3D views for some reason
MAPVIEW_UPDATE_ONLY_LOGICAL = 0x080, // update only Logical views for some reason
MAPVIEW_OPTIONS_CHANGED = 0x100, // view options has been changed
MAPVIEW_UPDATE_VISGROUP_STATE = 0x200, // a visgroup was hidden or shown.
MAPVIEW_UPDATE_VISGROUP_ALL = 0x400, // a visgroup was created or deleted.
MAPVIEW_RENDER_NOW = 0x800, // bypass the main frame loop and render now
};
// Flags for view2dinfo.wflags
enum
{
VI_ZOOM = 0x01,
VI_CENTER = 0x02
};
// Display modes for instances
enum ShowInstance_t
{
INSTANCES_HIDE = 0, // instance contents are not displayed
INSTANCES_SHOW_TINTED, // instance contents are displayed with a yellowish tint
INSTANCES_SHOW_NORMAL // instance contents are displayed normally
};
enum VMFLoadFlags_t
{
VMF_LOAD_ACTIVATE = 0x01, // loading map should be activated
VMF_LOAD_IS_SUBMAP = 0x02, // loading map is part of an instance / manifest
};
enum SelectCordonFlags_t
{
SELECT_CORDON_FROM_TOOL = 0x01,
SELECT_CORDON_FROM_DIALOG = 0x02,
};
// File state
#define FILE_IS_READ_ONLY 0x01
#define FILE_IS_CHECKED_OUT 0x02
#define FILE_IS_VERSION_CONTROLLED 0x04
typedef struct
{
WORD wFlags;
float fZoom;
Vector ptCenter;
} VIEW2DINFO;
struct ExportDXFInfo_s
{
int nObject;
bool bVisOnly;
CMapWorld *pWorld;
FILE *fp;
};
typedef struct
{
int m_nHammerID;
CMapEntity *m_pEntityFound;
} FindEntityByHammerID_t;
//
// The doc holds a list of objects with dependents that changed since the last render. The list
// must be processed before rendering so that interobject dependencies are resolved.
//
struct NotifyListEntry_t
{
CUtlReference< CMapClass > pObject;
Notify_Dependent_t eNotifyType;
};
//
// To pass as hint to UpdateAllViews.
//
class UpdateBox : public CObject
{
public:
UpdateBox(void) { Objects = NULL; }
CMapObjectList *Objects;
BoundBox Box;
};
// this holds all of the data needed to visualize the level's portal file
struct portalfile_t
{
CString fileName;
int totalVerts;
CUtlVector<Vector> verts;
CUtlVector<int> vertCount;
};
struct UpdateVisibilityData_t
{
CMapDoc *pDoc;
bool bRadiusCullingEnabled;
Vector vecRadiusCullCenter;
float flRadiusCullDistSq;
};
// this is a structure to manage clipboards
class IHammerClipboard
{
protected:
IHammerClipboard(){}
virtual ~IHammerClipboard() {}
public:
static IHammerClipboard *CreateInstance();
public:
virtual void Destroy() = 0;
};
class CMapDoc : public CDocument
{
friend class CManifest;
protected:
DECLARE_DYNCREATE(CMapDoc)
public:
// attribs:
bool m_bSnapToGrid;
bool m_bShowGrid;
bool m_bShowLogicalGrid;
// pointfile stuff:
enum
{
PFPNext = 1,
PFPPrev = -1
};
int m_iCurPFPoint;
CUtlVector<Vector> m_PFPoints;
CString m_strLastPointFile;
portalfile_t *m_pPortalFile;
static inline CMapDoc *GetActiveMapDoc(void);
static void SetActiveMapDoc(CMapDoc *pDoc);
static void ActivateMapDoc( CMapDoc *pDoc );
static inline CManifest *GetManifest( void );
static inline int GetInLevelLoad( );
static void NoteEngineGotFocus();
private:
static CMapDoc *m_pMapDoc;
static CManifest *m_pManifest;
static int m_nInLevelLoad;
public:
CMapDoc(void);
virtual ~CMapDoc();
virtual void Initialize( void );
virtual bool IsManifest( void ) { return false; }
IBSPLighting *GetBSPLighting() { return m_pBSPLighting; }
CToolManager *GetTools() { return m_pToolManager; } // return tools working on this document
CSelection *GetSelection() { return m_pSelection; } // return current selection
void BeginShellSession(void);
void EndShellSession(void);
bool IsShellSessionActive(void);
inline int GetDocVersion(void);
inline void DecrementDocVersion(void);
//
// Interface to the map document. Functions for object creation, deletion, etc.
//
CMapEntity *CreateEntity(const char *pszClassName, float x, float y, float z);
bool DeleteEntity(const char *pszClassName, float x, float y, float z);
CMapEntity *FindEntity(const char *pszClassName, float x, float y, float z);
CMapEntity *FindEntityByName( const char *pszName, bool bVisiblesOnly );
CMapEntity *FindEntityByHammerID( int nHammerID );
bool FindEntitiesByKeyValue(CMapEntityList &Found, const char *szKey, const char *szValue, bool bVisiblesOnly);
bool FindEntitiesByName(CMapEntityList &Found, const char *szName, bool bVisiblesOnly);
bool FindEntitiesByClassName(CMapEntityList &Found, const char *szClassName, bool bVisiblesOnly);
bool FindEntitiesByNameOrClassName(CMapEntityList &Found, const char *pszName, bool bVisiblesOnly);
void GetUsedModels( CUtlVector<AssetUsageInfo_t> &usedModels );
bool CheckOut( );
bool CheckOutBsp( );
bool AddToVersionControl( );
bool SyncToHeadRevision( );
bool SyncBspToHeadRevision( );
bool Revert( );
void CheckFileStatus( );
bool GetBspFileStatus( unsigned char &FileStatus );
bool BspOkToCheckOut();
void GetBspPathFromVmfPath( CUtlString &bspPath );
bool IsReadOnly( ) { return m_bReadOnly; }
bool IsVersionControlled( ) { return m_bIsVersionControlled; }
bool IsCheckedOut( ) { return m_bCheckedOut; }
bool IsDefaultCheckIn( ) { return m_bDefaultCheckin; }
void ClearDefaultCheckIn( ) { m_bDefaultCheckin = false; }
virtual void Update(void);
virtual void SetModifiedFlag(BOOL bModified = TRUE);
void SetAutosaveFlag(BOOL bAutosave = TRUE);
BOOL NeedsAutosave();
BOOL IsAutosave();
CString *AutosavedFrom();
void AddReference( void );
void RemoveReference( void );
int GetReferenceCount( void ) { return m_nExternalReferenceCount; }
// Used to track down a potential crash.
bool AnyNotificationsForObject(CMapClass *pObject);
void SetAnimationTime( float time );
float GetAnimationTime( void ) { return m_flAnimationTime; }
bool IsAnimating( void ) { return m_bIsAnimating; }
// other stuff
float m_flCurrentTime;
void UpdateCurrentTime( void );
float GetTime( void ) { return m_flCurrentTime; }
void GotoPFPoint(int iDirection);
//
// Users can create one or more cordons, which are sets of rectangular boxes that define a volumetric
// visibility region. When a cordon is active, any objects outside the cordon volume are hidden.
//
// Cordons can be named for convenience. When the map is saved with a cordon active, brushes are
// added to the file to seal the cordon volume so that the map compiles without leaks.
//
bool Cordon_SetCordoning( bool bState );
inline bool Cordon_IsCordoning();
inline int Cordon_GetCount();
inline Cordon_t *Cordon_GetCordon( int nIndex );
void Cordon_GetIndices( Cordon_t *pCordon, BoundBox *pBox, int *pnCordon, int *pnBox );
void Cordon_GetBounds( Vector &mins, Vector &maxs );
void Cordon_Activate( int nIndex, bool bActive );
Cordon_t *Cordon_CreateNewCordon( const char *name = NULL, BoundBox **ppBox = NULL );
Cordon_t *Cordon_AddCordon( const char *szName );
BoundBox *Cordon_AddBox( Cordon_t *cordon );
void Cordon_RemoveCordon( Cordon_t *cordon );
void Cordon_RemoveBox( Cordon_t *cordon, BoundBox *box );
void Cordon_CombineCordons( Cordon_t *pSourceCordon, BoundBox *pSourceBox, Cordon_t *pDestCordon );
// We can only edit one of our cordon bounds at a time
Cordon_t *Cordon_GetSelectedCordonForEditing( BoundBox **pBox = NULL );
void Cordon_SelectCordonForEditing( Cordon_t *cordon, BoundBox *box, int nFlags = 0 ); // NULL cordon here means use current edit cordon
void Cordon_GetEditCordon( Vector &mins, Vector &maxs );
void Cordon_SetEditCordon( const Vector &mins, const Vector &maxs );
inline bool Cordon_IsEditCordon( int nCordon, int nBox );
CMapWorld *Cordon_CreateWorld();
CMapWorld *Cordon_AddCordonObjectsToWorld( CMapObjectList &CordonList );
ChunkFileResult_t Cordon_SaveVMF( CChunkFile *pFile, CSaveInfo *pSaveInfo );
CMapWorld *Cordon_AddTempObjectsToWorld( CMapObjectList &CordonList );
bool Cordon_IsCulledByCordon( CMapClass *pObject );
void Cordon_MoveUp( Cordon_t *cordon );
void Cordon_MoveDown( Cordon_t *cordon );
protected:
CUtlVector<Cordon_t> m_Cordons;
bool m_bIsCordoning;
int m_nEditCordon;
int m_nEditCordonBox;
public:
CMapView *GetActiveMapView();
CMapView3D *GetFirst3DView();
void Snap( Vector &pt, int nFlags = 0 );
inline bool IsSnapEnabled();
//
// Face selection for face editing.
//
void SelectFace(CMapSolid *pSolid, int iFace, int cmd);
void UpdateForApplicator(BOOL bApplicator);
void UpdateAnimation( void );
void DeleteObject(CMapClass *pObject);
void DeleteObjectList(CMapObjectList &List);
void InternalEnableLightPreview( bool bCustomFilename );
//
// Object selection:
//
bool SelectObject(CMapClass *pobj, int cmd = scSelect);
void SelectObjectList(const CMapObjectList *pList, int cmd = (scSelect|scClear|scSaveChanges) );
void SelectRegion( BoundBox *pBox, bool bInsideOnly, bool ResetSelection = true );
void SelectLogicalRegion( const Vector2D &vecMins, const Vector2D &vecMaxs, bool bInsideOnly);
// View centering.
void CenterViewsOnSelection();
void CenterViewsOn(const Vector &vec);
void CenterLogicalViewsOnSelection();
void CenterLogicalViewsOn(const Vector2D &vecLogical);
void Center2DViewsOnSelection();
void Center2DViewsOn(const Vector &vec);
void Center3DViewsOnSelection();
void Center3DViewsOn(const Vector &vPos);
void Set3DViewsPosAng( const Vector &vPos, const Vector &vAng );
void GetSelectedCenter(Vector &vCenter);
void ClearEntitySelection();
void GetBestVisiblePoint(Vector &ptOrg);
void GetBestVisibleBox( Vector &vecMins, Vector &vecMaxs );
bool PickTrace( const Vector &vPosition, const Vector &vDirection, Vector *pHitPosition );
bool DropTraceOnDisplacementsAndClips( const Vector &vPosition, Vector *pHitPosition, bool *pHitClip );
void Cut( IHammerClipboard *pClipboard );
void Copy( IHammerClipboard *pClipboard = NULL );
void Paste(CMapObjectList &Objects, CMapWorld *pSourceWorld, CMapWorld *pDestWorld, Vector vecOffset, QAngle vecRotate, CMapClass *pParent, bool bMakeEntityNamesUnique, const char *pszEntityNamePrefix);
void PasteInstance(CMapObjectList &Objects, CMapWorld *pSourceWorld, CMapWorld *pDestWorld, Vector vecOffset, QAngle vecRotate, CMapClass *pParent, bool bMakeEntityNamesUnique, const char *pszEntityNamePrefix);
void Paste( IHammerClipboard *pClipboard, CMapWorld *pDestWorld, Vector vecOffset, QAngle vecRotate, CMapClass *pParent, bool bMakeEntityNamesUnique, const char *pszEntityNamePrefix );
void Delete( void );
// FIXME: refactor these!
void CloneObjects(const CMapObjectList &Objects);
void NudgeObjects(const Vector &Delta, bool bClone);
void GetNudgeVector(const Vector& vHorz, const Vector& vVert, int nChar, bool bSnap, Vector &vecNudge);
void GetBestPastePoint(Vector &vecPasteOrigin, IHammerClipboard *pClipboard);
void UpdateStatusbar();
void UpdateStatusBarSnap();
void SetView2dInfo(VIEW2DINFO& vi);
void SetViewLogicalInfo(VIEW2DINFO& vi);
void SetActiveView(CMapView *pViewActivate);
void SetUndoActive(bool bActive);
void UpdateTitle(CView*);
void CountSolids();
void CountSolids2();
void ReplaceTextures(
LPCTSTR pszFind,
LPCTSTR pszReplace,
BOOL bEverything,
int iAction,
BOOL bHidden,
bool bRescaleTextureCoordinates);
void BatchReplaceTextures( FileHandle_t fp );
bool Is3DGridEnabled(void) { return(m_bShow3DGrid); }
ShowInstance_t GetShowInstance( void ) { return m_tShowInstance; }
void ReleaseVideoMemory( );
inline MAPFORMAT GetMapFormat(void);
inline CMapWorld *GetMapWorld(void);
inline CGameConfig *GetGame(void);
inline int GetGridSpacing(void) { return(max(m_nGridSpacing, 1)); }
inline CGridNav *GetGridNav(void);
inline CHistory *GetDocHistory(void);
inline int GetNextMapObjectID(void);
inline int GetNextLoadID(); // PORTAL2 SHIP: keep track of load order to preserve it on save so that maps can be diffed.
inline int GetNextNodeID(void);
inline void SetNextNodeID(int nID);
static int GetDocumentCount();
static CMapDoc *GetDocument(int index);
void SetMRU(CMapView2D *pView);
void RemoveMRU(CMapView2D *pView);
CUtlVector<CMapView2D*> MRU2DViews;
// if theres anything the document whats to show, do it in RenderDocument()
void RenderDocument(CRender *pRender);
void RenderAllViews(void);
BOOL SelectDocType(void);
BOOL SaveModified(void);
// Set edit prefab mode.
void EditPrefab3D(DWORD dwPrefabID);
//
// Call these when modifying the document contents.
//
virtual void AddObjectToWorld(CMapClass *pObject, CMapClass *pParent = NULL);
BOOL FindObject(CMapClass *pObject);
void RemoveObjectFromWorld(CMapClass *pMapClass, bool bNotifyChildren);
void RenderPreloadObject(CMapClass *pObject);
void UpdateObject(CMapClass *pMapClass);
void UpdateVisibilityAll(void);
void UpdateVisibility(CMapClass *pObject);
void NotifyDependents(CMapClass *pObject, Notify_Dependent_t eNotifyType);
// Radius culling
bool IsCulledBy3DCameraDistance( CMapClass *pObject, UpdateVisibilityData_t *pData );
//
// Morph tool.
//
void Morph_SelectObject(CMapSolid *pSolid, unsigned int uCmd);
void Morph_GetBounds(Vector &mins, Vector &maxs, bool bReset);
int Morph_GetObjectCount(void);
CSSolid *Morph_GetFirstObject(POSITION &pos);
CSSolid *Morph_GetNextObject(POSITION &pos);
//
inline bool IsDispSolidDrawMask( void ) { return m_bDispSolidDrawMask; }
inline void SetDispDrawWalkable( bool bValue ) { m_bDispDrawWalkable = bValue; }
inline bool IsDispDrawWalkable( void ) { return m_bDispDrawWalkable; }
inline bool IsDispDraw3D() { return m_bDispDraw3D; }
inline void SetDispDrawBuildable( bool bValue ) { m_bDispDrawBuildable = bValue; }
inline bool IsDispDrawBuildable( void ) { return m_bDispDrawBuildable; }
inline bool IsDispDrawRemovedVerts( void ) { return m_bDispDrawRemovedVerts; }
inline void SetDispDrawRemovedVerts( bool bValue ) { m_bDispDrawRemovedVerts = bValue; }
//
// List of VisGroups.
//
void ShowNewVisGroupsDialog(CMapObjectList &Objects, bool bUnselectObjects);
void VisGroups_CreateNamedVisGroup(CMapObjectList &Objects, const char *szName, bool bHide, bool bRemoveFromOtherVisGroups);
void VisGroups_AddObjectsToVisGroup(CMapObjectList &Objects, CVisGroup *pVisGroup, bool bHide, bool bRemoveFromOtherVisGroups);
CVisGroup *VisGroups_AddGroup(CVisGroup *pGroup);
bool VisGroups_ObjectCanBelongToVisGroup(CMapClass *pObject);
CVisGroup *VisGroups_AddGroup(LPCTSTR pszName, bool bAuto = false);
static BOOL VisGroups_CheckForGroupCallback(CMapClass *pObject, CVisGroup *pGroup);
int VisGroups_GetCount();
CVisGroup *VisGroups_GetVisGroup(int nIndex);
int VisGroups_GetRootCount();
CVisGroup *VisGroups_GetRootVisGroup(int nIndex);
CVisGroup *VisGroups_GroupForID(DWORD id);
CVisGroup *VisGroups_GroupForName( const char *pszName, bool bIsAuto );
void VisGroups_PurgeGroups();
void VisGroups_MoveUp(CVisGroup *pGroup);
void VisGroups_MoveDown(CVisGroup *pGroup);
void VisGroups_ShowVisGroup(CVisGroup *pGroup, bool bShow);
void VisGroups_UpdateAll();
void VisGroups_UpdateForObject(CMapClass *pObject);
void VisGroups_SetParent(CVisGroup *pVisGroup, CVisGroup *pNewParent);
bool VisGroups_CanMoveUp(CVisGroup *pGroup);
bool VisGroups_CanMoveDown(CVisGroup *pGroup);
void VisGroups_RemoveGroup(CVisGroup *pGroup);
void VisGroups_CombineGroups(CVisGroup *pFrom, CVisGroup *pTo);
bool VisGroups_LockUpdates( bool bLock );
void VisGroups_CheckMemberVisibility(CVisGroup *pGroup);
// Quick Hide
void QuickHide_HideObjects( void );
void QuickHide_HideUnselectedObjects( void );
void QuickHide_Unhide( void );
bool QuickHide_IsObjectHidden( CMapClass *pObject );
ChunkFileResult_t QuickHide_SaveVMF( CChunkFile *pFile, CSaveInfo *pSaveInfo );
CUtlVector< CMapClass* > m_QuickHideGroup;
CUtlVector< CMapClass* > m_QuickHideGroupedParents;
// Default logical placement for new entities
void GetDefaultNewLogicalPosition( Vector2D &vecPosition );
// Fog of War
CFoW *GetFoW( void ) { return m_pFoW; }
private:
void VisGroups_Validate();
void VisGroups_UpdateParents();
void VisGroups_UnlinkGroup(CVisGroup *pGroup);
void VisGroups_DoRemoveOrCombine(CVisGroup *pFrom, CVisGroup *pTo);
bool FindNotification(CMapClass *pObject, Notify_Dependent_t eNotifyType);
protected:
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMapDoc)
public:
virtual BOOL OnNewDocument();
virtual void DeleteContents();
virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
virtual void OnCloseDocument(void);
virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
//}}AFX_VIRTUAL
BOOL Serialize(std::fstream &file, BOOL fIsStoring, BOOL bRMF);
// Save a VMF file. saveFlags is a combination of SAVEFLAGS_ defines.
bool SaveVMF(const char *pszFileName, int saveFlags );
void PreloadDocument();
bool LoadVMF( const char *pszFileName, int LoadFlags = VMF_LOAD_ACTIVATE );
void PostloadDocument(const char *pszFileName);
inline bool IsLoading(void);
inline void SetInitialUpdate( void ) { m_bHasInitialUpdate = true; }
inline bool HasInitialUpdate( void ) { return m_bHasInitialUpdate; }
// manifest routines
void SetManifest( CManifest *pManifest );
void SetEditable( bool IsEditable ) { m_bIsEditable = IsEditable; }
bool IsEditable( void ) { return m_bIsEditable; }
bool IsSelectionEditable( void );
bool CreateNewManifest( void );
CMapWorld *GetCurrentWorld( void );
int GetClipboardCount( void );
void ManifestPaste( CMapWorld *pDestWorld, Vector vecOffset, QAngle vecRotate, CMapClass *pParent, bool bMakeEntityNamesUnique, const char *pszEntityNamePrefix );
virtual void UpdateInstanceMap( CMapDoc *pInstanceMapDoc );
bool CollapseInstance( CMapEntity *pEntity, int &InstanceCount );
void CollapseInstances( bool bOnlySelected );
void CollapseInstancesRecursive( bool bOnlySelected );
void PopulateInstanceParms_r( CMapEntity *pEntity, const CMapObjectList *pChildren, CUtlVector< CString > &ParmList );
void PopulateInstanceParms( CMapEntity *pEntity );
void PopulateInstance( CMapEntity *pEntity );
void InstanceMoved( void );
void ShowWindow( bool bIsVisible );
bool IsVisible( void );
void BuildAllDetailObjects();
void ExpandObjectKeywords(CMapClass *pObject, CMapWorld *pWorld);
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
void UpdateAllCameras(const Vector *vecViewPos, const Vector *vecLookAt, const float *fZoom);
void UpdateAllViews(int nFlags, UpdateBox *ub = NULL );
void SetSmoothingGroupVisual( int iGroup ) { m_SmoothingGroupVisual = iGroup; }
int GetSmoothingGroupVisual( void ) { return m_SmoothingGroupVisual; }
void AddToAutoVisGroup( CMapClass *pObject );
void AddToAutoVisGroup( CMapClass *pObject, const char *pAutoVisGroup );
void AddAutoVisGroup( const char *pAutoVisGroup, const char *pParentName );
void AddChildGroupToAutoVisGroup( CMapClass *pObject, const char *pAutoVisGroup, const char *pParentName );
void RemoveFromAutoVisGroups( CMapClass *pObject );
void AddToFGDAutoVisGroups( CMapClass *pObject );
// Builds a list of all objects which are connected to outputs of pObj
void BuildCascadingSelectionList( CMapClass *pObj, CUtlRBTree< CMapClass*, unsigned short > &list, bool bRecursive );
void Public_SaveMap() { OnFileSave(); }
protected:
void AssignAllToAutoVisGroups();
CVisGroup *GetRootAutoVisGroup();
// Tools:
CToolManager *m_pToolManager;
int m_nGridSpacing;
bool m_bDispSolidDrawMask;
bool m_bDispDrawWalkable;
bool m_bDispDraw3D;
bool m_bDispDrawBuildable;
bool m_bDispDrawRemovedVerts;
bool m_bHasInitialUpdate;
bool m_bLoading; // Set to true while we are being loaded from VMF.
bool m_bReadOnly;
bool m_bIsVersionControlled;
bool m_bCheckedOut;
bool m_bDefaultCheckin;
bool m_bDeferredSave; // Used when deferring a re-save of the map while loading is occurring
static BOOL GetBrushNumberCallback(CMapClass *pObject, void *pFindInfo);
//
// Serialization.
//
ChunkFileResult_t SaveVersionInfoVMF(CChunkFile *pFile, bool bIsAutosave = false);
ChunkFileResult_t VisGroups_SaveVMF(CChunkFile *pFile, CSaveInfo *pSaveInfo);
ChunkFileResult_t SaveViewSettingsVMF(CChunkFile *pFile, CSaveInfo *pSaveInfo);
static bool HandleLoadError(CChunkFile *pFile, const char *szChunkName, ChunkFileResult_t eError, CMapDoc *pDoc);
// Cordon loading.
static ChunkFileResult_t LoadCordonsCallback( CChunkFile *pFile, CMapDoc *pDoc );
static ChunkFileResult_t LoadCordonsKeyCallback( const char *pszKey, const char *pszValue, CMapDoc *pDoc );
static ChunkFileResult_t LoadCordonCallback(CChunkFile *pFile, CMapDoc *pDoc);
static ChunkFileResult_t LoadCordonKeyCallback(const char *pszKey, const char *pszValue, Cordon_t *pCordon);
static ChunkFileResult_t LoadCordonBoxCallback( CChunkFile *pFile, Cordon_t *pCordon );
static ChunkFileResult_t LoadCordonBoxKeyCallback(const char *pszKey, const char *pszValue, BoundBox *pBox );
static ChunkFileResult_t LoadCordonCallback_Legacy( CChunkFile *pFile, CMapDoc *pDoc );
static ChunkFileResult_t LoadCordonKeyCallback_Legacy( const char *pszKey, const char *pszValue, CMapDoc *pDoc );
static ChunkFileResult_t LoadEntityCallback(CChunkFile *pFile, CMapDoc *pDoc);
static ChunkFileResult_t LoadHiddenCallback(CChunkFile *pFile, CMapDoc *pDoc);
static ChunkFileResult_t LoadGroupKeyCallback(const char *szKey, const char *szValue, CMapGroup *pGroup);
static ChunkFileResult_t LoadVersionInfoCallback(CChunkFile *pFile, CMapDoc *pDoc);
static ChunkFileResult_t LoadVersionInfoKeyCallback(const char *szKey, const char *szValue, CMapDoc *pDoc);
static ChunkFileResult_t LoadAutosaveCallback(CChunkFile *pFile, CMapDoc *pDoc);
static ChunkFileResult_t LoadAutosaveKeyCallback(const char *szKey, const char *szValue, CMapDoc *pDoc);
static ChunkFileResult_t LoadWorldCallback(CChunkFile *pFile, CMapDoc *pDoc);
static ChunkFileResult_t LoadViewSettingsCallback(CChunkFile *pFile, CMapDoc *pDoc);
static ChunkFileResult_t LoadViewSettingsKeyCallback(const char *szKey, const char *szValue, CMapDoc *pDoc);
//
// Search functions.
//
static BOOL FindEntityByHammerIDCallback( CMapClass *pObject, FindEntityByHammerID_t *pFindInfo );
static BOOL FindEntityCallback(CMapClass *pObject, FindEntity_t *pFindInfo);
static BOOL FindGroupCallback(CMapGroup *pGroup, FindGroup_t *pFindInfo);
void AssignToVisGroups(void);
void AssignToGroups(void);
void RemoveEmptyGroups(void);
void CountGUIDs(void);
void InitUpdateVisibilityData( UpdateVisibilityData_t &data );
bool ShouldObjectBeVisible( CMapClass *pObject, UpdateVisibilityData_t *pData );
static BOOL UpdateVisibilityCallback( CMapClass *pObject, UpdateVisibilityData_t *pData );
static BOOL ForceVisibilityCallback(CMapClass *pObject, bool bVisibility);
bool GetChildrenToHide(CMapClass *pObject, bool bSelected, CMapObjectList &List);
//
// Interobject dependency notification.
//
void ProcessNotifyList();
void DispatchNotifyDependents(CUtlReference< CMapClass > pObject, Notify_Dependent_t eNotifyType);
CUtlVector< NotifyListEntry_t* > m_NotifyList;
CMapWorld *m_pWorld; // The world that this document represents.
CMapObjectList m_UpdateList; // List of objects that have changed since the last call to Update.
CString m_strLastExportFileName; // The full path that we last exported this document to.
int m_nDocVersion; // A number that increments every time the doc is modified after being saved.
BOOL m_bNeedsAutosave; // True if the document has been changed and needs autosaved.
BOOL m_bIsAutosave;
CString m_strAutosavedFrom;
// Undo/Redo system.
CHistory *m_pUndo;
CHistory *m_pRedo;
CSelection *m_pSelection; // object selection list
int m_nNextMapObjectID; // The ID that will be assigned to the next CMapClass object in this document.
int m_nNextLoadID; // PORTAL2 SHIP: keep track of load order to preserve it on save so that maps can be diffed.
int m_nNextNodeID; // The ID that will be assigned to the next "info_node_xxx" object created in this document.
// Editing prefabs data.
DWORD m_dwPrefabID;
DWORD m_dwPrefabLibraryID;
BOOL m_bEditingPrefab;
bool m_bPrefab; // true if this document IS a prefab, false if not.
// Game configuration.
CGameConfig *m_pGame;
bool m_bShow3DGrid; // Whether to render a grid in the 3D views.
bool m_bHideItems; // Whether to render point entities in all views.
int m_nExternalReferenceCount; // Indicates how many external references ( instances ) are pointing to this map
ShowInstance_t m_tShowInstance; // Indicates how instance contents should be displayed
CManifest *m_pManifestOwner;
bool m_bIsEditable;
bool m_bCollapsingInstances;
//
// Animation.
//
float m_flAnimationTime; // Current time in the animation
bool m_bIsAnimating;
IBSPLighting *m_pBSPLighting;
//
// Visgroups.
//
CUtlVector<CVisGroup *> *m_VisGroups;
CUtlVector<CVisGroup *> *m_RootVisGroups;
bool m_bVisGroupUpdatesLocked;
int m_SmoothingGroupVisual;
int m_nLogicalPositionCount;
CFoW *m_pFoW;
CGridNav *m_pGridNav;
//
// Expands %i keyword in prefab targetnames to generate unique targetnames for this map.
//
bool ExpandTargetNameKeywords(char *szNewTargetName, const char *szOldTargetName, CMapWorld *pWorld);
bool DoExpandKeywords(CMapClass *pObject, CMapWorld *pWorld, char *szOldKeyword, char *szNewKeyword);
// Renames all named entities in pRoot
void RenameEntities( CMapClass *pRoot, CMapWorld *pWorld, bool bMakeUnique, const char *pszPrefix );
void CenterOriginsRecursive(CMapClass *pObject);
void SnapObjectsRecursive(CMapClass *pObject);
// Add all entities connected to all entities in the selection list recursively
void AddConnectedNodes( CMapClass *pClass, CUtlRBTree< CMapClass*, unsigned short >& list );
void DropTraceRecurse( CCullTreeNode *pCullTreeNode, const Vector &vTraceStart, CUtlVector< CMapSolid* > &objects );
void DropTraceObjectRecurse( CMapClass *pObject, const Vector &vTraceStart, CUtlVector< CMapSolid* > &objects );
//{{AFX_MSG(CMapDoc)
afx_msg void OnEditDelete();
afx_msg void OnMapSnaptogrid();
afx_msg void OnMapEntityGallery();
afx_msg void OnUpdateMapSnaptogrid(CCmdUI* pCmdUI);
afx_msg void OnEditApplytexture();
afx_msg void OnToolsSubtractselection();
afx_msg void OnToolsCenterOrigins();
afx_msg void OnEnableLightPreview();
afx_msg void OnEnableLightPreviewCustomFilename();
afx_msg void OnDisableLightPreview();
afx_msg void OnToggleLightPreview();
afx_msg void OnUpdateLightPreview();
afx_msg void OnAbortLightCalculation();
afx_msg void OnEditCopy();
afx_msg void OnEditPaste();
afx_msg void OnUpdateEditSelection(CCmdUI *pCmdUI);
afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI);
afx_msg void OnEditCut();
afx_msg void OnEditReplace();
afx_msg void OnToolsGroup();
afx_msg void OnToolsUngroup();
afx_msg void OnUpdateViewGrid(CCmdUI* pCmdUI);
afx_msg void OnUpdateViewLogicalGrid(CCmdUI* pCmdUI);
afx_msg void OnEditSelectall();
afx_msg void OnFileSaveAs();
afx_msg void OnFileSave();
afx_msg void OnMapGridlower();
afx_msg void OnMapGridhigher();
afx_msg void OnEditToworld();
afx_msg void OnEditToWorld();
afx_msg void OnFileExport();
afx_msg void OnFileExportAgain();
afx_msg void OnEditMapproperties();
afx_msg void OnFileConvertWAD();
afx_msg void OnUpdateFileConvertWAD(CCmdUI* pCmdUI);
afx_msg void OnFileRunmap();
afx_msg void OnToolsHideitems();
afx_msg void OnViewHideUnconnectedEntities();
afx_msg void OnUpdateViewHideUnconnectedEntities(CCmdUI* pCmdUI);
afx_msg void OnUpdateToolsSubtractselection(CCmdUI* pCmdUI);
afx_msg void OnUpdateToolsHideitems(CCmdUI* pCmdUI);
afx_msg void OnUpdateEditDelete(CCmdUI* pCmdUI);
afx_msg void OnUpdateEditFunction(CCmdUI* pCmdUI);
afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI);
afx_msg void OnUpdateEditMapproperties(CCmdUI* pCmdUI);
afx_msg void OnMapInformation();
// View menu
afx_msg void OnViewGrid();
afx_msg void OnViewLogicalGrid();
afx_msg void OnViewCenterOnSelection();
afx_msg void OnViewCenter3DViewsOnSelection();
afx_msg BOOL OnViewHideObjects(UINT nID);
afx_msg void OnQuickHide_HideObjects();
afx_msg void OnQuickHide_HideUnselectedObjects();
afx_msg void OnQuickHide_Unhide();
afx_msg void OnQuickHide_UpdateUnHide(CCmdUI *pCmdUI);
afx_msg void OnViewDotACamera();
afx_msg void OnQuickHide_CreateVisGroupFromHidden();
afx_msg void OnQuickHide_UpdateCreateVisGroupFromHidden(CCmdUI *pCmdUI);
afx_msg void OnViewShowconnections();
afx_msg void OnViewGotoBrush(void);
afx_msg void OnViewGotoCoords(void);
afx_msg void OnViewShowHelpers();
afx_msg void OnViewShowModelsIn2D();
afx_msg void OnViewPreviewModelFade();
afx_msg void OnViewPreviewGridNav();
afx_msg void OnCollisionWireframe();
afx_msg void OnShowDetailObjects();
afx_msg void OnShowNoDrawBrushes();
afx_msg void OnRadiusCulling();
afx_msg void OnUpdateRadiusCulling(CCmdUI *pCmdUI);
afx_msg void OnToolsHollow();
afx_msg void OnEditPastespecial();
afx_msg void OnUpdateEditPastespecial(CCmdUI* pCmdUI);
afx_msg void OnEditSelnext();
afx_msg void OnEditSelprev();
afx_msg void OnEditSelnextCascading();
afx_msg void OnEditSelprevCascading();
afx_msg void OnLogicalMoveBlock();
afx_msg void OnLogicalSelectAllCascading();
afx_msg void OnLogicalSelectAllConnected();
afx_msg void OnLogicalobjectLayoutgeometric();
afx_msg void OnLogicalobjectLayoutdefault();
afx_msg void OnLogicalobjectLayoutlogical();
afx_msg void OnMapCheck();
afx_msg void OnUpdateViewDotACamera(CCmdUI* pCmdUI);
afx_msg void OnUpdateViewShowconnections(CCmdUI* pCmdUI);
afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
afx_msg void OnToolsCreateprefab();
afx_msg void OnInsertprefabOriginal();
afx_msg void OnEditReplacetex();
afx_msg void OnToolsSnapselectedtogrid();
afx_msg void OnToolsSnapSelectedToGridIndividually();
afx_msg void OnUpdateToolsSplitface(CCmdUI* pCmdUI);
afx_msg void OnToolsSplitface();
afx_msg void OnToolsTransform();
afx_msg void OnToolsToggletexlock();
afx_msg void OnUpdateToolsToggletexlock(CCmdUI* pCmdUI);
afx_msg void OnToolsToggletexlockScale();
afx_msg void OnUpdateToolsToggletexlockScale(CCmdUI* pCmdUI);
afx_msg void OnToolsTextureAlignment(void);
afx_msg void OnUpdateToolsTextureAlignment(CCmdUI *pCmdUI);
afx_msg void OnToggleCordon();
afx_msg void OnUpdateToggleCordon(CCmdUI* pCmdUI);
afx_msg void OnUpdateShowNoDrawBrushes(CCmdUI* pCmdUI);
afx_msg void OnEditCordon();
afx_msg void OnUpdateEditCordon(CCmdUI* pCmdUI);
afx_msg void OnUpdateViewHideUnselectedObjects(CCmdUI* pCmdUI);
afx_msg void OnToggleGroupignore();
afx_msg void OnUpdateToggleGroupignore(CCmdUI* pCmdUI);
afx_msg void OnVscaleToggle();
afx_msg void OnMapEntityreport();
afx_msg void OnToggleSelectbyhandle();
afx_msg void OnUpdateToggleSelectbyhandle(CCmdUI* pCmdUI);
afx_msg void OnToggleInfiniteselect();
afx_msg void OnUpdateToggleInfiniteselect(CCmdUI* pCmdUI);
afx_msg void OnFileExporttodxf();
afx_msg void OnUpdateEditApplytexture(CCmdUI* pCmdUI);
afx_msg void OnMapLoadpointfile();
afx_msg void OnMapUnloadpointfile();
afx_msg void OnMapLoadportalfile();
afx_msg void OnMapUnloadportalfile();
afx_msg void OnUpdate3dViewUI(CCmdUI* pCmdUI);
afx_msg BOOL OnChange3dViewType(UINT nID);
afx_msg void OnEditToEntity();
afx_msg BOOL OnUndoRedo(UINT nID);
afx_msg void OnUpdateUndoRedo(CCmdUI* pCmdUI);
afx_msg void OnChangeVertexscale();
afx_msg void OnUpdateGroupEditFunction(CCmdUI* pCmdUI);
afx_msg void OnUpdateFileExport(CCmdUI *pCmdUI);
afx_msg void OnEditClearselection();
afx_msg void OnUpdateToggle3DGrid(CCmdUI* pCmdUI);
afx_msg void OnMapShowSelectedBrushNumber();
afx_msg void OnEditFindEntities(void);
afx_msg void OnToolsHideEntityNames(void);
afx_msg void OnUpdateToolsHideEntityNames(CCmdUI *pCmdUI);
afx_msg void OnToggleDispSolidMask( void );
afx_msg void OnUpdateToggleSolidMask(CCmdUI* pCmdUI);
afx_msg void OnToggleDispDrawWalkable( void );
afx_msg void OnUpdateToggleDispDrawWalkable(CCmdUI* pCmdUI);
afx_msg void OnToggleDispDraw3D( void );
afx_msg void OnUpdateToggleDispDraw3D(CCmdUI* pCmdUI);
afx_msg void OnToggleDispDrawBuildable( void );
afx_msg void OnUpdateToggleDispDrawBuildable(CCmdUI* pCmdUI);
afx_msg void OnToggleDispDrawRemovedVerts( void );
afx_msg void OnUpdateToggleDispDrawRemovedVerts(CCmdUI* pCmdUI);
afx_msg void OnUpdateViewShowHelpers(CCmdUI *pCmdUI);
afx_msg void OnUpdateViewShowModelsIn2D(CCmdUI *pCmdUI);
afx_msg void OnUpdateViewPreviewModelFade(CCmdUI *pCmdUI);
afx_msg void OnUpdateViewPreviewGridNav(CCmdUI *pCmdUI);
afx_msg void OnUpdateCollisionWireframe(CCmdUI *pCmdUI);
afx_msg void OnUpdateShowDetailObjects(CCmdUI *pCmdUI);
afx_msg void OnMapDiff();
afx_msg void OnToolsInstancesHide(void);
afx_msg void OnUpdateToolsInstancesHide(CCmdUI *pCmdUI);
afx_msg void OnToolsInstancesShowTinted(void);
afx_msg void OnUpdateToolsInstancesShowTinted(CCmdUI *pCmdUI);
afx_msg void OnToolsInstancesShowNormal(void);
afx_msg void OnUpdateToolsInstancesShowNormal(CCmdUI *pCmdUI);
afx_msg void OnInstancesHideAll( void );
afx_msg void OnInstancesShowAll( void );
afx_msg void OnFileVersionControlAdd( void );
afx_msg void OnUpdateVersionControlAdd(CCmdUI *pCmdUI);
afx_msg void OnFileVersionControlCheckOut( void );
afx_msg void OnFileVersionControlCheckOutBsp( void );
afx_msg void OnUpdateVersionControlCheckOut(CCmdUI *pCmdUI);
afx_msg void OnUpdateVersionControlCheckOutBsp(CCmdUI *pCmdUI);
afx_msg void OnFileVersionControlCheckIn( void );
afx_msg void OnUpdateVersionControlCheckIn(CCmdUI *pCmdUI);
afx_msg void OnFileVersionControlCheckInAll( void );
afx_msg void OnUpdateVersionControlCheckInAll(CCmdUI *pCmdUI);
afx_msg void OnFileVersionControlOverview( void );
afx_msg void OnInstancingCreatemanifest();
afx_msg void OnUpdateInstancingCreatemanifest( CCmdUI *pCmdUI );
afx_msg void OnInstancingCheckinAll();
afx_msg void OnUpdateInstancingCheckinAll( CCmdUI *pCmdUI );
afx_msg void OnInstancingCheckOutManifest();
afx_msg void OnUpdateInstancingCheckOutManifest( CCmdUI *pCmdUI );
afx_msg void OnInstancingAddManifest();
afx_msg void OnUpdateInstancingAddManifest( CCmdUI *pCmdUI );
afx_msg void OnInstancesCollapseAll();
afx_msg void OnInstancesCollapseSelection();
afx_msg void OnInstancesCollapseAllRecursive();
afx_msg void OnInstancesCollapseSelectionRecursive();
afx_msg void OnUpdateToolsSprinkle( CCmdUI *pCmdUI );
afx_msg void OnToolsSprinkle();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnNewCordon();
afx_msg void OnToggle3DGrid();
};
//-----------------------------------------------------------------------------
// Purpose:
// Output : inline void
//-----------------------------------------------------------------------------
void CMapDoc::DecrementDocVersion(void)
{
if (m_nDocVersion > 0)
{
m_nDocVersion--;
}
}
//-----------------------------------------------------------------------------