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