resize changes

This commit is contained in:
Eduardo Bart 2012-01-31 02:12:54 -02:00
parent 7b965a27af
commit deedef235d
3 changed files with 31 additions and 9 deletions

View File

@ -59,7 +59,7 @@ void MapView::draw(const Rect& rect)
if(isNearView())
tileDrawFlags = Otc::DrawGround | Otc::DrawWalls | Otc::DrawCommonItems | Otc::DrawCreatures | Otc::DrawEffects;
else if(isMidView())
tileDrawFlags = Otc::DrawGround | Otc::DrawWalls | Otc::DrawCommonItems | Otc::DrawCreatures;
tileDrawFlags = Otc::DrawGround | Otc::DrawWalls | Otc::DrawCommonItems;
else if(isFarView())
tileDrawFlags = Otc::DrawGround | Otc::DrawWalls;
else // huge far view
@ -137,6 +137,10 @@ void MapView::draw(const Rect& rect)
if(pos.z < m_cachedFirstVisibleFloor || pos.z > m_cachedLastVisibleFloor)
continue;
// dont draw animated texts from covered tiles
if(pos.z != cameraPosition.z && g_map.isCovered(pos, m_cachedFirstVisibleFloor))
continue;
Point p = transformPositionTo2D(pos) - drawOffset;
p.x = p.x * horizontalStretchFactor;
p.y = p.y * verticalStretchFactor;
@ -286,7 +290,7 @@ int MapView::getFirstVisibleFloor()
Position cameraPosition = getCameraPosition();
// avoid rendering multile floors on far views
if(!isNearView())
if(!isNearView() && !isMidView())
return cameraPosition.z;
// if nothing is limiting the view, the first visible floor is 0
@ -294,7 +298,7 @@ int MapView::getFirstVisibleFloor()
// limits to underground floors while under sea level
if(cameraPosition.z > Otc::SEA_FLOOR)
firstFloor = cameraPosition.z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE;
firstFloor = std::max(cameraPosition.z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::UNDERGROUND_FLOOR);
// loop in 3x3 tiles around the camera
for(int ix = -1; ix <= 1 && firstFloor < cameraPosition.z; ++ix) {
@ -302,7 +306,7 @@ int MapView::getFirstVisibleFloor()
Position pos = cameraPosition.translated(ix, iy);
// process tiles that we can look through, e.g. windows, doors
if((ix == 0 && iy == 0) || g_map.isLookPossible(pos)) {
if((ix == 0 && iy == 0) || (/*(std::abs(ix) != std::abs(iy)) && */g_map.isLookPossible(pos))) {
Position upperPos = pos;
Position coveredPos = pos;
@ -336,7 +340,7 @@ int MapView::getLastVisibleFloor()
Position cameraPosition = getCameraPosition();
// avoid rendering multile floors on far views
if(!isNearView())
if(!isNearView() && !isMidView())
return cameraPosition.z;
// view only underground floors when below sea level

View File

@ -30,10 +30,10 @@
class MapView : public LuaObject
{
enum {
DEFAULT_FRAMBUFFER_SIZE = 2048,
DEFAULT_FRAMBUFFER_SIZE = 3840,
NEAR_VIEW_AREA = 64*64,
MID_VIEW_AREA = 128*128,
FAR_VIEW_AREA = 192*192
FAR_VIEW_AREA = 256*256
};
public:

View File

@ -56,7 +56,16 @@ void UIMap::draw()
void UIMap::zoomIn()
{
m_mapView->setVisibleDimension(m_mapView->getVisibleDimension() + Size(2,2));
int dimensionHeight = m_mapView->getVisibleDimension().height() * 0.99;
if(dimensionHeight == m_mapView->getVisibleDimension().height())
dimensionHeight -= 1;
if(dimensionHeight % 2 == 0)
dimensionHeight -= 1;
int dimensionWidth = dimensionHeight * getSize().ratio();
if(dimensionWidth % 2 == 0)
dimensionWidth -= 1;
m_mapView->setVisibleDimension(Size(dimensionWidth, dimensionHeight));
Rect mapRect = getChildrenRect().expanded(-1);
Size mapSize = m_mapView->getVisibleSize();
@ -68,7 +77,16 @@ void UIMap::zoomIn()
void UIMap::zoomOut()
{
m_mapView->setVisibleDimension(m_mapView->getVisibleDimension() - Size(2,2));
int dimensionHeight = m_mapView->getVisibleDimension().height() * 1.01;
if(dimensionHeight == m_mapView->getVisibleDimension().height())
dimensionHeight += 1;
if(dimensionHeight % 2 == 0)
dimensionHeight += 1;
int dimensionWidth = dimensionHeight * getSize().ratio();
if(dimensionWidth % 2 == 0)
dimensionWidth += 1;
m_mapView->setVisibleDimension(Size(dimensionWidth, dimensionHeight));
Rect mapRect = getChildrenRect().expanded(-1);
Size mapSize = m_mapView->getVisibleSize();