ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Wish List (https://www.esoui.com/forums/forumdisplay.php?f=177)
-   -   [implemented] ZO_WorldMap_SetMapById() (https://www.esoui.com/forums/showthread.php?t=9734)

Masteroshi430 05/14/21 11:33 PM

[implemented] ZO_WorldMap_SetMapById()
 
Many maps don't have a map index but it looks like all maps have a map ID so :

ZO_WorldMap_SetMapById()

would be of a great help for map / navigation AddOns
e. g. my QuickMapNav AddOn.

Shinni 05/15/21 06:05 AM

There exists the api function SetMapToMapId(mapId), so you could just call the following
Lua Code:
  1. if SetMapToMapId(mapId) == SET_MAP_RESULT_MAP_CHANGED then
  2.     CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
  3. end

Masteroshi430 05/15/21 11:43 AM

Wow! Thanks I totally missed that! :banana:

Masteroshi430 05/15/21 09:37 PM

I added it to the Wiki :
https://wiki.esoui.com/SetMapToMapId
:)

IsJustaGhost 05/11/22 06:05 AM

There is a SetMapToMapId. However, unless the user changes the map manually first, the map will reset to the on map open default after SetMapToMapId is used. Making it almost useless.

I've proposed this.
Lua Code:
  1. function ZO_WorldMap_SetMapById(mapId)
  2.     if WORLD_MAP_MANAGER:IsMapChangingAllowed() then
  3.         if SetMapToMapId(mapId) == SET_MAP_RESULT_MAP_CHANGED then
  4.             g_playerChoseCurrentMap = true
  5.             CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
  6.         end
  7.     end
  8. end

You see, the g_playerChoseCurrentMap must be true in order for the map to not be reset.
Lua Code:
  1. function Update(map, currentTimeS)
  2.         -- ... in short
  3.  
  4.             -- If the player is just wandering around the world, with their map open, then refresh it every so often so that
  5.             -- it's showing the appropriate location for where they are.  If they actually picked a loction, then avoid this update.
  6.             if not g_playerChoseCurrentMap then
  7.                 if SetMapToPlayerLocation() == SET_MAP_RESULT_MAP_CHANGED then

The alternative is to:
Lua Code:
  1. local original_CALLBACK_MANAGER = CALLBACK_MANAGER
  2. local function setMapById(mapId)
  3.     -- lets prevent the callback from firing when we only want to set g_playerChoseCurrentMap to true
  4.     CALLBACK_MANAGER = {FireCallbacks = function() end}
  5.  
  6.     -- Lets fire this so it will set g_playerChoseCurrentMap to true
  7.     ZO_WorldMap_SetMapByIndex(1)
  8.    
  9.     -- Now reset the callback manager
  10.     CALLBACK_MANAGER = original_CALLBACK_MANAGER
  11.    
  12.     -- Set map by mapId and fire callback
  13.     if SetMapToMapId(mapId) == SET_MAP_RESULT_MAP_CHANGED then
  14.         CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
  15.     end
  16. end

Sharlikran 05/11/22 06:44 AM

Or do things a better way and use what is already available which will be more compatible with other mods.
Code:

  local GPS = LibGPS3
  SetMapToMapId(mapId)
  GPS:SetPlayerChoseCurrentMap()
  CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")


IsJustaGhost 11/01/22 06:04 PM

This can be closed.
WORLD_MAP_MANAGER:SetMapById(mapId) exists now

Baertram 11/01/22 08:00 PM

Closed and updated the Wiki


All times are GMT -6. The time now is 03:57 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI