diff --git a/mfile b/mfile index 7ca2919..70779da 100644 --- a/mfile +++ b/mfile @@ -1,4 +1,4 @@ { "package": "lotj-ui", - "version": "v2.0" + "version": "v2.2" } \ No newline at end of file diff --git a/src/scripts/galaxy-map/galaxy-map.lua b/src/scripts/galaxy-map/galaxy-map.lua index c0ca69f..a08bec8 100644 --- a/src/scripts/galaxy-map/galaxy-map.lua +++ b/src/scripts/galaxy-map/galaxy-map.lua @@ -19,6 +19,8 @@ function lotj.galaxyMap.setup() height = "100%", }, lotj.layout.upperRightTabData.contents["galaxy"]) 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({ name = "galaxyMapRefresh", diff --git a/src/scripts/mapper/mapper.lua b/src/scripts/mapper/mapper.lua index aefc1dd..d8894ef 100644 --- a/src/scripts/mapper/mapper.lua +++ b/src/scripts/mapper/mapper.lua @@ -208,12 +208,6 @@ function lotj.mapper.startMapping(areaName) if areaTable[areaName] == nil then addAreaName(areaName) lotj.mapper.log("Mapping in new area "..areaName..".") - - if lotj.mapper.noAreasPrompt ~= nil then - lotj.mapper.noAreasPrompt:hide() - lotj.mapper.noAreasPrompt = nil - lotj.mapper.mapperInstance:show() - end else lotj.mapper.log("Mapping in existing area "..areaName..".") end @@ -292,11 +286,18 @@ end function lotj.mapper.setup() - lotj.mapper.mapperInstance = Geyser.Mapper:new({ - x = 0, y = 0, - width = "100%", - height = "100%", - }, lotj.layout.upperRightTabData.contents["map"]) + 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, + width = "100%", + height = "100%", + }, lotj.layout.upperRightTabData.contents["map"]) + else + lotj.layout.upperRightTabData.contents["map"]:add(geyserMapper) + geyserMapper:raiseAll() + end setMapZoom(15) local hasAnyAreas = false @@ -313,6 +314,11 @@ function lotj.mapper.setup() lotj.setup.registerEventHandler("gmcp.Room.Info", lotj.mapper.onEnterRoom) 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 function lotj.mapper.handleSentCommand(event, cmd) diff --git a/src/scripts/setup/setup.lua b/src/scripts/setup/setup.lua index d15e109..5c4974c 100644 --- a/src/scripts/setup/setup.lua +++ b/src/scripts/setup/setup.lua @@ -41,6 +41,7 @@ local function teardown() killAnonymousEventHandler(killId) end + lotj.mapper.teardown() lotj.layout.teardown() lotj = nil end