namespace dk { template Viewport::Viewport (Tyler& parTyler) : m_tyler(parTyler) { } template Viewport::Viewport (Tyler& parTyler, const coords& parSize, const coords& parPos) : m_size(parSize), m_position(parPos), m_tyler(parTyler) { DK_ASSERT(parPos <= parPos + parSize); DK_ASSERT(parSize + parPos <= parTyler.map_size()); m_tyler.preload(m_position, m_position + m_size); } template template typename Layer::iterator Viewport::begin (Layer& parLayer) const { typedef typename Layer::iterator IterType; return IterType(&parLayer.m_tiles, m_position, m_tyler.map_size() - 1); } template template typename Layer::iterator Viewport::end (Layer& parLayer) const { typedef typename Layer::iterator IterType; return IterType(&parLayer.m_tiles, make_past_end_coords(m_tyler.map_size() - 1), make_past_end_coords(m_tyler.map_size() - 1)); } template template typename Layer::const_iterator Viewport::begin (const Layer& parLayer) const { return this->cbegin(parLayer); } template template typename Layer::const_iterator Viewport::end (const Layer& parLayer) const { return this->cend(parLayer); } template template typename Layer::const_iterator Viewport::cbegin (const Layer& parLayer) const { typedef typename Layer::const_iterator IterType; return IterType(&parLayer.m_tiles, m_position, m_tyler.map_size() - 1); } template template typename Layer::const_iterator Viewport::cend (const Layer& parLayer) const { typedef typename Layer::const_iterator IterType; return IterType(&parLayer.m_tiles, make_past_end_coords(m_tyler.map_size() - 1), make_past_end_coords(m_tyler.map_size() - 1)); } template void Viewport::setSize (const coords& parSize) { DK_ASSERT(m_position <= m_position + parSize); DK_ASSERT(parSize + m_position <= m_tyler.map_size()); m_size = parSize; m_tyler.preload(m_position, m_position + m_size); } template void Viewport::setFrom (const coords& parFrom) { DK_ASSERT(parFrom <= parFrom + m_size); DK_ASSERT(m_size + parFrom <= m_tyler.map_size()); m_position = parFrom; m_tyler.preload(m_position, m_position + m_size); } template void Viewport::setFromSize (const coords& parFrom, const coords& parSize) { DK_ASSERT(parFrom <= parFrom + parSize); DK_ASSERT(parSize + parFrom <= m_tyler.map_size()); m_position = parFrom; m_size = parSize; m_tyler.preload(m_position, m_position + m_size); } } //namespace dk