Don't pass the map size from the c++ code anymore.
This commit is contained in:
parent
f13d38bda9
commit
ccd00df6d8
5 changed files with 14 additions and 20 deletions
|
@ -32,7 +32,7 @@ int main() {
|
||||||
std::cout << "Welcome to " GAME_NAME " v" << GAME_VER_MAJOR << '.' << GAME_VER_MINOR << '.' << GAME_VER_PATCH << '\n';
|
std::cout << "Welcome to " GAME_NAME " v" << GAME_VER_MAJOR << '.' << GAME_VER_MINOR << '.' << GAME_VER_PATCH << '\n';
|
||||||
|
|
||||||
IntPoolType pool;
|
IntPoolType pool;
|
||||||
pool.opener = [](const std::string& parName) { std::cout << "Opening " << parName << std::endl; return new dkh::AsciiMapSource(parName, coords2(10, 8), dk::MapType_IsometricStaggered, coords2(64, 64)); };
|
pool.opener = [](const std::string& parName) { std::cout << "Opening " << parName << std::endl; return new dkh::AsciiMapSource(parName, dk::MapType_IsometricStaggered, coords2(64, 64)); };
|
||||||
dkh::PushLayerMapType<2> pushers;
|
dkh::PushLayerMapType<2> pushers;
|
||||||
pushers.insert(std::make_pair(dk::type_name_hash<int>(), &Tyler2d::push_layer_void<int>));
|
pushers.insert(std::make_pair(dk::type_name_hash<int>(), &Tyler2d::push_layer_void<int>));
|
||||||
Tyler2d tiler(dkh::call_map_load(pool, std::string("test_level.dk"), pushers));
|
Tyler2d tiler(dkh::call_map_load(pool, std::string("test_level.dk"), pushers));
|
||||||
|
|
|
@ -41,9 +41,9 @@ namespace dkh {
|
||||||
AsciiMapSource ( void ) = delete;
|
AsciiMapSource ( void ) = delete;
|
||||||
AsciiMapSource ( const AsciiMapSource& ) = delete;
|
AsciiMapSource ( const AsciiMapSource& ) = delete;
|
||||||
AsciiMapSource ( AsciiMapSource&& parOther ) = default;
|
AsciiMapSource ( AsciiMapSource&& parOther ) = default;
|
||||||
AsciiMapSource ( const char* parFilename, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize );
|
AsciiMapSource ( const char* parFilename, dk::MapTypes parMapType, const coords& parTileSize );
|
||||||
AsciiMapSource ( const std::string& parFilename, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize );
|
AsciiMapSource ( const std::string& parFilename, dk::MapTypes parMapType, const coords& parTileSize );
|
||||||
AsciiMapSource ( std::istream& parData, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize );
|
AsciiMapSource ( std::istream& parData, dk::MapTypes parMapType, const coords& parTileSize );
|
||||||
virtual ~AsciiMapSource ( void ) noexcept = default;
|
virtual ~AsciiMapSource ( void ) noexcept = default;
|
||||||
|
|
||||||
virtual const coords& mapSize ( void ) const;
|
virtual const coords& mapSize ( void ) const;
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
namespace dkh {
|
namespace dkh {
|
||||||
///-------------------------------------------------------------------------
|
///-------------------------------------------------------------------------
|
||||||
///-------------------------------------------------------------------------
|
///-------------------------------------------------------------------------
|
||||||
AsciiMapSource::AsciiMapSource (const char* parFilename, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize) :
|
AsciiMapSource::AsciiMapSource (const char* parFilename, dk::MapTypes parMapType, const coords& parTileSize) :
|
||||||
m_mapSize(parSize),
|
m_mapSize(0),
|
||||||
m_pixel_conv(parTileSize),
|
m_pixel_conv(parTileSize),
|
||||||
m_mapType(parMapType)
|
m_mapType(parMapType)
|
||||||
{
|
{
|
||||||
|
@ -40,8 +40,8 @@ namespace dkh {
|
||||||
|
|
||||||
///-------------------------------------------------------------------------
|
///-------------------------------------------------------------------------
|
||||||
///-------------------------------------------------------------------------
|
///-------------------------------------------------------------------------
|
||||||
AsciiMapSource::AsciiMapSource (const std::string& parFilename, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize) :
|
AsciiMapSource::AsciiMapSource (const std::string& parFilename, dk::MapTypes parMapType, const coords& parTileSize) :
|
||||||
m_mapSize(parSize),
|
m_mapSize(0),
|
||||||
m_pixel_conv(parTileSize),
|
m_pixel_conv(parTileSize),
|
||||||
m_mapType(parMapType)
|
m_mapType(parMapType)
|
||||||
{
|
{
|
||||||
|
@ -51,8 +51,8 @@ namespace dkh {
|
||||||
|
|
||||||
///-------------------------------------------------------------------------
|
///-------------------------------------------------------------------------
|
||||||
///-------------------------------------------------------------------------
|
///-------------------------------------------------------------------------
|
||||||
AsciiMapSource::AsciiMapSource (std::istream& parData, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize) :
|
AsciiMapSource::AsciiMapSource (std::istream& parData, dk::MapTypes parMapType, const coords& parTileSize) :
|
||||||
m_mapSize(parSize),
|
m_mapSize(0),
|
||||||
m_pixel_conv(parTileSize),
|
m_pixel_conv(parTileSize),
|
||||||
m_mapType(parMapType)
|
m_mapType(parMapType)
|
||||||
{
|
{
|
||||||
|
@ -92,12 +92,6 @@ namespace dkh {
|
||||||
//http://boost.2283326.n4.nabble.com/Possible-bug-in-line-pos-iterator-td4636592.html
|
//http://boost.2283326.n4.nabble.com/Possible-bug-in-line-pos-iterator-td4636592.html
|
||||||
map_size.x() = grammar.lengths.front();
|
map_size.x() = grammar.lengths.front();
|
||||||
map_size.y() = m_wholedata.size() / map_size.x();
|
map_size.y() = m_wholedata.size() / map_size.x();
|
||||||
if (map_size != m_mapSize) {
|
|
||||||
std::ostringstream oss;
|
|
||||||
oss << "Calculated map size is " << map_size <<
|
|
||||||
" which is different than the expected size " << m_mapSize;
|
|
||||||
throw std::runtime_error(oss.str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AsciiMapSource::coords& AsciiMapSource::mapSize() const {
|
const AsciiMapSource::coords& AsciiMapSource::mapSize() const {
|
||||||
|
|
|
@ -168,7 +168,7 @@ namespace {
|
||||||
typedef dkh::AsciiMapSource::coords coords;
|
typedef dkh::AsciiMapSource::coords coords;
|
||||||
|
|
||||||
parLayerInfo.path = parPath;
|
parLayerInfo.path = parPath;
|
||||||
parLayerInfo.device.reset(new dkh::AsciiMapSource(parLayerInfo.path, coords(10, 6), dk::MapType_IsometricStaggered, coords(64, 64)));
|
parLayerInfo.device.reset(new dkh::AsciiMapSource(parLayerInfo.path, dk::MapType_IsometricStaggered, coords(64, 64)));
|
||||||
parLayerInfo.layer = &parTiler.push_layer<int>(parLayerInfo.device.get(), 0);
|
parLayerInfo.layer = &parTiler.push_layer<int>(parLayerInfo.device.get(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ asciimapsource::asciimapsource() :
|
||||||
layer(nullptr)
|
layer(nullptr)
|
||||||
{
|
{
|
||||||
std::istringstream iss((std::string(map_data)));
|
std::istringstream iss((std::string(map_data)));
|
||||||
loader.reset(new dkh::AsciiMapSource(iss, coords2(map_width, map_height), dk::MapType_Isometric, coords2(tile_size)));
|
loader.reset(new dkh::AsciiMapSource(iss, dk::MapType_Isometric, coords2(tile_size)));
|
||||||
layer = &tiler.push_layer<dkh::AsciiMapSource::MapTileType>(loader.get(), 0);
|
layer = &tiler.push_layer<dkh::AsciiMapSource::MapTileType>(loader.get(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ void asciimapsource::SetUp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(asciimapsource, load) {
|
TEST_F(asciimapsource, load) {
|
||||||
dk::Viewport<2> full_view(tiler, coords2(map_width, map_height), coords2(0));
|
dk::Viewport<2> full_view(tiler, tiler.map_size(), coords2(0));
|
||||||
|
|
||||||
EXPECT_EQ(coords2(map_width, map_height), tiler.map_size());
|
EXPECT_EQ(coords2(map_width, map_height), tiler.map_size());
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ TEST_F(asciimapsource, load) {
|
||||||
|
|
||||||
TEST_F(asciimapsource, coordinates) {
|
TEST_F(asciimapsource, coordinates) {
|
||||||
const coords2 tsize(tile_size);
|
const coords2 tsize(tile_size);
|
||||||
dk::Viewport<2> full_view(tiler, coords2(map_width, map_height), coords2(0));
|
dk::Viewport<2> full_view(tiler, tiler.map_size(), coords2(0));
|
||||||
dk::PixelConvSquare<2> iso_conv((tsize));
|
dk::PixelConvSquare<2> iso_conv((tsize));
|
||||||
dk::PixelConvDiamond diamond_conv(tsize, true, false);
|
dk::PixelConvDiamond diamond_conv(tsize, true, false);
|
||||||
dk::PixelConvDiamond diamond_conv2(tsize, true, true);
|
dk::PixelConvDiamond diamond_conv2(tsize, true, true);
|
||||||
|
|
Loading…
Reference in a new issue