/
imap.h
195 lines (154 loc) · 5.41 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
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
#pragma once
#include "imodule.h"
#include "inode.h"
#include "imapexporter.h"
#include "imapformat.h"
#include "ikeyvaluestore.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";
// Whether to load the most recently used map on app startup
const char* const RKEY_LOAD_LAST_MAP = "user/ui/map/loadLastMap";
const char* const LOAD_PREFAB_AT_CMD = "LoadPrefabAt";
// Namespace forward declaration
class INamespace;
typedef std::shared_ptr<INamespace> INamespacePtr;
// see mapfile.h
class IMapFileChangeTracker;
// see ientity.h
class ITargetManager;
// see ilayer.h
class ILayerManager;
namespace selection
{
class ISelectionSetManager;
class ISelectionGroupManager;
}
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 IKeyValueStore
{
public:
virtual ~IMapRootNode() {}
virtual void setName(const std::string& name) = 0;
/**
* greebo: Returns the namespace of this root.
*/
virtual const INamespacePtr& getNamespace() = 0;
/**
* Access the selection group manager of this hierarchy.
*/
virtual selection::ISelectionGroupManager& getSelectionGroupManager() = 0;
/**
* Gives access to the selectionset manager in this scene.
*/
virtual selection::ISelectionSetManager& getSelectionSetManager() = 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;
/**
* Provides methods to create and assign layers in this map.
*/
virtual ILayerManager& getLayerManager() = 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;
enum class EditMode
{
Normal,
Merge,
};
// The currently active edit mode
virtual EditMode getEditMode() = 0;
// Change the edit mode to the specified value
virtual void setEditMode(EditMode mode) = 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;
// Returns true if this map is still unnamed (never saved yet)
virtual bool isUnnamed() const = 0;
/**
* Signal fired when the name of this map is changing.
*/
virtual sigc::signal<void>& signal_mapNameChanged() = 0;
// Returns true if the map has unsaved changes.
virtual bool isModified() const = 0;
// Sets the modified status of this map
virtual void setModified(bool modifiedFlag) = 0;
/**
* Signal fired when the modified status of this map has changed.
*/
virtual sigc::signal<void>& signal_modifiedChanged() = 0;
// Caution: this is upposed to be called on startup, since it doesn't ask the user
// whether to save the current map. Use the "NewMap" command for regular purposes.
virtual void createNewMap() = 0;
// Create a MapExporter instance which can be used to export a scene,
// including the necessary preparation, info-file handling, etc.
// This is mainly a service method for external code, like the gameconnection.
virtual map::IMapExporter::Ptr createMapExporter(map::IMapWriter& writer,
const scene::IMapRootNodePtr& root, std::ostream& mapStream) = 0;
// Exports the current selection to the given output stream, using the map's format
virtual void exportSelected(std::ostream& out) = 0;
// Exports the current selection to the given output stream, using the given map format
virtual void exportSelected(std::ostream& out, const map::MapFormatPtr& format) = 0;
};
typedef std::shared_ptr<IMap> IMapPtr;
const char* const MODULE_MAP("Map");
// Application-wide Accessor to the currently active map
inline IMap& GlobalMapModule()
{
static module::InstanceReference<IMap> _reference(MODULE_MAP);
return _reference;
}