]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/map.h
q3map2: fix prt loading for vis computation when using -prtfile
[xonotic/netradiant.git] / radiant / map.h
1 /*
2    Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3    For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22 #if !defined( INCLUDED_MAP_H )
23 #define INCLUDED_MAP_H
24
25 #include "iscenegraph.h"
26 #include "generic/callback.h"
27 #include "signal/signalfwd.h"
28 #include "string/stringfwd.h"
29
30 class Map;
31
32 extern Map g_map;
33
34 class MapFormat;
35
36 void Map_addValidCallback(Map &map, const SignalHandler &handler);
37
38 bool Map_Valid(const Map &map);
39
40 class DeferredDraw {
41     Callback<void()> m_draw;
42     bool m_defer;
43     bool m_deferred;
44 public:
45     DeferredDraw(const Callback<void()> &draw) : m_draw(draw), m_defer(false), m_deferred(false)
46     {
47     }
48
49     void defer()
50     {
51         m_defer = true;
52     }
53
54     void draw()
55     {
56         if (m_defer) {
57             m_deferred = true;
58         } else {
59             m_draw();
60         }
61     }
62
63     void flush()
64     {
65         if (m_defer && m_deferred) {
66             m_draw();
67         }
68         m_deferred = false;
69         m_defer = false;
70     }
71 };
72
73 inline void DeferredDraw_onMapValidChanged(DeferredDraw &self)
74 {
75     if (Map_Valid(g_map)) {
76         self.flush();
77     } else {
78         self.defer();
79     }
80 }
81
82 typedef ReferenceCaller<DeferredDraw, void(), DeferredDraw_onMapValidChanged> DeferredDrawOnMapValidChangedCaller;
83
84
85 const char *Map_Name(const Map &map);
86
87 const MapFormat &Map_getFormat(const Map &map);
88
89 bool Map_Unnamed(const Map &map);
90
91
92 namespace scene {
93     class Node;
94
95     class Graph;
96 }
97
98 scene::Node *Map_GetWorldspawn(const Map &map);
99
100 scene::Node *Map_FindWorldspawn(Map &map);
101
102 scene::Node &Map_FindOrInsertWorldspawn(Map &map);
103
104 template<typename Element>
105 class BasicVector3;
106
107 typedef BasicVector3<float> Vector3;
108
109 extern Vector3 region_mins, region_maxs;
110 extern bool region_active;
111
112 // used to be #defines, multiple engine support suggests we should go towards dynamic
113 extern float g_MaxWorldCoord;
114 extern float g_MinWorldCoord;
115
116 void Map_LoadFile(const char *filename);
117
118 bool Map_SaveFile(const char *filename);
119
120 void Map_New();
121
122 void Map_Free();
123
124 void Map_RegionOff();
125
126 bool Map_SaveRegion(const char *filename);
127
128 class TextInputStream;
129
130 class TextOutputStream;
131
132 void Map_ImportSelected(TextInputStream &in, const MapFormat &format);
133
134 void Map_ExportSelected(TextOutputStream &out, const MapFormat &format);
135
136 bool Map_Modified(const Map &map);
137
138 void Map_SetModified(Map &map, bool modified);
139
140 bool Map_Save();
141
142 bool Map_SaveAs();
143
144 scene::Node &Node_Clone(scene::Node &node);
145
146 void DoMapInfo();
147
148 void Scene_parentSelectedBrushesToEntity(scene::Graph &graph, scene::Node &parent);
149
150 std::size_t Scene_countSelectedBrushes(scene::Graph &graph);
151
152 void Scene_parentSelected();
153
154 void OnUndoSizeChanged();
155
156 void NewMap();
157
158 void OpenMap();
159
160 void ImportMap();
161
162 void SaveMapAs();
163
164 void SaveMap();
165
166 void ExportMap();
167
168 void SaveRegion();
169
170
171 void Map_Traverse(scene::Node &root, const scene::Traversable::Walker &walker);
172
173
174 void SelectBrush(int entitynum, int brushnum);
175
176 extern CopiedString g_strLastMap;
177 extern bool g_bLoadLastMap;
178
179 void Map_Construct();
180
181 void Map_Destroy();
182
183
184 void Map_gatherNamespaced(scene::Node &root);
185
186 void Map_mergeClonedNames();
187
188
189 const char *getMapsPath();
190
191 #endif