|
|
@ -4,7 +4,7 @@ Minimap = {}
|
|
|
|
local minimapWidget
|
|
|
|
local minimapWidget
|
|
|
|
local minimapButton
|
|
|
|
local minimapButton
|
|
|
|
local minimapWindow
|
|
|
|
local minimapWindow
|
|
|
|
local DEFAULT_ZOOM = 45
|
|
|
|
local DEFAULT_ZOOM = 60
|
|
|
|
minimapFirstLoad = true
|
|
|
|
minimapFirstLoad = true
|
|
|
|
|
|
|
|
|
|
|
|
-- private functions
|
|
|
|
-- private functions
|
|
|
@ -105,30 +105,28 @@ function Minimap.onMiniWindowClose()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function Minimap.isClickInRange(position, fromPosition, toPosition)
|
|
|
|
function Minimap.isClickInRange(position, fromPosition, toPosition)
|
|
|
|
return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.x <= toPosition.x and position.y <= toPosition.y)
|
|
|
|
return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.x <= toPosition.x and position.y <= toPosition.y)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- hooked functions
|
|
|
|
-- hooked functions
|
|
|
|
local compassZones = {}
|
|
|
|
|
|
|
|
compassZones.west = {x = 0, y = 30, posx = -1, posy = 0}
|
|
|
|
|
|
|
|
compassZones.north = {x = 30, y = 0, posx = 0, posy = -1}
|
|
|
|
|
|
|
|
compassZones.south = {x = 30, y = 57, posx = 0, posy = 1}
|
|
|
|
|
|
|
|
compassZones.east = {x = 57, y = 30, posx = 1, posy = 0}
|
|
|
|
|
|
|
|
function Minimap.compassClick(self, mousePos)
|
|
|
|
function Minimap.compassClick(self, mousePos)
|
|
|
|
local compassPos = self:getRect()
|
|
|
|
local px = mousePos.x - self:getX()
|
|
|
|
local pos = {x = mousePos.x-compassPos.x, y = mousePos.y-compassPos.y}
|
|
|
|
local py = mousePos.y - self:getY()
|
|
|
|
local move = {x = 0, y = 0}
|
|
|
|
local dx = px - self:getWidth()/2
|
|
|
|
for i,v in pairs(compassZones) do
|
|
|
|
local dy = -(py - self:getHeight()/2)
|
|
|
|
local lowPos = {x = v.x-15, y = v.y-15}
|
|
|
|
local radius = math.sqrt(dx*dx+dy*dy)
|
|
|
|
local highPos = {x = v.x+15, y = v.y+15}
|
|
|
|
local movex=0
|
|
|
|
if Minimap.isClickInRange(pos, lowPos, highPos) then
|
|
|
|
local movey=0
|
|
|
|
move.x = move.x + v.posx * minimapWidget:getZoom()/10
|
|
|
|
dx = dx/radius
|
|
|
|
move.y = move.y + v.posy * minimapWidget:getZoom()/10
|
|
|
|
dy = dy/radius
|
|
|
|
break
|
|
|
|
|
|
|
|
end
|
|
|
|
if dx > 0.5 then movex = 1 end
|
|
|
|
end
|
|
|
|
if dx < -0.5 then movex = -1 end
|
|
|
|
|
|
|
|
if dy > 0.5 then movey = -1 end
|
|
|
|
|
|
|
|
if dy < -0.5 then movey = 1 end
|
|
|
|
|
|
|
|
|
|
|
|
local cameraPos = minimapWidget:getCameraPosition()
|
|
|
|
local cameraPos = minimapWidget:getCameraPosition()
|
|
|
|
local pos = {x = cameraPos.x + move.x, y = cameraPos.y + move.y, z = cameraPos.z}
|
|
|
|
local pos = {x = cameraPos.x + movex, y = cameraPos.y + movey, z = cameraPos.z}
|
|
|
|
minimapWidget:setCameraPosition(pos)
|
|
|
|
minimapWidget:setCameraPosition(pos)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|