1 /*
2  Copyright (C) 2010-2014 Kristian Duske
3 
4  This file is part of TrenchBroom.
5 
6  TrenchBroom is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  TrenchBroom is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef TrenchBroom_GameConfig
21 #define TrenchBroom_GameConfig
22 
23 #include "Color.h"
24 #include "StringUtils.h"
25 #include "IO/Path.h"
26 #include "Model/BrushContentType.h"
27 #include "Model/ModelTypes.h"
28 
29 #include <vector>
30 
31 namespace TrenchBroom {
32     namespace Model {
33         class GameConfig {
34         public:
35             struct FileSystemConfig {
36                 IO::Path searchPath;
37                 String packageFormat;
38 
39                 FileSystemConfig(const IO::Path& i_searchPath, const String& i_packageFormat);
40             };
41 
42             struct TextureConfig {
43                 String type;
44                 String attribute;
45                 IO::Path palette;
46                 IO::Path builtinTexturesSearchPath;
47 
48                 TextureConfig(const String& i_type, const String& i_attribute, const IO::Path& i_palette, const IO::Path& i_builtinTexturesSearchPath);
49             };
50 
51             struct EntityConfig {
52                 IO::Path::List defFilePaths;
53                 StringSet modelFormats;
54                 Color defaultColor;
55 
56                 EntityConfig(const IO::Path& i_defFilePath, const StringSet& i_modelFormats, const Color& i_defaultColor);
57                 EntityConfig(const IO::Path::List& i_defFilePaths, const StringSet& i_modelFormats, const Color& i_defaultColor);
58             };
59 
60             struct FlagConfig {
61                 String name;
62                 String description;
63 
64                 FlagConfig(const String& i_name, const String& i_description);
65             };
66 
67             typedef std::vector<FlagConfig> FlagConfigList;
68 
69             struct FlagsConfig {
70                 FlagConfigList flags;
71 
72                 FlagsConfig();
73                 FlagsConfig(const FlagConfigList& i_flags);
74 
75                 int flagValue(const String& flagName) const;
76                 String flagName(size_t index) const;
77                 StringList flagNames(int mask = ~0) const;
78             };
79 
80             struct FaceAttribsConfig {
81                 FlagsConfig surfaceFlags;
82                 FlagsConfig contentFlags;
83 
84                 FaceAttribsConfig();
85                 FaceAttribsConfig(const FlagConfigList& i_surfaceFlags, const FlagConfigList& i_contentFlags);
86 
87             };
88         private:
89             String m_name;
90             IO::Path m_path;
91             IO::Path m_icon;
92             StringList m_fileFormats;
93             FileSystemConfig m_fileSystemConfig;
94             TextureConfig m_textureConfig;
95             EntityConfig m_entityConfig;
96             FaceAttribsConfig m_faceAttribsConfig;
97             BrushContentType::List m_brushContentTypes;
98         public:
99             GameConfig();
100             GameConfig(const String& name, const IO::Path& path, const IO::Path& icon, const StringList& fileFormats, const FileSystemConfig& fileSystemConfig, const TextureConfig& textureConfig, const EntityConfig& entityConfig, const FaceAttribsConfig& faceAttribsConfig, const BrushContentType::List& brushContentTypes);
101 
102             const String& name() const;
103             const IO::Path& path() const;
104             const IO::Path& icon() const;
105             const StringList& fileFormats() const;
106             const FileSystemConfig& fileSystemConfig() const;
107             const TextureConfig& textureConfig() const;
108             const EntityConfig& entityConfig() const;
109             const FaceAttribsConfig& faceAttribsConfig() const;
110             const BrushContentType::List& brushContentTypes() const;
111             const IO::Path findConfigFile(const IO::Path& filePath) const;
112 
113             void addBrushContentType(const BrushContentType& contentType);
114         };
115     }
116 }
117 
118 #endif /* defined(TrenchBroom_GameConfig) */
119