maploader.h

00001 /**************************************************************************
00002 *   Copyright (C) 2005-2011 by the FIFE team                              *
00003 *   http://www.fifengine.net                                              *
00004 *   This file is part of FIFE.                                            *
00005 *                                                                         *
00006 *   FIFE is free software; you can redistribute it and/or                 *
00007 *   modify it under the terms of the GNU Lesser General Public            *
00008 *   License as published by the Free Software Foundation; either          *
00009 *   version 2.1 of the License, or (at your option) any later version.    *
00010 *                                                                         *
00011 *   This library is distributed in the hope that it will be useful,       *
00012 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014 *   Lesser General Public License for more details.                       *
00015 *                                                                         *
00016 *   You should have received a copy of the GNU Lesser General Public      *
00017 *   License along with this library; if not, write to the                 *
00018 *   Free Software Foundation, Inc.,                                       *
00019 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
00020 ***************************************************************************/
00021 
00022 #ifndef FIFE_MAPLOADER_H_
00023 #define FIFE_MAPLOADER_H_
00024 
00025 // Standard C++ library includes
00026 #include <string>
00027 #include <vector>
00028 
00029 // 3rd party library includes
00030 
00031 // FIFE includes
00032 // These includes are split up in two parts, separated by one empty line
00033 // First block: files included from the FIFE root src directory
00034 // Second block: files included from the same folder
00035 
00036 #include "imaploader.h"
00037 #include "ianimationloader.h"
00038 #include "percentdonelistener.h"
00039 
00040 namespace FIFE {
00041     class Model;
00042     class Map;
00043     class VFS;
00044     class Layer;
00045     class ImageManager;
00046     class RenderBackend;
00047     class PercentDoneListener;
00048 
00049     class MapLoader : public IMapLoader {
00050     public:
00051         MapLoader(Model* model, VFS* vfs, ImageManager* imageManager, RenderBackend* renderBackend);
00052         
00053         ~MapLoader();
00054 
00058         void setObjectLoader(const FIFE::ObjectLoaderPtr& objectLoader);
00059 
00063         void setAnimationLoader(const FIFE::AnimationLoaderPtr& animationLoader);
00064 
00068         void setAtlasLoader(const FIFE::AtlasLoaderPtr& atlasLoader);
00069 
00073         bool isLoadable(const std::string& filename) const;
00074 
00078         Map* load(const std::string& filename);
00079 
00085         void loadImportFile(const std::string& file, const std::string& directory="");
00086 
00091         void loadImportDirectory(const std::string& directory);
00092 
00097         void addPercentDoneListener(PercentDoneListener* listener);
00098 
00103         const std::string& getLoaderName() const;
00104 
00105     private:
00106         Model* m_model;
00107         VFS* m_vfs;
00108         ImageManager* m_imageManager;
00109         ObjectLoaderPtr m_objectLoader;
00110         AtlasLoaderPtr m_atlasLoader;
00111         RenderBackend* m_renderBackend;
00112         PercentDoneCallback m_percentDoneListener;
00113 
00114         std::string m_loaderName;
00115         std::string m_mapDirectory;
00116         std::vector<std::string> m_importDirectories;
00117 
00118     };
00119 
00124     MapLoader* createDefaultMapLoader(Model* model, VFS* vfs, ImageManager* imageManager, RenderBackend* renderBackend);
00125 }
00126 
00127 #endif