2013-01-21 22:36:53 +01:00
|
|
|
filename = nil
|
2012-08-15 01:58:25 +02:00
|
|
|
loaded = false
|
2012-08-10 00:54:03 +02:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function init()
|
2012-12-28 12:05:45 +01:00
|
|
|
connect(g_game, { onProtocolVersionChange = load })
|
2012-07-31 06:09:55 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function terminate()
|
2012-12-28 12:05:45 +01:00
|
|
|
disconnect(g_game, { onProtocolVersionChange = load })
|
2012-07-18 09:49:44 +02:00
|
|
|
end
|
|
|
|
|
2012-08-10 00:54:03 +02:00
|
|
|
function setFileName(name)
|
|
|
|
filename = name
|
|
|
|
end
|
|
|
|
|
2012-08-15 01:58:25 +02:00
|
|
|
function isLoaded()
|
|
|
|
return loaded
|
|
|
|
end
|
|
|
|
|
2012-07-26 08:10:28 +02:00
|
|
|
function load()
|
2013-08-04 00:21:08 +02:00
|
|
|
local version = g_game.getClientVersion()
|
2013-01-21 22:36:53 +01:00
|
|
|
|
|
|
|
local datPath, sprPath
|
|
|
|
if filename then
|
|
|
|
datPath = resolvepath('/things/' .. filename)
|
|
|
|
sprPath = resolvepath('/things/' .. filename)
|
|
|
|
else
|
|
|
|
datPath = resolvepath('/things/' .. version .. '/Tibia')
|
|
|
|
sprPath = resolvepath('/things/' .. version .. '/Tibia')
|
|
|
|
end
|
2012-08-10 00:54:03 +02:00
|
|
|
|
|
|
|
local errorMessage = ''
|
2012-07-26 08:10:28 +02:00
|
|
|
if not g_things.loadDat(datPath) then
|
2012-08-10 00:54:03 +02:00
|
|
|
errorMessage = errorMessage .. tr("Unable to load dat file, please place a valid dat in '%s'", datPath) .. '\n'
|
2012-07-26 08:10:28 +02:00
|
|
|
end
|
|
|
|
if not g_sprites.loadSpr(sprPath) then
|
2012-08-15 01:58:25 +02:00
|
|
|
errorMessage = errorMessage .. tr("Unable to load spr file, please place a valid spr in '%s'", sprPath)
|
2012-08-10 00:54:03 +02:00
|
|
|
end
|
|
|
|
|
2012-08-15 01:58:25 +02:00
|
|
|
loaded = (errorMessage:len() == 0)
|
|
|
|
|
2012-08-10 00:54:03 +02:00
|
|
|
if errorMessage:len() > 0 then
|
2012-08-15 01:58:25 +02:00
|
|
|
local messageBox = displayErrorBox(tr('Error'), errorMessage)
|
|
|
|
addEvent(function() messageBox:raise() messageBox:focus() end)
|
|
|
|
|
2012-12-28 12:05:45 +01:00
|
|
|
disconnect(g_game, { onProtocolVersionChange = load })
|
2012-12-30 12:32:09 +01:00
|
|
|
g_game.setProtocolVersion(0)
|
2012-12-28 12:05:45 +01:00
|
|
|
connect(g_game, { onProtocolVersionChange = load })
|
2012-07-26 08:10:28 +02:00
|
|
|
end
|
2012-07-18 10:34:17 +02:00
|
|
|
end
|