View Single Post
02/21/19, 01:32 PM   #23
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
I had changed the code in HideMe v3 already to use the name constant but you have stripped it again
Here is the changed code for v4, all files + the zip archive attached:

HideMe.txt
Code:
## Title: HideMe
## Description: Immersive changes to the map, pins and zoom
## Version: 4
## AddOnVersion: 4
## APIVersion: 100025 100026

HideMe.lua
src/NoZoom.lua
src/NoZoom.lua
Lua Code:
  1. local ZO_MapPanAndZoom = {MAX_OVER_ZOOM = 0.589}
  2. function ZO_MapPanAndZoom:CanMapZoom()
  3.     return GetMapContentType() ~= MAP_CONTENT_DUNGEON
  4. end
  5. function ZO_MapPanAndZoom:ComputeMinZoom()
  6.     return 1
  7. end
  8. function ZO_MapPanAndZoom:ComputeMaxZoom()
  9.     if(not self:CanMapZoom()) then
  10.         return 1
  11.     else
  12.         local numTiles = GetMapNumTiles()
  13.         local tilePixelWidth = ZO_WorldMapContainer1:GetTextureFileDimensions()
  14.         local totalPixels = numTiles * tilePixelWidth
  15.         local mapAreaUIUnits = ZO_WorldMapScroll:GetHeight()
  16.         local mapAreaPixels = mapAreaUIUnits * GetUIGlobalScale()
  17.         local maxZoomToStayBelowNative = totalPixels / mapAreaPixels
  18.         return zo_max(maxZoomToStayBelowNative * ZO_MapPanAndZoom.MAX_OVER_ZOOM, 0.589)
  19.     end
  20. end
  21.  
  22. local function ChangeZoomLimit()
  23.     local FACTOR = 1
  24.     local minZoom = ZO_MapPanAndZoom:ComputeMinZoom()
  25.     local maxZoom = ZO_MapPanAndZoom:ComputeMaxZoom()
  26.     ZO_WorldMap_SetCustomZoomLevels(minZoom, maxZoom * FACTOR)
  27. end
  28.  
  29. local orig_ZO_WorldMap_ShowWorldMap = ZO_WorldMap_ShowWorldMap
  30. ZO_WorldMap_ShowWorldMap = function()
  31.     orig_ZO_WorldMap_ShowWorldMap()
  32.     ZO_WorldMap_ClearCustomZoomLevels()
  33.     zo_callLater(ChangeZoomLimit, 1)
  34. end
  35.  
  36. local orig_ZO_WorldMap_UpdateMap = ZO_WorldMap_UpdateMap
  37. ZO_WorldMap_UpdateMap = function()
  38.     orig_ZO_WorldMap_UpdateMap()
  39.     ZO_WorldMap_ClearCustomZoomLevels()
  40.     zo_callLater(ChangeZoomLimit, 1)
  41. end

HideMe.lua
Lua Code:
  1. HideMe = {}
  2. HideMe.name = "HideMe"
  3.  
  4. local function Addon_Loaded(eventCode, addOnName)
  5.     if (addOnName == HideMe.name) then
  6.         --Hide player pin on map
  7.         ZO_MapPin0:SetHidden(true)
  8.         ZO_MapPin0.SetHidden = function()
  9.         end
  10.         --Disable "show player on map" keybind
  11.         ZO_PreHook("ZO_WorldMap_PanToPlayer", function()
  12.             return true
  13.         end
  14.         )
  15.     end
  16.     --Hide map pins in subZones (cities etc.)
  17.     ZO_PreHook("IsMapLocationVisible", function()
  18.         if GetParentZoneId ~= nil then
  19.             local zoneId, subZoneId
  20.             zoneId = GetParentZoneId ()
  21.             if zoneId ~= nil then
  22.                 local zoneIndex = GetUnitZoneIndex("player")
  23.                 if zoneIndex ~= nil then
  24.                     subZoneId = GetZoneId(zoneIndex)
  25.                     if subZoneId ~= nil then return true end
  26.                 end
  27.             end
  28.         end
  29.         return false
  30.     end)
  31. end
  32. EVENT_MANAGER:RegisterForEvent(HideMe.name, EVENT_ADD_ON_LOADED, Addon_Loaded)
Attached Files
File Type: zip HideMe_v4.zip (1.7 KB, 335 views)
  Reply With Quote