2015-01-06 15:38:52 +00:00
|
|
|
#include "doorkeeper/doorkeeper.hpp"
|
2014-12-29 15:17:59 +00:00
|
|
|
#include "doorkeepertestConfig.h"
|
2014-12-15 22:24:00 +00:00
|
|
|
#include "platform.h"
|
|
|
|
#include "platformstrings.h"
|
2015-01-06 15:38:52 +00:00
|
|
|
#include "doorkeeper/helpers/asciimapsource.hpp"
|
|
|
|
#include "doorkeeper/mapreaders/mapstreamraw.hpp"
|
2014-08-27 14:03:56 +00:00
|
|
|
#include <iostream>
|
2014-12-09 22:53:09 +00:00
|
|
|
#include <fstream>
|
2014-12-29 15:17:59 +00:00
|
|
|
#include <string>
|
2014-12-09 22:53:09 +00:00
|
|
|
#include <memory>
|
2014-08-27 14:03:56 +00:00
|
|
|
|
2014-12-29 15:17:59 +00:00
|
|
|
template <typename Device, typename Tile>
|
|
|
|
struct LayerWithData {
|
|
|
|
std::unique_ptr<dk::TileMapData<Tile, 2>> tilemap;
|
|
|
|
std::unique_ptr<Device> device;
|
|
|
|
dk::Layer<Tile, 2>* layer;
|
|
|
|
std::string path;
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
template <typename Device, typename Tile>
|
|
|
|
void createLayer ( dk::Tyler<2>& parTiler, LayerWithData<Device, Tile>& parOut );
|
|
|
|
void printWelcome ( void );
|
2015-01-05 17:01:28 +00:00
|
|
|
void addLayer ( dk::Tyler<2>& parTiler, LayerWithData<dkh::AsciiMapSource, int>& parLayerInfo, const char* parPath );
|
|
|
|
void printViewport ( const dk::Viewport<2>& parView, const dk::Layer<int, 2>& parLayer );
|
2014-12-29 15:17:59 +00:00
|
|
|
} //unnamed namespace
|
|
|
|
|
2014-08-27 14:03:56 +00:00
|
|
|
int main() {
|
2014-12-29 15:17:59 +00:00
|
|
|
typedef dk::Tyler<2>::coords coords2;
|
|
|
|
using dk::TileMapData;
|
|
|
|
using dkh::AsciiMapSource;
|
2014-12-09 21:30:06 +00:00
|
|
|
|
2014-12-29 15:17:59 +00:00
|
|
|
printWelcome();
|
2014-12-15 22:24:00 +00:00
|
|
|
|
2014-12-29 15:17:59 +00:00
|
|
|
dk::Tyler<2> tiler(coords2(10, 6), coords2(64));
|
2014-12-12 19:04:48 +00:00
|
|
|
|
2014-12-29 15:17:59 +00:00
|
|
|
LayerWithData<AsciiMapSource, int> bottomLayer;
|
2015-01-05 17:01:28 +00:00
|
|
|
addLayer(tiler, bottomLayer, DATA_PATH"/test.map");
|
2014-12-13 03:50:23 +00:00
|
|
|
|
2014-12-29 15:17:59 +00:00
|
|
|
LayerWithData<AsciiMapSource, int> topLayer;
|
2015-01-05 17:01:28 +00:00
|
|
|
addLayer(tiler, topLayer, DATA_PATH"/test_2.map");
|
2014-12-09 22:53:09 +00:00
|
|
|
|
2015-01-05 17:01:28 +00:00
|
|
|
printViewport(dk::Viewport<2>(tiler, coords2(10, 6), coords2(0)), *bottomLayer.layer);
|
|
|
|
printViewport(dk::Viewport<2>(tiler, coords2(4, 4), coords2(0)), *bottomLayer.layer);
|
2014-12-09 22:53:09 +00:00
|
|
|
|
|
|
|
#if !defined(NDEBUG)
|
|
|
|
std::cout << "Map size: " << tiler.map_size() << '\n';
|
|
|
|
#endif
|
|
|
|
std::cout << "Total tiles: " << tiler.tiles_count() << '\n';
|
2014-08-27 14:03:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2014-12-29 15:17:59 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
template <typename Device, typename Tile>
|
|
|
|
void createLayer (dk::Tyler<2>& parTiler, LayerWithData<Device, Tile>& parOut) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void printWelcome() {
|
|
|
|
std::cout << "Welcome to " << APP_NAME << ' ' << DK_DEVICE_STRING << " version for " << DK_OS_STRING << ' ' << DK_ARCH_STRING << ' ' << DK_BIT_STRING;
|
|
|
|
#if defined(DK_ARM)
|
|
|
|
std::cout << ' ' << DK_ARM_FAMILY_STRING << ' ' << DK_ARM_ARCH_STRING;
|
|
|
|
#endif
|
|
|
|
std::cout << '\n';
|
|
|
|
}
|
2015-01-05 17:01:28 +00:00
|
|
|
|
|
|
|
void addLayer (dk::Tyler<2>& parTiler, LayerWithData<dkh::AsciiMapSource, int>& parLayerInfo, const char* parPath) {
|
|
|
|
parLayerInfo.path = parPath;
|
|
|
|
parLayerInfo.device = std::unique_ptr<dkh::AsciiMapSource>(new dkh::AsciiMapSource(parLayerInfo.path));
|
|
|
|
std::unique_ptr<dk::MapStreamRaw<int, 2>> stream(new dk::MapStreamRaw<int, 2>(*parLayerInfo.device));
|
|
|
|
parLayerInfo.tilemap = std::unique_ptr<dk::TileMapData<int, 2>>(new dk::TileMapData<int, 2>(std::move(stream)));
|
|
|
|
parLayerInfo.layer = &parTiler.push_layer(*parLayerInfo.tilemap);
|
|
|
|
}
|
|
|
|
|
|
|
|
void printViewport (const dk::Viewport<2>& parView, const dk::Layer<int, 2>& parLayer) {
|
|
|
|
int col = 0;
|
|
|
|
const auto tilecount = parView.count();
|
|
|
|
for (auto itTile = parView.begin(parLayer), itTileEND = parView.end(parLayer); itTile != itTileEND; ++itTile) {
|
|
|
|
std::cout << *itTile;
|
|
|
|
++col;
|
|
|
|
if (col == tilecount.x()) {
|
|
|
|
col = 0;
|
|
|
|
std::cout << '\n';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-29 15:17:59 +00:00
|
|
|
} //unnamed namespace
|