More changes to minimap

This commit is contained in:
Henrique Santiago 2013-01-31 18:34:15 -02:00
parent 36a60419ec
commit e370ffdb0f
2 changed files with 16 additions and 2 deletions

View File

@ -4,6 +4,8 @@ UIImageView = extends(UIWidget)
function UIImageView.create() function UIImageView.create()
local imageView = UIImageView.internalCreate() local imageView = UIImageView.internalCreate()
imageView.zoom = 1 imageView.zoom = 1
imageView.minZoom = math.pow(10, -2)
imageView.maxZoom = math.pow(10, 2)
imageView:setClipping(true) imageView:setClipping(true)
return imageView return imageView
end end
@ -36,6 +38,7 @@ function UIImageView:setImage(image)
end end
function UIImageView:setZoom(zoom, x, y) function UIImageView:setZoom(zoom, x, y)
zoom = math.max(math.min(zoom, self.maxZoom), self.minZoom)
local posX, posY = self:getImagePosition(x, y) local posX, posY = self:getImagePosition(x, y)
local textureWidth = self:getImageTextureWidth() local textureWidth = self:getImageTextureWidth()
local textureHeight = self:getImageTextureHeight() local textureHeight = self:getImageTextureHeight()

View File

@ -8,6 +8,7 @@ function UIMinimap:onSetup()
self.dx = 0 self.dx = 0
self.dy = 0 self.dy = 0
self.autowalk = true self.autowalk = true
self.allowFollowLocalPlayer = true
self.onPositionChange = function() self:followLocalPlayer() end self.onPositionChange = function() self:followLocalPlayer() end
self.onAddAutomapFlag = function(pos, icon, description) self:addFlag(pos, icon, description) end self.onAddAutomapFlag = function(pos, icon, description) self:addFlag(pos, icon, description) end
self.onRemoveAutomapFlag = function(pos, icon, description) self:addFlag(pos, icon, description) end self.onRemoveAutomapFlag = function(pos, icon, description) self:addFlag(pos, icon, description) end
@ -53,6 +54,10 @@ function UIMinimap:disableAutoWalk()
self.autowalk = false self.autowalk = false
end end
function UIMinimap:disableFollowPlayer()
self.allowFollowLocalPlayer = false
end
function UIMinimap:enableFullPanel(image) function UIMinimap:enableFullPanel(image)
self.fullImage = image self.fullImage = image
end end
@ -130,7 +135,7 @@ end
function UIMinimap:updateFlag(flag) function UIMinimap:updateFlag(flag)
local point = self:getPoint(flag.pos) local point = self:getPoint(flag.pos)
if self:containsPoint(point) and self:getZoom() > 0 then if self:containsPoint(point) and self:getZoom() >= 0 and flag.pos.z == self:getCameraPosition().z then
flag:setVisible(true) flag:setVisible(true)
flag:setMarginLeft(point.x - self:getX() - flag:getWidth()/2) flag:setMarginLeft(point.x - self:getX() - flag:getWidth()/2)
flag:setMarginTop(point.y - self:getY() - flag:getHeight()/2) flag:setMarginTop(point.y - self:getY() - flag:getHeight()/2)
@ -146,6 +151,12 @@ function UIMinimap:updateFlags()
end end
end end
UIMinimap.realSetCameraPosition = UIMinimap.realSetCameraPosition or UIMinimap.setCameraPosition
function UIMinimap:setCameraPosition(pos)
self:realSetCameraPosition(pos)
self:updateFlags()
end
UIMinimap.realZoomIn = UIMinimap.realZoomIn or UIMinimap.zoomIn UIMinimap.realZoomIn = UIMinimap.realZoomIn or UIMinimap.zoomIn
function UIMinimap:zoomIn() function UIMinimap:zoomIn()
self:realZoomIn() self:realZoomIn()
@ -183,7 +194,7 @@ function UIMinimap:floorDown(floors)
end end
function UIMinimap:followLocalPlayer() function UIMinimap:followLocalPlayer()
if not self:isDragging() then if not self:isDragging() and self.allowFollowLocalPlayer then
local player = g_game.getLocalPlayer() local player = g_game.getLocalPlayer()
self:followCreature(player) self:followCreature(player)
self:updateFlags() self:updateFlags()