void Map::SyncDraw(Gdiplus::Graphics* g) { Vector3i northWestTile = mMapViewport->GetNorthWestTileCoordinate(); Vector3i southEastTile = mMapViewport->GetSouthEastTileCoordinate(); Vector2i origin = mMapViewport->GetTileOrigin(northWestTile); int xTileCount = southEastTile.GetX() - northWestTile.GetX() + 1; int yTileCount = southEastTile.GetY() - northWestTile.GetY() + 1; int tileCount = xTileCount*yTileCount; int k = 0; for(int i = 0; i<xTileCount; i++) { for(int j = 0; j<yTileCount; j++) { k++; std::cout << k << "/" << tileCount << std::endl; Vector3i coord(northWestTile.GetX() + i, northWestTile.GetY() + j, mMapViewport->GetZoom()); Tile* tile = new Tile(coord, mMapSource); tile->Download(false); Gdiplus::Image* im = tile->GetImage(); if(im) g->DrawImage(im, origin.GetX() + i*mMapSource->GetTileSize(), origin.GetY() + j*mMapSource->GetTileSize()); delete tile; } } }
void Map::Draw(Gdiplus::Graphics* g) { Vector3i northWestTile = mMapViewport->GetNorthWestTileCoordinate(); Vector3i southEastTile = mMapViewport->GetSouthEastTileCoordinate(); Vector2i origin = mMapViewport->GetTileOrigin(northWestTile); int xTileCount = southEastTile.GetX() - northWestTile.GetX() + 1; int yTileCount = southEastTile.GetY() - northWestTile.GetY() + 1; int tileCount = xTileCount*yTileCount; for(int i = 0; i<xTileCount; i++) { for(int j = 0; j<yTileCount; j++) { Vector3i coord(northWestTile.GetX() + i, northWestTile.GetY() + j, mMapViewport->GetZoom()); Tile* tile = GetTile(coord); if(!tile->IsLoaded()) { tile->SignalReady += [this](Tile* tile) { std::lock_guard<std::mutex> lock(signal_mutex); SignalNewTile.emit(); }; continue; } Gdiplus::Image* im = tile->GetImage(); if(im) g->DrawImage(im, origin.GetX() + i*mMapSource->GetTileSize(), origin.GetY() + j*mMapSource->GetTileSize()); } } }