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.
49 lines
1.7 KiB
C++
49 lines
1.7 KiB
C++
#ifndef id263B7DAF9A1C40BB8517D5D328DF8A1B
|
|
#define id263B7DAF9A1C40BB8517D5D328DF8A1B
|
|
|
|
#include "doorkeeper/primitivetypes.hpp"
|
|
#include "doorkeeper/implem/vector.hpp"
|
|
#include "doorkeeper/components/basemapsource.hpp"
|
|
#include <vector>
|
|
#include <memory>
|
|
|
|
namespace dkh {
|
|
namespace implem {
|
|
typedef int AsciiMapTileType;
|
|
} //namespace implem
|
|
|
|
class AsciiMapSource : public dk::BaseMapSource<2> {
|
|
public:
|
|
typedef dk::Vector<2> coords;
|
|
typedef implem::AsciiMapTileType MapTileType;
|
|
enum {
|
|
MapDimensions = 2
|
|
};
|
|
|
|
AsciiMapSource ( void ) = delete;
|
|
AsciiMapSource ( const AsciiMapSource& ) = delete;
|
|
AsciiMapSource ( AsciiMapSource&& parOther ) = default;
|
|
AsciiMapSource ( const char* parFilename, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize );
|
|
AsciiMapSource ( const std::string& parFilename, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize );
|
|
AsciiMapSource ( std::istream& parData, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize );
|
|
virtual ~AsciiMapSource ( void ) noexcept = default;
|
|
|
|
virtual const coords& mapSize ( void ) const;
|
|
virtual dk::MapTypes mapType ( void ) const;
|
|
virtual int layersCount ( void ) const;
|
|
virtual const coords& tileSize ( void ) const;
|
|
virtual void chainedMaps ( std::vector<std::string>& parOut ) const;
|
|
virtual dk::HashType layerTypeHash ( int parIndex ) const;
|
|
|
|
private:
|
|
void parse_map_data ( std::istream& parSrc );
|
|
virtual void fetch_raw ( char* parOut, const coords& parFrom, const coords& parTo, std::size_t parSize );
|
|
|
|
std::vector<MapTileType> m_wholedata;
|
|
const coords m_mapSize;
|
|
const coords m_tileSize;
|
|
const dk::MapTypes m_mapType;
|
|
};
|
|
} //namespace dkh
|
|
|
|
#endif
|