]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/map.h
fixed crash on disabling lighting
[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 "string/stringfwd.h"
28
29 class Map;
30 extern Map g_map;
31
32 class MapFormat;
33
34 void Map_addValidCallback(Map& map, const Callback& callback);
35 bool Map_Valid(const Map& map);
36
37 class DeferredDraw
38 {
39   Callback m_draw;
40   bool m_defer;
41   bool m_deferred;
42 public:
43   DeferredDraw(const Callback& draw) : m_draw(draw), m_defer(false), m_deferred(false)
44   {
45   }
46   void defer()
47   {
48     m_defer = true;
49   }
50   void draw()
51   {
52     if(m_defer)
53     {
54       m_deferred = true;
55     }
56     else
57     {
58       m_draw();
59     }
60   }
61   void flush()
62   {
63     if(m_defer && m_deferred)
64     {
65       m_draw();
66     }
67     m_deferred = false;
68     m_defer = false;
69   }
70 };
71
72 inline void DeferredDraw_onMapValidChanged(DeferredDraw& self)
73 {
74   if(Map_Valid(g_map))
75   {
76     self.flush();
77   }
78   else
79   {
80     self.defer();
81   }
82 }
83 typedef ReferenceCaller<DeferredDraw, DeferredDraw_onMapValidChanged> DeferredDrawOnMapValidChangedCaller;
84
85
86
87 const char* Map_Name(const Map& map);
88 const MapFormat& Map_getFormat(const Map& map);
89 bool Map_Unnamed(const Map& map);
90
91
92 namespace scene
93 {
94   class Node;
95   class Graph;
96 }
97
98 scene::Node* Map_GetWorldspawn(const Map& map);
99 scene::Node* Map_FindWorldspawn(Map& map);
100 scene::Node& Map_FindOrInsertWorldspawn(Map& map);
101
102 template<typename Element> class BasicVector3;
103 typedef BasicVector3<float> Vector3;
104
105 extern Vector3 region_mins, region_maxs;
106 extern bool region_active;
107
108 // used to be #defines, multiple engine support suggests we should go towards dynamic
109 extern float g_MaxWorldCoord;
110 extern float g_MinWorldCoord;
111
112 void Map_LoadFile(const char* filename);
113 bool Map_SaveFile(const char* filename);
114
115 void Map_New();
116 void Map_Free();
117
118 void Map_RegionOff();
119
120 bool Map_SaveRegion(const char* filename);
121
122 class TextInputStream;
123 class TextOutputStream;
124
125 void Map_ImportSelected(TextInputStream& in, const MapFormat& format);
126 void Map_ExportSelected(TextOutputStream& out, const MapFormat& format);
127
128 bool Map_Modified(const Map& map);
129 void Map_SetModified(Map& map, bool modified);
130
131 bool Map_Save();
132 bool Map_SaveAs();
133
134 scene::Node& Node_Clone(scene::Node& node);
135
136 void DoMapInfo();
137
138 void Scene_parentSelectedBrushesToEntity(scene::Graph& graph, scene::Node& parent);
139 std::size_t Scene_countSelectedBrushes(scene::Graph& graph);
140
141 void Scene_parentSelected();
142
143 void OnUndoSizeChanged();
144
145 void NewMap();
146 void OpenMap();
147 void ImportMap();
148 void SaveMapAs();
149 void SaveMap();
150 void ExportMap();
151 void SaveRegion();
152
153
154 void Map_Traverse(scene::Node& root, const scene::Traversable::Walker& walker);
155
156
157 void SelectBrush (int entitynum, int brushnum);
158
159 extern CopiedString g_strLastMap;
160 extern bool g_bLoadLastMap;
161
162 void Map_Construct();
163 void Map_Destroy();
164
165
166 void Map_gatherNamespaced(scene::Node& root);
167 void Map_mergeClonedNames();
168
169 #endif