Fix recreating land and galaxy map after uninstall/reinstall of client

This commit is contained in:
Matt Wagner 2021-06-05 15:59:19 -07:00
parent 053918418c
commit 4dc005893f
4 changed files with 21 additions and 12 deletions

2
mfile
View File

@ -1,4 +1,4 @@
{ {
"package": "lotj-ui", "package": "lotj-ui",
"version": "v2.0" "version": "v2.2"
} }

View File

@ -19,6 +19,8 @@ function lotj.galaxyMap.setup()
height = "100%", height = "100%",
}, lotj.layout.upperRightTabData.contents["galaxy"]) }, lotj.layout.upperRightTabData.contents["galaxy"])
lotj.galaxyMap.container:setBackgroundImage(getMudletHomeDir().."/@PKGNAME@/space.jpg") lotj.galaxyMap.container:setBackgroundImage(getMudletHomeDir().."/@PKGNAME@/space.jpg")
-- This seems necessary when recreating the UI after upgrading the package.
lotj.galaxyMap.container:raiseAll()
lotj.galaxyMap.refreshButton = Geyser.Label:new({ lotj.galaxyMap.refreshButton = Geyser.Label:new({
name = "galaxyMapRefresh", name = "galaxyMapRefresh",

View File

@ -208,12 +208,6 @@ function lotj.mapper.startMapping(areaName)
if areaTable[areaName] == nil then if areaTable[areaName] == nil then
addAreaName(areaName) addAreaName(areaName)
lotj.mapper.log("Mapping in new area <yellow>"..areaName.."<reset>.") lotj.mapper.log("Mapping in new area <yellow>"..areaName.."<reset>.")
if lotj.mapper.noAreasPrompt ~= nil then
lotj.mapper.noAreasPrompt:hide()
lotj.mapper.noAreasPrompt = nil
lotj.mapper.mapperInstance:show()
end
else else
lotj.mapper.log("Mapping in existing area <yellow>"..areaName.."<reset>.") lotj.mapper.log("Mapping in existing area <yellow>"..areaName.."<reset>.")
end end
@ -292,11 +286,18 @@ end
function lotj.mapper.setup() function lotj.mapper.setup()
lotj.mapper.mapperInstance = Geyser.Mapper:new({ if not geyserMapper then
-- Preserve this as a global. We can only create one mapper in a profile, so if we
-- unload and reload this UI, we need to reuse what was created before.
geyserMapper = Geyser.Mapper:new({
x = 0, y = 0, x = 0, y = 0,
width = "100%", width = "100%",
height = "100%", height = "100%",
}, lotj.layout.upperRightTabData.contents["map"]) }, lotj.layout.upperRightTabData.contents["map"])
else
lotj.layout.upperRightTabData.contents["map"]:add(geyserMapper)
geyserMapper:raiseAll()
end
setMapZoom(15) setMapZoom(15)
local hasAnyAreas = false local hasAnyAreas = false
@ -313,6 +314,11 @@ function lotj.mapper.setup()
lotj.setup.registerEventHandler("gmcp.Room.Info", lotj.mapper.onEnterRoom) lotj.setup.registerEventHandler("gmcp.Room.Info", lotj.mapper.onEnterRoom)
end end
function lotj.mapper.teardown()
lotj.layout.upperRightTabData.contents["map"]:remove(geyserMapper)
geyserMapper:hide()
end
-- Track the most recent movement command so we know which direction we moved when automapping -- Track the most recent movement command so we know which direction we moved when automapping
function lotj.mapper.handleSentCommand(event, cmd) function lotj.mapper.handleSentCommand(event, cmd)

View File

@ -41,6 +41,7 @@ local function teardown()
killAnonymousEventHandler(killId) killAnonymousEventHandler(killId)
end end
lotj.mapper.teardown()
lotj.layout.teardown() lotj.layout.teardown()
lotj = nil lotj = nil
end end