| 1 |
/************************************************************************** |
| 2 |
* Copyright (C) 2005-2019 by the FIFE team * |
| 3 |
* http://www.fifengine.net * |
| 4 |
* This file is part of FIFE. * |
| 5 |
* * |
| 6 |
* FIFE is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Lesser General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2.1 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library 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 GNU * |
| 14 |
* Lesser General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Lesser General Public * |
| 17 |
* License along with this library; if not, write to the * |
| 18 |
* Free Software Foundation, Inc., * |
| 19 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
| 20 |
***************************************************************************/ |
| 21 |
|
| 22 |
#ifndef FIFE_MAPLOADER_H_ |
| 23 |
#define FIFE_MAPLOADER_H_ |
| 24 |
|
| 25 |
// Standard C++ library includes |
| 26 |
#include <string> |
| 27 |
#include <vector> |
| 28 |
|
| 29 |
// 3rd party library includes |
| 30 |
|
| 31 |
// FIFE includes |
| 32 |
// These includes are split up in two parts, separated by one empty line |
| 33 |
// First block: files included from the FIFE root src directory |
| 34 |
// Second block: files included from the same folder |
| 35 |
|
| 36 |
#include "imaploader.h" |
| 37 |
#include "ianimationloader.h" |
| 38 |
#include "percentdonelistener.h" |
| 39 |
|
| 40 |
namespace FIFE { |
| 41 |
class Model; |
| 42 |
class Map; |
| 43 |
class VFS; |
| 44 |
class Layer; |
| 45 |
class ImageManager; |
| 46 |
class AnimationManager; |
| 47 |
class RenderBackend; |
| 48 |
class PercentDoneListener; |
| 49 |
|
| 50 |
class MapLoader : public IMapLoader { |
| 51 |
public: |
| 52 |
MapLoader(Model* model, VFS* vfs, ImageManager* imageManager, RenderBackend* renderBackend); |
| 53 |
|
| 54 |
~MapLoader(); |
| 55 |
|
| 56 |
/** |
| 57 |
* @see IMapLoader::setObjectLoader |
| 58 |
*/ |
| 59 |
void setObjectLoader(const FIFE::ObjectLoaderPtr& objectLoader); |
| 60 |
|
| 61 |
/** |
| 62 |
* @see IMapLoader::getObjectLoader |
| 63 |
*/ |
| 64 |
FIFE::ObjectLoaderPtr getObjectLoader(); |
| 65 |
|
| 66 |
/** |
| 67 |
* @see IMapLoader::setAnimationLoader |
| 68 |
*/ |
| 69 |
void setAnimationLoader(const FIFE::AnimationLoaderPtr& animationLoader); |
| 70 |
|
| 71 |
/** |
| 72 |
* @see IMapLoader::getAnimationLoader |
| 73 |
*/ |
| 74 |
FIFE::AnimationLoaderPtr getAnimationLoader(); |
| 75 |
|
| 76 |
/** |
| 77 |
* @see IMapLoader::setAtlasLoader |
| 78 |
*/ |
| 79 |
void setAtlasLoader(const FIFE::AtlasLoaderPtr& atlasLoader); |
| 80 |
|
| 81 |
/** |
| 82 |
* @see IMapLoader::getAtlasLoader |
| 83 |
*/ |
| 84 |
FIFE::AtlasLoaderPtr getAtlasLoader(); |
| 85 |
|
| 86 |
/** |
| 87 |
* @see IMapLoader::isLoadable |
| 88 |
*/ |
| 89 |
bool isLoadable(const std::string& filename) const; |
| 90 |
|
| 91 |
/** |
| 92 |
* @see IMapLoader::load |
| 93 |
*/ |
| 94 |
Map* load(const std::string& filename); |
| 95 |
|
| 96 |
/** used to load an object file |
| 97 |
* if directory is provided then file is assumed relative to directory |
| 98 |
* if relativeToMap is true then the file/directory is assumed to be relative to |
| 99 |
* location of map file |
| 100 |
*/ |
| 101 |
void loadImportFile(const std::string& file, const std::string& directory=""); |
| 102 |
|
| 103 |
/** used to load a directory of object files recursively |
| 104 |
* if relativeToMap is true then the directory is assumed to be relative to |
| 105 |
* location of map file |
| 106 |
*/ |
| 107 |
void loadImportDirectory(const std::string& directory); |
| 108 |
|
| 109 |
/** |
| 110 |
* allows adding a listener to the map loader |
| 111 |
* for percent completed events |
| 112 |
*/ |
| 113 |
void addPercentDoneListener(PercentDoneListener* listener); |
| 114 |
|
| 115 |
/** returns the loader name associated with this |
| 116 |
* map file loader, this will only be populated |
| 117 |
* after the load function is called |
| 118 |
*/ |
| 119 |
const std::string& getLoaderName() const; |
| 120 |
|
| 121 |
private: |
| 122 |
Model* m_model; |
| 123 |
VFS* m_vfs; |
| 124 |
ImageManager* m_imageManager; |
| 125 |
AnimationManager* m_animationManager; |
| 126 |
ObjectLoaderPtr m_objectLoader; |
| 127 |
RenderBackend* m_renderBackend; |
| 128 |
PercentDoneCallback m_percentDoneListener; |
| 129 |
|
| 130 |
std::string m_loaderName; |
| 131 |
std::string m_mapDirectory; |
| 132 |
std::vector<std::string> m_importDirectories; |
| 133 |
|
| 134 |
}; |
| 135 |
|
| 136 |
/** convenience function for creating the default fife map loader |
| 137 |
* deleting the object returned from this function is the |
| 138 |
* responsibility of the caller |
| 139 |
*/ |
| 140 |
MapLoader* createDefaultMapLoader(Model* model, VFS* vfs, ImageManager* imageManager, RenderBackend* renderBackend); |
| 141 |
} |
| 142 |
|
| 143 |
#endif |