|
|
@ -7,6 +7,7 @@ function UIMinimap:onSetup()
|
|
|
|
self.zoomOutWidget = self:getChildById('zoomOut')
|
|
|
|
self.zoomOutWidget = self:getChildById('zoomOut')
|
|
|
|
self.dx = 0
|
|
|
|
self.dx = 0
|
|
|
|
self.dy = 0
|
|
|
|
self.dy = 0
|
|
|
|
|
|
|
|
self.autowalk = 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
|
|
|
@ -24,6 +25,36 @@ function UIMinimap:onDestroy()
|
|
|
|
onRemoveAutomapFlag = self.onRemoveAutomapFlag,
|
|
|
|
onRemoveAutomapFlag = self.onRemoveAutomapFlag,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
self:destroyFlagWindow()
|
|
|
|
self:destroyFlagWindow()
|
|
|
|
|
|
|
|
self:destroyFullPanel()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function UIMinimap:onVisibilityChange()
|
|
|
|
|
|
|
|
if not self:isVisible() then
|
|
|
|
|
|
|
|
self:destroyFlagWindow()
|
|
|
|
|
|
|
|
self:destroyFullPanel()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function UIMinimap:hideFlags()
|
|
|
|
|
|
|
|
self.flagsWidget:hide()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function UIMinimap:hideFloor()
|
|
|
|
|
|
|
|
self.floorUpWidget:hide()
|
|
|
|
|
|
|
|
self.floorDownWidget:hide()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function UIMinimap:hideZoom()
|
|
|
|
|
|
|
|
self.zoomInWidget:hide()
|
|
|
|
|
|
|
|
self.zoomOutWidget:hide()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function UIMinimap:disableAutoWalk()
|
|
|
|
|
|
|
|
self.autowalk = false
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function UIMinimap:enableFullPanel(image)
|
|
|
|
|
|
|
|
self.fullImage = image
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function UIMinimap:load()
|
|
|
|
function UIMinimap:load()
|
|
|
@ -192,8 +223,7 @@ function UIMinimap:onMousePress(pos, button)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function UIMinimap:onMouseRelease(pos, button)
|
|
|
|
function UIMinimap:onMouseRelease(pos, button)
|
|
|
|
-- TODO:
|
|
|
|
if not self.allowNextRelease then return true end
|
|
|
|
--if not self.allowNextRelease then return true end
|
|
|
|
|
|
|
|
self.allowNextRelease = false
|
|
|
|
self.allowNextRelease = false
|
|
|
|
|
|
|
|
|
|
|
|
local mapPos = self:getPosition(pos)
|
|
|
|
local mapPos = self:getPosition(pos)
|
|
|
@ -201,15 +231,14 @@ function UIMinimap:onMouseRelease(pos, button)
|
|
|
|
|
|
|
|
|
|
|
|
if button == MouseLeftButton then
|
|
|
|
if button == MouseLeftButton then
|
|
|
|
local player = g_game.getLocalPlayer()
|
|
|
|
local player = g_game.getLocalPlayer()
|
|
|
|
if not player:autoWalk(mapPos) then
|
|
|
|
if self.autowalk and not player:autoWalk(mapPos) then
|
|
|
|
player.onAutoWalkFail = function() modules.game_textmessage.displayFailureMessage(tr('There is no way.')) end
|
|
|
|
player.onAutoWalkFail = function() modules.game_textmessage.displayFailureMessage(tr('There is no way.')) end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
elseif button == MouseRightButton then
|
|
|
|
elseif button == MouseRightButton then
|
|
|
|
local menu = g_ui.createWidget('PopupMenu')
|
|
|
|
local menu = g_ui.createWidget('PopupMenu')
|
|
|
|
menu:addOption(tr('Create mark'), function()
|
|
|
|
menu:addOption(tr('Create mark'), function() self:createFlagWindow(mapPos) end)
|
|
|
|
self:createFlagWindow(mapPos)
|
|
|
|
if self.fullImage then menu:addOption(tr('Full map'), function() self:createFullPanel() end) end
|
|
|
|
end)
|
|
|
|
|
|
|
|
menu:display(pos)
|
|
|
|
menu:display(pos)
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -229,6 +258,19 @@ function UIMinimap:onDragLeave(widget, pos)
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function UIMinimap:createFullPanel()
|
|
|
|
|
|
|
|
self.fullPanel = g_ui.createWidget('MinimapFullPanel', rootWidget)
|
|
|
|
|
|
|
|
self.fullPanel:setImageSource(self.fullImage)
|
|
|
|
|
|
|
|
self.fullPanel.onDestroy = function() self.fullPanel = nil end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function UIMinimap:destroyFullPanel()
|
|
|
|
|
|
|
|
if self.fullPanel then
|
|
|
|
|
|
|
|
self.fullPanel:destroy()
|
|
|
|
|
|
|
|
self.fullPanel = nil
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function UIMinimap:createFlagWindow(pos)
|
|
|
|
function UIMinimap:createFlagWindow(pos)
|
|
|
|
if self.flagWindow then return end
|
|
|
|
if self.flagWindow then return end
|
|
|
|
if not pos then return end
|
|
|
|
if not pos then return end
|
|
|
|