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 #include "Game.h" 21 22 #include "Model/BrushContentTypeBuilder.h" 23 #include "Model/GameFactory.h" 24 25 namespace TrenchBroom { 26 namespace Model { Game()27 Game::Game() : 28 m_brushContentTypeBuilder(NULL) {} 29 ~Game()30 Game::~Game() { 31 delete m_brushContentTypeBuilder; 32 m_brushContentTypeBuilder = NULL; 33 } 34 gameName() const35 const String& Game::gameName() const { 36 return doGameName(); 37 } 38 isGamePathPreference(const IO::Path & prefPath) const39 bool Game::isGamePathPreference(const IO::Path& prefPath) const { 40 const GameFactory& gameFactory = GameFactory::instance(); 41 return gameFactory.isGamePathPreference(gameName(), prefPath); 42 } 43 gamePath() const44 IO::Path Game::gamePath() const { 45 return doGamePath(); 46 } 47 setGamePath(const IO::Path & gamePath)48 void Game::setGamePath(const IO::Path& gamePath) { 49 doSetGamePath(gamePath); 50 } 51 setAdditionalSearchPaths(const IO::Path::List & searchPaths)52 void Game::setAdditionalSearchPaths(const IO::Path::List& searchPaths) { 53 doSetAdditionalSearchPaths(searchPaths); 54 } 55 newMap(const MapFormat::Type format,const BBox3 & worldBounds) const56 World* Game::newMap(const MapFormat::Type format, const BBox3& worldBounds) const { 57 return doNewMap(format, worldBounds); 58 } 59 loadMap(const MapFormat::Type format,const BBox3 & worldBounds,const IO::Path & path,Logger * logger) const60 World* Game::loadMap(const MapFormat::Type format, const BBox3& worldBounds, const IO::Path& path, Logger* logger) const { 61 return doLoadMap(format, worldBounds, path, logger); 62 } 63 writeMap(World * world,const IO::Path & path) const64 void Game::writeMap(World* world, const IO::Path& path) const { 65 assert(world != NULL); 66 doWriteMap(world, path); 67 } 68 parseNodes(const String & str,World * world,const BBox3 & worldBounds,Logger * logger) const69 NodeList Game::parseNodes(const String& str, World* world, const BBox3& worldBounds, Logger* logger) const { 70 return doParseNodes(str, world, worldBounds, logger); 71 } 72 parseBrushFaces(const String & str,World * world,const BBox3 & worldBounds,Logger * logger) const73 BrushFaceList Game::parseBrushFaces(const String& str, World* world, const BBox3& worldBounds, Logger* logger) const { 74 return doParseBrushFaces(str, world, worldBounds, logger); 75 } 76 writeNodesToStream(World * world,const Model::NodeList & nodes,std::ostream & stream) const77 void Game::writeNodesToStream(World* world, const Model::NodeList& nodes, std::ostream& stream) const { 78 doWriteNodesToStream(world, nodes, stream); 79 } 80 writeBrushFacesToStream(World * world,const Model::BrushFaceList & faces,std::ostream & stream) const81 void Game::writeBrushFacesToStream(World* world, const Model::BrushFaceList& faces, std::ostream& stream) const { 82 doWriteBrushFacesToStream(world, faces, stream); 83 } 84 isTextureCollection(const IO::Path & path) const85 bool Game::isTextureCollection(const IO::Path& path) const { 86 return doIsTextureCollection(path); 87 } 88 findBuiltinTextureCollections() const89 IO::Path::List Game::findBuiltinTextureCollections() const { 90 return doFindBuiltinTextureCollections(); 91 } 92 extractExternalTextureCollections(const World * world) const93 StringList Game::extractExternalTextureCollections(const World* world) const { 94 assert(world != NULL); 95 return doExtractExternalTextureCollections(world); 96 } 97 updateExternalTextureCollections(World * world,const StringList & collections) const98 void Game::updateExternalTextureCollections(World* world, const StringList& collections) const { 99 assert(world != NULL); 100 doUpdateExternalTextureCollections(world, collections); 101 } 102 isEntityDefinitionFile(const IO::Path & path) const103 bool Game::isEntityDefinitionFile(const IO::Path& path) const { 104 return doIsEntityDefinitionFile(path); 105 } 106 allEntityDefinitionFiles() const107 Assets::EntityDefinitionFileSpec::List Game::allEntityDefinitionFiles() const { 108 return doAllEntityDefinitionFiles(); 109 } 110 extractEntityDefinitionFile(const World * world) const111 Assets::EntityDefinitionFileSpec Game::extractEntityDefinitionFile(const World* world) const { 112 assert(world != NULL); 113 return doExtractEntityDefinitionFile(world); 114 } 115 findEntityDefinitionFile(const Assets::EntityDefinitionFileSpec & spec,const IO::Path::List & searchPaths) const116 IO::Path Game::findEntityDefinitionFile(const Assets::EntityDefinitionFileSpec& spec, const IO::Path::List& searchPaths) const { 117 return doFindEntityDefinitionFile(spec, searchPaths); 118 } 119 brushContentTypeBuilder() const120 const BrushContentTypeBuilder* Game::brushContentTypeBuilder() const { 121 if (m_brushContentTypeBuilder == NULL) 122 m_brushContentTypeBuilder = new BrushContentTypeBuilder(brushContentTypes()); 123 return m_brushContentTypeBuilder; 124 } 125 brushContentTypes() const126 const BrushContentType::List& Game::brushContentTypes() const { 127 return doBrushContentTypes(); 128 } 129 availableMods() const130 StringList Game::availableMods() const { 131 return doAvailableMods(); 132 } 133 extractEnabledMods(const World * world) const134 StringList Game::extractEnabledMods(const World* world) const { 135 assert(world != NULL); 136 return doExtractEnabledMods(world); 137 } 138 surfaceFlags() const139 const GameConfig::FlagsConfig& Game::surfaceFlags() const { 140 return doSurfaceFlags(); 141 } 142 contentFlags() const143 const GameConfig::FlagsConfig& Game::contentFlags() const { 144 return doContentFlags(); 145 } 146 } 147 } 148