New lightweight minimap format, finish #15

This commit is contained in:
Eduardo Bart
2013-01-27 14:06:47 -02:00
parent cf0ecf418d
commit e81dd31ae3
14 changed files with 261 additions and 124 deletions

View File

@@ -6,7 +6,7 @@ navigating = false
minimapWidget = nil
minimapButton = nil
minimapWindow = nil
otmm = false
flagsPanel = nil
flagWindow = nil
nextFlagId = 0
@@ -49,6 +49,7 @@ function init()
reset()
minimapWindow:setup()
loadMapFlags()
useOTMM()
if g_game.isOnline() then
addEvent(function() updateMapFlags() end)
@@ -263,17 +264,32 @@ end
function loadMap()
local protocolVersion = g_game.getProtocolVersion()
local minimapFile = '/minimap_' .. protocolVersion .. '.otcm'
if g_resources.fileExists(minimapFile) then
g_map.clean()
g_map.loadOtcm(minimapFile)
g_map.clean()
g_minimap.clean()
if otmm then
local minimapFile = '/minimap.otmm'
if g_resources.fileExists(minimapFile) then
g_minimap.loadOtmm(minimapFile)
end
else
local minimapFile = '/minimap_' .. protocolVersion .. '.otcm'
if g_resources.fileExists(minimapFile) then
g_map.loadOtcm(minimapFile)
end
end
end
function saveMap()
local protocolVersion = g_game.getProtocolVersion()
local minimapFile = '/minimap_' .. protocolVersion .. '.otcm'
g_map.saveOtcm(minimapFile)
if otmm then
local minimapFile = '/minimap.otmm'
g_minimap.saveOtmm(minimapFile)
else
local minimapFile = '/minimap_' .. protocolVersion .. '.otcm'
g_map.saveOtcm(minimapFile)
end
end
function toggle()
@@ -286,6 +302,10 @@ function toggle()
end
end
function useOTMM()
otmm = true
end
function isClickInRange(position, fromPosition, toPosition)
return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.x <= toPosition.x and position.y <= toPosition.y)
end