More changes to minimap

master
Henrique Santiago 11 years ago
parent 36a60419ec
commit e370ffdb0f

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

@ -8,6 +8,7 @@ function UIMinimap:onSetup()
self.dx = 0
self.dy = 0
self.autowalk = true
self.allowFollowLocalPlayer = true
self.onPositionChange = function() self:followLocalPlayer() 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
@ -53,6 +54,10 @@ function UIMinimap:disableAutoWalk()
self.autowalk = false
end
function UIMinimap:disableFollowPlayer()
self.allowFollowLocalPlayer = false
end
function UIMinimap:enableFullPanel(image)
self.fullImage = image
end
@ -130,7 +135,7 @@ end
function UIMinimap:updateFlag(flag)
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:setMarginLeft(point.x - self:getX() - flag:getWidth()/2)
flag:setMarginTop(point.y - self:getY() - flag:getHeight()/2)
@ -146,6 +151,12 @@ function UIMinimap:updateFlags()
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
function UIMinimap:zoomIn()
self:realZoomIn()
@ -183,7 +194,7 @@ function UIMinimap:floorDown(floors)
end
function UIMinimap:followLocalPlayer()
if not self:isDragging() then
if not self:isDragging() and self.allowFollowLocalPlayer then
local player = g_game.getLocalPlayer()
self:followCreature(player)
self:updateFlags()

Loading…
Cancel
Save