1 /**
2  * @file
3  */
4 
5 /*
6  Copyright (C) 2002-2013 UFO: Alien Invasion.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 2
11  of the License, or (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 
17  See the GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 
23  */
24 
25 #pragma once
26 
27 #include "ientity.h"
28 #include "../brush/Brush.h"
29 
30 class LevelFilter
31 {
32 	private:
33 
34 		void filter_level (int level);
35 		void filter_level1 ();
36 		void filter_level2 ();
37 		void filter_level3 ();
38 		void filter_level4 ();
39 		void filter_level5 ();
40 		void filter_level6 ();
41 		void filter_level7 ();
42 		void filter_level8 ();
43 
44 	private:
45 
46 		typedef std::vector<std::string> EntityClassNameList;
47 		typedef std::list<Brush*> BrushList;
48 		typedef std::list<Entity*> EntityList;
49 
50 		class EntityFindByName: public scene::Graph::Walker
51 		{
52 				const std::string& m_name;
53 				EntityList& m_entitylist;
54 				/* this starts at 1 << level */
55 				int m_flag;
56 				int m_hide;
57 			public:
58 				EntityFindByName (const std::string& name, EntityList& entitylist, int flag, bool hide);
59 				bool pre (const scene::Path& path, scene::Instance& instance) const;
60 		};
61 
62 		class ForEachFace: public BrushVisitor
63 		{
64 			public:
65 				mutable int m_contentFlagsVis;
66 				mutable int m_surfaceFlagsVis;
67 
68 				ForEachFace (Brush& brush);
69 
70 				void visit (Face& face) const;
71 		};
72 
73 		class BrushGetLevel: public scene::Graph::Walker
74 		{
75 				BrushList& m_brushlist;
76 				int m_flag;
77 				mutable bool m_hide;
78 			public:
79 				BrushGetLevel (BrushList& brushlist, int flag, bool hide);
80 				bool pre (const scene::Path& path, scene::Instance& instance) const;
81 		};
82 
83 	private:
84 
85 		int currentActiveLevel;
86 		EntityClassNameList _classNameList;
87 
88 	public:
89 
90 		LevelFilter ();
91 
92 		void registerCommands (void);
93 
94 		int getCurrentLevel (void);
95 };
96 
GlobalLevelFilter()97 inline LevelFilter& GlobalLevelFilter ()
98 {
99 	static LevelFilter _levelFilter;
100 	return _levelFilter;
101 }
102