King_DuckZ
fd8a1cbabc
This is needed to recognize what type of tiles a layer contains. Client code has to fill in a map of hash => add_layer<T>() pointers. As a layer is loaded, the correct add_layer<T>() is called based on the hash saved with the layer itself.
57 lines
1.9 KiB
C++
57 lines
1.9 KiB
C++
#ifndef idA52FEA0859494D3FBDF8ED5565091C59
|
|
#define idA52FEA0859494D3FBDF8ED5565091C59
|
|
|
|
#include "doorkeeper/components/tyler.hpp"
|
|
#include "doorkeeper/components/basemapsource.hpp"
|
|
#include "doorkeeper/helpers/hashing.hpp"
|
|
#include "doorkeeper/components/exception.hpp"
|
|
#include <cstdint>
|
|
#include <utility>
|
|
#include <string>
|
|
#include <memory>
|
|
#include <map>
|
|
#include <stack>
|
|
#include <ciso646>
|
|
|
|
namespace dkh {
|
|
template <uint32_t D>
|
|
using PushLayerMapType = std::map<dk::HashType, void(dk::Tyler<D>::*)(dk::BaseMapSource<D>*,int)>;
|
|
|
|
template <uint32_t D, typename C>
|
|
struct MapLoaderPool {
|
|
typedef std::unique_ptr<dk::BaseMapSource<D>> BaseMapSourceUPtr;
|
|
typedef std::map<std::string, BaseMapSourceUPtr> PoolMapType;
|
|
|
|
enum { dimensions = D };
|
|
typedef C opener_type;
|
|
|
|
PoolMapType pool;
|
|
C opener;
|
|
|
|
dk::BaseMapSource<D>* operator() ( const std::string& parName );
|
|
};
|
|
|
|
class UnknownLayerTemplateException : public dk::DoorKeeperException {
|
|
};
|
|
|
|
template <typename M>
|
|
dk::Tyler<M::dimensions> call_map_load ( M& parFileOpener, const std::string& parOpen, const PushLayerMapType<M::dimensions>& parPusher );
|
|
|
|
template <typename M>
|
|
dk::Tyler<M::dimensions> call_map_load ( dk::Tyler<M::dimensions>& parTyler, M& parFileOpener, const std::string& parOpen, const PushLayerMapType<M::dimensions>& parPusher );
|
|
|
|
template <uint32_t D, typename C>
|
|
dk::Tyler<D> map_load ( C& parFileOpener, const std::string& parOpen, const PushLayerMapType<D>& parPusher );
|
|
|
|
template <uint32_t D, typename C>
|
|
dk::Tyler<D>& map_load ( dk::Tyler<D>& parTyler, C& parFileOpener, const std::string& parOpen, const PushLayerMapType<D>& parPusher );
|
|
|
|
namespace implem {
|
|
template <uint32_t D>
|
|
void call_push_layer ( dk::Tyler<D>& parTyler, const PushLayerMapType<D>& parPusher, dk::BaseMapSource<D>* parReader, int parIndex );
|
|
} //namespace implem
|
|
} //namespace dkh
|
|
|
|
#include "doorkeeper/implem/maploader.inl"
|
|
|
|
#endif
|