/
imap.h
116 lines (96 loc) · 2.99 KB
/
imap.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
#pragma once
#include "imodule.h"
#include "inode.h"
#include <sigc++/signal.h>
// Registry setting for suppressing the map load progress dialog
const char* const RKEY_MAP_SUPPRESS_LOAD_STATUS_DIALOG = "user/ui/map/suppressMapLoadDialog";
// Namespace forward declaration
class INamespace;
typedef std::shared_ptr<INamespace> INamespacePtr;
// see mapfile.h
class IMapFileChangeTracker;
// see ientity.h
class ITargetManager;
namespace scene
{
/**
* greebo: A root node is the top level element of a map.
* It also owns the namespace of the corresponding map.
*/
class IMapRootNode :
public virtual INode
{
public:
virtual ~IMapRootNode() {}
/**
* greebo: Returns the namespace of this root.
*/
virtual const INamespacePtr& getNamespace() = 0;
/**
* Returns the target manager keeping track of all
* the named targets in the map.
*/
virtual ITargetManager& getTargetManager() = 0;
/**
* The map root node is holding an implementation of the change tracker
* interface, to keep track of whether the map resource on disk is
* up to date or not.
*/
virtual IMapFileChangeTracker& getUndoChangeTracker() = 0;
};
typedef std::shared_ptr<IMapRootNode> IMapRootNodePtr;
} // namespace scene
/**
* greebo: This is the global interface to the currently
* active map file.
*/
class IMap :
public RegisterableModule
{
public:
enum MapEvent
{
MapLoading, // emitted just before a map is starting to be loaded
MapLoaded, // emitted when the current map is done loading
MapUnloading, // emitted just before a map is unloaded from memory
MapUnloaded, // emitted after a map has been unloaded
MapSaving, // emitted before a map is about to be saved (changes are possible)
MapSaved, // emitted right after a map has been saved
};
typedef sigc::signal<void, MapEvent> MapEventSignal;
/// Returns the signal that is emitted on various events
virtual MapEventSignal signal_mapEvent() const = 0;
/**
* Returns the worldspawn node of this map. The worldspawn
* node is NOT created if it doesn't exist yet, so this
* might return an empty pointer.
*/
virtual const scene::INodePtr& getWorldspawn() = 0;
/**
* This retrieves the worldspawn node of this map.
* If no worldspawn can be found, this creates one.
* Use this instead of getWorldSpawn() if your code needs
* a worldspawn to work with.
*/
virtual const scene::INodePtr& findOrInsertWorldspawn() = 0;
/**
* Returns the root node of this map or NULL if this is an empty map.
*/
virtual scene::IMapRootNodePtr getRoot() = 0;
/**
* Returns the name of the map.
*/
virtual std::string getMapName() const = 0;
};
typedef std::shared_ptr<IMap> IMapPtr;
const char* const MODULE_MAP("Map");
// Application-wide Accessor to the currently active map
inline IMap& GlobalMapModule() {
// Cache the reference locally
static IMap& _mapModule(
*std::static_pointer_cast<IMap>(
module::GlobalModuleRegistry().getModule(MODULE_MAP)
)
);
return _mapModule;
}