2014-12-12 19:04:48 +00:00
|
|
|
namespace dk {
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-14 12:13:10 +00:00
|
|
|
Viewport<D>::Viewport (Tyler<D>& parTyler) :
|
|
|
|
m_tyler(parTyler)
|
2014-12-12 19:04:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-14 12:13:10 +00:00
|
|
|
Viewport<D>::Viewport (Tyler<D>& parTyler, const coords& parSize, const coords& parPos) :
|
2014-12-12 19:04:48 +00:00
|
|
|
m_size(parSize),
|
|
|
|
m_position(parPos),
|
2014-12-14 12:13:10 +00:00
|
|
|
m_tyler(parTyler)
|
2014-12-12 19:04:48 +00:00
|
|
|
{
|
2014-12-29 15:17:59 +00:00
|
|
|
DK_ASSERT(parPos <= parPos + parSize);
|
|
|
|
DK_ASSERT(parSize + parPos <= parTyler.map_size());
|
2014-12-14 12:13:10 +00:00
|
|
|
m_tyler.preload(m_position, m_position + m_size);
|
|
|
|
}
|
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-14 12:13:10 +00:00
|
|
|
template <typename T>
|
|
|
|
typename Layer<T, D>::iterator Viewport<D>::begin (Layer<T, D>& parLayer) const {
|
|
|
|
typedef typename Layer<T, D>::iterator IterType;
|
2015-01-05 17:01:28 +00:00
|
|
|
return IterType(&parLayer.m_tiles, m_position, m_position + m_size, coords(0), m_tyler.map_size());
|
2014-12-14 12:13:10 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-14 12:13:10 +00:00
|
|
|
template <typename T>
|
|
|
|
typename Layer<T, D>::iterator Viewport<D>::end (Layer<T, D>& parLayer) const {
|
|
|
|
typedef typename Layer<T, D>::iterator IterType;
|
2015-01-05 17:01:28 +00:00
|
|
|
const auto to(m_position + m_size);
|
2015-08-16 20:29:34 +00:00
|
|
|
return IterType(&parLayer.m_tiles, m_tyler.map_size(), m_tyler.map_size());
|
2015-01-05 17:01:28 +00:00
|
|
|
}
|
2014-12-14 12:13:10 +00:00
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2015-01-05 17:01:28 +00:00
|
|
|
template <typename T>
|
|
|
|
typename Layer<T, D>::const_iterator Viewport<D>::begin (const Layer<T, D>& parLayer) const {
|
|
|
|
return this->cbegin(parLayer);
|
|
|
|
}
|
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2015-01-05 17:01:28 +00:00
|
|
|
template <typename T>
|
|
|
|
typename Layer<T, D>::const_iterator Viewport<D>::end (const Layer<T, D>& parLayer) const {
|
|
|
|
return this->cend(parLayer);
|
|
|
|
}
|
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2015-01-05 17:01:28 +00:00
|
|
|
template <typename T>
|
|
|
|
typename Layer<T, D>::const_iterator Viewport<D>::cbegin (const Layer<T, D>& parLayer) const {
|
|
|
|
typedef typename Layer<T, D>::const_iterator IterType;
|
2015-08-16 20:29:34 +00:00
|
|
|
return IterType(&parLayer.m_tiles, m_position, m_position + m_size, m_tyler.map_size());
|
2015-01-05 17:01:28 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2015-01-05 17:01:28 +00:00
|
|
|
template <typename T>
|
|
|
|
typename Layer<T, D>::const_iterator Viewport<D>::cend (const Layer<T, D>& parLayer) const {
|
|
|
|
typedef typename Layer<T, D>::const_iterator IterType;
|
2014-12-14 12:13:10 +00:00
|
|
|
const auto to(m_position + m_size);
|
2015-08-16 20:29:34 +00:00
|
|
|
return IterType(&parLayer.m_tiles, m_tyler.map_size(), m_tyler.map_size());
|
2014-12-14 12:13:10 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-14 12:13:10 +00:00
|
|
|
void Viewport<D>::setSize (const coords& parSize) {
|
2014-12-29 15:17:59 +00:00
|
|
|
DK_ASSERT(m_position <= m_position + parSize);
|
|
|
|
DK_ASSERT(parSize + m_position <= m_tyler.map_size());
|
2014-12-14 12:13:10 +00:00
|
|
|
m_size = parSize;
|
|
|
|
m_tyler.preload(m_position, m_position + m_size);
|
|
|
|
}
|
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-14 12:13:10 +00:00
|
|
|
void Viewport<D>::setFrom (const coords& parFrom) {
|
2014-12-29 15:17:59 +00:00
|
|
|
DK_ASSERT(parFrom <= parFrom + m_size);
|
|
|
|
DK_ASSERT(m_size + parFrom <= m_tyler.map_size());
|
2014-12-14 12:13:10 +00:00
|
|
|
m_position = parFrom;
|
|
|
|
m_tyler.preload(m_position, m_position + m_size);
|
|
|
|
}
|
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-14 12:13:10 +00:00
|
|
|
void Viewport<D>::setFromSize (const coords& parFrom, const coords& parSize) {
|
2014-12-29 15:17:59 +00:00
|
|
|
DK_ASSERT(parFrom <= parFrom + parSize);
|
|
|
|
DK_ASSERT(parSize + parFrom <= m_tyler.map_size());
|
2014-12-14 12:13:10 +00:00
|
|
|
m_position = parFrom;
|
|
|
|
m_size = parSize;
|
|
|
|
m_tyler.preload(m_position, m_position + m_size);
|
2014-12-12 19:04:48 +00:00
|
|
|
}
|
|
|
|
} //namespace dk
|