|
|
@ -101,7 +101,11 @@ void MapView::draw(const Rect& rect)
|
|
|
|
if(!m_drawMinimapColors)
|
|
|
|
if(!m_drawMinimapColors)
|
|
|
|
tile->draw(transformPositionTo2D(tilePos, cameraPosition), scaleFactor, drawFlags);
|
|
|
|
tile->draw(transformPositionTo2D(tilePos, cameraPosition), scaleFactor, drawFlags);
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
g_painter->setColor(tile->getMinimapColor());
|
|
|
|
uint8 c = tile->getMinimapColorByte();
|
|
|
|
|
|
|
|
if(c == 0)
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_painter->setColor(Color::from8bit(c));
|
|
|
|
g_painter->drawFilledRect(Rect(transformPositionTo2D(tilePos, cameraPosition), tileSize));
|
|
|
|
g_painter->drawFilledRect(Rect(transformPositionTo2D(tilePos, cameraPosition), tileSize));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -399,22 +403,28 @@ void MapView::updateVisibleTilesCache(int start)
|
|
|
|
|
|
|
|
|
|
|
|
void MapView::updateGeometry(const Size& visibleDimension, const Size& optimizedSize)
|
|
|
|
void MapView::updateGeometry(const Size& visibleDimension, const Size& optimizedSize)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int possiblesTileSizes[] = {1,2,4,8,16,32};
|
|
|
|
|
|
|
|
int tileSize = 0;
|
|
|
|
int tileSize = 0;
|
|
|
|
Size bufferSize;
|
|
|
|
Size bufferSize;
|
|
|
|
for(int candidateTileSize : possiblesTileSizes) {
|
|
|
|
|
|
|
|
bufferSize = (visibleDimension + Size(3,3)) * candidateTileSize;
|
|
|
|
|
|
|
|
if(bufferSize.width() > g_graphics.getMaxTextureSize() || bufferSize.height() > g_graphics.getMaxTextureSize())
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tileSize = candidateTileSize;
|
|
|
|
if(!m_drawMinimapColors) {
|
|
|
|
if(optimizedSize.width() < bufferSize.width() - 3*candidateTileSize && optimizedSize.height() < bufferSize.height() - 3*candidateTileSize)
|
|
|
|
int possiblesTileSizes[] = {1,2,4,8,16,32};
|
|
|
|
break;
|
|
|
|
for(int candidateTileSize : possiblesTileSizes) {
|
|
|
|
}
|
|
|
|
bufferSize = (visibleDimension + Size(3,3)) * candidateTileSize;
|
|
|
|
|
|
|
|
if(bufferSize.width() > g_graphics.getMaxTextureSize() || bufferSize.height() > g_graphics.getMaxTextureSize())
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
if(tileSize == 0) {
|
|
|
|
tileSize = candidateTileSize;
|
|
|
|
g_logger.traceError("reached max zoom out");
|
|
|
|
if(optimizedSize.width() < bufferSize.width() - 3*candidateTileSize && optimizedSize.height() < bufferSize.height() - 3*candidateTileSize)
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(tileSize == 0) {
|
|
|
|
|
|
|
|
g_logger.traceError("reached max zoom out");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
tileSize = 1;
|
|
|
|
|
|
|
|
bufferSize = visibleDimension + Size(3,3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Size drawDimension = visibleDimension + Size(3,3);
|
|
|
|
Size drawDimension = visibleDimension + Size(3,3);
|
|
|
@ -456,10 +466,15 @@ void MapView::updateGeometry(const Size& visibleDimension, const Size& optimized
|
|
|
|
|
|
|
|
|
|
|
|
void MapView::onTileUpdate(const Position& pos)
|
|
|
|
void MapView::onTileUpdate(const Position& pos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//if(m_viewMode <= FAR_VIEW)
|
|
|
|
if(!m_drawMinimapColors)
|
|
|
|
requestVisibleTilesCacheUpdate();
|
|
|
|
requestVisibleTilesCacheUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MapView::onMapCenterChange(const Position& pos)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
requestVisibleTilesCacheUpdate();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MapView::lockFirstVisibleFloor(int firstVisibleFloor)
|
|
|
|
void MapView::lockFirstVisibleFloor(int firstVisibleFloor)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_lockedFirstVisibleFloor = firstVisibleFloor;
|
|
|
|
m_lockedFirstVisibleFloor = firstVisibleFloor;
|
|
|
@ -656,3 +671,14 @@ TilePtr MapView::getTile(const Point& mousePos, const Rect& mapRect)
|
|
|
|
return tile;
|
|
|
|
return tile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MapView::setDrawMinimapColors(bool enable)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(m_drawMinimapColors == enable)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_drawMinimapColors = enable;
|
|
|
|
|
|
|
|
updateGeometry(m_visibleDimension, m_optimizedSize);
|
|
|
|
|
|
|
|
requestVisibleTilesCacheUpdate();
|
|
|
|
|
|
|
|
m_smooth = !enable;
|
|
|
|
|
|
|
|
m_framebuffer->setSmooth(m_smooth);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|