Advertisement
Guest User

Untitled

a guest
May 8th, 2023
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 367.93 KB | None | 0 0
  1. FyrMM = {}
  2. FyrMM.Panel = {}
  3. FyrMM.Options = {}
  4. FyrMM.noMap = false
  5. FyrMM.Visible = true
  6. FyrMM.AutoHidden = false
  7. FyrMM.FpsTest = false
  8. FyrMM.Fps = 0
  9. FyrMM.FpsRaw = 0
  10. FyrMM.Initialized = false
  11. FyrMM.pScale = 75
  12. FyrMM.pScalePercent = 0.75
  13. FyrMM.questPinCount = 0
  14. FyrMM.currentLocationsCount = 0
  15. FyrMM.currentPOICount = 0
  16. FyrMM.currentForwardCamps = 0
  17. FyrMM.currentWayshrineCount = 0
  18. FyrMM.AfterCombatUnhidePending = false
  19. FyrMM.AfterCombatUnhideTimeStamp = 0
  20. FyrMM.LastQuestPinRequest = 0
  21. FyrMM.MovementSpeed = 0
  22. FyrMM.MovementSpeedPrevious = 0
  23. FyrMM.MovementSpeedMax = 0
  24. FyrMM.UseOriginalFunctions = true
  25. FyrMM.MeasureMaps = true
  26. FyrMM.DistanceMeasurementStarted = false
  27. FyrMM.InitialPreloadTimeStamp = nil
  28. FyrMM.currentMap = {}
  29. FyrMM.currentMap.MapId = 0
  30. FyrMM.currentMap.PlayerNX = 0
  31. FyrMM.currentMap.PlayerNY = 0
  32. FyrMM.currentMap.mapBuilt = false
  33. FyrMM.currentMap.PlayerMounted = false
  34. FyrMM.currentMap.PlayerSwimming = false
  35. FyrMM.currentMap.movedTimeStamp = 0
  36. FyrMM.currentMap.ZoneIndex = 0
  37. FyrMM.currentMap.MapContent = GetMapContentType()
  38. FyrMM.CheckingZone = false
  39. FyrMM.CustomPinList = {}
  40. FyrMM.CustomPinCheckList = {}
  41. FyrMM.LoadingCustomPins = {}
  42. FyrMM.UpdatingCustomPins = {}
  43. FyrMM.CustomPinsEnabled = true
  44. FyrMM.CustomWaypointsList = {}
  45. FyrMM.IsGroup = false
  46. FyrMM.IsWaypoint = false
  47. FyrMM.Waypoint = nil
  48. FyrMM.IsRally = false
  49. FyrMM.Rally = nil
  50. FyrMM.IsPing = false
  51. FyrMM.Ping = nil
  52. FyrMM.OverMiniMap = false
  53. FyrMM.OverMenu = false
  54. FyrMM.MenuFadingIn = false
  55. FyrMM.MenuFadingOut = false
  56. FyrMM.DisableSubzones = false
  57. FyrMM.Halted = false
  58. FyrMM.HaltTimeOffset = 0
  59. FyrMM.LastReload = 0
  60. FyrMM.DebugMode = false
  61. FyrMM.MapAPI0Present = false
  62. FyrMM.FadingEdges = false
  63. FyrMM.KeepRefreshNeeded = true
  64. FyrMM.GroupRefreshNeeded = true
  65. FyrMM.CustomPinCount = 0
  66. FyrMM.AvailableQuestGivers = {}
  67. FYRMM_ZOOM_MAX = 50
  68. FYRMM_ZOOM_MIN = 1
  69. FYRMM_DEFAULT_ZOOM_LEVEL = 10
  70. FYRMM_ZOOM_INCREMENT_AMOUNT = nil
  71. FYRMM_QUEST_PIN_REQUEST_TIMEOUT = 10000 -- Time in miliseconds to wait for quest pin data
  72. FYRMM_QUEST_PIN_REQUEST_MINIMUM_DELAY = 1000 -- Time in miliseconds to be passed before requesting quest pins again
  73. MM_GetNumMapLocations = GetNumMapLocations -- Location pin count
  74. MM_IsMapLocationVisible = IsMapLocationVisible -- is Location visible
  75. MM_GetMapLocationIcon = GetMapLocationIcon -- Location pin texture
  76. MM_GetNumPOIs = GetNumPOIs -- POI pin count
  77. MM_GetPOIMapInfo = GetPOIMapInfo -- POI pin info
  78. FyrMM.QuestPins = {}
  79. FyrMM.RequestedQuestPins = {}
  80. FyrMM.currentDigSiteCount = 0
  81. FyrMM.TimeFormat = 0
  82. FyrMM.pinZoomScale = 1
  83.  
  84. local QuestPins = FyrMM.QuestPins
  85. local RequestedQuestPins = FyrMM.RequestedQuestPins
  86.  
  87. local FreeQuestPinIndex = {}
  88. local CurrentTasks = {}
  89. local NeedQuestPinUpdate = true
  90. local QuestPinsUpdating = false
  91. local QuestTasksPending = false
  92. local CustomPinsCopying = false
  93. local PinRef = nil
  94. local PRCustomPins = nil
  95. local PRMap = nil -- data is put into this variable but never used.
  96. local LastQuestPinIndex = 0
  97. local CurrentMap = FyrMM.currentMap
  98. local CurrentMapId = 0
  99. local CurrentTasks = CurrentTasks
  100. local CWSTimeStamp = 0 -- never used
  101. local AQGTimeStamp = 0 -- never used
  102. local CleanPOIs = 0
  103. local CustomPinIndex = {}
  104. local CustomPinKeyIndex = {}
  105. local FreeCustomPinIndex = {}
  106. local LastCustomPinIndex = 0
  107. local CustomPinMapId = 0
  108. local PinsList = {}
  109. local PinsIndex = {} -- never used
  110. local Wayshrines = {}
  111. local WayshrineDistancesTimeStamp = 0
  112. local KeepIndex = {}
  113. local PositionLog3D = {}
  114. local PositionLogCounter = 0
  115. local Treasures = {}
  116. local DragonNextLocation = {}
  117. local Digsites = {}
  118. local AQGList = {}
  119. local AQGListFull = {}
  120. local wuthreads = 0 -- never used
  121. local ruthreads = 0 -- never used
  122. local MenuAnimation
  123. local wrc = 0 -- never used
  124. local mapContentType = 0 -- never used
  125. local ZOpinData = ZO_MapPin.PIN_DATA
  126. local pi = math.pi
  127. local detectedNewCustomPin = false
  128. local CustomPinCrossReference = {}
  129. local IsCompanionAround = false
  130. local ASSISTED_PIN_TYPES = ZO_MapPin.ASSISTED_PIN_TYPES
  131. local QUEST_PIN_TYPES = ZO_MapPin.QUEST_PIN_TYPES
  132.  
  133. local questPinTextures = {
  134. [MAP_PIN_TYPE_ASSISTED_QUEST_CONDITION] = "EsoUI/Art/Compass/quest_icon_assisted.dds",
  135. [MAP_PIN_TYPE_ASSISTED_QUEST_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/quest_icon_assisted.dds",
  136. [MAP_PIN_TYPE_ASSISTED_QUEST_ENDING] = "EsoUI/Art/Compass/quest_icon_assisted.dds",
  137. [MAP_PIN_TYPE_ASSISTED_QUEST_REPEATABLE_CONDITION] = "EsoUI/Art/Compass/repeatableQuest_icon_assisted.dds",
  138. [MAP_PIN_TYPE_ASSISTED_QUEST_REPEATABLE_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/repeatableQuest_icon_assisted.dds",
  139. [MAP_PIN_TYPE_ASSISTED_QUEST_REPEATABLE_ENDING] = "EsoUI/Art/Compass/repeatableQuest_icon_assisted.dds",
  140. [MAP_PIN_TYPE_ASSISTED_QUEST_ZONE_STORY_CONDITION] = "EsoUI/Art/Compass/zoneStoryQuest_icon_assisted.dds",
  141. [MAP_PIN_TYPE_ASSISTED_QUEST_ZONE_STORY_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/zoneStoryQuest_icon_assisted.dds",
  142. [MAP_PIN_TYPE_ASSISTED_QUEST_ZONE_STORY_ENDING] = "EsoUI/Art/Compass/zoneStoryQuest_icon_assisted.dds",
  143. [MAP_PIN_TYPE_TRACKED_QUEST_CONDITION] = "EsoUI/Art/Compass/quest_icon.dds",
  144. [MAP_PIN_TYPE_TRACKED_QUEST_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/quest_icon.dds",
  145. [MAP_PIN_TYPE_TRACKED_QUEST_ENDING] = "EsoUI/Art/Compass/quest_icon.dds",
  146. [MAP_PIN_TYPE_TRACKED_QUEST_REPEATABLE_CONDITION] = "EsoUI/Art/Compass/repeatableQuest_icon.dds",
  147. [MAP_PIN_TYPE_TRACKED_QUEST_REPEATABLE_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/repeatableQuest_icon.dds",
  148. [MAP_PIN_TYPE_TRACKED_QUEST_REPEATABLE_ENDING] = "EsoUI/Art/Compass/repeatableQuest_icon.dds",
  149. [MAP_PIN_TYPE_TRACKED_QUEST_ZONE_STORY_CONDITION] = "EsoUI/Art/Compass/zoneStoryQuest_icon.dds",
  150. [MAP_PIN_TYPE_TRACKED_QUEST_ZONE_STORY_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/zoneStoryQuest_icon.dds",
  151. [MAP_PIN_TYPE_TRACKED_QUEST_ZONE_STORY_ENDING] = "EsoUI/Art/Compass/zoneStoryQuest_icon.dds",
  152. [MAP_PIN_TYPE_QUEST_CONDITION] = "EsoUI/Art/Compass/quest_icon.dds",
  153. [MAP_PIN_TYPE_QUEST_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/quest_icon.dds",
  154. [MAP_PIN_TYPE_QUEST_ENDING] = "EsoUI/Art/Compass/quest_icon.dds",
  155. [MAP_PIN_TYPE_QUEST_REPEATABLE_CONDITION] = "EsoUI/Art/Compass/repeatableQuest_icon.dds",
  156. [MAP_PIN_TYPE_QUEST_REPEATABLE_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/repeatableQuest_icon.dds",
  157. [MAP_PIN_TYPE_QUEST_REPEATABLE_ENDING] = "EsoUI/Art/Compass/repeatableQuest_icon.dds",
  158. [MAP_PIN_TYPE_QUEST_ZONE_STORY_CONDITION] = "EsoUI/Art/Compass/zoneStoryQuest_icon.dds",
  159. [MAP_PIN_TYPE_QUEST_ZONE_STORY_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/zoneStoryQuest_icon.dds",
  160. [MAP_PIN_TYPE_QUEST_ZONE_STORY_ENDING] = "EsoUI/Art/Compass/zoneStoryQuest_icon.dds",
  161. [MAP_PIN_TYPE_TRACKED_QUEST_OFFER_ZONE_STORY] = "EsoUI/Art/Compass/zoneStoryQuest_available_icon.dds"
  162. }
  163.  
  164. local breadcrumbQuestPinTextures = {
  165. [MAP_PIN_TYPE_ASSISTED_QUEST_CONDITION] = "EsoUI/Art/Compass/quest_icon_door_assisted.dds",
  166. [MAP_PIN_TYPE_ASSISTED_QUEST_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/quest_icon_door_assisted.dds",
  167. [MAP_PIN_TYPE_ASSISTED_QUEST_ENDING] = "EsoUI/Art/Compass/quest_icon_door_assisted.dds",
  168. [MAP_PIN_TYPE_ASSISTED_QUEST_REPEATABLE_CONDITION] = "EsoUI/Art/Compass/repeatableQuest_icon_door_assisted.dds",
  169. [MAP_PIN_TYPE_ASSISTED_QUEST_REPEATABLE_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/repeatableQuest_icon_door_assisted.dds",
  170. [MAP_PIN_TYPE_ASSISTED_QUEST_REPEATABLE_ENDING] = "EsoUI/Art/Compass/repeatableQuest_icon_door_assisted.dds",
  171. [MAP_PIN_TYPE_ASSISTED_QUEST_ZONE_STORY_CONDITION] = "EsoUI/Art/Compass/zoneStoryQuest_icon_door_assisted.dds",
  172. [MAP_PIN_TYPE_ASSISTED_QUEST_ZONE_STORY_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/zoneStoryQuest_icon_door_assisted.dds",
  173. [MAP_PIN_TYPE_ASSISTED_QUEST_ZONE_STORY_ENDING] = "EsoUI/Art/Compass/zoneStoryQuest_icon_door_assisted.dds",
  174. [MAP_PIN_TYPE_TRACKED_QUEST_CONDITION] = "EsoUI/Art/Compass/quest_icon_door.dds",
  175. [MAP_PIN_TYPE_TRACKED_QUEST_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/quest_icon_door.dds",
  176. [MAP_PIN_TYPE_TRACKED_QUEST_ENDING] = "EsoUI/Art/Compass/quest_icon_door.dds",
  177. [MAP_PIN_TYPE_TRACKED_QUEST_REPEATABLE_CONDITION] = "EsoUI/Art/Compass/repeatableQuest_icon_door.dds",
  178. [MAP_PIN_TYPE_TRACKED_QUEST_REPEATABLE_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/repeatableQuest_icon_door.dds",
  179. [MAP_PIN_TYPE_TRACKED_QUEST_REPEATABLE_ENDING] = "EsoUI/Art/Compass/repeatableQuest_icon_door.dds",
  180. [MAP_PIN_TYPE_TRACKED_QUEST_ZONE_STORY_CONDITION] = "EsoUI/Art/Compass/zoneStoryQuest_icon_door.dds",
  181. [MAP_PIN_TYPE_TRACKED_QUEST_ZONE_STORY_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/zoneStoryQuest_icon_door.dds",
  182. [MAP_PIN_TYPE_TRACKED_QUEST_ZONE_STORY_ENDING] = "EsoUI/Art/Compass/zoneStoryQuest_icon_door.dds",
  183. [MAP_PIN_TYPE_QUEST_CONDITION] = "EsoUI/Art/Compass/quest_icon_door.dds",
  184. [MAP_PIN_TYPE_QUEST_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/quest_icon_door.dds",
  185. [MAP_PIN_TYPE_QUEST_ENDING] = "EsoUI/Art/Compass/quest_icon_door.dds",
  186. [MAP_PIN_TYPE_QUEST_REPEATABLE_CONDITION] = "EsoUI/Art/Compass/repeatableQuest_icon_door.dds",
  187. [MAP_PIN_TYPE_QUEST_REPEATABLE_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/repeatableQuest_icon_door.dds",
  188. [MAP_PIN_TYPE_QUEST_REPEATABLE_ENDING] = "EsoUI/Art/Compass/repeatableQuest_icon_door.dds",
  189. [MAP_PIN_TYPE_QUEST_ZONE_STORY_CONDITION] = "EsoUI/Art/Compass/zoneStoryQuest_icon_door.dds",
  190. [MAP_PIN_TYPE_QUEST_ZONE_STORY_OPTIONAL_CONDITION] = "EsoUI/Art/Compass/zoneStoryQuest_icon_door.dds",
  191. [MAP_PIN_TYPE_QUEST_ZONE_STORY_ENDING] = "EsoUI/Art/Compass/zoneStoryQuest_icon_door.dds",
  192. [MAP_PIN_TYPE_TRACKED_QUEST_OFFER_ZONE_STORY] = "EsoUI/Art/Compass/zoneStoryQuest_available_icon_door.dds"
  193. }
  194.  
  195. local ZONE_EXPLORATION_PIN_TYPES = ZO_MapPin.SUGGESTION_PIN_TYPES -- showsPinAndArea = true is forward camps and SUGGESTION_PIN_TYPES
  196.  
  197. local OBJECTIVE_PIN_TYPES = ZO_MapPin.OBJECTIVE_PIN_TYPES
  198.  
  199. local CustomWaypoints = ZO_MapPin.MAP_PING_PIN_TYPES
  200.  
  201. ----------------------------------------------------------------
  202.  
  203. local function GetQuestPinCount()
  204. return FyrMM.questPinCount
  205. end
  206.  
  207. local function AvailableCustomPins()
  208. local count = 0
  209. for _, b in pairs(FyrMM.CustomPinList) do
  210. count = count + #b
  211. end
  212. return count
  213. end
  214.  
  215. local function IsCustomPinsLoading()
  216. for _, b in pairs(FyrMM.LoadingCustomPins) do
  217. if b then
  218. return b
  219. end
  220. end
  221. return false
  222. end
  223.  
  224. local function GetQuestFreePinIndex()
  225. local index = LastQuestPinIndex
  226. if not IsTableEmpty(FreeQuestPinIndex) then
  227. index = table.remove(FreeQuestPinIndex)
  228. return index
  229. end
  230. index = index + 1
  231. LastQuestPinIndex = index
  232. return index
  233. end
  234.  
  235. FyrMM.RequestJournalQuestConditionAssistance = RequestJournalQuestConditionAssistance
  236. function RequestJournalQuestConditionAssistance(questIndex, stepIndex, conditionIndex, assisted)
  237. local taskId = FyrMM.RequestJournalQuestConditionAssistance(questIndex, stepIndex, conditionIndex, assisted)
  238. local tag = ZO_MapPin.CreateQuestPinTag(questIndex, stepIndex, conditionIndex)
  239. local currentTime = GetGameTimeMilliseconds()
  240. if currentTime - FyrMM.LastQuestPinRequest > FYRMM_QUEST_PIN_REQUEST_MINIMUM_DELAY then
  241. FyrMM.questPinCount = GetQuestPinCount()
  242. QuestPinsUpdating = true
  243. end
  244. if taskId and not FyrMM.Halted then
  245. FyrMM.LastQuestPinRequest = currentTime
  246. local currentTask = {}
  247. currentTask = tag
  248. currentTask.RequestTimeStamp = FyrMM.LastQuestPinRequest
  249. currentTask.MapId = CurrentMap.MapId
  250. currentTask.Fetched = true
  251. currentTask.ZO_MapVisible = ZO_WorldMap:IsHidden()
  252. CurrentTasks[taskId] = currentTask
  253. end
  254. return taskId
  255. end
  256.  
  257. FyrMM.CancelRequestJournalQuestConditionAssistance = CancelRequestJournalQuestConditionAssistance
  258. function CancelRequestJournalQuestConditionAssistance(taskId)
  259. if taskId and CurrentTasks[taskId] and CurrentTasks[taskId].Fetched then
  260. CurrentTasks[taskId] = nil
  261. FyrMM.CancelRequestJournalQuestConditionAssistance(taskId)
  262. end
  263. end
  264.  
  265. -----------------------------------------------------------------
  266. -- Utility functions
  267. -----------------------------------------------------------------
  268. function IsTableEmpty(tbl)
  269. return next(tbl) == nil
  270. end
  271.  
  272. local function CancelUpdates()
  273. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapDelayedRegister")
  274. -- EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapZoneCheck")
  275. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapPOIPins")
  276. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapLocationsPins")
  277. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapWayshrinesPins")
  278. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapCustomPins")
  279. -- EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapPOIPinsD")
  280. -- EVENT_MANAGER:UnregisterForUpdate("OnFyrMiniMapInitialPreload")
  281. EVENT_MANAGER:UnregisterForUpdate("OnFyrMiniMapCustomPinGroupAll")
  282. FyrMM.UpdatingCustomPins = {}
  283. FyrMM.LoadingCustomPins = {}
  284. if PinRef then
  285. for i, n in pairs(PRCustomPins) do
  286. if i > MAP_PIN_TYPE_INVALID then
  287. EVENT_MANAGER:UnregisterForUpdate("OnFyrMiniMapCustomPinGroup" .. tostring(i))
  288. end
  289. end
  290. end
  291. end
  292.  
  293. local function IsCurrentLocation(pin)
  294. if not pin then
  295. return
  296. end
  297.  
  298. local x, y = CurrentMap.PlayerNX, CurrentMap.PlayerNY -- GetMapPlayerPosition("player")
  299. local nX = pin.nX or pin.normalizedX
  300. local nY = pin.nY or pin.normalizedY
  301.  
  302. if not (nX and nY and CurrentMap.TrueMapSize) then
  303. return false
  304. end
  305.  
  306. local distance = zo_round(CurrentMap.TrueMapSize * math.sqrt(((x - nX) ^ 2) + ((y - nY) ^ 2)) * 7.55) / 10 -- assumed size is 1.325 times larger than approximate effective skill distance in meters.
  307. local message = GetString(SI_MM_STRING_DISTANCE) .. " " .. tostring(distance) .. " m"
  308. if not InformationTooltip:IsHidden() then
  309. InformationTooltip:AddLine(message, "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
  310. end
  311.  
  312. if not ZO_MapLocationTooltip:IsHidden() then
  313. ZO_MapLocationTooltip:AddLine(message, "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
  314. end
  315.  
  316. return CurrentMap.TrueMapSize * math.sqrt((x - nX) ^ 2 + (y - nY) ^ 2) < 14 -- Approximate distance to use a wayshrine
  317. end
  318.  
  319. local function IsCraftingService(pin)
  320. if not pin then
  321. return false
  322. end
  323.  
  324. local tooltipIndex = pin.locationIndex
  325. if not tooltipIndex then
  326. return false
  327. end
  328.  
  329. for _, v in pairs(FyrMM.CSProviders) do
  330. if v then
  331. for j = 1, GetNumMapLocationTooltipLines(tooltipIndex) do
  332. local _, tooltipLineText = GetMapLocationTooltipLineInfo(tooltipIndex, j)
  333. if tooltipLineText:find(v) then
  334. return true
  335. end
  336. end
  337. end
  338. end
  339.  
  340. return false
  341. end
  342.  
  343. local function SetTooltipMessage(pin)
  344. if not pin then
  345. return
  346. end
  347. if pin:IsFastTravelWayShrine() then
  348. local nodeIndex = pin:GetFastTravelNodeIndex()
  349. local known, name = GetFastTravelNodeInfo(nodeIndex)
  350. if not known then
  351. name = name .. " (undiscovered)"
  352. end
  353. InformationTooltip:AddLine(zo_strformat(SI_WORLD_MAP_LOCATION_NAME, name), "",
  354. ZO_TOOLTIP_DEFAULT_COLOR:UnpackRGB()) -- Wayshrine name
  355. if IsCurrentLocation(pin) then
  356. InformationTooltip:AddLine(GetString(SI_TOOLTIP_WAYSHRINE_CURRENT_LOC), "", ZO_HIGHLIGHT_TEXT:UnpackRGB()) -- Player is near wayshrine
  357. else
  358. if IsInAvAZone() then
  359. InformationTooltip:AddLine(GetString(SI_TOOLTIP_WAYSHRINE_CANT_RECALL_AVA), "",
  360. ZO_ERROR_COLOR:UnpackRGB()) -- Can't travel to a wayshrine in Cyrodiil
  361. else
  362. local _, premiumTimeLeft = GetRecallCooldown()
  363. if premiumTimeLeft == 0 then
  364. InformationTooltip:AddLine(GetString(SI_TOOLTIP_WAYSHRINE_CLICK_TO_RECALL), "",
  365. ZO_HIGHLIGHT_TEXT:UnpackRGB()) -- Recall text line
  366. local cost = GetRecallCost()
  367. if cost > 0 then
  368. if cost <= GetCurrentMoney() then
  369. ZO_ItemTooltip_AddMoney(InformationTooltip, cost, SI_TOOLTIP_RECALL_COST,
  370. CURRENCY_HAS_ENOUGH)
  371. else
  372. ZO_ItemTooltip_AddMoney(InformationTooltip, cost, SI_TOOLTIP_RECALL_COST,
  373. CURRENCY_NOT_ENOUGH)
  374. end
  375. end
  376. else
  377. local cooldownText = zo_strformat(SI_TOOLTIP_WAYSHRINE_RECALL_COOLDOWN, ZO_FormatTimeMilliseconds(
  378. premiumTimeLeft, TIME_FORMAT_STYLE_DESCRIPTIVE, TIME_FORMAT_PRECISION_SECONDS))
  379. InformationTooltip:AddLine(cooldownText, "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
  380. end
  381. end
  382. end
  383. else
  384. local poiIndex = pin:GetPOIIndex()
  385. local zoneIndex = pin:GetPOIZoneIndex()
  386. local poiName, _, poiStartDesc, poiFinishedDesc = GetPOIInfo(zoneIndex, poiIndex)
  387. InformationTooltip:AddLine(zo_strformat(SI_WORLD_MAP_LOCATION_NAME, poiName), "",
  388. ZO_TOOLTIP_DEFAULT_COLOR:UnpackRGB())
  389. local pinType = select(3, MM_GetPOIMapInfo(zoneIndex, poiIndex))
  390. if not (ZO_MapPin.POI_PIN_TYPES[pinType]) then
  391. InformationTooltip:AddLine("(undiscovered)", "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
  392. end
  393. if pinType == MAP_PIN_TYPE_POI_COMPLETE then
  394. if poiFinishedDesc ~= "" then
  395. InformationTooltip:AddLine(poiFinishedDesc, "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
  396. end
  397. else
  398. if poiStartDesc ~= "" then
  399. InformationTooltip:AddLine(poiStartDesc, "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
  400. end
  401. end
  402. end
  403. end
  404.  
  405. function GetCurrentMapTextureFileInfo()
  406. local tileTexture = (GetMapTileTexture()):lower()
  407. if tileTexture == nil or tileTexture == "" then
  408. return "tamriel_0", "tamriel_", "art/maps/tamriel/"
  409. end
  410. local pos = select(2, tileTexture:find("maps/([%w%-]+)/"))
  411. if pos == nil then
  412. return "tamriel_0", "tamriel_", "art/maps/tamriel/"
  413. end
  414. pos = pos + 1
  415. return string.gsub(string.sub(tileTexture, pos), ".dds", ""),
  416. string.gsub(string.sub(tileTexture, pos), "0.dds", ""), tileTexture:sub(1, pos - 1)
  417. end
  418.  
  419. local function GetTrueMapSize() -- never used
  420. local currentMapId = CurrentMap.MapId
  421. local size = FyrMM.MapSizes[currentMapId] or 1
  422. return currentMapId, size
  423. end
  424.  
  425. function FyrMM.GetMapTextureFileInfo(mapId)
  426. local tileTexture = GetMapTileTextureForMapId(mapId, 1)
  427. if tileTexture == nil or tileTexture == "" then
  428. return "tamriel_0", "tamriel_", "art/maps/tamriel/"
  429. end
  430. local _, pos = tileTexture:find("maps/([%w%-]+)/")
  431. if not pos then
  432. return "tamriel_0", "tamriel_", "art/maps/tamriel/"
  433. end
  434. return string.gsub(string.sub(tileTexture, pos + 1), ".dds", "")
  435. end
  436.  
  437. function FyrMM.GetMapId()
  438. return GetCurrentMapId()
  439. end
  440.  
  441. local function SetMapToZone()
  442. if FyrMM.DisableSubzones == true and GetMapType() == 1 and not IsUnitInDungeon("player") and not IsPlayerInRaid() and
  443. not IsActiveWorldBattleground() and not IsInAvAZone() then
  444. MapZoomOut()
  445. FyrMM.UpdateLabels()
  446. end
  447. end
  448.  
  449. function FyrMM.MapHalfDiagonal()
  450. FyrMM.DiagonalND = math.sqrt((Fyr_MM_Player:GetRight() - Fyr_MM:GetRight()) ^ 2 +
  451. (Fyr_MM_Player:GetTop() - Fyr_MM:GetTop()) ^ 2)
  452. return FyrMM.DiagonalND
  453. end
  454.  
  455. local function IsSubmap() -- never used
  456. return CurrentMap.MapContent == MAP_CONTENT_DUNGEON or GetMapType() == MAPTYPE_SUBZONE
  457. end
  458.  
  459. local function GetQuestJournalMaxValidIndex()
  460. local index = 0
  461. for i = 1, MAX_JOURNAL_QUESTS do
  462. if (IsValidQuestIndex(i)) and index < i then
  463. index = i
  464. end
  465. end
  466. return index
  467. end
  468.  
  469. local function IsAssisted(pinType)
  470. return ASSISTED_PIN_TYPES[pinType] ~= nil -- non-existent key = nil
  471. end
  472.  
  473. local function IsQuestType(pinType) -- never used
  474. return QUEST_PIN_TYPES[pinType] ~= nil -- non-existent key = nil
  475. end
  476.  
  477. local function valueExists(i, x)
  478. for j = 1, #x do -- instead of ipairs to avoid overhead
  479. if x[j] == i then
  480. return true
  481. end
  482. end
  483. return false
  484. end
  485.  
  486. local function questpinDataExists(pinData, array)
  487. -- Avoid continuous table lookups localize the values instead
  488. local questIndex, questName, conditionText, conditionIndex, normX, normY, radius, stepIndex = pinData.questIndex,
  489. pinData.questName, pinData.conditionText, pinData.conditionIndex, pinData.normalizedX, pinData.normalizedY,
  490. pinData.radius, pinData.stepIndex
  491.  
  492. for i, v in pairs(array) do
  493. if v.questIndex == questIndex and v.questName == questName and v.conditionText == conditionText and
  494. v.conditionIndex == conditionIndex and v.normalizedX == normX and v.normalizedY == normY and v.radius ==
  495. radius and v.stepIndex == stepIndex then
  496. return i
  497. end
  498. end
  499. return nil
  500. end
  501.  
  502. function FyrMM.SetTargetScale(pin, targetScale)
  503. if not pin or not targetScale or not ((pin.targetScale and targetScale ~= pin.targetScale) or
  504. (pin.targetScale == nil and targetScale ~= pin:GetScale())) then
  505. return
  506. end
  507.  
  508. local primaryPin, secondaryPin, tertiaryPin = pin.primaryPin, pin.secondaryPin, pin.tertiaryPin
  509. local newScale
  510. pin.targetScale = targetScale
  511. for i = 1, 50 do
  512. zo_callLater(function()
  513. newScale = zo_deltaNormalizedLerp(pin:GetScale(), targetScale, 0.1)
  514. if (zo_abs(newScale - targetScale) < 0.01) then
  515. pin:SetScale(targetScale)
  516. if primaryPin then
  517. pin.primaryPin:SetScale(targetScale)
  518. end
  519. if secondaryPin then
  520. pin.secondaryPin:SetScale(targetScale)
  521. end
  522. if tertiaryPin then
  523. pin.tertiaryPin:SetScale(targetScale)
  524. end
  525. pin.targetScale = nil
  526. return
  527. end
  528. pin:SetScale(newScale)
  529. if primaryPin then
  530. pin.primaryPin:SetScale(newScale)
  531. end
  532. if secondaryPin then
  533. pin.secondaryPin:SetScale(newScale)
  534. end
  535. if tertiaryPin then
  536. pin.tertiaryPin:SetScale(newScale)
  537. end
  538. end, i * 5)
  539. end
  540. end
  541.  
  542. local function AfterCombatShow()
  543. if not FyrMM.AfterCombatUnhidePending then
  544. return
  545. end
  546. if GetFrameTimeMilliseconds() - FyrMM.AfterCombatUnhideTimeStamp < 1000 * (FyrMM.SV.AfterCombatUnhideDelay - 1) then
  547. return
  548. end
  549. FyrMM.AfterCombatUnhidePending = false
  550. if not IsUnitActivelyEngaged("player") then
  551. FyrMM.AutoHidden = false
  552. FyrMM.Visible = true
  553. end
  554. end
  555.  
  556. local function WayshrineDistances(nDistance)
  557. if not (FyrMM.SV.BorderPins and FyrMM.SV.BorderWayshrine) or FyrMM.currentWayshrineCount == 0 then
  558. return
  559. end
  560.  
  561. if CurrentMap.movedTimeStamp == WayshrineDistancesTimeStamp and WayshrineDistancesTimeStamp ~= 0 then
  562. return
  563. end
  564.  
  565. WayshrineDistancesTimeStamp = CurrentMap.movedTimeStamp
  566.  
  567. local gameTime = GetGameTimeMilliseconds()
  568. local wDi, wDmi, minWD, owDmi = 1, 1, 1, 1
  569.  
  570. if FyrMM.DebugMode then
  571. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  572. "WayshrineDistances Start:" .. tostring(FyrMM.currentWayshrineCount))
  573. end
  574.  
  575. if FyrMM.currentWayshrineCount == 1 then
  576. Wayshrines[1].Closest = Wayshrines[1].isRealWayshrine
  577. return
  578. end
  579.  
  580. EVENT_MANAGER:RegisterForUpdate("OnFyrMiniMapDistances", 100, -- 150 ~8s 50 ~6s -- 100 ~ loads about the same as 50 on initial load.
  581. function()
  582. local playerX, playerY = CurrentMap.PlayerNX, CurrentMap.PlayerNY
  583.  
  584. if Wayshrines[wDi] and Wayshrines[wDi].isRealWayshrine then
  585. Wayshrines[wDi].nDistance =
  586. math.sqrt((playerX - Wayshrines[wDi].nX) ^ 2 + (playerY - Wayshrines[wDi].nY) ^ 2)
  587. if Wayshrines[wDi].nDistance < minWD then
  588. minWD = Wayshrines[wDi].nDistance
  589. wDmi = wDi
  590. end
  591. end
  592.  
  593. if wDi <= FyrMM.currentWayshrineCount then
  594. wDi = wDi + 1
  595. return
  596. end
  597.  
  598. for i, _ in pairs(Wayshrines) do
  599. Wayshrines[i].Closest = (i == wDmi)
  600. Wayshrines[i].pin.Closest = (i == wDmi)
  601. end
  602.  
  603. if FyrMM.DebugMode then
  604. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "WayshrineDistances Done. (" .. tostring(wDmi) .. ") " ..
  605. tostring(GetGameTimeMilliseconds() - gameTime))
  606. end
  607.  
  608. EVENT_MANAGER:UnregisterForUpdate("OnFyrMiniMapDistances")
  609. end)
  610. end
  611.  
  612. local function sort(a, b)
  613. local typeA, typeB = type(a.index), type(b.index) -- avoid repeated calls to the type function
  614.  
  615. if typeA == "number" and typeB == "number" then
  616. return a.index < b.index
  617. end
  618. if typeA == "number" and typeB ~= "number" then
  619. return true
  620. end
  621. if typeA ~= "number" and typeB == "number" then
  622. return false
  623. end
  624.  
  625. return a.index and b.index and tostring(a.index) < tostring(b.index)
  626. end
  627.  
  628. local function FirstKey(Table, offset) -- never used
  629. if IsTableEmpty(Table) then
  630. return nil
  631. end
  632. if offset == nil then
  633. offset = 0
  634. end
  635. local key = next(Table, offset)
  636. while key ~= nil do
  637. if Table[key] ~= nil then
  638. return key
  639. end
  640. key = next(Table, key)
  641. end
  642. return nil
  643. end
  644.  
  645. local function QuestGiverDistances()
  646. if not (FyrMM.SV.BorderPins and FyrMM.SV.BorderQuestGivers) or #FyrMM.AvailableQuestGivers == 0 then
  647. return
  648. end
  649.  
  650. local gameTime = GetGameTimeMilliseconds()
  651. local x, y = CurrentMap.PlayerNX, CurrentMap.PlayerNY -- GetMapPlayerPosition("player")
  652. AQGListFull = {}
  653. local multiplier = Fyr_MM:GetWidth()
  654.  
  655. for _, v in ipairs(FyrMM.AvailableQuestGivers) do
  656. if v.nX == nil and v.mpin.normalizedX ~= nil then -- workaround just in case
  657. v.nX = v.mpin.normalizedX
  658. v.nY = v.mpin.normalizedY
  659. end
  660.  
  661. if v.nX and v.nY then
  662. v.nDistance = math.sqrt((x - v.nX) * (x - v.nX) + (y - v.nY) * (y - v.nY))
  663. AQGListFull[#AQGListFull + 1] = {
  664. index = math.floor(multiplier * v.nDistance),
  665. data = v
  666. }
  667. end
  668. end
  669.  
  670. table.sort(AQGListFull, sort)
  671.  
  672. AQGList = {}
  673. if FyrMM.ZoneStoryPin then
  674. AQGList[#AQGList + 1] = FyrMM.ZoneStoryPin
  675. end
  676.  
  677. for i, n in ipairs(AQGListFull) do
  678. if i > 5 then
  679. break
  680. end
  681. AQGList[#AQGList + 1] = n.data
  682. end
  683.  
  684. if FyrMM.DebugMode then
  685. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  686. "QuestGiverDistances " .. tostring(GetGameTimeMilliseconds() - gameTime))
  687. end
  688. end
  689.  
  690. function FyrMM.MenuTooltip(button, message)
  691. -- Fyr_MM_Menu:SetAlpha(1)
  692. FyrMM.OverMenu = true
  693. Fyr_MM_Close:SetAlpha(1)
  694. if not message or not button then
  695. return
  696. end
  697. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 38, button:GetTop())
  698. InformationTooltip:AddLine(message, "", ZO_TOOLTIP_DEFAULT_COLOR:UnpackRGB())
  699. end
  700.  
  701. function FyrMM.TooltipExit()
  702. FyrMM.OverMenu = false
  703. -- Fyr_MM_Menu:SetAlpha(0.1)
  704. Fyr_MM_Close:SetAlpha(0)
  705. ClearTooltip(InformationTooltip)
  706. end
  707.  
  708. function FyrMM.PinToggle(value)
  709. MM_SetLockPosition(value)
  710. MM_RefreshPanel()
  711. end
  712.  
  713. function FyrMM.OpenSettingsPanel()
  714. FyrMM.LAM:OpenToPanel(FyrMM.CPL)
  715. end
  716.  
  717. function FyrMM.API_Check()
  718. if FyrMM.SV.UseOriginalAPI then -- if Community Leveling Guides is active and original functions to be used
  719. if _IsMapLocationVisible then
  720. MM_IsMapLocationVisible = _IsMapLocationVisible
  721. end
  722. if _GetMapLocationIcon then
  723. MM_GetNumMapLocations = _GetNumMapLocations
  724. end
  725. if _GetMapLocationIcon then
  726. MM_GetMapLocationIcon = _GetMapLocationIcon
  727. end
  728. if _G.GetPOIMapInfo then -- _GetPOIMapInfo_ORIG_ZGV
  729. MM_GetPOIMapInfo = _G.GetPOIMapInfo -- _GetPOIMapInfo_ORIG_ZGV
  730. end
  731. if _GetNumMapLocations ~= nil then -- _0GetNumMapLocations
  732. FyrMM.MapAPI0Present = true
  733. MM_GetNumMapLocations = _GetNumMapLocations -- _0GetNumMapLocations
  734. end
  735. if _IsMapLocationVisible ~= nil then -- _0IsMapLocationVisible
  736. MM_IsMapLocationVisible = _IsMapLocationVisible -- _0IsMapLocationVisible
  737. end
  738. if _GetMapLocationIcon ~= nil then -- _0GetMapLocationIcon
  739. MM_GetMapLocationIcon = _GetMapLocationIcon -- _0GetMapLocationIcon
  740. end
  741. if _G.GetNumPOIs ~= nil then -- _0GetNumPOIs
  742. MM_GetNumPOIs = _G.GetNumPOIs -- _0GetNumPOIs
  743. end
  744. if _G.GetPOIMapInfo ~= nil then -- _0GetPOIMapInfo
  745. MM_GetPOIMapInfo = _G.GetPOIMapInfo -- _0GetPOIMapInfo
  746. end
  747. else
  748. MM_GetNumMapLocations = GetNumMapLocations
  749. MM_IsMapLocationVisible = IsMapLocationVisible
  750. MM_GetMapLocationIcon = GetMapLocationIcon
  751. MM_GetPOIMapInfo = GetPOIMapInfo
  752. end
  753. end
  754.  
  755. function GetCurrentMapSize()
  756. return CurrentMap and CurrentMap.TrueMapSize or nil -- Returns assumed calculated map size in feet, returns nil no calculated size or not possible to do so
  757. end
  758.  
  759. local function GetRotatedPosition(x, y) -- Inspired by DeathAngel's RadarMiniMap
  760. if not CurrentMap.Heading then
  761. return
  762. end
  763. if not (x or CurrentMap.PlayerX) then
  764. return x, y
  765. end
  766. local mWidth, mHeight = Fyr_MM_Scroll_Map:GetDimensions()
  767. local ix, iy = (x * mWidth) - CurrentMap.PlayerX, (y * mHeight) - CurrentMap.PlayerY
  768. local rx = math.cos(-CurrentMap.Heading) * ix - math.sin(-CurrentMap.Heading) * iy
  769. local ry = math.sin(-CurrentMap.Heading) * ix + math.cos(-CurrentMap.Heading) * iy
  770. return zo_round(rx), zo_round(ry)
  771. end
  772.  
  773. local function GetNorthFacingPosition(x, y)
  774. if not (x and y) then
  775. return x, y
  776. end
  777. local mWidth, mHeight = Fyr_MM_Scroll_Map:GetDimensions()
  778. return math.floor(mWidth * x), math.floor(mHeight * y) -- math.floor is faster than zo_round
  779. end
  780.  
  781. local function Is_PinInsideWheel(pin)
  782. if pin.nX == nil and pin.nY == nil and pin.normalizedX == nil and pin.normalizedY == nil then
  783. return false
  784. end
  785.  
  786. local di = Fyr_MM:GetWidth()
  787. local x, y = pin:GetCenter()
  788. local x1, y1 = Fyr_MM_Player:GetCenter()
  789. local width = pin:GetWidth()
  790. local distance = math.sqrt((x - x1) ^ 2 + (y - y1) ^ 2)
  791.  
  792. if (pin.radius and pin.radius > 0) or pin.borderInformation then
  793. return distance < di / 2 - ((30 / 512) * di) + width / 2 - 10
  794. end
  795.  
  796. return distance < di / 2 - ((30 / 512) * di)
  797. end
  798.  
  799. local function smoothHeadingRotation() -- added by @Masteroshi430
  800. local x, y, pheading = CurrentMap.PlayerNX, CurrentMap.PlayerNY,
  801. CurrentMap.PlayerHeading or GetMapPlayerPosition("player")
  802. local headingTo = math.abs(pheading - pi * 2)
  803.  
  804. if not FyrMM.SV.RotateMap then
  805. return headingTo
  806. end
  807.  
  808. local heading = CurrentMap.Heading or 0
  809. local diff = ((headingTo - heading) + pi) % (pi * 2) - pi
  810. local currentHeading = (heading + (diff / 10)) % (pi * 2)
  811.  
  812. if currentHeading < 0 then
  813. currentHeading = currentHeading + (pi * 2)
  814. end
  815.  
  816. return currentHeading
  817. end
  818.  
  819. local function SetDigSitePoints(digSite)
  820. local borderInformation = digSite.borderInformation
  821. local RotateMap = FyrMM.SV.RotateMap
  822.  
  823. digSite:ClearPoints()
  824.  
  825. local heading = CurrentMap.Heading
  826.  
  827. if not (RotateMap and heading and CurrentMap.PlayerNX) then
  828. for i = 1, #borderInformation.borderPoints do
  829. digSite:AddPoint(borderInformation.borderPoints[i].x, borderInformation.borderPoints[i].y)
  830. end
  831. return
  832. end
  833.  
  834. local math_sin = math.sin
  835. local math_cos = math.cos
  836. local points = borderInformation.borderPoints
  837.  
  838. for i = 1, #points do
  839. local point = points[i]
  840. local ix = point.x - 0.5
  841. local iy = point.y - 0.5
  842. local sine = math_sin(-heading)
  843. local cosine = math_cos(-heading)
  844. local rx = cosine * ix - sine * iy
  845. local ry = sine * ix + cosine * iy
  846. digSite:AddPoint(rx, ry)
  847. end
  848. end
  849.  
  850. local function SetPinFunctions(pin)
  851. if pin.UpdateWheelVisibility == nil then
  852. pin.UpdateWheelVisibility = function(self)
  853. if FyrMM.SV.WheelMap then
  854. self:SetHidden(not Is_PinInsideWheel(self))
  855. end
  856. end
  857. end
  858.  
  859. if pin.RefreshAnchor then
  860. return
  861. end
  862.  
  863. pin.RefreshAnchor = function(self)
  864. local x = self.nX or self.normalizedX
  865. local y = self.nY or self.normalizedY
  866.  
  867. if not (x and y) then
  868. return
  869. end
  870.  
  871. self:ClearAnchors()
  872.  
  873. if FyrMM.SV.RotateMap then
  874. if pin.borderInformation then
  875. SetDigSitePoints(pin)
  876. self:SetAnchor(TOPLEFT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(x, y))
  877. return
  878. end
  879. self:SetAnchor(CENTER, Fyr_MM_Scroll, CENTER, GetRotatedPosition(x, y))
  880. return
  881. end
  882.  
  883. if FyrMM.SV.WheelMap then
  884. self:SetAnchor(CENTER, Fyr_MM_Scroll_Map_Pins, TOPLEFT, GetNorthFacingPosition(x, y))
  885. if pin.borderInformation then
  886. self:SetParent(FyrMM.GetScrollObject(self))
  887. end
  888. return
  889. end
  890.  
  891. self:SetAnchor(CENTER, self:GetParent(), TOPLEFT, GetNorthFacingPosition(x, y))
  892. end
  893. end
  894.  
  895. function FyrMM.AxisPosition(angle)
  896. local mapWidth, mapHeight = Fyr_MM:GetDimensions() or FyrMM.SV.MapWidth, FyrMM.SV.MapHeight
  897.  
  898. local halfPi = pi * 0.5
  899. local doublePi = pi * 2.0
  900.  
  901. mapWidth = mapWidth / 2
  902. mapHeight = mapHeight / 2
  903.  
  904. local northAngle = math.atan(mapWidth / mapHeight)
  905. local southAngle = halfPi - northAngle
  906. local northPos, eastPos, southPos, westPos
  907.  
  908. local aMinusNorth = angle - northAngle
  909. local aPlusNorth = angle + northAngle
  910.  
  911. if aPlusNorth >= doublePi or aMinusNorth <= 0 then -- Upper border line
  912. if aMinusNorth <= 0 then
  913. northPos = mapWidth + mapHeight * math.sin(angle) / math.sin(halfPi - angle)
  914. else
  915. northPos = mapWidth - mapHeight * math.sin(doublePi - angle) / math.sin(halfPi - (doublePi - angle))
  916. end
  917. return northPos, 0
  918. end
  919.  
  920. local doubleSouthAngle = southAngle * 2
  921.  
  922. if aMinusNorth > 0 and aMinusNorth < doubleSouthAngle then -- Right border line
  923. if aMinusNorth > southAngle then
  924. eastPos = mapHeight + mapWidth * math.sin(aMinusNorth - southAngle) /
  925. math.sin(halfPi - (aMinusNorth - southAngle))
  926. else
  927. eastPos = mapWidth * math.sin(aMinusNorth) / math.sin(halfPi - aMinusNorth)
  928. end
  929. return mapWidth * 2, eastPos
  930. end
  931.  
  932. if aMinusNorth >= doubleSouthAngle and angle <= 3 * northAngle + doubleSouthAngle then -- Bottom border line
  933. if aMinusNorth - northAngle > doubleSouthAngle then
  934. southPos = mapWidth - mapHeight * math.sin(angle - 2 * northAngle - doubleSouthAngle) /
  935. math.sin(halfPi - (angle - 2 * northAngle - doubleSouthAngle))
  936. else
  937. southPos = mapWidth * 2 - mapHeight * math.sin(aMinusNorth - doubleSouthAngle) /
  938. math.sin(halfPi - (aMinusNorth - doubleSouthAngle))
  939. end
  940. return southPos, mapHeight * 2
  941. end
  942.  
  943. if aPlusNorth > doublePi - doubleSouthAngle and aPlusNorth < doublePi then -- Left border line
  944. if aMinusNorth > southAngle then
  945. westPos = mapHeight - mapWidth * math.sin(angle - 3 * northAngle - 3 * southAngle) /
  946. math.sin(halfPi - (angle - 3 * northAngle - 3 * southAngle))
  947. else
  948. westPos = mapHeight - mapWidth * math.sin(angle - 3 * northAngle - doubleSouthAngle) /
  949. math.sin(halfPi - (angle - 3 * northAngle - doubleSouthAngle))
  950. end
  951. return 0, westPos
  952. end
  953. end
  954.  
  955. local function RoundArc(angle) -- return angle % (math.pi * 2) faster for loops higher than ~100 of this function
  956. return (angle > pi * 2) and angle - pi * 2 or angle -- return angle if angle is not less than double pi
  957. end
  958.  
  959. local function CanDrawCardinalForRotateWheelmap(x, y)
  960. if not FyrMM.SV.WheelMap then
  961. return true
  962. end
  963. if not FyrMM.SV.CardinalPoints then
  964. return false
  965. end
  966.  
  967. local margin = Fyr_MM:GetWidth() / 3.5
  968.  
  969. return (y == Fyr_MM:GetTop()) and (x >= Fyr_MM:GetLeft() + margin) and (x <= Fyr_MM:GetRight() - margin) -- twice as fas
  970. end
  971.  
  972. local function AxisSwitch()
  973. local rotateMap = FyrMM.SV.RotateMap
  974.  
  975. for i = 1, Fyr_MM_Axis_Textures:GetNumChildren() do
  976. local texture = Fyr_MM_Axis_Textures:GetChild(i)
  977. if texture then
  978. texture:ClearAnchors()
  979. local x, y = texture:GetCenter()
  980. texture:SetHidden(not rotateMap or not CanDrawCardinalForRotateWheelmap(x, y))
  981.  
  982. local name = texture:GetName()
  983. name = string.gsub(name, "Fyr_MM_Axis_", "")
  984. texture:SetDimensions(#name == 1 and 24 or 32, 24)
  985. end
  986. end
  987.  
  988. for i = 1, Fyr_MM_Axis_Labels:GetNumChildren() do
  989. local label = Fyr_MM_Axis_Labels:GetChild(i)
  990. if label then
  991. label:ClearAnchors()
  992. local x, y = label:GetCenter()
  993. label:SetHidden(not rotateMap or not CanDrawCardinalForRotateWheelmap(x, y))
  994. end
  995. end
  996. end
  997.  
  998. function FyrMM.AxisPins()
  999. if FyrMM.SV.WheelMap and FyrMM.SV.RotateMap and FyrMM.SV.CardinalPoints then
  1000. AxisSwitch()
  1001. elseif (FyrMM.SV.WheelMap and not Fyr_MM_Axis_N:IsHidden()) or
  1002. not (FyrMM.SV.RotateMap and not Fyr_MM_Axis_N:IsHidden()) then
  1003. AxisSwitch()
  1004. return
  1005. end
  1006.  
  1007. if not FyrMM.SV.RotateMap or not CurrentMap.Heading then
  1008. return
  1009. end
  1010. -- Fyr_MM_Axis_Control:SetTopmost(true)
  1011.  
  1012. local angles = { {
  1013. pin = Fyr_MM_Axis_N,
  1014. label = Fyr_MM_Axis_N_Label
  1015. }, {
  1016. pin = Fyr_MM_Axis_NE,
  1017. label = Fyr_MM_Axis_NE_Label
  1018. }, {
  1019. pin = Fyr_MM_Axis_E,
  1020. label = Fyr_MM_Axis_E_Label
  1021. }, {
  1022. pin = Fyr_MM_Axis_SE,
  1023. label = Fyr_MM_Axis_SE_Label
  1024. }, {
  1025. pin = Fyr_MM_Axis_S,
  1026. label = Fyr_MM_Axis_S_Label
  1027. }, {
  1028. pin = Fyr_MM_Axis_SW,
  1029. label = Fyr_MM_Axis_SW_Label
  1030. }, {
  1031. pin = Fyr_MM_Axis_W,
  1032. label = Fyr_MM_Axis_W_Label
  1033. }, {
  1034. pin = Fyr_MM_Axis_NW,
  1035. label = Fyr_MM_Axis_NW_Label
  1036. } }
  1037. local n = pi * 2 - CurrentMap.Heading
  1038.  
  1039. for i, angle in ipairs(angles) do
  1040. local angleValue = RoundArc(n + pi * (i * 0.25))
  1041. angle.pin:ClearAnchors()
  1042. angle.label:ClearAnchors()
  1043. angle.pin:SetAnchor(CENTER, Fyr_MM_Axis_Control, TOPLEFT, FyrMM.AxisPosition(angleValue))
  1044. angle.label:SetAnchor(CENTER, Fyr_MM_Axis_Control, TOPLEFT, FyrMM.AxisPosition(angleValue))
  1045. end
  1046. end
  1047.  
  1048. local function IsCoordinateInRange(x, y)
  1049. if not CurrentMap.TrueMapSize or not CurrentMap.PlayerNX or not FyrMM.SV.CustomPinViewRange or
  1050. not FyrMM.SV.ViewRangeFiltering then
  1051. return true
  1052. end
  1053. return CurrentMap.TrueMapSize *
  1054. math.sqrt(
  1055. (x - CurrentMap.PlayerNX) * (x - CurrentMap.PlayerNX) + (y - CurrentMap.PlayerNY) *
  1056. (y - CurrentMap.PlayerNY)) <= FyrMM.SV.CustomPinViewRange
  1057. end
  1058.  
  1059. function FyrMM.SetPinSize(pin, size, _)
  1060. local properSize = math.floor(size / 2) * 2
  1061. if (not pin.radius or pin.radius == 0) and CurrentMap.MapId ~= 16 and CurrentMap.MapId ~= 660 and
  1062. GetMapContentType() ~= MAP_CONTENT_BATTLEGROUND and properSize > 42 then
  1063. properSize = 42
  1064. end
  1065. if (not pin.radius or pin.radius == 0) and CurrentMap.MapId ~= 16 and CurrentMap.MapId ~= 660 and
  1066. GetMapContentType() ~= MAP_CONTENT_BATTLEGROUND and properSize < 23 then
  1067. properSize = 23
  1068. end
  1069. pin:SetDimensions(properSize, properSize)
  1070. end
  1071.  
  1072. function FyrMM.SetPinAnchor(pin, x, y, AnchorToControl, hidden)
  1073. local newX, newY, currentX, currentY, currentObject, _
  1074. if pin == nil then
  1075. return
  1076. end
  1077. SetPinFunctions(pin)
  1078.  
  1079. if pin.nX == nil and pin.nY == nil and pin.normalizedX == nil and pin.normalizedY == nil then
  1080. PinsList[pin:GetName()] = nil
  1081. pin:ClearAnchors()
  1082. pin:SetHidden()
  1083. return
  1084. end
  1085.  
  1086. if x and y and AnchorToControl then
  1087. _, _, currentObject, _, currentX, currentY = pin:GetAnchor()
  1088. if PinsList[pin:GetName()] == nil then
  1089. PinsList[pin:GetName()] = pin
  1090. end
  1091.  
  1092. if FyrMM.SV.RotateMap then
  1093. newX, newY = GetRotatedPosition(x, y)
  1094. AnchorToControl = Fyr_MM_Scroll
  1095. else
  1096. newX, newY = GetNorthFacingPosition(x, y)
  1097. end
  1098.  
  1099. if newX ~= currentX or newY ~= currentY or currentObject ~= AnchorToControl then
  1100. pin:ClearAnchors()
  1101. if FyrMM.SV.RotateMap then
  1102. if pin.borderInformation then
  1103. pin:SetAnchor(TOPLEFT, AnchorToControl, CENTER, newX, newY)
  1104. else
  1105. pin:SetAnchor(CENTER, AnchorToControl, CENTER, newX, newY)
  1106. end
  1107. else
  1108. pin:SetAnchor(CENTER, AnchorToControl, TOPLEFT, newX, newY)
  1109. end
  1110. end
  1111. end
  1112.  
  1113. if hidden then
  1114. pin:SetHidden(true)
  1115. return
  1116. end
  1117.  
  1118. if FyrMM.SV.WheelMap and x and y then
  1119. pin:SetHidden(not Is_PinInsideWheel(pin))
  1120. end
  1121. end
  1122.  
  1123. local function RescaleLinks()
  1124. if not IsInAvAZone() then
  1125. return
  1126. end
  1127. local mWidth, mHeight = Fyr_MM_Scroll_Map:GetDimensions()
  1128. local Count, mapLink, startX, startY, endX, endY
  1129. for i = 1, 100 do
  1130. mapLink = GetControl("Fyr_MM_Scroll_Map_Links_Link" .. tostring(i))
  1131. if mapLink then
  1132. if FyrMM.SV.WheelMap then
  1133. mapLink:SetParent(Fyr_MM_Scroll_CW_Map_Pins)
  1134. else
  1135. mapLink:SetParent(Fyr_MM_Scroll_Map_Links)
  1136. end
  1137.  
  1138. if FyrMM.SV.RotateMap then
  1139. mapLink:ClearAnchors()
  1140. mapLink:SetAnchor(TOPLEFT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(mapLink.startNX, mapLink.startNY))
  1141. mapLink:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(mapLink.endNX, mapLink.endNY))
  1142. else
  1143. startX, startY, endX, endY = mapLink.startNX * mWidth - mWidth / 2,
  1144. mapLink.startNY * mHeight - mHeight / 2,
  1145. mapLink.endNX * mWidth - mWidth / 2, mapLink.endNY * mHeight - mHeight / 2
  1146. mapLink:ClearAnchors()
  1147. mapLink:SetAnchor(TOPLEFT, Fyr_MM_Scroll_Map_Links, CENTER, zo_round(startX), zo_round(startY))
  1148. mapLink:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll_Map_Links, CENTER, zo_round(endX), zo_round(endY))
  1149. end
  1150. else
  1151. i = 99
  1152. end
  1153.  
  1154. mapLink = GetControl("Fyr_MM_Scroll_Map_LinksNS_Link" .. tostring(i))
  1155. if mapLink then
  1156. if FyrMM.SV.RotateMap then
  1157. mapLink:ClearAnchors()
  1158. mapLink:SetAnchor(TOPLEFT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(mapLink.startNX, mapLink.startNY))
  1159. mapLink:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(mapLink.endNX, mapLink.endNY))
  1160. else
  1161. startX, startY, endX, endY = mapLink.startNX * mWidth - mWidth / 2,
  1162. mapLink.startNY * mHeight - mHeight / 2,
  1163. mapLink.endNX * mWidth - mWidth / 2, mapLink.endNY * mHeight - mHeight / 2
  1164. mapLink:ClearAnchors()
  1165. mapLink:SetAnchor(TOPLEFT, Fyr_MM_Scroll_Map_Links, CENTER, zo_round(startX), zo_round(startY))
  1166. mapLink:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll_Map_Links, CENTER, zo_round(endX), zo_round(endY))
  1167. end
  1168. end
  1169. mapLink = GetControl("Fyr_MM_Scroll_Map_LinksWE_Link" .. tostring(i))
  1170. if mapLink then
  1171. if FyrMM.SV.RotateMap then
  1172. mapLink:ClearAnchors()
  1173. mapLink:SetAnchor(TOPLEFT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(mapLink.startNX, mapLink.startNY))
  1174. mapLink:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(mapLink.endNX, mapLink.endNY))
  1175. else
  1176. startX, startY, endX, endY = mapLink.startNX * mWidth - mWidth / 2,
  1177. mapLink.startNY * mHeight - mHeight / 2,
  1178. mapLink.endNX * mWidth - mWidth / 2, mapLink.endNY * mHeight - mHeight / 2
  1179. mapLink:ClearAnchors()
  1180. mapLink:SetAnchor(TOPLEFT, Fyr_MM_Scroll_Map_Links, CENTER, zo_round(startX), zo_round(startY))
  1181. mapLink:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll_Map_Links, CENTER, zo_round(endX), zo_round(endY))
  1182. end
  1183. end
  1184. end
  1185. end
  1186.  
  1187. local function UpdateWheelPins()
  1188. if Fyr_MM:IsHidden() then
  1189. return
  1190. end
  1191. local RotateMap = FyrMM.SV.RotateMap
  1192. local WheelMap = FyrMM.SV.WheelMap
  1193. if not RotateMap and not WheelMap then
  1194. return
  1195. end
  1196. for _, v in pairs(PinsList) do
  1197. if WheelMap then
  1198. v:UpdateWheelVisibility()
  1199. end
  1200. if RotateMap then
  1201. if not v:IsHidden() or v.BorderPin then
  1202. v:RefreshAnchor()
  1203. end
  1204. end
  1205. end
  1206. RescaleLinks()
  1207. end
  1208.  
  1209. function FyrMM.RegisterRWUpdates() -- never called
  1210. EVENT_MANAGER:RegisterForUpdate("FyrMiniMapRWUpdate", 100, UpdateWheelPins)
  1211. end
  1212.  
  1213. function FyrMM.UnRegisterRWUpdates() -- never called
  1214. EVENT_MANAGER:UnRegisterForUpdate("FyrMiniMapRWUpdate")
  1215. end
  1216.  
  1217. local function UpdateCustomPinPositions()
  1218. if not FyrMM.Visible or Fyr_MM:IsHidden() or FyrMM.worldMapShowing or CustomPinsCopying then
  1219. return
  1220. end
  1221. -- local currentZone = CurrentMap.MapId
  1222. local mWidth, mHeight = Fyr_MM_Scroll_Map:GetDimensions()
  1223. local enabled
  1224. for _, p in pairs(PinsList) do
  1225. if p and p.m_PinType then
  1226. if p.m_PinType == 9999 then -- fix attempt 10/10/2022
  1227. p:SetHidden(not IsCoordinateInRange(p.nX, p.nY))
  1228. p:RefreshAnchor()
  1229. elseif p.m_PinType >= MAP_PIN_TYPE_INVALID then
  1230. if PinRef then
  1231. if PRCustomPins then
  1232. enabled = PRCustomPins[p.m_PinType].enabled
  1233. end
  1234. else
  1235. enabled = ZO_WorldMap_IsCustomPinEnabled(p.m_PinType) -- checks filter for custom pin
  1236. end
  1237.  
  1238. if p.nX and p.nY and enabled then
  1239. p:SetHidden(not IsCoordinateInRange(p.nX, p.nY))
  1240. if not p:IsHidden() then
  1241. if p.pinTexture and p.pinTexture ~= p:GetTextureFileName() then
  1242. p:SetTexture(p.pinTexture)
  1243. end
  1244. p:RefreshAnchor()
  1245. end
  1246. end
  1247. end
  1248. end
  1249. end
  1250. end
  1251.  
  1252. local function RescalePinPositions()
  1253. if Fyr_MM:IsHidden() or not CurrentMap.needRescale then
  1254. return
  1255. end
  1256. CurrentMap.needRescale = false
  1257. local mWidth, mHeight = Fyr_MM_Scroll_Map:GetDimensions()
  1258. for _, v in pairs(PinsList) do
  1259. v:RefreshAnchor()
  1260. if v.borderInformation ~= nil then -- antiquity digging sites
  1261. local width = v.borderInformation.borderWidth * mWidth
  1262. local height = v.borderInformation.borderHeight * mHeight
  1263. v:SetDimensions(width, height)
  1264. elseif FyrMM.SV.autoResizePin and v ~= ZO_WorldMap_GetPinManager():GetPlayerPin() and v.m_textureAnimTimeline ==
  1265. nil and CurrentMap.MapId ~= 16 and CurrentMap.MapId ~= 660 and (v.radius == 0 or v.radius == nil) and
  1266. GetMapContentType() ~= MAP_CONTENT_BATTLEGROUND and not v.noZoomResize then
  1267. if v.m_PinType == 9999 then -- Elder Scroll aura
  1268. local size = 64
  1269. FyrMM.SetPinSize(v, size * FyrMM.pScalePercent)
  1270. elseif v.m_PinType then
  1271. local size = 32
  1272. if ZO_MapPin.FAST_TRAVEL_WAYSHRINE_PIN_TYPES[v.m_PinType] or ZO_MapPin.POI_PIN_TYPES[v.m_PinType] or
  1273. v.m_PinType == MAP_PIN_TYPE_LOCATION then -- scale pin to zoom level only for these types
  1274. FyrMM.SetPinSize(v, size * FyrMM.pScalePercent * FyrMM.pinZoomScale)
  1275. else
  1276. FyrMM.SetPinSize(v, size * FyrMM.pScalePercent)
  1277. end
  1278. end
  1279. elseif v.radius and v.radius > 0 then -- resize area pin in case of zoom
  1280. local size = mHeight * v.radius * 2
  1281. v:SetDimensions(size, size)
  1282. end
  1283.  
  1284. if FyrMM.SV.WheelMap then
  1285. v:SetHidden(not Is_PinInsideWheel(v))
  1286. if v.BorderPin then
  1287. v.BorderPin:SetHidden(not v:IsHidden())
  1288. end
  1289. end
  1290. end
  1291. RescaleLinks()
  1292. FyrMM.UpdateQuestPinPositions()
  1293. FyrMM.PlaceBorderPins()
  1294. end
  1295.  
  1296. local ZoomAnimating = false
  1297. local function AnimateZoom(newzoom)
  1298. if CurrentMap.ZoomLevel == newzoom then
  1299. return
  1300. end
  1301.  
  1302. local step = (newzoom - CurrentMap.ZoomLevel) / 10
  1303. ZoomAnimating = true
  1304.  
  1305. EVENT_MANAGER:RegisterForUpdate("OnFyrMMZoomAnimate", 1, function()
  1306. FyrMM.SetCurrentMapZoom(CurrentMap.ZoomLevel + step)
  1307.  
  1308. if FyrMM.SV.autoResizePin and CurrentMap.MapId ~= 16 and CurrentMap.MapId ~= 660 and GetMapContentType() ~=
  1309. MAP_CONTENT_BATTLEGROUND then
  1310. -- zoom: 1 to 50 default: 10
  1311. -- should be between 0.1 and 5
  1312. FyrMM.pinZoomScale = (CurrentMap.ZoomLevel) / 10
  1313. -- d("pinzoom: "..FyrMM.pinZoomScale)
  1314. else
  1315. FyrMM.pinZoomScale = 1
  1316. end
  1317.  
  1318. if (CurrentMap.ZoomLevel <= newzoom and step < 0) or (CurrentMap.ZoomLevel >= newzoom and step > 0) then
  1319. EVENT_MANAGER:UnregisterForUpdate("OnFyrMMZoomAnimate")
  1320. FyrMM.SetCurrentMapZoom(newzoom)
  1321. -- FyrMM.UpdateMapTiles(true)
  1322. FyrMM.PositionUpdate()
  1323. CurrentMap.needRescale = true
  1324. RescalePinPositions()
  1325. FyrMM.UpdateMapTiles(true)
  1326. ZoomAnimating = false
  1327. else
  1328. -- FyrMM.UpdateMapTiles(true)
  1329. FyrMM.PositionUpdate()
  1330. CurrentMap.needRescale = true
  1331. RescalePinPositions()
  1332. FyrMM.UpdateMapTiles(true)
  1333. end
  1334. end)
  1335. end
  1336.  
  1337. local function GetQuestData(pin)
  1338. return pin.m_PinTag[1], pin.m_PinTag[3], pin.m_PinTag[2]
  1339. end
  1340.  
  1341. local function SetQuestTooltip(pin)
  1342. if pin == nil then
  1343. return
  1344. end
  1345. local tooltipLines = {}
  1346. local line = ""
  1347. local nX = pin.normalizedX
  1348. local nY = pin.normalizedY
  1349. local pinCount = Fyr_MM_Scroll_Map_QuestPins:GetNumChildren()
  1350. for index = 1, pinCount + 10 do
  1351. local questPin = GetControl("Fyr_MM_Scroll_Map_QuestPins_Pin" .. tostring(index))
  1352. if questPin and (not questPin:IsHidden() or FyrMM.SV.WheelMap) then
  1353. line = ""
  1354. if questPin.normalizedX == nX and questPin.normalizedY == nY then
  1355. -- if l.m_PinType == MAP_PIN_TYPE_ASSISTED_QUEST_ENDING or l.m_PinType == MAP_PIN_TYPE_TRACKED_QUEST_ENDING then
  1356. -- line = GenerateQuestEndingTooltipLine(questIndex)
  1357. -- if valueExists(line, tooltipLines) then
  1358. -- line = ""
  1359. -- else
  1360. -- InformationTooltip:AppendQuestEnding(l.m_PinTag[1])
  1361. -- end
  1362. -- end
  1363. if QUEST_PIN_TYPES[questPin.m_PinType] then
  1364. line = GenerateQuestConditionTooltipLine(GetQuestData(questPin))
  1365. if valueExists(line, tooltipLines) then
  1366. line = ""
  1367. else
  1368. InformationTooltip:AppendQuestCondition(GetQuestData(questPin))
  1369. end
  1370. end
  1371. if GetTrackedIsAssisted(TRACK_TYPE_QUEST, questPin.questIndex) then
  1372. questPin:SetMouseEnabled(true)
  1373. else
  1374. questPin:SetMouseEnabled(false)
  1375. end
  1376. end
  1377. if line ~= "" then
  1378. table.insert(tooltipLines, line)
  1379. end
  1380. end
  1381. end
  1382. pin:SetMouseEnabled(true)
  1383. end
  1384.  
  1385. -- local function GetQuestPinById(Id) -- Returns first visible pin by quest Id
  1386. -- for i=1, FyrMM.questPinCount do
  1387. -- local l = GetControl("Fyr_MM_Scroll_Map_QuestPins_Pin"..tostring(i))
  1388. -- if l ~= nil then
  1389. -- if l.questIndex == Id and not l:IsHidden() then
  1390. -- return l
  1391. -- end
  1392. -- end
  1393. -- end
  1394. -- return nil
  1395. -- end
  1396.  
  1397. function FyrMM.IsPinVisible(pin) -- Check for pin leaving map limits
  1398. return (pin:GetRight() >= Fyr_MM:GetLeft() + 6 and pin:GetLeft() <= Fyr_MM:GetRight() - 10 and pin:GetBottom() >=
  1399. Fyr_MM:GetTop() + 6 and pin:GetTop() <= Fyr_MM:GetBottom() - 10)
  1400. end
  1401.  
  1402. function FyrMM.IsValidBorderPin(pin)
  1403. if not FyrMM.SV.BorderPins then
  1404. return false
  1405. end
  1406.  
  1407. local Visible, Tracked
  1408. Visible = FyrMM.SV.WheelMap and Is_PinInsideWheel(pin) or FyrMM.IsPinVisible(pin)
  1409.  
  1410. if pin.m_PinType == MAP_PIN_TYPE_GROUP or pin.m_PinType == MAP_PIN_TYPE_GROUP_LEADER then
  1411. if IsUnitOnline(pin.unitTag) then
  1412. if FyrMM.SV.BorderPinsOnlyLeader and not IsUnitGroupLeader("player") and not IsActiveWorldBattleground() then
  1413. Tracked = IsUnitGroupLeader(pin.unitTag) and (GetUnitZone("player") == GetUnitZone(pin.unitTag))
  1414. else
  1415. Tracked = (GetUnitZone("player") == GetUnitZone(pin.unitTag))
  1416. end
  1417. end
  1418. else
  1419. if FyrMM.SV.BorderPinsOnlyAssisted then
  1420. Tracked = GetTrackedIsAssisted(TRACK_TYPE_QUEST, pin.questIndex)
  1421. else
  1422. Tracked = true
  1423. end
  1424. end
  1425.  
  1426. if pin.m_PinType == MAP_PIN_TYPE_ACTIVE_COMPANION then
  1427. Tracked = true
  1428. end
  1429.  
  1430. if CustomWaypoints[pin.m_PinType] then
  1431. Tracked = FyrMM.SV.BorderPinsWaypoint
  1432. end
  1433.  
  1434. if pin.m_Pin then
  1435. if pin.m_Pin:IsFastTravelWayShrine() then
  1436. local index, _ = string.gsub(pin:GetName(), "Fyr_MM_Scroll_Map_WayshrinePins_Pin", "")
  1437. if Wayshrines[tonumber(index)] then
  1438. if Wayshrines[tonumber(index)].Closest and CurrentMap.MapId and CurrentMap.MapId ~= 16 then -- removes wayshrine border pin on Crodiil map
  1439. Tracked = FyrMM.SV.BorderWayshrine
  1440. else
  1441. Tracked = false
  1442. end
  1443. end
  1444. end
  1445. end
  1446.  
  1447. if pin.m_PinType == MAP_PIN_TYPE_LOCATION then
  1448. Tracked = false
  1449. if pin.IsBankPin and FyrMM.SV.BorderPinsBank then
  1450. Tracked = pin.IsBankPin
  1451. end
  1452. if pin.IsStablePin and FyrMM.SV.BorderPinsStables then
  1453. Tracked = pin.IsStablePin
  1454. end
  1455. if pin.IsCraftingServicePin and FyrMM.SV.BorderCrafting then
  1456. Tracked = pin.IsCraftingServicePin
  1457. end
  1458. -- Community Leveling Guides
  1459. if pin.isZGESO then
  1460. Tracked = pin.isZGESO
  1461. end
  1462. end
  1463.  
  1464. -- AVA and Battlegrounds moving pins
  1465. if pin.AVABGtype ~= nil then
  1466. Tracked = true
  1467. end
  1468.  
  1469. -- lost treasure & Map pins treasures & surveys
  1470. if pin.IsTreasure then
  1471. if (pin.pinTexture and string.find(pin.pinTexture, "MapPins/Treasure_")) or
  1472. (PRCustomPins and PRCustomPins[pin.m_PinType] and PRCustomPins[pin.m_PinType].pinTypeString and
  1473. string.find(PRCustomPins[pin.m_PinType].pinTypeString, "LostTreasure")) then
  1474. Tracked = FyrMM.SV.BorderTreasures
  1475. else
  1476. pin.IsTreasure = nil
  1477. Tracked = false
  1478. end
  1479. end
  1480.  
  1481. -- Dragon Next location
  1482. if FyrMM.SV.WorldEvents and pin.IsDragonNextLocation then
  1483. if pin.pinTexture and string.find(pin.pinTexture, "dragonNextLocation") and (pin.nX ~= -1 and pin.nX ~= -1) then
  1484. Tracked = FyrMM.SV.WorldEvents
  1485. else
  1486. pin.IsDragonNextLocation = nil
  1487. Tracked = false
  1488. end
  1489. end
  1490.  
  1491. -- antiquity digging sites
  1492. if pin.borderInformation ~= nil then
  1493. Tracked = FyrMM.SV.BorderTreasures
  1494. end
  1495.  
  1496. -- quest givers and zonestory
  1497. if pin.IsAvailableQuest then
  1498. if pin.m_PinTag ~= nil then
  1499. if pin.m_PinTag.IsAvailableQuest then
  1500. if pin.m_PinTag.isZoneStory and pin == FyrMM.ZoneStoryPin then
  1501. Tracked = FyrMM.SV.BorderQuestGivers
  1502. elseif not pin.m_PinTag.isZoneStory then
  1503. Tracked = FyrMM.SV.BorderQuestGivers
  1504. else
  1505. Tracked = false
  1506. end
  1507. else
  1508. pin.IsAvailableQuest = nil
  1509. end
  1510. else
  1511. pin.IsAvailableQuest = nil
  1512. end
  1513. end
  1514.  
  1515. -- world events -- has to stay on bottom
  1516. if pin.context ~= nil and FyrMM.SV.WorldEvents then
  1517. if pin.weDistance then
  1518. if GetMapType() == MAPTYPE_SUBZONE then -- world events within X subzone map are displayed on border
  1519. local distance = CurrentMap.TrueMapSize or 1
  1520. local weDistance = distance *
  1521. math.sqrt(
  1522. (pin.nX - CurrentMap.PlayerNX) * (pin.nX - CurrentMap.PlayerNX) + (pin.nY - CurrentMap.PlayerNY) * (pin.nY - CurrentMap.PlayerNY))
  1523. Tracked = (weDistance <= distance)
  1524. -- d(CurrentMap.filename.." subzone tms "..distance.." dist "..weDistance)
  1525. else -- world events within zone map / 8 are displayed on border
  1526. local TrueMapSize = CurrentMap.TrueMapSize or 1
  1527. local distance = TrueMapSize / 8
  1528. Tracked = (pin.weDistance <= distance)
  1529. -- d(CurrentMap.filename.." tms "..distance.." dist "..pin.weDistance)
  1530. end
  1531. else
  1532. Tracked = false
  1533. end
  1534. end
  1535.  
  1536. return not Visible and Tracked
  1537. end
  1538.  
  1539. local function GetNumBorderPins()
  1540. local totalPins = Fyr_MM_Axis_Border_Pins:GetNumChildren()
  1541. local count = 0
  1542. for index = 1, totalPins do
  1543. local borderPinChild = Fyr_MM_Axis_Border_Pins:GetChild(index)
  1544. if borderPinChild then
  1545. if borderPinChild.pin then
  1546. count = count + 1
  1547. else
  1548. borderPinChild:SetHidden(true)
  1549. end
  1550. end
  1551. end
  1552. return count
  1553. end
  1554.  
  1555. local function RemoveBorderPin(pin)
  1556. if not pin then
  1557. return
  1558. end
  1559. pin:SetHidden(true)
  1560. pin:SetMouseEnabled(false)
  1561. pin:ClearAnchors()
  1562. -- pin:SetTexture(nil)
  1563. -- pin:SetHandler("OnMouseEnter", function() return end)
  1564. -- pin:SetHandler("OnMouseExit", function() return end)
  1565. -- pin:SetHandler("OnMouseUp", function() return end)
  1566. if pin.pin then
  1567. if pin.pin.OnBorder then
  1568. pin.pin.OnBorder = nil
  1569. end
  1570. if pin.pin.BorderPin then
  1571. pin.pin.BorderPin = nil
  1572. end
  1573. pin.pin = nil -- test 30/04/2023
  1574. end
  1575. end
  1576.  
  1577. local function CleanUpMisc()
  1578. local gameTime = GetGameTimeMilliseconds()
  1579. if not IsInAvAZone() then
  1580. KeepIndex = {}
  1581. local LinksDone = false
  1582. local LinksNSDone = false
  1583. local LinksWEDone = false
  1584. local LocksDone = false
  1585. for index = 1, 100 do
  1586. l = GetControl("Fyr_MM_Scroll_Map_Links_Link" .. tostring(index))
  1587. if l ~= nil then
  1588. l:ClearAnchors()
  1589. l:SetHidden(true)
  1590. l:SetMouseEnabled(false)
  1591. else
  1592. LinksDone = true
  1593. end
  1594. l = GetControl("Fyr_MM_Scroll_Map_LinksNS_Link" .. tostring(index))
  1595. if l ~= nil then
  1596. l:ClearAnchors()
  1597. l:SetHidden(true)
  1598. l:SetMouseEnabled(false)
  1599. else
  1600. LinksNSDone = true
  1601. end
  1602. l = GetControl("Fyr_MM_Scroll_Map_LinksWE_Link" .. tostring(index))
  1603. if l ~= nil then
  1604. l:ClearAnchors()
  1605. l:SetHidden(true)
  1606. l:SetMouseEnabled(false)
  1607. else
  1608. LinksWEDone = true
  1609. end
  1610. l = GetControl("Fyr_MM_Scroll_Map_Locks_Lock" .. tostring(index))
  1611. if l ~= nil then
  1612. l:ClearAnchors()
  1613. l.normalizedX = nil
  1614. l.normalizedY = nil
  1615. l:SetHidden(true)
  1616. l:SetMouseEnabled(false)
  1617. -- l:SetTexture(nil)
  1618. l:SetDimensions(0, 0)
  1619. else
  1620. LocksDone = true
  1621. end
  1622. if LinksDone and LinksNSDone and LinksWEDone and LocksDone then
  1623. index = 100
  1624. end
  1625. end
  1626. end
  1627.  
  1628. FyrMM.CustomPinCount = 0
  1629. FreeCustomPinIndex = {}
  1630. CustomPinIndex = {}
  1631. CustomPinKeyIndex = {}
  1632. LastCustomPinIndex = 0
  1633. FyrMM.Reloading = false
  1634.  
  1635. FyrMM.InitialPreload()
  1636.  
  1637. -- Some InitialPreload functions are moved here to speed up things 21/04/2023 -- CAUSING DISPLAY BUGS WITH CUSTOM PINS
  1638. -- YO FyrMM.SetMapToPlayerLocation() -- test 21/04/2023
  1639. -- YO CurrentMap.ZoneIndex = GetCurrentMapZoneIndex() -- test 21/04/2023
  1640. -- FyrMM.UpdateMapInfo() -- test 21/04/2023
  1641. -- FyrMM.UpdateMapTiles(true) -- test 21/04/2023
  1642. -- YO FyrMM.GroupEvent() -- test 21/04/2023
  1643. -- YO FyrMM.UpdateQuestPins() -- test 21/04/2023
  1644.  
  1645. -- YO if IsInAvAZone() then FyrMM.RequestKeepRefresh() end -- test 21/04/2023
  1646. -- YO FyrMM.PlaceWaypointBorderPins() -- test 01/05/2023
  1647. -- YO FyrMM.LoadCustomPinList() -- test 01/05/2023
  1648. -- YO FyrMM.UpdateAntiquityDigSites() -- test 21/04/2023
  1649. -- YO FyrMM.RegisterUpdates() -- test 21/04/2023
  1650.  
  1651. if FyrMM.DebugMode then
  1652. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "CleanUpMisc " .. tostring(GetGameTimeMilliseconds() - gameTime))
  1653. end
  1654. end
  1655.  
  1656. local function RemoveCustomPin(p)
  1657. if not p then --[[ d("RemoveCustomPin pin is nil") --]]
  1658. return
  1659. end
  1660. if p.BorderPin then
  1661. RemoveBorderPin(p.BorderPin)
  1662. end
  1663.  
  1664. local key = tostring(p.nX) .. ":" .. tostring(p.nY) .. ":" .. tostring(p.radius)
  1665. if p.m_PinType and FyrMM.CustomPinCheckList[p.m_PinType] and FyrMM.CustomPinCheckList[p.m_PinType][key] then
  1666. FyrMM.CustomPinCheckList[p.m_PinType][key].Id = 0
  1667. end
  1668.  
  1669. p:ClearAnchors()
  1670. p:SetHidden(true)
  1671. p.m_PinTag = nil
  1672. p.MapId = nil
  1673. p.radius = nil
  1674. p.nX = nil
  1675. p.nY = nil
  1676. p.IsTreasure = nil
  1677. p.IsAvailableQuest = nil
  1678. p.pinTexture = nil
  1679.  
  1680. -- if p.Key == nil then d("p.Key == nil, could not remove that pin") end
  1681. -- if p.Index == nil then d("p.Index == nil, could not remove that pin") end
  1682.  
  1683. if FyrMM.CustomPinList[p.m_PinType] and FyrMM.CustomPinList[p.m_PinType][p.Key] and FyrMM.CustomPinList[p.m_PinType][p.Key].pin then
  1684. FyrMM.CustomPinList[p.m_PinType][p.Key].pin = nil
  1685. FyrMM.CustomPinList[p.m_PinType][p.Key] = nil
  1686. end
  1687.  
  1688. if not IsTableEmpty(CustomPinIndex) then
  1689. if p.Index then
  1690. table.insert(FreeCustomPinIndex, p.Index)
  1691. FyrMM.CustomPinCount = FyrMM.CustomPinCount - 1
  1692. end
  1693.  
  1694. if CustomPinIndex[p.m_PinType] and p.Index and CustomPinIndex[p.m_PinType][p.Index] then
  1695. CustomPinIndex[p.m_PinType][p.Index] = nil
  1696.  
  1697. -- if p.Key ~= nil then
  1698. -- CustomPinKeyIndex[p.m_PinType][p.Key] = nil
  1699. -- end
  1700. end
  1701. end
  1702.  
  1703. if p:GetName() and PinsList[p:GetName()] then
  1704. PinsList[p:GetName()] = nil
  1705. end
  1706.  
  1707. p.Key = nil
  1708. p.m_PinType = nil
  1709. p.Index = nil
  1710. p = nil
  1711. -- d("pin was removed")
  1712. end
  1713.  
  1714. local function CheckCustomPinConsistence(Type)
  1715. local pin
  1716. if Type == nil then
  1717. for i, n in pairs(CustomPinKeyIndex) do
  1718. if FyrMM.CustomPinList[i] == nil then
  1719. for j, index in pairs(n) do
  1720. pin = GetControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(index))
  1721. RemoveCustomPin(pin)
  1722. CustomPinKeyIndex[i][j] = nil
  1723. end
  1724. else
  1725. if #n ~= #FyrMM.CustomPinList[i] then
  1726. for j, index in pairs(n) do
  1727. if FyrMM.CustomPinList[i][j] == nil then
  1728. pin = GetControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(index))
  1729. RemoveCustomPin(pin)
  1730. CustomPinKeyIndex[i][j] = nil
  1731. end
  1732. end
  1733. end
  1734. end
  1735. end
  1736. else
  1737. if CustomPinKeyIndex[Type] == nil then
  1738. return
  1739. end
  1740. if FyrMM.CustomPinList[Type] == nil then
  1741. for j, index in pairs(CustomPinKeyIndex[Type]) do
  1742. pin = GetControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(index))
  1743. RemoveCustomPin(pin)
  1744. CustomPinKeyIndex[Type][j] = nil
  1745. end
  1746. else
  1747. if #CustomPinKeyIndex[Type] ~= #FyrMM.CustomPinList[Type] then
  1748. for j, index in pairs(CustomPinKeyIndex[Type]) do
  1749. if FyrMM.CustomPinList[Type][j] == nil then
  1750. pin = GetControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(index))
  1751. RemoveCustomPin(pin)
  1752. CustomPinKeyIndex[Type][j] = nil
  1753. end
  1754. end
  1755. end
  1756. end
  1757. end
  1758. end
  1759.  
  1760. local function CleanUpPins()
  1761. -- faster ways for cleaning up pins result in occasional pins not removing
  1762.  
  1763. if IsTableEmpty(PinsList) then
  1764. FyrMM.Reloading = false
  1765. return
  1766. end
  1767.  
  1768. if FyrMM.DebugMode then
  1769. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  1770. "CleanUpPins Start:" .. tostring(chunk) .. "..." .. tostring(delay))
  1771. end
  1772.  
  1773. local cui = 0
  1774. local chunk = FyrMM.SV.ChunkSize or 50
  1775. local delay = FyrMM.SV.ChunkDelay or 50
  1776.  
  1777. EVENT_MANAGER:RegisterForUpdate("FyrMiniMapCleanupPinsTask", delay, function()
  1778. local count = 0
  1779. local isCustomPin = false
  1780. cui = cui + 1
  1781. local gameTime = GetGameTimeMilliseconds()
  1782. for index, pin in pairs(PinsList) do
  1783. count = count + 1
  1784.  
  1785. if count >= chunk then
  1786. if FyrMM.DebugMode then
  1787. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "CleanUpPins " .. tostring(cui) .. " " ..
  1788. tostring(GetGameTimeMilliseconds() - gameTime))
  1789. end
  1790. return
  1791. end
  1792.  
  1793. if pin then
  1794. if pin.m_PinType and pin.m_PinType >= MAP_PIN_TYPE_INVALID then -- is custom pin
  1795. RemoveCustomPin(pin)
  1796. isCustomPin = true
  1797. end
  1798.  
  1799. if not isCustomPin then -- is regular pin
  1800. if pin.BorderPin then
  1801. RemoveBorderPin(pin.BorderPin)
  1802. end
  1803. pin:ClearAnchors()
  1804. pin:SetHidden(true)
  1805. pin:SetMouseEnabled(false)
  1806. pin.nX = nil
  1807. pin.nY = nil
  1808. pin:ClearAnchors()
  1809. pin:SetHidden(true)
  1810. pin:SetMouseEnabled(false)
  1811. -- l:SetTexture(nil)
  1812. pin:SetDimensions(0, 0)
  1813. pin.m_PinTag = nil
  1814. pin.m_PinType = nil
  1815. pin.m_Pin = nil
  1816. pin.IsAvailableQuest = nil
  1817. pin.normalizedX = nil
  1818. pin.normalizedY = nil
  1819. pin.radius = nil
  1820. pin.MapId = nil
  1821. pin.Index = nil
  1822. pin.questName = nil
  1823. pin.PinToolTipText = nil
  1824. pin.primaryPin = nil
  1825. pin.secondaryPin = nil
  1826. pin.tertiaryPin = nil
  1827. pin.MM_Tag = nil
  1828. pin.pinAge = nil
  1829. pin.IsTreasure = nil
  1830. pin.isDps = nil
  1831. pin.isHeal = nil
  1832. pin.isTank = nil
  1833. pin.ClassId = nil
  1834. pin.isLeader = nil
  1835. PinsList[index] = nil
  1836. end
  1837. end
  1838. if IsTableEmpty(PinsList) then
  1839. if FyrMM.DebugMode then
  1840. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  1841. "CleanUpPins Done. " .. tostring(GetGameTimeMilliseconds() - gameTime))
  1842. end
  1843. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapCleanupPinsTask")
  1844. CleanUpMisc()
  1845. return
  1846. end
  1847. end
  1848. end)
  1849. end
  1850.  
  1851. local function GetNewBorderPinIndex()
  1852. if Fyr_MM_Axis_Border_Pins:GetNumChildren() == 0 then
  1853. return 1
  1854. end
  1855.  
  1856. if Fyr_MM_Axis_Border_Pins:GetNumChildren() ~= GetNumBorderPins() then
  1857. for i = 1, Fyr_MM_Axis_Border_Pins:GetNumChildren() do
  1858. local l = Fyr_MM_Axis_Border_Pins:GetChild(i)
  1859. if l and not l.pin then
  1860. return i
  1861. end
  1862. end
  1863. end
  1864.  
  1865. return Fyr_MM_Axis_Border_Pins:GetNumChildren() + 1
  1866. end
  1867.  
  1868. local function GetTextureForBorderPin(pin)
  1869. local texture = pin.pinTexture
  1870.  
  1871. if pin.IsTreasure and texture then
  1872. return texture
  1873. end
  1874.  
  1875. if pin.IsDragonNextLocation and texture then
  1876. return texture
  1877. -- zone stories
  1878. end
  1879.  
  1880. if pin.IsAvailableQuest then
  1881. if pin.m_PinTag.isZoneStory or ZO_MapPin.SUGGESTION_PIN_TYPES[pin.m_PinType] then
  1882. if pin.m_PinType == MAP_PIN_TYPE_SKYSHARD_SUGGESTED then
  1883. return "EsoUI/Art/MapPins/skyshard_seen.dds"
  1884. end
  1885.  
  1886. return "esoui/art/lfg/gamepad/lfg_menuicon_zonestories.dds"
  1887. end
  1888.  
  1889. if texture then
  1890. return texture
  1891. end
  1892.  
  1893. -- antiquities
  1894. end
  1895.  
  1896. if pin.borderInformation then
  1897. return "/esoui/art/icons/servicemappins/servicepin_antiquities.dds"
  1898. end
  1899.  
  1900. if pin.m_PinType == MAP_PIN_TYPE_PLAYER_WAYPOINT then
  1901. return "EsoUI/Art/MapPins/UI_Worldmap_pin_customDestination.dds"
  1902. end
  1903.  
  1904. if pin.m_PinType == MAP_PIN_TYPE_RALLY_POINT then
  1905. return "MiniMap/Textures/rally.dds"
  1906. end
  1907.  
  1908. if pin.m_PinType == MAP_PIN_TYPE_PING then
  1909. return "MiniMap/Textures/ping.dds"
  1910. end
  1911.  
  1912. if pin.m_PinType == MAP_PIN_TYPE_LOCATION and pin.m_PinTag[2] then
  1913. return pin.m_PinTag[2]
  1914. end
  1915.  
  1916. if (pin.m_PinType == MAP_PIN_TYPE_GROUP or pin.m_PinType == MAP_PIN_TYPE_GROUP_LEADER) and texture then
  1917. return texture
  1918. end
  1919.  
  1920. if pin.m_PinType == MAP_PIN_TYPE_ACTIVE_COMPANION and texture then
  1921. return texture
  1922. -- dragons & world events
  1923. end
  1924.  
  1925. if pin.context then
  1926. return texture
  1927. end
  1928.  
  1929. if QUEST_PIN_TYPES[pin.m_PinType] then
  1930. if pin.m_PinTag.isBreadcrumb then
  1931. return breadcrumbQuestPinTextures[pin.m_PinType]
  1932. end
  1933.  
  1934. return questPinTextures[pin.m_PinType]
  1935. end
  1936.  
  1937. if pin.m_Pin and pin.m_Pin:IsFastTravelWayShrine() then
  1938. if pin.m_Pin.m_PinTag[2] then
  1939. return pin.m_Pin.m_PinTag[2]
  1940. end
  1941. return "/esoui/art/icons/poi_wayshrine_complete.dds"
  1942. -- AVA and Battlegrounds
  1943. end
  1944.  
  1945. if OBJECTIVE_PIN_TYPES[pin.m_PinType] or ZO_MapPin.RETURN_OBJECTIVE_PIN_TYPES[pin.m_PinType] or
  1946. ZO_MapPin.SPAWN_OBJECTIVE_PIN_TYPES[pin.m_PinType] then
  1947. return ZO_MapPin.PIN_DATA[pin.m_PinType].texture
  1948. end
  1949.  
  1950. if pin.m_PinType == 9999 then
  1951. return "MiniMap/Textures/scroll_aura.dds"
  1952. -- Elder Scroll aura
  1953. end
  1954. end
  1955.  
  1956. local function ProcessQuestPinClick(pin)
  1957. local PinHandlers = {}
  1958. local Pins = {}
  1959. local HandlerCount = 0
  1960. local Handler = {}
  1961. local entries = {}
  1962. local entry = ""
  1963. Handler.Callback = function(questIndex)
  1964. FOCUSED_QUEST_TRACKER:ForceAssist(questIndex)
  1965. end
  1966. Handler.Name = zo_strformat(SI_WORLD_MAP_ACTION_SELECT_QUEST, GetJournalQuestName(pin.questIndex))
  1967. table.insert(PinHandlers, Handler)
  1968. table.insert(Pins, pin)
  1969. for i = 1, FyrMM.questPinCount do
  1970. local p = GetControl("Fyr_MM_Scroll_Map_QuestPins_Pin" .. tostring(i))
  1971. if p ~= nil then
  1972. if p ~= pin and p.normalizedX == pin.normalizedX and p.normalizedY == pin.normalizedY and not p:IsHidden() then
  1973. entry = zo_strformat(SI_WORLD_MAP_ACTION_SELECT_QUEST, GetJournalQuestName(p.questIndex))
  1974. if not valueExists(entry, entries) then
  1975. HandlerCount = HandlerCount + 1
  1976. local Handler = {}
  1977. Handler.Callback = function(questIndex)
  1978. FOCUSED_QUEST_TRACKER:ForceAssist(questIndex)
  1979. end
  1980. Handler.Name = zo_strformat(SI_WORLD_MAP_ACTION_SELECT_QUEST, GetJournalQuestName(p.questIndex))
  1981. table.insert(PinHandlers, Handler)
  1982. table.insert(Pins, p)
  1983. table.insert(entries, entry)
  1984. end
  1985. end
  1986. end
  1987. end
  1988. if HandlerCount <= 1 then
  1989. PinHandlers[1].Callback(Pins[1].questIndex)
  1990. else
  1991. ClearMenu()
  1992. for i = 1, HandlerCount do
  1993. local Handler = PinHandlers[i]
  1994. local questIndex = Pins[i].questIndex
  1995. local Name = Handler.Name
  1996. if type(Name) == "function" then
  1997. Name = Name(Pins[i])
  1998. end
  1999. AddMenuItem(Name, function()
  2000. Handler.Callback(questIndex)
  2001. end)
  2002. end
  2003. ShowMenu(pin)
  2004. end
  2005. end
  2006.  
  2007. local function PinOnMouseExit(pin)
  2008. if pin == nil then
  2009. return
  2010. end
  2011. FyrMM.SetTargetScale(pin, 1)
  2012. if pin.m_PinType == MAP_PIN_TYPE_LOCATION then
  2013. ClearTooltip(ZO_MapLocationTooltip)
  2014. else
  2015. ClearTooltip(InformationTooltip)
  2016. end
  2017. end
  2018.  
  2019. local function PinOnMouseEnter(pin)
  2020. FyrMM.SetTargetScale(pin, 1.3)
  2021. if not FyrMM.SV.PinTooltips then
  2022. return
  2023. end
  2024. if pin.pinType ~= nil then
  2025. if pin.pinType == MAP_PIN_TYPE_TRACKED_ANTIQUITY_DIG_SITE or pin.pinType == MAP_PIN_TYPE_ANTIQUITY_DIG_SITE then
  2026. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2027. InformationTooltip:AppendDigSiteAntiquities(pin.Tag)
  2028. end
  2029. end
  2030. if pin.m_PinType ~= nil then
  2031. if QUEST_PIN_TYPES[pin.m_PinType] then
  2032. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2033. SetQuestTooltip(pin)
  2034. IsCurrentLocation(pin)
  2035. return
  2036. elseif ZONE_EXPLORATION_PIN_TYPES[pin.m_PinType] then
  2037. if ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType] == nil then
  2038. return
  2039. end
  2040. if ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType].tooltip then
  2041. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2042. end
  2043. ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType].creator(pin.mpin)
  2044. IsCurrentLocation(pin)
  2045. elseif CustomWaypoints[pin.m_PinType] then
  2046. if ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType] then
  2047. if ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType].tooltip and
  2048. ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType].creator then
  2049. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2050. ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType].creator(pin)
  2051. IsCurrentLocation(pin)
  2052. return
  2053. end
  2054. end
  2055. elseif ZO_MapPin.FAST_TRAVEL_WAYSHRINE_PIN_TYPES[pin.m_PinType] or ZO_MapPin.POI_PIN_TYPES[pin.m_PinType] then
  2056. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2057. SetTooltipMessage(pin.m_Pin)
  2058. if not ZO_MapPin.FAST_TRAVEL_WAYSHRINE_PIN_TYPES[pin.m_PinType] then
  2059. IsCurrentLocation(pin)
  2060. end
  2061. return
  2062. elseif pin.m_PinType == MAP_PIN_TYPE_LOCATION then
  2063. if ZO_MapPin.TOOLTIP_CREATORS[MAP_PIN_TYPE_LOCATION].tooltip then
  2064. InitializeTooltip(ZO_MapLocationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2065. ZO_MapPin.TOOLTIP_CREATORS[MAP_PIN_TYPE_LOCATION].creator(pin.m_Pin)
  2066. IsCurrentLocation(pin)
  2067. return
  2068. end
  2069. elseif ZO_MapPin.GROUP_PIN_TYPES[pin.m_PinType] then
  2070. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2071. InformationTooltip:AppendUnitName(pin.unitTag)
  2072. IsCurrentLocation(pin)
  2073. return
  2074.  
  2075. -- world events and dragons
  2076. elseif pin.context ~= nil then
  2077. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2078. InformationTooltip:AppendUnitName(pin.unitTag)
  2079. IsCurrentLocation(pin)
  2080. return
  2081. elseif pin.m_PinType >= MAP_PIN_TYPE_INVALID then -- has to stay on bottom
  2082. if ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType] then
  2083. if ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType].tooltip and
  2084. ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType].creator then
  2085. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2086. ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType].creator(pin.mpin)
  2087. IsCurrentLocation(pin)
  2088. return
  2089. end
  2090. end
  2091. end
  2092. end
  2093. end
  2094.  
  2095. local function PinOnMouseUp(pin)
  2096. FyrMM.SetTargetScale(pin, 1.3)
  2097. if not FyrMM.SV.PinTooltips then
  2098. return
  2099. end
  2100. if pin.m_PinType ~= nil then
  2101. if QUEST_PIN_TYPES[pin.m_PinType] then
  2102. ProcessQuestPinClick(pin)
  2103. FyrMM.UpdateQuestPins()
  2104. end
  2105. if ZO_MapPin.FAST_TRAVEL_WAYSHRINE_PIN_TYPES[pin.m_PinType] then
  2106. if not IsInAvAZone() and FyrMM.SV.FastTravelEnabled then
  2107. if IsCurrentLocation(pin.m_Pin) then
  2108. return
  2109. end -- No need to recall if player is near wayshrine
  2110. local nodeIndex = pin.m_Pin:GetFastTravelNodeIndex()
  2111. ZO_Dialogs_ReleaseDialog("FAST_TRAVEL_CONFIRM")
  2112. local name = select(2, GetFastTravelNodeInfo(nodeIndex))
  2113. ZO_Dialogs_ShowDialog("FAST_TRAVEL_CONFIRM", {
  2114. nodeIndex = nodeIndex,
  2115. recall = true
  2116. }, {
  2117. mainTextParams = { name }
  2118. })
  2119. end
  2120. end
  2121. end
  2122. end
  2123.  
  2124. local function BorderPinOnMouseExit(pin)
  2125. if pin == nil then
  2126. return
  2127. end
  2128. if pin.pin == nil then
  2129. return
  2130. end
  2131. FyrMM.SetTargetScale(pin, 1)
  2132. if pin.pin.m_PinType then
  2133. if pin.pin.m_PinType == MAP_PIN_TYPE_LOCATION then
  2134. ClearTooltip(ZO_MapLocationTooltip)
  2135. else
  2136. ClearTooltip(InformationTooltip)
  2137. end
  2138. else
  2139. if pin.pin.borderInformation ~= nil then
  2140. ClearTooltip(InformationTooltip)
  2141. end
  2142. end
  2143. end
  2144.  
  2145. local function BorderPinOnMouseEnter(pin)
  2146. if pin.pin == nil then
  2147. RemoveBorderPin(pin)
  2148. return
  2149. end
  2150. FyrMM.SetTargetScale(pin, 1.3)
  2151. if not FyrMM.SV.PinTooltips then
  2152. return
  2153. end
  2154. if pin.pin.borderInformation ~= nil then
  2155. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2156. InformationTooltip:AppendDigSiteAntiquities(pin.pin.Tag)
  2157. IsCurrentLocation(pin.pin)
  2158. return
  2159. end
  2160. if pin.pin.m_PinType then
  2161. if pin.pin.m_PinType == MAP_PIN_TYPE_LOCATION then
  2162. if ZO_MapPin.TOOLTIP_CREATORS[MAP_PIN_TYPE_LOCATION].tooltip then
  2163. InitializeTooltip(ZO_MapLocationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2164. ZO_MapPin.TOOLTIP_CREATORS[MAP_PIN_TYPE_LOCATION].creator(pin.pin.m_Pin)
  2165. end
  2166. IsCurrentLocation(pin.pin)
  2167. return
  2168. else
  2169. if ZO_MapPin.FAST_TRAVEL_WAYSHRINE_PIN_TYPES[pin.pin.m_PinType] then
  2170. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2171. SetTooltipMessage(pin.pin.m_Pin)
  2172. return
  2173. end
  2174. if pin.pin.IsTreasure or pin.pin.IsAvailableQuest then
  2175. if ZO_MapPin.TOOLTIP_CREATORS[pin.pin.m_PinType] == nil then
  2176. return
  2177. end
  2178. if ZO_MapPin.TOOLTIP_CREATORS[pin.pin.m_PinType].tooltip then
  2179. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2180. end
  2181. ZO_MapPin.TOOLTIP_CREATORS[pin.pin.m_PinType].creator(pin.pin.mpin)
  2182. IsCurrentLocation(pin.pin)
  2183. return
  2184. end
  2185. if pin.pin.m_PinType == MAP_PIN_TYPE_GROUP or pin.pin.m_PinType == MAP_PIN_TYPE_GROUP_LEADER then
  2186. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2187. InformationTooltip:AppendUnitName(pin.pin.unitTag)
  2188. IsCurrentLocation(pin.pin)
  2189. return
  2190. end
  2191. if ZO_MapPin.MAP_PING_PIN_TYPES[pin.pin.m_PinType] then
  2192. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2193. InformationTooltip:AppendMapPing(pin.pin.m_PinType, "player")
  2194. IsCurrentLocation(pin.pin)
  2195. end
  2196. if QUEST_PIN_TYPES[pin.pin.m_PinType] then
  2197. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  2198. InformationTooltip:AppendQuestCondition(GetQuestData(pin.pin))
  2199. IsCurrentLocation(pin.pin)
  2200. end
  2201. end
  2202. end
  2203. end
  2204.  
  2205. local function SetBorderPinHandlers(pin)
  2206. if pin == nil then
  2207. local l
  2208. for i = 1, Fyr_MM_Axis_Border_Pins:GetNumChildren() + 50 do
  2209. l = GetControl("Fyr_MM_Axis_Border_Pins_Pin" .. tostring(i))
  2210. if l ~= nil then
  2211. if l.pin ~= nil then
  2212. if CustomWaypoints[l.pin.m_PinType] then
  2213. RemoveBorderPin(l)
  2214. end
  2215. end
  2216. else
  2217. return
  2218. end
  2219. end
  2220. return
  2221. end
  2222. pin:SetHandler("OnMouseEnter", BorderPinOnMouseEnter)
  2223. pin:SetHandler("OnMouseExit", BorderPinOnMouseExit)
  2224. pin:SetMouseEnabled(true)
  2225. end
  2226.  
  2227. function FyrMM.CreateBorderPin(pin) -- Should have been called create / update border pin
  2228. if pin == nil then
  2229. return
  2230. end
  2231. if pin.m_PinType == nil then
  2232. return
  2233. end
  2234. local borderpin
  2235.  
  2236. local pdata = ZO_MapPin.PIN_DATA[pin.m_PinType]
  2237. local bpsize
  2238.  
  2239. if pin.m_PinType == 9999 then -- Elder Scroll aura
  2240. bpsize = 64
  2241. elseif pdata == nil or pdata.size == nil then
  2242. bpsize = 32
  2243. else
  2244. bpsize = pdata.size
  2245. end
  2246.  
  2247. if not FyrMM.IsValidBorderPin(pin) then
  2248. if pin.BorderPin ~= nil then
  2249. RemoveBorderPin(pin.BorderPin)
  2250. end
  2251. return
  2252. end
  2253.  
  2254. local mmWidth, mmHeight = Fyr_MM:GetDimensions()
  2255. local mmX, mmY = Fyr_MM_Player:GetRight(), Fyr_MM_Player:GetTop()
  2256. local pinX, pinY = math.abs(pin:GetRight() - mmX), math.abs(pin:GetTop() - mmY)
  2257. local m = 0
  2258. if pinX ~= 0 then
  2259. m = pinY / pinX
  2260. end
  2261. local D = mmWidth / 2 - ((38 / 512) * mmWidth)
  2262. local newX, newY
  2263. local na = math.atan((mmWidth / 2) / (mmHeight / 2))
  2264. local nb = pi * 0.5 - na
  2265. local pa = math.atan(pinX / (pinY))
  2266. local pb = pi * 0.5 - pa
  2267.  
  2268. if not pin.BorderPin then -- pin.OnBorder
  2269. local index = GetNewBorderPinIndex()
  2270. borderpin = GetControl("Fyr_MM_Axis_Border_Pin" .. tostring(index))
  2271. if borderpin == nil then
  2272. borderpin = WINDOW_MANAGER:CreateControl("Fyr_MM_Axis_Border_Pin" .. tostring(index),
  2273. Fyr_MM_Axis_Border_Pins, CT_TEXTURE)
  2274. end
  2275. pin.BorderPin = borderpin
  2276. borderpin.pin = pin
  2277.  
  2278. SetBorderPinHandlers(borderpin)
  2279. else
  2280. borderpin = pin.BorderPin
  2281. end
  2282.  
  2283. SetBorderPinHandlers(borderpin)
  2284. pin.OnBorder = true
  2285. borderpin:SetTexture(GetTextureForBorderPin(pin))
  2286.  
  2287. -- antiquities
  2288. if pin.borderInformation ~= nil then
  2289. local antiquityIds = { GetInProgressAntiquitiesForDigSite(pin.Tag) }
  2290. for index, antiquityId in pairs(antiquityIds) do -- removed ipairs for pairs here
  2291. local antiquityData = ANTIQUITY_DATA_MANAGER:GetAntiquityData(antiquityId)
  2292. if not antiquityData:IsInCurrentPlayerZone() then
  2293. RemoveCustomPin(pin)
  2294. break
  2295. end -- fix for antiquities border pins of other zones showing
  2296.  
  2297. local c = GetAntiquityQualityColor(antiquityData:GetQuality())
  2298. if c.r ~= nil then
  2299. borderpin:SetColor(c.r, c.g, c.b, c.a) -- last antiquityId gets the digsite quality color *shrug*
  2300. else
  2301. borderpin:SetColor(1, 1, 1, 1)
  2302. end
  2303. end
  2304.  
  2305. -- group leader colour
  2306. elseif pin.isLeader then
  2307. borderpin:SetColor(FyrMM.SV.LeaderDeadPinColor.r, FyrMM.SV.LeaderDeadPinColor.g, FyrMM.SV.LeaderDeadPinColor.b,
  2308. 1)
  2309.  
  2310. -- coloured custom pins
  2311. elseif pin.m_PinType ~= nil and pin.context == nil and not (pin.m_PinTag and pin.m_PinTag.isZoneStory) then
  2312. if pin.tint then -- compatibility with addons which modify pin colors by pin
  2313. if type(pin.tint) ~= "function" then
  2314. borderpin:SetColor(pin.tint:UnpackRGBA())
  2315. else
  2316. if type(pin.tint) == "table" then
  2317. borderpin:SetColor(pin.tint.r, pin.tint.g, pin.tint.b, pin.tint.a)
  2318. end
  2319. end
  2320. elseif ZOpinData[pin.m_PinType].tint ~= nil then
  2321. if type(ZOpinData[pin.m_PinType].tint) ~= "function" then
  2322. borderpin:SetColor(ZOpinData[pin.m_PinType].tint:UnpackRGBA())
  2323. else
  2324. if borderpin.pin.m_Pin ~= nil then
  2325. borderpin:SetColor(ZOpinData[pin.m_PinType].tint(borderpin.pin.m_Pin):UnpackRGBA())
  2326. elseif borderpin.pin ~= nil then
  2327. borderpin:SetColor(ZOpinData[pin.m_PinType].tint(borderpin.pin):UnpackRGBA())
  2328. else
  2329. borderpin:SetColor(1, 1, 1, 1)
  2330. end
  2331. end
  2332. else
  2333. borderpin:SetColor(1, 1, 1, 1)
  2334. end
  2335. end
  2336.  
  2337. if pin.color then
  2338. borderpin:SetColor(pin.color[1], pin.color[2], pin.color[3], 1)
  2339. end
  2340.  
  2341. if pinX > 0 and pinY > 0 then
  2342. if pa <= na then
  2343. if pin:GetRight() >= mmX then
  2344. newX = mmWidth / 2 + mmHeight / 2 * math.sin(pa) / math.sin(pi * 0.5 - pa)
  2345. else
  2346. newX = mmWidth / 2 - mmHeight / 2 * math.sin(pa) / math.sin(pi * 0.5 - pa)
  2347. end
  2348. if pin:GetTop() < mmY then
  2349. newY = 4
  2350. else
  2351. newY = mmHeight - (bpsize * FyrMM.pScalePercent) / 2 + 2
  2352. end
  2353. else
  2354. if pin:GetRight() > mmX then
  2355. newX = mmWidth - (bpsize * FyrMM.pScalePercent) / 2 + 4
  2356. else
  2357. newX = 2
  2358. end
  2359. pa = pi * 0.5 - (pa - na)
  2360. if pin:GetTop() <= mmY then
  2361. newY = mmHeight / 2 - mmWidth / 2 * math.sin(pa - na) / math.sin(pi * 0.5 - (pa - na))
  2362. else
  2363. newY = mmHeight / 2 + mmWidth / 2 * math.sin(pa - na) / math.sin(pi * 0.5 - (pa - na))
  2364. end
  2365. end
  2366. if pin.m_PinType == MAP_PIN_TYPE_GROUP then
  2367. FyrMM.SetPinSize(borderpin, pin:GetDimensions())
  2368. else
  2369. FyrMM.SetPinSize(borderpin, bpsize * FyrMM.pScalePercent, 0)
  2370. end
  2371. if FyrMM.SV.WheelMap then
  2372. if pin:GetRight() >= mmX and pin:GetTop() >= mmY then
  2373. newX = D / math.sqrt(1 + m * m) + mmWidth / 2
  2374. newY = (m * D) / math.sqrt(1 + m * m) + mmHeight / 2
  2375. end
  2376. if pin:GetRight() >= mmX and pin:GetTop() < mmY then
  2377. newX = D / math.sqrt(1 + m * m) + mmWidth / 2
  2378. newY = mmWidth / 2 - (m * D) / math.sqrt(1 + m * m)
  2379. end
  2380. if pin:GetRight() < mmX and pin:GetTop() < mmY then
  2381. newX = mmWidth / 2 - D / math.sqrt(1 + m * m)
  2382. newY = mmWidth / 2 - (m * D) / math.sqrt(1 + m * m)
  2383. end
  2384. if pin:GetRight() < mmX and pin:GetTop() >= mmY then
  2385. newX = mmWidth / 2 - D / math.sqrt(1 + m * m)
  2386. newY = (m * D) / math.sqrt(1 + m * m) + mmWidth / 2
  2387. end
  2388. end
  2389.  
  2390. borderpin:SetHidden(false)
  2391. borderpin:ClearAnchors()
  2392. borderpin:SetAnchor(CENTER, Fyr_MM_Axis_Control, TOPLEFT, newX, newY)
  2393.  
  2394. -- animated world events
  2395. if pin.context ~= nil then
  2396. borderpin:SetColor(1, 1, 1, 1)
  2397. if ZO_MapPin.WORLD_EVENT_UNIT_PIN_TYPES[pin.m_PinType] then
  2398. if IsUnitInCombat(pin.unitTag) then
  2399. borderpin:SetColor(1, 0, 0, 1)
  2400. FyrMM.CheapAnimation(borderpin)
  2401. end
  2402. else
  2403. FyrMM.CheapAnimation(borderpin, true)
  2404. end
  2405. else
  2406. borderpin:SetTransformRotationZ(0)
  2407. end
  2408.  
  2409. if pin.m_PinTag and (pin.m_PinTag.isZoneStory or ZO_MapPin.SUGGESTION_PIN_TYPES[pin.m_PinType]) then
  2410. borderpin:SetColor(1, 1, 1, 1)
  2411. FyrMM.SetPinSize(borderpin, 48 * FyrMM.pScalePercent, 0)
  2412. end
  2413.  
  2414. borderpin:SetDrawLevel(pin:GetDrawLevel())
  2415. borderpin:SetDrawTier(pin:GetDrawTier())
  2416. borderpin:SetDrawLayer(pin:GetDrawLayer())
  2417.  
  2418. -- if pdata.isAnimated then -- removed animated BORDERPINS to test
  2419. -- if not borderpin.textureAntl then
  2420. -- local an
  2421. -- an, borderpin.textureAntl = CreateSimpleAnimation(ANIMATION_TEXTURE, borderpin)
  2422. -- an:SetHandler("OnStop", function() borderpin:SetTextureCoords(0, 1, 0, 1) end)
  2423. -- end
  2424. -- local anim = borderpin.textureAntl:GetAnimation(1)
  2425. -- anim:SetImageData(pdata.framesWide, pdata.framesHigh)
  2426. -- anim:SetFramerate(pdata.framesPerSecond)
  2427. -- borderpin.textureAntl:SetPlaybackType(ANIMATION_PLAYBACK_LOOP, LOOP_INDEFINITELY)
  2428. -- borderpin.textureAntl:PlayFromStart()
  2429. -- end
  2430. end
  2431.  
  2432. if (pin.nX and pin.nY) or (pin.normalizedX and pin.normalizedY) then -- fade distant pin texture
  2433. local nX = pin.nX or pin.normalizedX
  2434. local nY = pin.nY or pin.normalizedY
  2435.  
  2436. local distance = CurrentMap.TrueMapSize *
  2437. math.sqrt(
  2438. (nX - CurrentMap.PlayerNX) * (nX - CurrentMap.PlayerNX) + (nY - CurrentMap.PlayerNY) *
  2439. (nY - CurrentMap.PlayerNY)) or 1
  2440. if distance > 650 then
  2441. distance = 650
  2442. end
  2443. local iDistance = 650 - distance
  2444.  
  2445. local minVal1 = 0 -- min distance value
  2446. local maxVal1 = 650 -- max distance value
  2447. local minVal2 = 0.6 -- min alpha
  2448. local maxVal2 = 1 -- max alpha
  2449.  
  2450. local alpha = ((maxVal2 - minVal2) * (((iDistance) - (minVal1)) / ((maxVal1) - (minVal1)))) + minVal2
  2451.  
  2452. -- d("alpha "..alpha.." distance "..distance)
  2453. borderpin:SetAlpha(alpha)
  2454. else
  2455. borderpin:SetAlpha(1)
  2456. end
  2457.  
  2458. return borderpin
  2459. end
  2460.  
  2461. function FyrMM.PlaceBorderPins()
  2462. local i, j, l, v
  2463. if ((not FyrMM.Visible or Fyr_MM:IsHidden())) then
  2464. return
  2465. end
  2466. for i = 1, Fyr_MM_Axis_Border_Pins:GetNumChildren() do
  2467. l = Fyr_MM_Axis_Border_Pins:GetChild(i)
  2468. if l ~= nil then
  2469. if FyrMM.SV.BorderPins then
  2470. if not l.pin then
  2471. l:SetHidden(true)
  2472. else
  2473. if not FyrMM.IsValidBorderPin(l.pin) then
  2474. RemoveBorderPin(l)
  2475. end
  2476. end
  2477. else
  2478. RemoveBorderPin(l)
  2479. end
  2480. end
  2481. end
  2482.  
  2483. if not FyrMM.SV.BorderPins then
  2484. return
  2485. end
  2486.  
  2487. -- border pins for moving or interesting AVA & Battleground pins
  2488. if (not IsInAvAZone() and not IsActiveWorldBattleground()) and AVABGobjectivesToBorderPins then
  2489. AVABGobjectivesToBorderPins = nil
  2490. end
  2491. if FyrMM.SV.borderAVABG then
  2492. local bgContext = ZO_WorldMap_GetBattlegroundQueryType()
  2493. if AVABGobjectivesToBorderPins and not IsTableEmpty(AVABGobjectivesToBorderPins) then
  2494. for i, v in pairs(AVABGobjectivesToBorderPins) do
  2495. if v ~= nil then
  2496. local type = GetObjectiveType(v.keepId, v.objectiveId, bgContext)
  2497. local objectiveControlState = GetObjectiveControlState(v.keepId, v.objectiveId, bgContext)
  2498. local exists = DoesObjectiveExist(v.keepId, v.objectiveId, bgContext)
  2499. local visible = IsObjectiveObjectVisible(v.keepId, v.objectiveId, bgContext)
  2500. local gameType = GetBattlegroundGameType(GetCurrentBattlegroundId())
  2501.  
  2502. if exists and visible then
  2503. local daedricWeapon = type == OBJECTIVE_DAEDRIC_WEAPON and objectiveControlState ~=
  2504. OBJECTIVE_CONTROL_STATE_UNKNOWN
  2505. local elderScroll = (type == OBJECTIVE_ARTIFACT_DEFENSIVE or type ==
  2506. OBJECTIVE_ARTIFACT_OFFENSIVE or type == OBJECTIVE_ARTIFACT_RETURN) and
  2507. (objectiveControlState == OBJECTIVE_CONTROL_STATE_FLAG_HELD or
  2508. objectiveControlState == OBJECTIVE_CONTROL_STATE_FLAG_DROPPED)
  2509. local captureTheRelicRelic = type == OBJECTIVE_FLAG_CAPTURE
  2510. local captureTheRelicOwnBase = v.AVABGtype == "spawn"
  2511. local showAllWithThisGameType = gameType == BATTLEGROUND_GAME_TYPE_DOMINATION or gameType ==
  2512. BATTLEGROUND_GAME_TYPE_CRAZY_KING or gameType ==
  2513. BATTLEGROUND_GAME_TYPE_MURDERBALL
  2514.  
  2515. if daedricWeapon or elderScroll or captureTheRelicRelic or captureTheRelicOwnBase or
  2516. showAllWithThisGameType then
  2517. v.size = 32
  2518. if elderScroll then
  2519. v.size = 80
  2520. end
  2521. if battlegroundMovingPins then
  2522. v.size = 64
  2523. end
  2524. FyrMM.CreateBorderPin(v)
  2525. else
  2526. if v.BorderPin ~= nil then
  2527. RemoveBorderPin(v.BorderPin)
  2528. end
  2529. end
  2530. else
  2531. if v.BorderPin ~= nil then
  2532. RemoveBorderPin(v.BorderPin)
  2533. end
  2534. end
  2535. end
  2536. end
  2537. end
  2538. end
  2539.  
  2540. -- waypoints
  2541. FyrMM.PlaceWaypointBorderPins()
  2542.  
  2543. -- border pins
  2544. if Fyr_MM_Axis_Control:IsHidden() and FyrMM.SV.BorderPins then
  2545. Fyr_MM_Axis_Control:SetHidden(false)
  2546. end
  2547.  
  2548. -- quest pins
  2549. for i, v in pairs(QuestPins) do
  2550. if not v.Pin:IsHidden() and FyrMM.IsValidBorderPin(v.Pin) then
  2551. FyrMM.CreateBorderPin(v.Pin)
  2552. end
  2553. end
  2554.  
  2555. -- group pins
  2556. for i = 1, 24 do
  2557. l = GetControl("Fyr_MM_Scroll_Map_Pinsgroup" .. tostring(i))
  2558. if l ~= nil then
  2559. if not l:IsHidden() and FyrMM.IsValidBorderPin(l) then
  2560. FyrMM.CreateBorderPin(l)
  2561. end
  2562. end
  2563. end
  2564.  
  2565. -- Bank - stables - crafting - community leveling guides
  2566. if FyrMM.SV.BorderPinsBank or FyrMM.SV.BorderPinsStables or FyrMM.SV.BorderCrafting or FyrMM.SV.UseOriginalAPI then
  2567. for i = 1, FyrMM.currentLocationsCount do
  2568. l = GetControl("Fyr_MM_Scroll_Map_LocationPins_Pin" .. tostring(i))
  2569. if l ~= nil then
  2570. if l.m_PinType == MAP_PIN_TYPE_LOCATION and FyrMM.IsValidBorderPin(l) then
  2571. FyrMM.CreateBorderPin(l)
  2572. elseif l.isZGESO and FyrMM.IsValidBorderPin(l) then
  2573. l.m_PinType = MAP_PIN_TYPE_LOCATION
  2574. FyrMM.CreateBorderPin(l)
  2575. end
  2576. end
  2577. end
  2578. end
  2579.  
  2580. -- wayshrines
  2581. if FyrMM.SV.BorderWayshrine and FyrMM.currentWayshrineCount > 0 then
  2582. for i, v in ipairs(Wayshrines) do
  2583. if v.Closest then
  2584. l = GetControl("Fyr_MM_Scroll_Map_WayshrinePins_Pin" .. tostring(i))
  2585. if l ~= nil then
  2586. FyrMM.CreateBorderPin(l)
  2587. end
  2588. end
  2589. end
  2590. end
  2591.  
  2592. -- treasures and antiquities
  2593. if FyrMM.SV.BorderTreasures then
  2594. if not IsTableEmpty(Treasures) then
  2595. for i, v in pairs(Treasures) do
  2596. if v ~= nil then
  2597. if v.IsTreasure then
  2598. FyrMM.CreateBorderPin(v)
  2599. end
  2600. end
  2601. end
  2602. end
  2603. end
  2604.  
  2605. -- Dragon next location
  2606. if FyrMM.SV.WorldEvents then
  2607. if not IsTableEmpty(DragonNextLocation) then
  2608. for i, v in pairs(DragonNextLocation) do
  2609. if v ~= nil then
  2610. if v.IsDragonNextLocation then
  2611. FyrMM.CreateBorderPin(v)
  2612. end
  2613. end
  2614. end
  2615. end
  2616. end
  2617.  
  2618. -- digsites
  2619. if not IsTableEmpty(Digsites) then
  2620. for i, v in pairs(Digsites) do
  2621. if v ~= nil then
  2622. if v.borderInformation ~= nil then
  2623. FyrMM.CreateBorderPin(v)
  2624. end
  2625. end
  2626. end
  2627. end
  2628.  
  2629. -- Quest givers
  2630. if FyrMM.SV.BorderQuestGivers and not IsTableEmpty(FyrMM.AvailableQuestGivers) then
  2631. if #FyrMM.AvailableQuestGivers <= 5 then
  2632. for i, v in pairs(FyrMM.AvailableQuestGivers) do
  2633. if v ~= nil then
  2634. if v.IsAvailableQuest then
  2635. FyrMM.CreateBorderPin(v)
  2636. end
  2637. end
  2638. end
  2639. else
  2640. if not IsTableEmpty(AQGList) then
  2641. for i = 1, 5 do
  2642. if AQGList[i] ~= nil then
  2643. FyrMM.CreateBorderPin(AQGList[i])
  2644. end
  2645. end
  2646. end
  2647. end
  2648. end
  2649. end
  2650.  
  2651. function FyrMM.PlaceWaypointBorderPins()
  2652. SetBorderPinHandlers()
  2653. if FyrMM.SV.BorderPinsWaypoint then
  2654. if FyrMM.IsWaypoint then
  2655. if not FyrMM.Waypoint:IsHidden() or not Is_PinInsideWheel(FyrMM.Waypoint) then
  2656. FyrMM.CreateBorderPin(FyrMM.Waypoint)
  2657. if FyrMM.Waypoint.BorderPin then
  2658. FyrMM.Waypoint.BorderPin:SetHandler("OnMouseEnter", BorderPinOnMouseEnter)
  2659. FyrMM.Waypoint.BorderPin:SetHandler("OnMouseExit", BorderPinOnMouseExit)
  2660. FyrMM.Waypoint.BorderPin:SetMouseEnabled(true)
  2661. end
  2662. else
  2663. if FyrMM.Waypoint.BorderPin ~= nil then
  2664. RemoveBorderPin(FyrMM.Waypoint)
  2665. end
  2666. end
  2667. end
  2668. if FyrMM.IsPing then
  2669. if not FyrMM.Ping:IsHidden() or not Is_PinInsideWheel(FyrMM.Ping) then
  2670. FyrMM.CreateBorderPin(FyrMM.Ping)
  2671. if FyrMM.Ping.BorderPin then
  2672. FyrMM.Ping.BorderPin:SetHandler("OnMouseEnter", BorderPinOnMouseEnter)
  2673. FyrMM.Ping.BorderPin:SetHandler("OnMouseExit", BorderPinOnMouseExit)
  2674. FyrMM.Ping.BorderPin:SetMouseEnabled(true)
  2675. end
  2676. else
  2677. if FyrMM.Ping.BorderPin ~= nil then
  2678. RemoveBorderPin(FyrMM.Ping)
  2679. end
  2680. end
  2681. end
  2682. if FyrMM.IsRally then
  2683. if not FyrMM.Rally:IsHidden() or not Is_PinInsideWheel(FyrMM.Rally) then
  2684. FyrMM.CreateBorderPin(FyrMM.Rally)
  2685. if FyrMM.Rally.BorderPin then
  2686. FyrMM.Rally.BorderPin:SetHandler("OnMouseEnter", BorderPinOnMouseEnter)
  2687. FyrMM.Rally.BorderPin:SetHandler("OnMouseExit", BorderPinOnMouseExit)
  2688. FyrMM.Rally.BorderPin:SetMouseEnabled(true)
  2689. end
  2690. else
  2691. if FyrMM.Rally.BorderPin ~= nil then
  2692. RemoveBorderPin(FyrMM.Rally)
  2693. end
  2694. end
  2695. end
  2696. end
  2697. end
  2698.  
  2699. function FyrMM.isSameZone(PinMapId)
  2700. local _, _, _, pinZone = GetMapInfoById(PinMapId)
  2701. local _, _, _, currentMapZone = GetMapInfoById(CurrentMap.MapId)
  2702.  
  2703. if PinMapId == CurrentMap.MapId or pinZone == currentMapZone then
  2704. return true
  2705. else
  2706. return false
  2707. end
  2708. end
  2709.  
  2710. -----------------------------------------------------------------
  2711. -- Pin Clean up
  2712. -----------------------------------------------------------------
  2713. local function CleanupMapLocations()
  2714. local t = GetGameTimeMilliseconds()
  2715. local totalPins = Fyr_MM_Scroll_Map_LocationPins:GetNumChildren()
  2716. if totalPins > FyrMM.currentLocationsCount then
  2717. for i = FyrMM.currentLocationsCount + 1, totalPins do
  2718. local l = GetControl("Fyr_MM_Scroll_Map_LocationPins_Pin" .. tostring(i))
  2719. if l ~= nil then
  2720. if l.BorderPin ~= nil then
  2721. RemoveBorderPin(l.BorderPin)
  2722. end
  2723. l.nX = nil
  2724. l.nY = nil
  2725. l:ClearAnchors()
  2726. l:SetHidden(true)
  2727. l:SetMouseEnabled(false)
  2728. -- l:SetTexture(nil)
  2729. l:SetDimensions(0, 0)
  2730. l.m_Pin = nil
  2731. PinsList[l:GetName()] = nil
  2732. end
  2733. end
  2734. end
  2735. if FyrMM.DebugMode then
  2736. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "CleanupMapLocations " .. tostring(GetGameTimeMilliseconds() - t))
  2737. end
  2738. end
  2739.  
  2740. local function CleanupWayshrines()
  2741. local t = GetGameTimeMilliseconds()
  2742. local totalPins = Fyr_MM_Scroll_Map_WayshrinePins:GetNumChildren()
  2743. if totalPins > FyrMM.currentWayshrineCount then
  2744. for i = FyrMM.currentWayshrineCount + 1, totalPins do
  2745. local l = GetControl("Fyr_MM_Scroll_Map_WayshrinePins_Pin" .. tostring(i))
  2746. if l ~= nil then
  2747. if l.BorderPin ~= nil then
  2748. RemoveBorderPin(l.BorderPin)
  2749. end
  2750. l.nX = nil
  2751. l.nY = nil
  2752. l:ClearAnchors()
  2753. l:SetHidden(true)
  2754. l:SetMouseEnabled(false)
  2755. -- l:SetTexture(nil)
  2756. l:SetDimensions(0, 0)
  2757. l.m_Pin = nil
  2758. PinsList[l:GetName()] = nil
  2759. end
  2760. end
  2761. end
  2762. if FyrMM.DebugMode then
  2763. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "CleanupWayshrines " .. tostring(GetGameTimeMilliseconds() - t))
  2764. end
  2765. end
  2766.  
  2767. local function CleanupPOIs()
  2768. local t = GetGameTimeMilliseconds()
  2769. local totalPins = Fyr_MM_Scroll_Map_POIPins:GetNumChildren()
  2770. if totalPins == 0 then
  2771. return
  2772. end
  2773. if CleanPOIs + FyrMM.currentPOICount ~= totalPins then
  2774. -- if totalPins > FyrMM.currentPOICount then
  2775. CleanPOIs = 0
  2776. for i = FyrMM.currentPOICount + 1, totalPins do
  2777. local l = GetControl("Fyr_MM_Scroll_Map_POIPins_Pin" .. tostring(i))
  2778. if l ~= nil then
  2779. l.nX = nil
  2780. l.nY = nil
  2781. l:ClearAnchors()
  2782. l:SetHidden(true)
  2783. l:SetMouseEnabled(false)
  2784. -- l:SetTexture(nil)
  2785. l:SetDimensions(0, 0)
  2786. l.m_Pin = nil
  2787. PinsList[l:GetName()] = nil
  2788. CleanPOIs = CleanPOIs + 1
  2789. end
  2790. end
  2791. end
  2792. if FyrMM.DebugMode then
  2793. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  2794. "CleanupPOIs (" .. tostring(FyrMM.currentPOICount + 1) .. " - " .. tostring(totalPins) .. ") (" .. CleanPOIs ..
  2795. ") " .. tostring(GetGameTimeMilliseconds() - t))
  2796. end
  2797. end
  2798.  
  2799. local function RemoveQuestPin(l)
  2800. if l == nil then
  2801. return
  2802. end
  2803. if l.MM_Tag ~= nil then
  2804. if l.MM_Tag == 1 then
  2805. if l.secondaryPin ~= nil then
  2806. l.secondaryPin.MM_Tag = nil
  2807. RemoveQuestPin(l.secondaryPin)
  2808. end
  2809. if l.tertiaryPin ~= nil then
  2810. l.tertiaryPin.MM_Tag = nil
  2811. RemoveQuestPin(l.tertiaryPin)
  2812. end
  2813. else
  2814. if l.primaryPin ~= nil then
  2815. l.primaryPin.MM_Tag = nil
  2816. RemoveQuestPin(l.primaryPin)
  2817. end
  2818. end
  2819. end
  2820. if l.OnBorder then
  2821. if l.BorderPin then
  2822. l.BorderPin:ClearAnchors()
  2823. l.BorderPin:SetHidden()
  2824. l.BorderPin.pin = nil
  2825. l.BorderPin = nil
  2826. end
  2827. l.OnBorder = nil
  2828. end
  2829. if l.questdataIndex ~= nil then
  2830. if FyrMM.questPinCount > 0 then
  2831. FyrMM.questPinCount = FyrMM.questPinCount - 1
  2832. end
  2833. if QuestPins[l.questdataIndex] ~= nil then
  2834. table.insert(FreeQuestPinIndex, QuestPins[l.questdataIndex].pinIndex)
  2835. end
  2836. QuestPins[l.questdataIndex] = nil
  2837. end
  2838.  
  2839. l:SetParent(Fyr_MM_Scroll_Map_QuestPins)
  2840. l:ClearAnchors()
  2841. l:SetHidden(true)
  2842. l:SetMouseEnabled(false)
  2843. -- l:SetTexture(nil)
  2844. l:SetDimensions(0, 0)
  2845. l.questdataIndex = nil
  2846. l.MM_Tag = nil
  2847. l.m_PinTag = nil
  2848. l.m_PinType = nil
  2849. l.m_Pin = nil
  2850. l.normalizedX = nil
  2851. l.normalizedY = nil
  2852. l.radius = nil
  2853. l.MapId = nil
  2854. l.questIndex = nil
  2855. l.questName = nil
  2856. l.PinToolTipText = nil
  2857. l.primaryPin = nil
  2858. l.secondaryPin = nil
  2859. l.tertiaryPin = nil
  2860. l.pinAge = nil
  2861. PinsList[l:GetName()] = nil
  2862. end
  2863.  
  2864. local function ClearDigsiteBlob(digSite)
  2865. digSite.pinType = nil
  2866. digSite.m_PinType = nil
  2867. digSite.Tag = nil
  2868. digSite.nX = nil
  2869. digSite.nY = nil
  2870. digSite.MapId = nil
  2871. digSite.borderInformation = nil
  2872. digSite:SetHidden(true)
  2873. digSite:ClearPoints()
  2874. digSite:ClearAnchors()
  2875. end
  2876.  
  2877. local function CreateDigSiteAreaSidePins(pin, width, height, isTracked)
  2878. local DigSiteAreaSidePinNS
  2879. DigSiteAreaSidePinNS = GetControl("Fyr_MM_Scroll_Map_DigSite" .. tostring(FyrMM.currentDigSiteCount) .. "_NS")
  2880. if DigSiteAreaSidePinNS == nil then
  2881. DigSiteAreaSidePinNS = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_DigSite" ..
  2882. tostring(FyrMM.currentDigSiteCount) .. "_NS",
  2883. Fyr_MM_Scroll_NS_Map_Pins, CT_POLYGON)
  2884. else
  2885. DigSiteAreaSidePinNS:SetParent(Fyr_MM_Scroll_NS_Map_Pins)
  2886. end
  2887.  
  2888. DigSiteAreaSidePinNS.m_PinType = pin.m_PinType
  2889. DigSiteAreaSidePinNS.nX = pin.nX
  2890. DigSiteAreaSidePinNS.nY = pin.nY
  2891. DigSiteAreaSidePinNS.borderInformation = pin.borderInformation
  2892. DigSiteAreaSidePinNS.MapId = pin.MapId
  2893. DigSiteAreaSidePinNS:SetDimensions(width, height)
  2894. DigSiteAreaSidePinNS:SetHidden(not ZO_WorldMap_IsPinGroupShown(MAP_FILTER_DIG_SITES))
  2895.  
  2896. local centerColor = isTracked and ZO_MAP_PIN_TRACKED_DIG_SITE_COLOR or ZO_MAP_PIN_DIG_SITE_COLOR
  2897. local r, g, b = centerColor:UnpackRGB()
  2898. local alpha = 0.39
  2899. DigSiteAreaSidePinNS:SetCenterColor(r, g, b, alpha)
  2900. local borderColor = ZO_MAP_PIN_DIG_SITE_BORDER_COLOR
  2901. DigSiteAreaSidePinNS:SetBorderColor(borderColor:UnpackRGBA())
  2902. DigSiteAreaSidePinNS:SetSmoothingEnabled(true)
  2903. DigSiteAreaSidePinNS:SetBorderThickness(3, 3, 0)
  2904. DigSiteAreaSidePinNS:SetShapeType(SHAPE_CIRCLE)
  2905. DigSiteAreaSidePinNS:SetDrawLayer(1)
  2906.  
  2907. FyrMM.SetPinAnchor(DigSiteAreaSidePinNS, DigSiteAreaSidePinNS.nX, DigSiteAreaSidePinNS.nY, Fyr_MM_Scroll_Map_Pins)
  2908. if FyrMM.SV.WheelMap then
  2909. DigSiteAreaSidePinNS:SetParent(Fyr_MM_Scroll_NS_Map_Pins)
  2910. end
  2911. DigSiteAreaSidePinNS:SetHandler("OnMouseUp", PinOnMouseUp)
  2912. DigSiteAreaSidePinNS:SetHandler("OnMouseEnter", PinOnMouseEnter)
  2913. DigSiteAreaSidePinNS:SetHandler("OnMouseExit", PinOnMouseExit)
  2914. SetDigSitePoints(DigSiteAreaSidePinNS)
  2915.  
  2916. local DigSiteAreaSidePinWE
  2917. DigSiteAreaSidePinWE = GetControl("Fyr_MM_Scroll_Map_DigSite" .. tostring(FyrMM.currentDigSiteCount) .. "_WE")
  2918. if DigSiteAreaSidePinWE == nil then
  2919. DigSiteAreaSidePinWE = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_DigSite" ..
  2920. tostring(FyrMM.currentDigSiteCount) .. "_WE",
  2921. Fyr_MM_Scroll_WE_Map_Pins, CT_POLYGON)
  2922. else
  2923. DigSiteAreaSidePinWE:SetParent(Fyr_MM_Scroll_WE_Map_Pins)
  2924. end
  2925.  
  2926. DigSiteAreaSidePinWE.m_PinType = pin.m_PinType
  2927. DigSiteAreaSidePinWE.nX = pin.nX
  2928. DigSiteAreaSidePinWE.nY = pin.nY
  2929. DigSiteAreaSidePinWE.borderInformation = pin.borderInformation
  2930. DigSiteAreaSidePinWE.MapId = pin.MapId
  2931. DigSiteAreaSidePinWE:SetDimensions(width, height)
  2932. DigSiteAreaSidePinWE:SetHidden(not ZO_WorldMap_IsPinGroupShown(MAP_FILTER_DIG_SITES))
  2933. DigSiteAreaSidePinWE:SetCenterColor(r, g, b, alpha)
  2934. DigSiteAreaSidePinWE:SetBorderColor(borderColor:UnpackRGBA())
  2935. DigSiteAreaSidePinWE:SetSmoothingEnabled(true)
  2936. DigSiteAreaSidePinWE:SetBorderThickness(3, 3, 0)
  2937. DigSiteAreaSidePinWE:SetShapeType(SHAPE_CIRCLE)
  2938. DigSiteAreaSidePinWE:SetDrawLayer(1)
  2939. FyrMM.SetPinAnchor(DigSiteAreaSidePinWE, DigSiteAreaSidePinWE.nX, DigSiteAreaSidePinWE.nY, Fyr_MM_Scroll_Map_Pins)
  2940. if FyrMM.SV.WheelMap then
  2941. DigSiteAreaSidePinWE:SetParent(Fyr_MM_Scroll_WE_Map_Pins)
  2942. end
  2943. DigSiteAreaSidePinWE:SetHandler("OnMouseUp", PinOnMouseUp)
  2944. DigSiteAreaSidePinWE:SetHandler("OnMouseEnter", PinOnMouseEnter)
  2945. DigSiteAreaSidePinWE:SetHandler("OnMouseExit", PinOnMouseExit)
  2946. SetDigSitePoints(DigSiteAreaSidePinWE)
  2947. end
  2948.  
  2949. local function CreateDigSiteBlob(DigsiteId)
  2950. local centerX, centerZ, isShownInCurrentMap = GetDigSiteNormalizedCenterPosition(DigsiteId)
  2951. if isShownInCurrentMap then
  2952. local isTracked = IsDigSiteAssociatedWithTrackedAntiquity(DigsiteId)
  2953. local points = {}
  2954. local minX = 1.0
  2955. local maxX = 0.0
  2956. local minY = 1.0
  2957. local maxY = 0.0
  2958.  
  2959. local borderPoints = { GetDigSiteNormalizedBorderPoints(DigsiteId) }
  2960.  
  2961. for i = 1, #borderPoints, 2 do -- loop by 2 because we are getting x and z coordinates
  2962. local x = borderPoints[i]
  2963. local y = borderPoints[i + 1] -- UI is going to treat z as y
  2964.  
  2965. minX = zo_min(x, minX)
  2966. maxX = zo_max(x, maxX)
  2967.  
  2968. minY = zo_min(y, minY)
  2969. maxY = zo_max(y, maxY)
  2970.  
  2971. local coordinates = {
  2972. x = x,
  2973. y = y
  2974. }
  2975. table.insert(points, coordinates)
  2976. end
  2977.  
  2978. for index, coordinates in ipairs(points) do
  2979. coordinates.x = zo_normalize(coordinates.x, minX, maxX)
  2980. coordinates.y = zo_normalize(coordinates.y, minY, maxY)
  2981. end
  2982.  
  2983. local borderInformation = {
  2984. borderPoints = points,
  2985. borderWidth = maxX - minX,
  2986. borderHeight = maxY - minY
  2987. }
  2988.  
  2989. local mWidth, mHeight = Fyr_MM_Scroll_Map:GetDimensions()
  2990.  
  2991. local digSite
  2992. FyrMM.currentDigSiteCount = FyrMM.currentDigSiteCount + 1
  2993. digSite = GetControl("Fyr_MM_Scroll_Map_DigSite" .. tostring(FyrMM.currentDigSiteCount))
  2994. if digSite == nil then
  2995. digSite = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_DigSite" .. tostring(FyrMM.currentDigSiteCount),
  2996. Fyr_MM_Scroll_Map_Pins, CT_POLYGON)
  2997.  
  2998. digSite.nDistance = function(self)
  2999. if self.nX == nil then
  3000. return 1
  3001. end
  3002. return math.sqrt((zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nX * 10000)) *
  3003. (zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nX * 10000)) +
  3004. (zo_round(CurrentMap.PlayerNY * 10000) - zo_round(self.nY * 10000)) *
  3005. (zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nY * 10000))) / 10000
  3006. end
  3007. digSite:SetMouseEnabled(true)
  3008. digSite:SetHandler("OnMouseEnter", PinOnMouseEnter)
  3009. digSite:SetHandler("OnMouseExit", PinOnMouseExit)
  3010. digSite:SetHandler("OnMouseUp", PinOnMouseUp)
  3011. end
  3012. digSite.pinType = isTracked and MAP_PIN_TYPE_TRACKED_ANTIQUITY_DIG_SITE or MAP_PIN_TYPE_ANTIQUITY_DIG_SITE
  3013. digSite.Tag = DigsiteId
  3014. digSite.nX = centerX
  3015. digSite.nY = centerZ
  3016.  
  3017. SetMapToDigSitePosition(DigsiteId)
  3018. digSite.MapId = CurrentMap.MapId
  3019. FyrMM.SetMapToPlayerLocation()
  3020.  
  3021. digSite.borderInformation = borderInformation
  3022. digSite.m_PinType = digSite.pinType
  3023. digSite:SetDrawLayer(1)
  3024. local width = borderInformation.borderWidth * mWidth
  3025. local height = borderInformation.borderHeight * mHeight
  3026. digSite:SetDimensions(width, height)
  3027. local centerColor = isTracked and ZO_MAP_PIN_TRACKED_DIG_SITE_COLOR or ZO_MAP_PIN_DIG_SITE_COLOR
  3028. local r, g, b = centerColor:UnpackRGB()
  3029. local alpha = 0.39
  3030. digSite:SetCenterColor(r, g, b, alpha)
  3031. local borderColor = ZO_MAP_PIN_DIG_SITE_BORDER_COLOR
  3032. digSite:SetBorderColor(borderColor:UnpackRGBA())
  3033. digSite:SetSmoothingEnabled(true)
  3034. digSite:SetBorderThickness(3, 3, 0)
  3035. digSite:SetShapeType(SHAPE_CIRCLE)
  3036. FyrMM.SetPinAnchor(digSite, centerX, centerZ, Fyr_MM_Scroll_Map_Pins)
  3037.  
  3038. if FyrMM.SV.WheelMap then -- root of the problem was here
  3039. if FyrMM.SV.RotateMap then
  3040. digSite:SetParent(Fyr_MM_Scroll_CW_Map_Pins)
  3041. else
  3042. digSite:SetParent(FyrMM.GetScrollObject(digSite))
  3043. -- FyrMM.SetPinAnchor(digSite, centerX, centerZ, Fyr_MM_Scroll_CW_Map_Pins)
  3044. end
  3045.  
  3046. CreateDigSiteAreaSidePins(digSite, width, height, isTracked)
  3047. end
  3048.  
  3049. digSite:SetHidden(not ZO_WorldMap_IsPinGroupShown(MAP_FILTER_DIG_SITES))
  3050.  
  3051. SetDigSitePoints(digSite)
  3052. table.insert(Digsites, digSite)
  3053. end
  3054. end
  3055.  
  3056. function FyrMM.UpdateAntiquityDigSites()
  3057. if FyrMM.currentDigSiteCount > 0 then
  3058. Digsites = {}
  3059. for i = 1, FyrMM.currentDigSiteCount, 1 do
  3060. local digSite = GetControl("Fyr_MM_Scroll_Map_DigSite" .. tostring(i))
  3061. local digSiteNS = GetControl("Fyr_MM_Scroll_Map_DigSite" .. tostring(i) .. "_NS")
  3062. local digSiteWE = GetControl("Fyr_MM_Scroll_Map_DigSite" .. tostring(i) .. "_WE")
  3063. ClearDigsiteBlob(digSite)
  3064. if FyrMM.SV.WheelMap then
  3065. if digSiteNS then
  3066. ClearDigsiteBlob(digSiteNS)
  3067. end
  3068. if digSiteWE then
  3069. ClearDigsiteBlob(digSiteWE)
  3070. end
  3071. end
  3072. end
  3073. end
  3074. FyrMM.currentDigSiteCount = 0
  3075. local numInprogress = GetNumInProgressAntiquities()
  3076. for antiquityIndex = 1, numInprogress, 1 do
  3077. local numDigSites = GetNumDigSitesForInProgressAntiquity(antiquityIndex)
  3078. if numDigSites > 0 then
  3079. if numDigSites == 1 then
  3080. local digSiteId = GetInProgressAntiquityDigSiteId(antiquityIndex, 1)
  3081. if digSiteId > 0 then
  3082. CreateDigSiteBlob(digSiteId)
  3083. end
  3084. else
  3085. for digSiteIndex = 1, numDigSites, 1 do
  3086. local digSiteId = GetInProgressAntiquityDigSiteId(antiquityIndex, digSiteIndex)
  3087. if digSiteId > 0 then
  3088. CreateDigSiteBlob(digSiteId)
  3089. end
  3090. end
  3091. end
  3092. end
  3093. end
  3094. end
  3095.  
  3096. function FyrMM.RemoveInvalidQuestPins()
  3097. local t = GetGameTimeMilliseconds()
  3098. local _
  3099. local compleate
  3100. for i, v in pairs(QuestPins) do
  3101. local l = v.Pin
  3102. if l ~= nil then
  3103. if not l:IsHidden() then
  3104. local a = l.m_PinTag[1]
  3105. local b = l.m_PinTag[3]
  3106. local c = l.m_PinTag[2]
  3107. local qi = l.questIndex
  3108. if l.questIndex ~= nil then
  3109. if not IsValidQuestIndex(qi) or GetJournalQuestName(qi) ~= l.questName then
  3110. RemoveQuestPin(l)
  3111. else
  3112. if l.m_PinTag ~= nil and l.PinToolTipText ~= nil then
  3113. if l.PinToolTipText ~= GenerateQuestConditionTooltipLine(a, b, c) then
  3114. RemoveQuestPin(l)
  3115. else
  3116. _, _, _, _, compleate, _ = GetJournalQuestConditionInfo(a, b, c)
  3117. if compleate then
  3118. RemoveQuestPin(l)
  3119. end
  3120. end
  3121. else
  3122. RemoveQuestPin(l)
  3123. end
  3124. end
  3125. else
  3126. RemoveQuestPin(l)
  3127. end
  3128. end
  3129. end
  3130. end
  3131. if FyrMM.DebugMode then
  3132. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  3133. "RemoveInvalidQuestPins " .. tostring(GetGameTimeMilliseconds() - t))
  3134. end
  3135. end
  3136.  
  3137. function FyrMM.UpdateLabels(eventCode, zoneName, subZoneName, newSubzone, someID, subzoneId)
  3138. if not FyrMM.SV then
  3139. return
  3140. end -- too soon
  3141.  
  3142. if Fyr_MM:IsHidden() then
  3143. Fyr_MM_ZoneFrame:SetHidden(true)
  3144. return
  3145. end
  3146.  
  3147. local currentMapName, _ = string.gsub(GetMapName(), "(%w+)[%^]+.*", "%1")
  3148. local currentAreaName = string.gsub(GetPlayerLocationName(), "(%w+)[%^]+.*", "%1")
  3149. if not FyrMM.SV.ZoneNameContents ~= nil then
  3150. if FyrMM.SV.ZoneNameContents == "Classic (Map only)" then
  3151. Fyr_MM_Zone:SetText(currentMapName)
  3152. elseif FyrMM.SV.ZoneNameContents == "Map & Area" then
  3153. if currentMapName ~= currentAreaName then
  3154. Fyr_MM_Zone:SetText(currentMapName .. "\n" .. currentAreaName)
  3155. else
  3156. Fyr_MM_Zone:SetText(currentMapName)
  3157. end
  3158. else
  3159. Fyr_MM_Zone:SetText(currentAreaName)
  3160. end
  3161. else
  3162. Fyr_MM_Zone:SetText(currentMapName)
  3163. end
  3164.  
  3165. local zoneWidth, zoneHeight = Fyr_MM_Zone:GetTextDimensions() or 100, 20
  3166. if string.find(Fyr_MM_Zone:GetText(), "\n") then
  3167. zoneHeight = zoneHeight * 2
  3168. end
  3169.  
  3170. Fyr_MM_ZoneFrame:SetDimensions(zoneWidth + 10, zoneHeight + 3)
  3171. if FyrMM.SV.ZoneFrameLocationOption == "Free" then
  3172. Fyr_MM_ZoneFrame:ClearAnchors()
  3173. Fyr_MM_ZoneFrame:SetAnchor(MM_GetZoneFrameAnchor())
  3174. end
  3175. Fyr_MM_ZoomLevel:SetText(tostring(CurrentMap.ZoomLevel))
  3176. end
  3177.  
  3178. -----------------------------------------------------------------
  3179. -- Updates
  3180. -----------------------------------------------------------------
  3181.  
  3182. function FyrMM.GetMapMeasureMultiplier()
  3183. -- Based on assumption that player constantly moves at the same speed anywhere - world size has to be adjusted to match it. According to Tamriel distance difference for some specific maps I made a few adjustments for the worldsizes while in those maps.
  3184. -- Maps like Auridon or Glenumbra indicate same player speeds while Cyrodiil, Craglorn and starting maps show compleately different speeds (for mapsize 33440)
  3185.  
  3186. local mapIndex = GetCurrentMapIndex()
  3187. local multiplier = 1
  3188. -- walking = 2.00/2.03 m/s
  3189. -- if mapIndex == 14 then -- cyrodiil
  3190. -- multiplier = 2.2
  3191. -- elseif mapIndex == 18 then -- Bal foyen
  3192. -- multiplier = 1 --1.353
  3193. -- elseif mapIndex == 19 then -- stros m'kai
  3194. -- multiplier = 2.6
  3195. -- elseif mapIndex == 21 then -- kenarthi's roost
  3196. -- multiplier = 2.4865
  3197. -- elseif mapIndex == 22 then -- Bleakrock isle
  3198. -- multiplier = 1 --3.1
  3199. -- elseif mapIndex == 25 then -- craglorn
  3200. -- multiplier = 1 --1.087
  3201. if mapIndex == 39 then -- Greymoor Caverns
  3202. multiplier = 4.5
  3203. end
  3204. -- alik'r, artaeum, auridon, Bal foyen, Bangkorai , Betnikh, Arkhzand cavern, Blackwood, Bleakrock, clockwork city, craglorn, deshaan, eastmarch,
  3205. -- fargrave, glenumbra, gold coast, grahtwood, greenshade, hew's bane, high isle, kenarthi's roost, malabal tor, murkmire, northern elsweyr
  3206. -- reaper's march, rivenspire, shadowfen, southern elsweyr, stonefalls, stormhaven, stros m'kai, summerset, the deadlands, the reach
  3207. -- the rift, western skyrim, wrothgar are multiplier = 1
  3208.  
  3209. return multiplier
  3210. end
  3211.  
  3212. function FyrMM.MeasureDistance()
  3213. if not FyrMM.MeasureMaps then
  3214. return
  3215. end
  3216.  
  3217. if CurrentMap.TrueMapSize and CurrentMap.TrueMapSize > 1 then
  3218. FyrMM.DistanceMeasurementStarted = false
  3219. return
  3220. end
  3221.  
  3222. local _
  3223. FyrMM.SetMapToPlayerLocation()
  3224. FyrMM.MeasurementXl, FyrMM.MeasurementYl, _ = GetMapPlayerPosition("player")
  3225. local mapIndex = GetCurrentMapIndex()
  3226. if mapIndex == nil then
  3227. MapZoomOut()
  3228. mapIndex = GetCurrentMapIndex()
  3229. end
  3230.  
  3231. if mapIndex ~= 23 then
  3232. SetMapToMapListIndex(1)
  3233. end
  3234.  
  3235. FyrMM.MeasurementX, FyrMM.MeasurementY, _ = GetMapPlayerPosition("player")
  3236. FyrMM.DistanceMeasurementStarted = true
  3237. FyrMM.SetMapToPlayerLocation()
  3238. zo_callLater(FyrMM.FinishDistanceMeasurement, 5000)
  3239. end
  3240.  
  3241. function FyrMM.FinishDistanceMeasurement()
  3242. if Fyr_MM:IsHidden() or FyrMM.worldMapShowing then
  3243. return
  3244. end
  3245. FyrMM.DistanceMeasurementStarted = false
  3246. if CurrentMap.TrueMapSize > 1 then
  3247. return
  3248. end
  3249. local x, y = FyrMM.MeasurementX, FyrMM.MeasurementY
  3250. FyrMM.SetMapToPlayerLocation()
  3251. local xl, yl = FyrMM.MeasurementXl, FyrMM.MeasurementYl
  3252. local x2l, y2l, _ = GetMapPlayerPosition("player")
  3253. local mapIndex = GetCurrentMapIndex()
  3254. if mapIndex == nil then
  3255. MapZoomOut()
  3256. mapIndex = GetCurrentMapIndex()
  3257. end
  3258. local worldsize, multiplier
  3259.  
  3260. if mapIndex ~= 23 then -- not coldharbour
  3261. SetMapToMapListIndex(1)
  3262. worldsize = 33440 -- Assumed Tamriel size in feet taken from ZygorGuides
  3263. else
  3264. worldsize = 5684 -- Assumed Coldharbour size in feet
  3265. end
  3266.  
  3267. local multiplier = FyrMM.GetMapMeasureMultiplier()
  3268.  
  3269. local x2, y2, _ = GetMapPlayerPosition("player")
  3270. FyrMM.SetMapToPlayerLocation()
  3271. local localdistance = math.sqrt((xl - x2l) * (xl - x2l) + (yl - y2l) * (yl - y2l)) -- Local map distance
  3272. local continentdistance = math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2)) -- Tamriel/Coldharbour
  3273. local mapSize = (worldsize * continentdistance / localdistance) * multiplier
  3274. if not (mapSize > 0) then -- Error
  3275. FyrMM.DistanceMeasurementStarted = true
  3276. return
  3277. end
  3278. if FyrMM.SV.MapSizes == nil then
  3279. FyrMM.SV.MapSizes = {}
  3280. end
  3281. if not CurrentMap.filename or CurrentMap.filename == "" then
  3282. local filename, nameNoNum, path = GetCurrentMapTextureFileInfo()
  3283. CurrentMap.filename = string.lower(filename)
  3284. end
  3285. FyrMM.SV.MapSizes[CurrentMap.filename] = mapSize
  3286. CurrentMap.TrueMapSize = mapSize
  3287. end
  3288.  
  3289. function FyrMM.InCombatAutoHideCheck()
  3290. if not FyrMM.SV.InCombatAutoHide then
  3291. return
  3292. end
  3293. if IsUnitActivelyEngaged("player") then
  3294. FyrMM.AfterCombatUnhidePending = false
  3295. if not Fyr_MM:IsHidden() then
  3296. FyrMM.Visible = false
  3297. FyrMM.AutoHidden = true
  3298. end
  3299. else
  3300. if Fyr_MM:IsHidden() and FyrMM.AutoHidden then
  3301. if not FyrMM.AfterCombatUnhidePending then
  3302. FyrMM.AfterCombatUnhidePending = true
  3303. FyrMM.AfterCombatUnhideTimeStamp = GetFrameTimeMilliseconds()
  3304. zo_callLater(AfterCombatShow, 1000 * FyrMM.SV.AfterCombatUnhideDelay)
  3305. end
  3306. end
  3307. end
  3308. end
  3309.  
  3310. local function DelayedReload()
  3311. if FyrMM.Reloading then
  3312. return
  3313. end
  3314. zo_callLater(FyrMM.Reload, 100)
  3315. end
  3316.  
  3317. local function DelayedShow()
  3318. if not Fyr_MM:IsHidden() or FyrMM.Reloading then
  3319. return
  3320. end
  3321. zo_callLater(FyrMM.Show, 100)
  3322. end
  3323.  
  3324. local frameRatePrevious = GetFramerate()
  3325.  
  3326. function FyrMM.HideCheck() -- fires every 100 ticks
  3327. -- if FyrMM.Reloading then --[[ d("Reloading") --]] return end
  3328. -- FyrMM.Refresh = false
  3329.  
  3330. -------- hide compass -------------------------------------------------------------
  3331. if FyrMM.SV.hideCompass == true and not ZO_CompassFrame:IsHidden() then
  3332. ZO_CompassFrame:SetHidden(true)
  3333. end
  3334.  
  3335. -- FPS stuff ----------------------------------------------------------------------
  3336. if FyrMM.SV.ShowFPS or FyrMM.FpsTest then
  3337. local frameRate = GetFramerate()
  3338. frameRatePrevious = (frameRatePrevious + frameRate) / 2
  3339.  
  3340. if (frameRate < 20.0) then
  3341. Fyr_MM_FPS:SetColor(1, 0, 0, 1)
  3342. elseif (frameRate < 30.0) then
  3343. Fyr_MM_FPS:SetColor(1, 0.6, 0, 1)
  3344. elseif (frameRate < 60.0) then
  3345. Fyr_MM_FPS:SetColor(0, 1, 0, 1)
  3346. else
  3347. Fyr_MM_FPS:SetColor(1, 1, 1, 1)
  3348. end
  3349. Fyr_MM_FPS:SetText(string.format(" %.1f", frameRate))
  3350.  
  3351. if not Fyr_MM:IsHidden() and FyrMM.FpsTest then
  3352. if FyrMM.Fps == 0 then
  3353. FyrMM.Fps = frameRate
  3354. else
  3355. FyrMM.Fps = (FyrMM.Fps + frameRate) / 2
  3356. end
  3357. end
  3358.  
  3359. if Fyr_MM:IsHidden() and FyrMM.FpsTest then
  3360. if FyrMM.FpsRaw == 0 then
  3361. FyrMM.FpsRaw = frameRate
  3362. else
  3363. FyrMM.FpsRaw = (FyrMM.FpsRaw + frameRate) / 2
  3364. end
  3365. end
  3366. else
  3367. Fyr_MM_FPS:SetText("")
  3368. Fyr_MM_FPS:SetAlpha(0)
  3369. end
  3370.  
  3371. --------------- clock -------------------------------------------------------------
  3372. if FyrMM.SV.ShowClock then
  3373. if GetSecondsSinceMidnight() ~= FyrMM.SecondsSinceMidnight then
  3374. local TS = ""
  3375. local a = GetTimeString()
  3376. if FyrMM.TimeFormat == 0 then
  3377. Fyr_MM_Time:SetText(a)
  3378. elseif FyrMM.TimeFormat == 2 then
  3379. TS = " " .. string.sub(a, 1, 5) .. " "
  3380. Fyr_MM_Time:SetText(TS)
  3381. else
  3382. local h = tonumber(string.sub(a, 1, 2))
  3383. if h > 12 then
  3384. local H = tostring(h - 12)
  3385. if (h - 12) < 10 then
  3386. H = "0" .. H
  3387. end
  3388. TS = (H .. string.sub(a, 3, 5) .. "pm")
  3389. else
  3390. TS = (string.sub(a, 1, 5) .. "am")
  3391. end
  3392. Fyr_MM_Time:SetText(TS)
  3393. end
  3394. Fyr_MM_Time:SetMouseEnabled(true)
  3395. if Fyr_MM_Time:IsHidden() then
  3396. Fyr_MM_Time:SetHidden(false)
  3397. end
  3398. FyrMM.SecondsSinceMidnight = GetSecondsSinceMidnight()
  3399. end
  3400. else
  3401. Fyr_MM_Time:SetMouseEnabled(false)
  3402. Fyr_MM_Time:SetHidden(true)
  3403. end
  3404.  
  3405. --------------- SHOW / HIDE MINIMAP STUFF ---------------------------------------------------------------------------------------------------
  3406.  
  3407. ------ Protect against minimap conflicts stuff
  3408. if BUI and BUI.MiniMap and BUI.Vars.MiniMap == true then -- disables to avoid conflicts with BUI minimap
  3409. if not FyrMM.minimapConflictMessage then
  3410. d("|ceeeeeeMiniMap by |c006600Fyrakin |ceeeeee v" .. FyrMM.Panel.version .. "|r" ..
  3411. "|c00BFFF is disabled to avoid conflicts with |cFF0000Bandits User Interface|r|c00BFFF's minimap. To use Minimap by |c006600Fyrakin|r|c00BFFF you need to disable |cFF0000Bandits User Interface|r|c00BFFF's minimap first. Please, always test/compare your minimaps one by one.")
  3412. end
  3413. FyrMM.minimapConflictMessage = true
  3414. elseif AUI and AUI.Minimap and AUI.Minimap.IsEnabled() then -- disables to avoid conflicts with AUI's minimap
  3415. if not FyrMM.minimapConflictMessage then
  3416. d("|ceeeeeeMiniMap by |c006600Fyrakin |ceeeeee v" .. FyrMM.Panel.version .. "|r" ..
  3417. "|c00BFFF is disabled to avoid conflicts with |cFF0000Advanced User Interface|r|c00BFFF's minimap. To use Minimap by |c006600Fyrakin|r|c00BFFF you need to disable |cFF0000Advanced User Interface|r|c00BFFF's minimap first. Please, always test/compare your minimaps one by one.")
  3418. end
  3419. FyrMM.minimapConflictMessage = true
  3420. elseif VOTANS_MINIMAP and VOTANS_MINIMAP.account.enableMap then -- disables to avoid conflicts with Votan's minimap
  3421. if not FyrMM.minimapConflictMessage then
  3422. d("|ceeeeeeMiniMap by |c006600Fyrakin |ceeeeee v" .. FyrMM.Panel.version .. "|r" ..
  3423. "|c00BFFF is disabled to avoid conflicts with |cFF0000Votan|r|c00BFFF's minimap. To use Minimap by |c006600Fyrakin|r|c00BFFF you need to disable |cFF0000Votan|r|c00BFFF's minimap first. Please, always test/compare your minimaps one by one.")
  3424. end
  3425. FyrMM.minimapConflictMessage = true
  3426. else
  3427. FyrMM.minimapConflictMessage = false
  3428. end
  3429.  
  3430. -- menus, scenes stuff
  3431. local siegeControlling = IsPlayerControllingSiegeWeapon()
  3432. local menuShowing = not ZO_KeybindStripControl:IsHidden()
  3433. local interactShowing = not ZO_InteractWindow:IsHidden()
  3434. local gameMenuShowing = not ZO_GameMenu_InGame:IsHidden()
  3435. local crownStoreActive = WINDOW_MANAGER:IsSecureRenderModeEnabled() or
  3436. not ZO_ProvisionerTopLevelNavigationContainerScroll:IsHidden() or
  3437. not ZO_SharedRightPanelBackground:IsHidden()
  3438.  
  3439. if FyrMM.SV.InCombatAutoHide then
  3440. FyrMM.InCombatAutoHideCheck()
  3441. end -- checks for combat autohide and returns FyrMM.AutoHidden
  3442.  
  3443. if siegeControlling and FyrMM.SV.Siege and not FyrMM.manuallyHidden then -- controlling siege weapon
  3444. FyrMM.Visible = true
  3445. elseif (FyrMM.worldMapShowing or FyrMM.FastTravelOpen or TRIBUTE_SCENE:IsShowing() or SCRYING_SCENE:IsShowing() or
  3446. ANTIQUITY_DIGGING_SCENE:IsShowing() or GAME_MENU_SCENE:IsShowing() or crownStoreActive or
  3447. (FyrMM.isInHouse and FyrMM.SV.InHouseAutoHide) or menuShowing or interactShowing or gameMenuShowing or
  3448. FyrMM.AutoHidden or FyrMM.minimapConflictMessage) and ZO_Loot:IsHidden() and
  3449. not LORE_READER_INTERACTION_SCENE:IsShowing() then
  3450. FyrMM.Visible = false
  3451. elseif not FyrMM.manuallyHidden then
  3452. FyrMM.Visible = true
  3453. end
  3454.  
  3455. if FyrMM.manuallyHidden then -- if hidden by user, never show
  3456. FyrMM.Hide()
  3457. elseif FyrMM.Visible == false or FyrMM.noMap == true then -- not visible or no map data
  3458. FyrMM.Hide()
  3459. else -- if everything is good we show the mini map
  3460. DelayedShow()
  3461. end
  3462.  
  3463. if FyrMM.Visible == true and FyrMM.noMap == true then -- reload in case of problem
  3464. FyrMM.noMap = false
  3465. DelayedReload()
  3466. DelayedShow()
  3467. return
  3468. end
  3469.  
  3470. -- checks for Mini compass
  3471. if FyrMM.SV.miniCompassOption and not COMPASS_FRAME:GetBossBarActive() then
  3472. if ZO_CompassFrame:IsHidden() and not Fyr_MM:IsHidden() then
  3473. ZO_CompassFrame:SetHidden(false)
  3474. end
  3475. FyrMM.SetMiniCompass()
  3476. elseif FyrMM.SV.miniCompassOption and COMPASS_FRAME:GetBossBarActive() then
  3477. if FyrMM.SV.miniCompassNoBossBar then
  3478. if not ZO_CompassFrame:IsHidden() then
  3479. ZO_CompassFrame:SetHidden(true)
  3480. end
  3481. else
  3482. FyrMM.compassDefaultWidth = FyrMM.compassDefaultWidth or 650
  3483. local width = ZO_CompassFrame:GetWidth()
  3484. if width ~= FyrMM.compassDefaultWidth then
  3485. ZO_CompassFrame:SetWidth(FyrMM.compassDefaultWidth)
  3486. if width ~= MM_GetMapWidth() - 10 then
  3487. FyrMM.compassDefaultWidth = width
  3488. end
  3489. end
  3490. end
  3491. end
  3492. end
  3493.  
  3494. function FyrMM.WorldMapShowHide()
  3495. if ZO_WorldMap:IsHidden() then
  3496. FyrMM.UnregisterUpdates()
  3497. CancelUpdates()
  3498. FyrMM.worldMapShowing = true
  3499. FyrMM.Reloading = true
  3500. else
  3501. CurrentTasks = {}
  3502. FyrMM.worldMapShowing = false
  3503. FyrMM.Reloading = false
  3504. -- zo_callLater(FyrMM.SetMapToPlayerLocation,50)
  3505. end
  3506. end
  3507.  
  3508. function FyrMM.SetMapToPlayerLocation(stealth)
  3509. local changed = false
  3510. if not Stealth then
  3511. if Fyr_MM:IsHidden() then
  3512. return
  3513. end
  3514. end
  3515.  
  3516. if GetMapFilterType() == 0 and stealth then
  3517. zo_callLater(FyrMM.SetMapToPlayerLocation, 50)
  3518. return
  3519. end
  3520. if FyrMM.worldMapShowing or not ZO_QuestJournal:IsHidden() then
  3521. return
  3522. end
  3523. if FyrMM.DisableSubzones == true and GetMapType() ~= 1 then
  3524. return
  3525. end
  3526.  
  3527. if FyrMM.DisableSubzones == true and GetMapType() == 1 and not IsUnitInDungeon("player") and not IsPlayerInRaid() and
  3528. not IsActiveWorldBattleground() and not IsInAvAZone() then
  3529. SetMapToZone()
  3530. return true
  3531. end
  3532.  
  3533. if SetMapToPlayerLocation() ~= SET_MAP_RESULT_CURRENT_MAP_UNCHANGED then -- SET_MAP_RESULT_CURRENT_MAP_UNCHANGED = 1 SET_MAP_RESULT_FAILED = 0 SET_MAP_RESULT_MAP_CHANGED = 2
  3534. changed = true
  3535. if stealth then
  3536. if FyrMM.DebugMode then
  3537. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "OnWorldMapChanged (SetMapToPlayerLocation)" ..
  3538. tostring(GetGameTimeMilliseconds()))
  3539. end
  3540. CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
  3541. end
  3542. end
  3543.  
  3544. return changed
  3545. end
  3546.  
  3547. function FyrMM.Hide()
  3548. if Fyr_MM:IsHidden() then
  3549. return
  3550. end
  3551. FyrMM.UnregisterUpdates()
  3552. CancelUpdates()
  3553. Fyr_MM_Wheel_Background:SetHidden(true)
  3554. Fyr_MM_Menu:SetHidden(true)
  3555. Fyr_MM_Coordinates:SetHidden(true)
  3556. Fyr_MM_Axis_Control:SetHidden(true)
  3557. Fyr_MM_Scroll_WheelCenter:SetHidden(true)
  3558. Fyr_MM_Scroll_WheelNS:SetHidden(true)
  3559. Fyr_MM_Scroll_WheelWE:SetHidden(true)
  3560. Fyr_MM_Frame_Wheel:SetHidden(true)
  3561. if not FyrMM.SV.ShowBorder then
  3562. Fyr_MM_Border:SetAlpha(0)
  3563. end
  3564. Fyr_MM:SetMouseEnabled(false)
  3565. Fyr_MM_Menu:SetMouseEnabled(false)
  3566. Fyr_MM_FPS_Frame:SetHidden(true)
  3567. Fyr_MM_Zone_Background:SetHidden(true)
  3568. Fyr_MM_ZoneFrame:SetHidden(true)
  3569. Fyr_MM_Zone:SetText("")
  3570. Fyr_MM_Speed:SetHidden(true)
  3571. Fyr_MM:SetMouseEnabled(false)
  3572. Fyr_MM_Frame_Control:SetMouseEnabled(false)
  3573. Fyr_MM_ZoneFrame:SetMouseEnabled(false)
  3574. Fyr_MM_FPS_Frame:SetMouseEnabled(false)
  3575. Fyr_MM:SetHidden(true)
  3576. end
  3577.  
  3578. function FyrMM.Show_WheelScrolls()
  3579. FyrMM.UpdateMapTiles(true)
  3580. Fyr_MM_Wheel_Background:SetHidden(not FyrMM.SV.WheelMap)
  3581. Fyr_MM_Scroll_WheelCenter:SetHidden(not FyrMM.SV.WheelMap)
  3582. Fyr_MM_Scroll_WheelNS:SetHidden(not FyrMM.SV.WheelMap)
  3583. Fyr_MM_Scroll_WheelWE:SetHidden(not FyrMM.SV.WheelMap)
  3584. Fyr_MM_Scroll:SetHorizontalScroll(CurrentMap.hpos)
  3585. Fyr_MM_Scroll:SetVerticalScroll(CurrentMap.vpos)
  3586. Fyr_MM_Scroll_WheelCenter:SetHorizontalScroll(CurrentMap.hpos)
  3587. Fyr_MM_Scroll_WheelCenter:SetVerticalScroll(CurrentMap.vpos)
  3588. Fyr_MM_Scroll_WheelNS:SetHorizontalScroll(CurrentMap.hpos)
  3589. Fyr_MM_Scroll_WheelNS:SetVerticalScroll(CurrentMap.vpos)
  3590. Fyr_MM_Scroll_WheelWE:SetHorizontalScroll(CurrentMap.hpos)
  3591. Fyr_MM_Scroll_WheelWE:SetVerticalScroll(CurrentMap.vpos)
  3592. end
  3593.  
  3594. function FyrMM.Show()
  3595. if FyrMM.Reloading or not Fyr_MM:IsHidden() then
  3596. return
  3597. end -- or not Fyr_MM:IsHidden() was added for optimization 20/04/2023
  3598.  
  3599. if not (IsPlayerControllingSiegeWeapon() and FyrMM.SV.Siege) then
  3600. if not FyrMM.Visible or FyrMM.worldMapShowing or not ZO_KeybindStripControl:IsHidden() or
  3601. not ZO_InteractWindow:IsHidden() or not ZO_GameMenu_InGame:IsHidden() or
  3602. WINDOW_MANAGER:IsSecureRenderModeEnabled() then
  3603. return
  3604. end
  3605. end
  3606.  
  3607. if FyrMM.Halted and FyrMM.Visible and not FyrMM.worldMapShowing and FyrMM.HaltTimeOffset ~= 0 then
  3608. if GetFrameTimeMilliseconds() - FyrMM.HaltTimeOffset > 1000 then
  3609. FyrMM.RegisterUpdates()
  3610. end
  3611. end
  3612.  
  3613. FyrMM.SetMapToPlayerLocation()
  3614. if Fyr_MM:IsHidden() then
  3615. zo_callLater(function()
  3616. FyrMM.UpdateMapTiles(true)
  3617. FyrMM.RegisterUpdates()
  3618. end, 100)
  3619.  
  3620. Fyr_MM_Frame_Wheel:SetHidden(not FyrMM.SV.WheelMap)
  3621. if FyrMM.SV.WheelMap then
  3622. FyrMM.Show_WheelScrolls()
  3623. end
  3624. Fyr_MM_Frame_Control:SetHidden(not FyrMM.SV.WheelMap)
  3625. Fyr_MM:SetHidden(false)
  3626. Fyr_MM_Menu:SetHidden(FyrMM.SV.MenuDisabled)
  3627. Fyr_MM_Menu:SetMouseEnabled(not FyrMM.SV.MenuDisabled)
  3628. Fyr_MM_Zone_Background:SetHidden(not FyrMM.SV.ShowZoneBackground)
  3629. Fyr_MM_ZoneFrame:SetHidden(FyrMM.SV.HideZoneLabel)
  3630. if not FyrMM.SV.HideZoneLabel then
  3631. FyrMM.UpdateLabels()
  3632. end
  3633. Fyr_MM_Coordinates:SetHidden(not FyrMM.SV.ShowPosition)
  3634. Fyr_MM_Axis_Control:SetHidden(not (FyrMM.SV.RotateMap or FyrMM.SV.BorderPins))
  3635. Fyr_MM_FPS_Frame:SetHidden(not FyrMM.SV.ShowFPS)
  3636. Fyr_MM_Speed:SetHidden(not FyrMM.SV.ShowSpeed)
  3637. Fyr_MM_ZoneFrame:SetMouseEnabled(true)
  3638. Fyr_MM:SetMouseEnabled(true)
  3639. end
  3640.  
  3641. if FyrMM.SV.ShowBorder then
  3642. Fyr_MM_Border:SetAlpha(100)
  3643. end
  3644.  
  3645. Fyr_MM:SetMouseEnabled(true)
  3646. FyrMM.RequestQuestPinUpdate() -- test 03/05/2023
  3647. if FyrMM.checkLater == true then
  3648. FyrMM.ZoneCheck()
  3649. end
  3650. end
  3651.  
  3652. function FyrMM.ZoneUpdate()
  3653. if FyrMM.Reloading then
  3654. return
  3655. end
  3656. if FyrMM.SV.DisableSubzones then
  3657. FyrMM.ZoneCheck()
  3658. end
  3659. end
  3660.  
  3661. function FyrMM.playerMoved()
  3662. FyrMM.newPos = { CurrentMap.PlayerNX, CurrentMap.PlayerNY } -- GetMapPlayerPosition("player")
  3663. if rawequal(FyrMM.newPos, FyrMM.oldPos) then
  3664. return false
  3665. end
  3666. FyrMM.oldPos = FyrMM.newPos
  3667. return true
  3668. end
  3669.  
  3670. local function ZoneCheck()
  3671. if Fyr_MM:IsHidden() then
  3672. FyrMM.checkLater = true
  3673. return
  3674. end
  3675. FyrMM.RegisterUpdates() -- Solves the bug where custom pins of parent zone are displayed on current subzone map after porting to a wayshrine in the same subzone 24/07/2022
  3676.  
  3677. if not FyrMM.worldMapShowing then
  3678. if GetMapFilterType() == 0 then
  3679. zo_callLater(ZoneCheck, 50)
  3680. return
  3681. end
  3682. FyrMM.CheckingZone = true
  3683.  
  3684. local filename, _, _ = GetCurrentMapTextureFileInfo()
  3685. if filename == "tamriel_0" then
  3686. FyrMM.CheckingZone = false
  3687. return
  3688. end
  3689. CurrentMap.ZoneIndex = GetCurrentMapZoneIndex()
  3690.  
  3691. if string.lower(CurrentMap.filename) ~= string.lower(filename) then
  3692. FyrMM.UnregisterUpdates()
  3693. CancelUpdates()
  3694. local ZoneIndex = 0
  3695. local mapId = FyrMM.GetMapId()
  3696.  
  3697. if FyrMM.MapSizes[mapId] then
  3698. FyrMM.LoadCustomPinList()
  3699. end
  3700.  
  3701. if ZoneIndex == 0 then
  3702. FyrMM.SetMapToPlayerLocation()
  3703. CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
  3704. else
  3705. CurrentMap.ZoneIndex = ZoneIndex
  3706. end
  3707.  
  3708. FyrMM.UpdateMapInfo()
  3709. FyrMM.UpdateMapTiles(true)
  3710. FyrMM.MovementSpeed = 0
  3711. FyrMM.MovementSpeedPrevious = 0
  3712. FyrMM.MovementSpeedMax = 0
  3713. CustomPinIndex = {}
  3714.  
  3715. if IsInAvAZone() then
  3716. zo_callLater(FyrMM.RequestKeepRefresh, 100) -- WAS 1000
  3717. end
  3718.  
  3719. CurrentMap.PlayerNX, CurrentMap.PlayerNY, CurrentMap.PlayerHeading = GetMapPlayerPosition("player")
  3720. CurrentMap.MapId = mapId
  3721. CurrentMap.MapContent = GetMapContentType()
  3722.  
  3723. CALLBACK_MANAGER:FireCallbacks("OnFyrMiniNewMapEntered")
  3724. end
  3725.  
  3726. if FyrMM.SV.RotateMap then
  3727. Fyr_MM_Scroll:SetHorizontalScroll(0)
  3728. Fyr_MM_Scroll:SetVerticalScroll(0)
  3729. else
  3730. Fyr_MM_Scroll:SetHorizontalScroll(CurrentMap.hpos)
  3731. Fyr_MM_Scroll:SetVerticalScroll(CurrentMap.vpos)
  3732. end
  3733.  
  3734. if FyrMM.SV.WheelMap then
  3735. FyrMM.WheelScroll(CurrentMap.hpos, CurrentMap.vpos)
  3736. end
  3737.  
  3738. FyrMM.customPinsUpdateCount = nil
  3739. end
  3740. FyrMM.CheckingZone = false
  3741. FyrMM.checkLater = false
  3742. end
  3743.  
  3744. function FyrMM.ZoneCheck()
  3745. if FyrMM.CheckingZone then
  3746. return
  3747. end
  3748. zo_callLater(ZoneCheck, 50)
  3749. end
  3750.  
  3751. local function TaskExists(tag)
  3752. for i, v in pairs(CurrentTasks) do
  3753. if CurrentTasks[i] ~= nil then
  3754. if GetFrameTimeMilliseconds() - CurrentTasks[i].RequestTimeStamp < FYRMM_QUEST_PIN_REQUEST_TIMEOUT then
  3755. if CurrentTasks[i][1] == tag[1] and CurrentTasks[i][2] == tag[2] and CurrentTasks[i][3] == tag[3] and
  3756. CurrentTasks[i].isBreadcrumb == tag.isBreadcrumb then
  3757. return true
  3758. end
  3759. else
  3760. -- CurrentTasks[i] = nil
  3761. end
  3762. end
  3763. end
  3764. return false
  3765. end
  3766.  
  3767. local function DestroyTasks()
  3768. for i, v in pairs(CurrentTasks) do
  3769. if CurrentTasks[i] ~= nil then
  3770. CurrentTasks[i] = nil
  3771. end
  3772. end
  3773. end
  3774.  
  3775. local function RemoveObsoleteQuestPins()
  3776. local t = GetGameTimeMilliseconds()
  3777. for i, v in pairs(QuestPins) do
  3778. if questpinDataExists(v, RequestedQuestPins) == nil then
  3779. RemoveQuestPin(v.Pin)
  3780. end
  3781. end
  3782. local pinCount = Fyr_MM_Scroll_Map_QuestPins:GetNumChildren()
  3783. local l
  3784. local nilcount = 0
  3785. for i = 1, pinCount + 100 do
  3786. l = GetControl("Fyr_MM_Scroll_Map_QuestPins_Pin" .. tostring(i))
  3787. if l == nil then
  3788. nilcount = nilcount + 1
  3789. if nilcount > 1 then
  3790. return
  3791. end
  3792. end
  3793. if l ~= nil and l.questdataIndex ~= nil then
  3794. if QuestPins[l.questdataIndex] == nil then
  3795. if l.MM_Tag == nil then
  3796. RemoveQuestPin(l)
  3797. else
  3798. if l.MM_Tag == 1 then
  3799. if l.secondaryPin ~= nil then
  3800. l.secondaryPin.MM_Tag = nil
  3801. RemoveQuestPin(l.secondaryPin)
  3802. end
  3803. if l.tertiaryPin ~= nil then
  3804. l.tertiaryPin.MM_Tag = nil
  3805. RemoveQuestPin(l.tertiaryPin)
  3806. end
  3807. l.MM_Tag = nil
  3808. RemoveQuestPin(l)
  3809. end
  3810. end
  3811. zo_callLater(FyrMM.RequestQuestPinUpdate, 1000)
  3812. end
  3813. end
  3814. end
  3815. if FyrMM.DebugMode then
  3816. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  3817. "RemoveObsoleteQuestPins " .. tostring(GetGameTimeMilliseconds() - t))
  3818. end
  3819. end
  3820.  
  3821. local function AddMissingQuestPins()
  3822. local properType, pinTexture, size
  3823. for i, v in pairs(RequestedQuestPins) do
  3824. if questpinDataExists(v, QuestPins) == nil then
  3825. properType, pinTexture, size = FyrMM.GetQuestPinInfo(MAP_PIN_TYPE_TRACKED_QUEST_CONDITION,
  3826. GetTrackedIsAssisted(TRACK_TYPE_QUEST, v.questIndex), v.isBreadcrumb, v.radius)
  3827. FyrMM.CreateQuestPin(properType, v.tag, v.normalizedX, v.normalizedY, v.radius)
  3828. zo_callLater(FyrMM.RequestQuestPinUpdate, 1000)
  3829. end
  3830. end
  3831. end
  3832.  
  3833. function FyrMM.checkDuplicateCustompin() -- added by @Masteroshi430 -- testing purposes, should never been called!
  3834. if Fyr_MM_Scroll_Map_Pins:GetNumChildren() == 0 then
  3835. return
  3836. end
  3837. FyrMM.scrollMapPinToCheck = FyrMM.scrollMapPinToCheck or 1
  3838.  
  3839. local pinToTest = Fyr_MM_Scroll_Map_Pins:GetChild(FyrMM.scrollMapPinToCheck)
  3840. local total = 1
  3841. local notFoundYet = true
  3842. for i = 1, Fyr_MM_Scroll_Map_Pins:GetNumChildren() do
  3843. l = Fyr_MM_Scroll_Map_Pins:GetChild(i)
  3844. if l ~= nil and l.nX then
  3845. if FyrMM.scrollMapPinToCheck ~= i and pinToTest.nX == l.nX and pinToTest.nY == l.nY and pinToTest.radius ==
  3846. l.radius then
  3847. local texture = l:GetTextureFileName() or ""
  3848. RemoveCustomPin(l)
  3849. d("custom pin duplicate removed " .. texture)
  3850. end
  3851. if i > FyrMM.scrollMapPinToCheck and notFoundYet == true then
  3852. FyrMM.scrollMapPinToCheck = i
  3853. notFoundYet = false
  3854. end
  3855. total = total + 1
  3856. else
  3857. if i > FyrMM.scrollMapPinToCheck and notFoundYet == true then
  3858. FyrMM.scrollMapPinToCheck = i
  3859. end
  3860. end
  3861. end
  3862. if FyrMM.scrollMapPinToCheck >= 1200 then
  3863. FyrMM.scrollMapPinToCheck = 1
  3864. end
  3865.  
  3866. d("Next tested pin: " .. FyrMM.scrollMapPinToCheck .. " total custom pins: " .. total)
  3867. end
  3868.  
  3869. function FyrMM.customPinsUpdate(count) -- added by @Masteroshi430
  3870. if FyrMM.Reloading then
  3871. return
  3872. end
  3873. -- d("tries to update custom pins")
  3874. if IsCustomPinsLoading() or count ~= FyrMM.customPinsUpdateCount then
  3875. return
  3876. end
  3877.  
  3878. if FyrMM.CustomPinCount == AvailableCustomPins() then
  3879. FyrMM.customPinsUpdateCount = nil
  3880. if FyrMM.DebugMode then
  3881. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "FyrMM.CustomPins End: (" .. tostring(FyrMM.CustomPinCount) ..
  3882. ") " .. tostring(GetGameTimeMilliseconds()))
  3883. end
  3884. return
  3885. end
  3886.  
  3887. count = count or 1
  3888.  
  3889. if count < 5 then
  3890. if FyrMM.DebugMode then
  3891. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  3892. "FyrMM.CustomPins Start: (" .. tostring(FyrMM.CustomPinCount) .. ") " ..
  3893. tostring(GetGameTimeMilliseconds()))
  3894. end
  3895. FyrMM.CustomPins()
  3896. -- d("check custompins attempt "..count)
  3897. zo_callLater(function()
  3898. FyrMM.customPinsUpdate(count + 1)
  3899. end, 1000 + (count * 100))
  3900. FyrMM.customPinsUpdateCount = count + 1
  3901. return
  3902. end
  3903.  
  3904. FyrMM.ResetCustomPinList()
  3905. FyrMM.customPinsUpdateCount = nil
  3906. -- d("check custompins attempt "..count..": resetting custompins!")
  3907. end
  3908.  
  3909. function FyrMM.PinUpdate()
  3910. if FyrMM.Halted then
  3911. return
  3912. end
  3913. if ((not FyrMM.Visible or Fyr_MM:IsHidden()) and FyrMM.Initialized) or FyrMM.worldMapShowing then
  3914. return
  3915. end
  3916. local a = GetGameTimeMilliseconds()
  3917. CurrentMap.ZoneIndex = GetCurrentMapZoneIndex()
  3918. FyrMM.RemoveInvalidQuestPins()
  3919. CheckCustomPinConsistence()
  3920.  
  3921. if FyrMM.currentPOICount == 0 then
  3922. EVENT_MANAGER:RegisterForUpdate("FyrMiniMapPOIPins", 30, function()
  3923. if FyrMM.Reloading then
  3924. return
  3925. end
  3926. FyrMM.POIPins()
  3927. if FyrMM.currentPOICount ~= 0 then
  3928. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapPOIPins")
  3929. return
  3930. end
  3931. end)
  3932. end
  3933.  
  3934. if FyrMM.currentLocationsCount == 0 then
  3935. EVENT_MANAGER:RegisterForUpdate("FyrMiniMapLocationsPins", 30, function()
  3936. if FyrMM.Reloading then
  3937. return
  3938. end
  3939. FyrMM.LocationPins()
  3940. if FyrMM.currentLocationsCount ~= 0 then
  3941. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapLocationsPins")
  3942. return
  3943. end
  3944. end)
  3945. end
  3946.  
  3947. if FyrMM.currentWayshrineCount == 0 then
  3948. EVENT_MANAGER:RegisterForUpdate("FyrMiniMapWayshrinesPins", 30, function()
  3949. if FyrMM.Reloading then
  3950. return
  3951. end
  3952. FyrMM.Wayshrines()
  3953. if FyrMM.currentWayshrineCount ~= 0 then
  3954. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapWayshrinesPins")
  3955. return
  3956. end
  3957. end)
  3958. end
  3959.  
  3960. -- FyrMM.checkDuplicateCustompin() -- testing purposes, should never been called!
  3961.  
  3962. if FyrMM.CustomPinCount ~= AvailableCustomPins() or IsTableEmpty(FyrMM.CustomPinList) or detectedNewCustomPin then
  3963. if IsTableEmpty(FyrMM.CustomPinList) then
  3964. FyrMM.LoadCustomPinList()
  3965. elseif detectedNewCustomPin then
  3966. FyrMM.CheckForNewCustomPins()
  3967. end
  3968.  
  3969. FyrMM.customPinsUpdate()
  3970. end
  3971.  
  3972. if IsTableEmpty(CurrentTasks) and QuestPinsUpdating and not QuestTasksPending then
  3973. RemoveObsoleteQuestPins()
  3974. AddMissingQuestPins()
  3975. GetNumBorderPins()
  3976. QuestPinsUpdating = false
  3977. end
  3978.  
  3979. if (NeedQuestPinUpdate or FyrMM.questPinCount == 0) and GetQuestJournalMaxValidIndex() > 0 then
  3980. if not QuestPinsUpdating then
  3981. if not (IsTableEmpty(CurrentTasks) and GetFrameTimeMilliseconds() - FyrMM.LastQuestPinRequest <
  3982. FYRMM_QUEST_PIN_REQUEST_MINIMUM_DELAY) then
  3983. RequestedQuestPins = {}
  3984. FyrMM.UpdateQuestPins()
  3985. NeedQuestPinUpdate = false
  3986. end
  3987. end
  3988. end
  3989.  
  3990. -- testing only !
  3991. -- if #PinsList ~= PL then PL = #PinsList d(PL.." total pins") end
  3992. -- if Fyr_MM_Scroll_Map_Pins:GetNumChildren() ~= SMP then SMP = Fyr_MM_Scroll_Map_Pins:GetNumChildren() d(SMP.." custom pins") end
  3993. -- if Fyr_MM_Scroll_Map_WayshrinePins:GetNumChildren() ~= WSP then WSP = Fyr_MM_Scroll_Map_WayshrinePins:GetNumChildren() d(WSP.." wayshrine pins") end
  3994. -- if Fyr_MM_Scroll_Map_LocationPins:GetNumChildren() ~= LP then LP = Fyr_MM_Scroll_Map_LocationPins:GetNumChildren() d(LP.." location pins") end
  3995. -- if Fyr_MM_Scroll_Map_POIPins:GetNumChildren() ~= POIP then POIP = Fyr_MM_Scroll_Map_POIPins:GetNumChildren() d(POIP.." POI pins") end
  3996. -- if Fyr_MM_Axis_Border_Pins:GetNumChildren() ~= BP then BP = Fyr_MM_Axis_Border_Pins:GetNumChildren() d(BP.." border pins") end
  3997. -- if Fyr_MM_Scroll_Map_GroupPins:GetNumChildren() ~= GP then GP = Fyr_MM_Scroll_Map_GroupPins:GetNumChildren() d(GP.." group pins") end
  3998.  
  3999. a = GetFrameTimeMilliseconds() - a
  4000. if FyrMM.DebugMode and a > 0 then
  4001. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "FyrMM.PinUpdate " .. tostring(a))
  4002. end
  4003. end
  4004.  
  4005. function FyrMM.Debug_d(value)
  4006. if FyrMM.DebugMode and FyrMM.SV then
  4007. if FyrMM.SV.DebugLog == nil then
  4008. FyrMM.SV.DebugLog = {}
  4009. end
  4010. local t = GetGameTimeMilliseconds() - math.floor(GetGameTimeMilliseconds() / 1000) * 1000
  4011. d("[" .. GetTimeString() .. string.format("] %s", tostring(value)))
  4012. table.insert(FyrMM.SV.DebugLog,
  4013. "[" .. GetTimeString() .. "." .. tostring(t) .. "] FPS:" .. tostring(zo_round(GetFramerate() * 10) / 10) ..
  4014. " RAM:" .. tostring(zo_round((collectgarbage("count") / 1024) * 100) / 100) .. " MAP:" ..
  4015. tostring(CurrentMap.MapId) .. " LOC:" ..
  4016. string.format("%05.02f, %05.02f", zo_round(CurrentMap.PlayerNX * 10000) / 100,
  4017. zo_round(CurrentMap.PlayerNY * 10000) / 100) .. " FN:" .. tostring(value))
  4018. else
  4019. FyrMM.SV.DebugLog = nil
  4020. end
  4021. d("debug triggering")
  4022. end
  4023.  
  4024. function FyrMM.SetMiniCompass()
  4025. if ZO_Compass:GetScale() ~= MM_GetMapWidth() / 350 then
  4026. if not Harvest then
  4027. ZO_Compass:SetScale(MM_GetMapWidth() / 350)
  4028. end
  4029. end
  4030. ZO_Compass:SetDimensions(MM_GetMapWidth() - 10, MM_GetMapWidth() / 20)
  4031. ZO_CompassCenterOverPinLabel:SetScale(MM_GetMapWidth() / 300)
  4032. ZO_CompassFrameLeft:SetDimensions(10, MM_GetMapWidth() / 20)
  4033. ZO_CompassFrameRight:SetDimensions(10, MM_GetMapWidth() / 20)
  4034. ZO_CompassFrame:SetDimensions(MM_GetMapWidth() - 10, MM_GetMapWidth() / 20)
  4035.  
  4036. ZO_CompassCenterOverPinLabel:SetHidden(true) -- hide compass pin text
  4037.  
  4038. ZO_CompassFrame:ClearAnchors()
  4039. if FyrMM.SV.miniCompassLocation == "Top" then
  4040. ZO_CompassFrame:SetAnchor(BOTTOMLEFT, Fyr_MM, TOPLEFT, 5, -5) -- TOP POSITION
  4041. else
  4042. local verticalOffset = 5
  4043. if (not Fyr_MM_Frame_RoundMenu:IsHidden()) and Fyr_MM_Frame_RoundMenu:GetAlpha() ~= 0 then
  4044. verticalOffset = verticalOffset + (Fyr_MM_Frame_RoundMenu:GetHeight() / 3)
  4045. end
  4046. if (not Fyr_MM_Frame_SquareMenu:IsHidden()) and Fyr_MM_Frame_SquareMenu:GetAlpha() ~= 0 then
  4047. verticalOffset = verticalOffset + (Fyr_MM_Frame_SquareMenu:GetHeight() / 3)
  4048. end
  4049.  
  4050. if not Fyr_MM_ZoneFrame:IsHidden() then
  4051. verticalOffset = verticalOffset + Fyr_MM_ZoneFrame:GetHeight()
  4052. end
  4053. ZO_CompassFrame:SetAnchor(TOPLEFT, Fyr_MM, BOTTOMLEFT, 5, verticalOffset) -- BOTTOM POSITION
  4054. end
  4055. ZO_CompassFrame:SetClampedToScreen(true)
  4056. ZO_CompassFrame:SetDrawLayer(-1)
  4057. end
  4058.  
  4059. function FyrMM.Reload()
  4060. if FyrMM.Reloading then
  4061. return
  4062. end
  4063. local t = GetGameTimeMilliseconds()
  4064. if FyrMM.DebugMode then
  4065. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "FyrMM.Reload Start:")
  4066. end
  4067. FyrMM.Reloading = true
  4068. CancelUpdates()
  4069. CustomPinsCopying = false
  4070. FyrMM.LastReload = GetFrameTimeMilliseconds()
  4071. FyrMM.UnregisterUpdates()
  4072. if not FyrMM.SV.HideZoneLabel then
  4073. FyrMM.UpdateLabels()
  4074. end
  4075. FyrMM.MapHalfDiagonal()
  4076. FyrMM.UpdateMapInfo()
  4077. FyrMM.UpdateMapTiles(true)
  4078. FyrMM.PositionUpdate()
  4079.  
  4080. FreeQuestPinIndex = {}
  4081. QuestPins = {}
  4082. LastQuestPinIndex = 0
  4083. FyrMM.DistanceMeasurementStarted = false
  4084. FyrMM.MovementSpeedMax = 0
  4085. FyrMM.questPinCount = 0
  4086. FyrMM.currentLocationsCount = 0
  4087. FyrMM.currentPOICount = 0
  4088. FyrMM.currentForwardCamps = 0
  4089. FyrMM.currentWayshrineCount = 0
  4090. CleanUpPins()
  4091. FyrMM.MeasureDistance()
  4092. FyrMM.PlaceWaypointBorderPins()
  4093. FyrMM.LoadCustomPinList()
  4094. FyrMM.UpdateAntiquityDigSites()
  4095. if FyrMM.DebugMode then
  4096. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "FyrMM.Reload Done." .. tostring(GetGameTimeMilliseconds() - t))
  4097. end
  4098. -- EVENT_MANAGER:UnregisterForUpdate("MiniMapReload")
  4099. end
  4100.  
  4101. function FyrMM.WheelScroll(x, y)
  4102. if x and y then
  4103. Fyr_MM_Scroll_WheelCenter:SetHorizontalScroll(x)
  4104. Fyr_MM_Scroll_WheelCenter:SetVerticalScroll(y)
  4105. Fyr_MM_Scroll_WheelNS:SetHorizontalScroll(x)
  4106. Fyr_MM_Scroll_WheelNS:SetVerticalScroll(y)
  4107. Fyr_MM_Scroll_WheelWE:SetHorizontalScroll(x)
  4108. Fyr_MM_Scroll_WheelWE:SetVerticalScroll(y)
  4109. end
  4110. end
  4111.  
  4112. local function SetSpeedLabel(speed)
  4113. if speed == nil then
  4114. speed = 0
  4115. end
  4116. if speed ~= 0 then
  4117. if FyrMM.SV.SpeedUnit == "ft/s" then
  4118. speed = zo_round(speed * 22.0632) / 100
  4119. Fyr_MM_SpeedLabel:SetText(string.format("%05.02f ft/s", speed))
  4120. end
  4121. if FyrMM.SV.SpeedUnit == "m/s" then
  4122. speed = zo_round(speed * 6.7249) / 100
  4123. Fyr_MM_SpeedLabel:SetText(string.format("%05.02f m/s", speed))
  4124. end
  4125. if FyrMM.SV.SpeedUnit == "%" then
  4126. speed = zo_round(speed * 100) / 100
  4127. Fyr_MM_SpeedLabel:SetText(string.format("%05.01f ", speed) .. "%")
  4128. end
  4129. else
  4130. Fyr_MM_SpeedLabel:SetText("0 " .. FyrMM.SV.SpeedUnit)
  4131. end
  4132. local speedWidth, speedHeight = Fyr_MM_SpeedLabel:GetTextDimensions() or 100, 20
  4133. Fyr_MM_Speed:SetDimensions(speedWidth + 10, speedHeight + 3)
  4134. end
  4135.  
  4136. local function LogPosition()
  4137. local MapId = FyrMM.GetMapId()
  4138. local size = CurrentMap.TrueMapSize
  4139. local gameTime = GetGameTimeMilliseconds()
  4140. IsCompanionAround = DoesUnitExist("companion")
  4141. CurrentMap.PlayerNX, CurrentMap.PlayerNY, CurrentMap.PlayerHeading = GetMapPlayerPosition("player")
  4142. if FyrMM.SV.ShowSpeed then
  4143. PositionLogCounter = PositionLogCounter + 1
  4144. PositionLog3D[PositionLogCounter] = { GetUnitWorldPosition("player") }
  4145. PositionLog3D[PositionLogCounter][5] = GetFrameTimeMilliseconds()
  4146. PositionLog3D[PositionLogCounter][6] = CurrentMap.PlayerNX
  4147. PositionLog3D[PositionLogCounter][7] = CurrentMap.PlayerNY
  4148. end
  4149. CurrentMap.CameraHeading = GetPlayerCameraHeading()
  4150. CurrentMap.PlayerTurned = (CurrentMap.Heading ~= math.abs(CurrentMap.PlayerHeading - pi * 2))
  4151. CurrentMap.Heading = smoothHeadingRotation()
  4152.  
  4153. CurrentMap.PlayerMoved = FyrMM.playerMoved()
  4154.  
  4155. if CurrentMap.PlayerHeading < 0 then
  4156. CurrentMap.PlayerHeading = pi * 2 + CurrentMap.PlayerHeading
  4157. end
  4158. if zo_round(CurrentMap.PlayerNX * 100) / 100 <= 0 or zo_round(CurrentMap.PlayerNY * 100) / 100 <= 0 or
  4159. CurrentMap.PlayerNX >= 1 or CurrentMap.PlayerNY >= 1 then
  4160. if not Fyr_MM:IsHidden() then
  4161. zo_callLater(FyrMM.SetMapToPlayerLocation, 50)
  4162. end
  4163. end
  4164.  
  4165. if MapId ~= CurrentMap.MapId and FyrMM.CheckingZone == false then
  4166. FyrMM.ZoneCheck()
  4167. end
  4168. CurrentMap.PlayerX, CurrentMap.PlayerY = Fyr_MM_Scroll_Map:GetDimensions()
  4169. CurrentMap.PlayerX = CurrentMap.PlayerX * CurrentMap.PlayerNX
  4170. CurrentMap.PlayerY = CurrentMap.PlayerY * CurrentMap.PlayerNY
  4171. CurrentMap.currentTimeStamp = gameTime
  4172.  
  4173. if CurrentMap.PlayerMoved then
  4174. CurrentMap.movedTimeStamp = gameTime
  4175. end
  4176.  
  4177. Fyr_MM_Position:SetText(string.format("%05.02f, %05.02f", CurrentMap.PlayerNX * 100, CurrentMap.PlayerNY * 100)) -- thanks Garkin
  4178. local textWidth, textHeight = Fyr_MM_Position:GetTextDimensions() or 100, 20
  4179. Fyr_MM_Position_Background:SetDimensions(textWidth + 10, textHeight + 3)
  4180. Fyr_MM_Player_incombat:SetHidden(not (FyrMM.SV.InCombatState and IsUnitActivelyEngaged("player")))
  4181. end
  4182.  
  4183. local function SpeedMeasure()
  4184. FyrMM.WaypointPins()
  4185.  
  4186. if not FyrMM.SV.ShowSpeed then
  4187. return
  4188. end
  4189.  
  4190. local multiplier = FyrMM.GetMapMeasureMultiplier()
  4191.  
  4192. local x13d, y13d, z13d, t1, x12d, y12d = PositionLog3D[1][2], PositionLog3D[1][3], PositionLog3D[1][4],
  4193. PositionLog3D[1][5], PositionLog3D[1][6], PositionLog3D[1][7]
  4194. local x23d, y23d, z23d, t2, x22d, y22d
  4195. local d3d, d2d, v13d, va3d = 0, 0, 0, 0
  4196. local size = FyrMM.MapSizes[CurrentMap.MapId] or FyrMM.currentMap.TrueMapSize
  4197.  
  4198. if IsPlayerMoving() then
  4199. for i = 2, PositionLogCounter do
  4200. local posData = PositionLog3D[i]
  4201. x23d, y23d, z23d, t2, x22d, y22d = posData[2], posData[3], posData[4], posData[5], posData[6], posData[7]
  4202. d3d = math.sqrt((x23d - x13d) ^ 2 + (y23d - y13d) ^ 2 + (z23d - z13d) ^ 2)
  4203. v13d = 0.1487 * d3d / math.abs((t2 - t1) / 1000)
  4204. x13d, y13d, z13d, t1, x12d, y12d = x23d, y23d, z23d, t2, x22d, y22d
  4205. va3d = va3d + v13d
  4206. end
  4207. if PositionLogCounter == 0 then
  4208. return
  4209. end
  4210. local nsize = 0.0143 * math.sqrt((x23d - x13d) ^ 2 + (y23d - y13d) ^ 2) /
  4211. math.sqrt((x22d - x12d) ^ 2 + (y22d - y12d) ^ 2)
  4212. if nsize and size and nsize ~= 1e309 and size < nsize then
  4213. FyrMM.currentMap.TrueMapSize = nsize
  4214. end
  4215. va3d = va3d / (PositionLogCounter - 1) * multiplier
  4216. end
  4217.  
  4218. PositionLogCounter = 0
  4219. local MovementSpeedPrevious = FyrMM.MovementSpeedPrevious -- cache global variable
  4220. if MovementSpeedPrevious then
  4221. FyrMM.MovementSpeed = (va3d + MovementSpeedPrevious) / 2
  4222. else
  4223. FyrMM.MovementSpeed = va3d
  4224. end
  4225.  
  4226. if MovementSpeedPrevious ~= FyrMM.MovementSpeed then
  4227. CALLBACK_MANAGER:FireCallbacks("MovementSpeedChanged", va3d)
  4228. FyrMM.MovementSpeedPrevious = FyrMM.MovementSpeed
  4229. end
  4230.  
  4231. if va3d > FyrMM.MovementSpeedMax then
  4232. FyrMM.MovementSpeedMax = va3d
  4233. end
  4234. SetSpeedLabel(va3d)
  4235. end
  4236.  
  4237. function FyrMM.PositionUpdate()
  4238. if not FyrMM.Visible or Fyr_MM:IsHidden() or FyrMM.worldMapShowing or not FyrMM.Initialized or
  4239. not Fyr_MM_Scroll_Map_0 or not CurrentMap.Dx then
  4240. return
  4241. end
  4242.  
  4243. if FyrMM.GetMapId() ~= CurrentMap.MapId and not FyrMM.CheckingZone then
  4244. FyrMM.ZoneCheck()
  4245. end
  4246.  
  4247. local a = GetGameTimeMilliseconds()
  4248. local x = CurrentMap.PlayerNX
  4249. local y = CurrentMap.PlayerNY
  4250. local pheading = CurrentMap.PlayerHeading
  4251. if x == nil or pheading == nil then
  4252. x, y, pheading = GetMapPlayerPosition("player")
  4253. end
  4254.  
  4255. local moved = CurrentMap.PlayerMoved
  4256. CurrentMap.CameraHeading = CurrentMap.CameraHeading or GetPlayerCameraHeading()
  4257.  
  4258. local cpheading = FyrMM.SV.RotateMap and math.abs(pheading - pi * 2) + CurrentMap.CameraHeading or
  4259. CurrentMap.CameraHeading
  4260. Fyr_MM_Camera:SetTextureRotation(cpheading)
  4261.  
  4262. local hpos = (x * (Fyr_MM_Scroll_Map_0:GetWidth() * CurrentMap.Dx)) - (Fyr_MM_Scroll:GetWidth() / 2)
  4263. local vpos = (y * (Fyr_MM_Scroll_Map_0:GetHeight() * CurrentMap.Dx)) - (Fyr_MM_Scroll:GetHeight() / 2)
  4264.  
  4265. local heading = pheading
  4266. if FyrMM.SV.PPStyle ~= GetString(SI_MM_STRING_PLAYERANDCAMERA) then
  4267. if FyrMM.SV.Heading == "CAMERA" then
  4268. heading = CurrentMap.CameraHeading
  4269. end
  4270. if not moved and FyrMM.SV.Heading == "MIXED" then
  4271. heading = CurrentMap.CameraHeading
  4272. end
  4273. end
  4274.  
  4275. if moved and FyrMM.SV.ViewRangeFiltering then
  4276. UpdateCustomPinPositions()
  4277. end
  4278.  
  4279. if ((x < 1.2 and x > -0.2) and (y < 1.2 and y > -0.2)) then -- Can't let the scroll go too far outside view (Black map issue)
  4280. if not Fyr_MM:IsHidden() and moved then
  4281. FyrMM.SetMapToPlayerLocation()
  4282. end
  4283. CurrentMap.hpos = hpos
  4284. CurrentMap.vpos = vpos
  4285.  
  4286. if FyrMM.SV.RotateMap then
  4287. Fyr_MM_Scroll:SetHorizontalScroll(0)
  4288. Fyr_MM_Scroll:SetVerticalScroll(0)
  4289. else
  4290. Fyr_MM_Scroll:SetHorizontalScroll(hpos)
  4291. Fyr_MM_Scroll:SetVerticalScroll(vpos)
  4292. end
  4293.  
  4294. if FyrMM.SV.WheelMap then
  4295. FyrMM.WheelScroll(CurrentMap.hpos, CurrentMap.vpos)
  4296. end
  4297. else
  4298. CurrentMap.hpos = hpos
  4299. CurrentMap.vpos = vpos
  4300.  
  4301. if FyrMM.SV.RotateMap then
  4302. Fyr_MM_Scroll:SetHorizontalScroll(0)
  4303. Fyr_MM_Scroll:SetVerticalScroll(0)
  4304. else
  4305. Fyr_MM_Scroll:SetHorizontalScroll(CurrentMap.hpos)
  4306. Fyr_MM_Scroll:SetVerticalScroll(CurrentMap.vpos)
  4307. end
  4308.  
  4309. if FyrMM.SV.WheelMap then
  4310. FyrMM.WheelScroll(CurrentMap.hpos, CurrentMap.vpos)
  4311. end
  4312. end
  4313.  
  4314. FyrMM.UpdateMapTiles(moved) -- can cause tiles not updating but should be fixed by now
  4315. CurrentMap.needRescale = true -- REMOVING THIS CAUSES OCCASIONAL PINS DEPHASING ON ROTATING MAPS
  4316.  
  4317. if FyrMM.SV.RotateMap then
  4318. Fyr_MM_Player:SetTextureRotation(0)
  4319. FyrMM.AxisPins()
  4320. else
  4321. Fyr_MM_Player:SetTextureRotation(heading)
  4322. end
  4323.  
  4324. a = GetGameTimeMilliseconds() - a
  4325. if FyrMM.DebugMode and a > 0 then
  4326. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "FyrMM.PositionUpdate " .. tostring(a))
  4327. end
  4328. end
  4329.  
  4330. -------------------------------------------------------------
  4331. -- Map Building
  4332. -------------------------------------------------------------
  4333. -- get map info for minimap
  4334. function FyrMM.UpdateMapInfo(IgnoreZone)
  4335. local t = GetGameTimeMilliseconds()
  4336. CurrentMap.ready = false
  4337. CurrentMap.name = GetMapName()
  4338. CurrentMap.tileTexture = string.lower(GetMapTileTexture())
  4339. CurrentMap.Dx, CurrentMap.Dy = GetMapNumTiles()
  4340. local filename, nameNoNum, path = GetCurrentMapTextureFileInfo()
  4341. CurrentMap.filename = string.lower(filename)
  4342. CurrentMap.nameNoNum = nameNoNum
  4343. CurrentMap.path = path
  4344. CurrentMap.TextureAngle = 0
  4345. local id = FyrMM.GetMapId()
  4346.  
  4347. if string.lower(CurrentMap.filename) == "tamriel_0" then
  4348. CurrentMap.ready = true
  4349. zo_callLater(FyrMM.UpdateMapInfo, 5)
  4350. return
  4351. end
  4352.  
  4353. if CurrentMap.Dx < 2 or CurrentMap.Dy < 2 or CurrentMap.Dx == nil or CurrentMap.Dy == nil then
  4354. if id ~= 0 then
  4355. CurrentMap.Dx, CurrentMap.Dy = GetMapNumTilesForMapId(id)
  4356. else
  4357. CurrentMap.Dx = 3
  4358. CurrentMap.Dy = 3
  4359. end
  4360. end
  4361. CurrentMap.type = GetMapType()
  4362. if not IgnoreZone then
  4363. CurrentMap.ZoneIndex = GetCurrentMapZoneIndex()
  4364. end
  4365. -- if we have no texture we have nothing further to do
  4366. if CurrentMap.tileTexture == "" or CurrentMap.Dx == nil or CurrentMap.Dy == nil then
  4367. FyrMM.noMap = true
  4368. return
  4369. else
  4370. FyrMM.noMap = false
  4371. end
  4372.  
  4373. CurrentMap.numTiles = CurrentMap.Dx * CurrentMap.Dy
  4374. CurrentMap.TrueMapSize = 1
  4375. if id ~= 0 and FyrMM.MapSizes[id] then
  4376. CurrentMap.TrueMapSize = FyrMM.MapSizes[id]
  4377. if FyrMM.SV.MapSizes then
  4378. if FyrMM.SV.MapSizes[CurrentMap.filename] and CurrentMap.TrueMapSize > 1 then
  4379. FyrMM.SV.MapSizes[CurrentMap.filename] = nil
  4380. end
  4381. end
  4382. end
  4383.  
  4384. -- store tile textures in table
  4385. CurrentMap.tiles = {}
  4386. for i = 1, CurrentMap.numTiles do
  4387. table.insert(CurrentMap.tiles, string.lower(GetMapTileTexture(i)))
  4388. end
  4389.  
  4390. if not CurrentMap.filename or CurrentMap.filename == "" then
  4391. local filename, _, _ = GetCurrentMapTextureFileInfo()
  4392. CurrentMap.filename = string.lower(filename)
  4393. end
  4394.  
  4395. if FyrMM.SV.ZoomTable[CurrentMap.filename] == nil then
  4396. FyrMM.SV.ZoomTable[CurrentMap.filename] = FYRMM_DEFAULT_ZOOM_LEVEL
  4397. CurrentMap.ZoomLevel = FYRMM_DEFAULT_ZOOM_LEVEL
  4398. else
  4399. CurrentMap.ZoomLevel = FyrMM.SV.ZoomTable[CurrentMap.filename]
  4400. end
  4401.  
  4402. if FyrMM.SV.autoResizePin and CurrentMap.MapId ~= 16 and CurrentMap.MapId ~= 660 and GetMapContentType() ~=
  4403. MAP_CONTENT_BATTLEGROUND then
  4404. -- zoom: 1 to 50 default: 10
  4405. FyrMM.pinZoomScale = (CurrentMap.ZoomLevel) / 10
  4406. else
  4407. FyrMM.pinZoomScale = 1
  4408. end
  4409.  
  4410. if id ~= 0 then
  4411. CurrentMap.MapId = id
  4412. if CurrentMap.TrueMapSize == 1 then
  4413. if FyrMM.SV.MapSizes[CurrentMap.filename] then
  4414. CurrentMap.TrueMapSize = FyrMM.SV.MapSizes[CurrentMap.filename]
  4415. end
  4416. end
  4417. else
  4418. CurrentMap.MapId = 0 -- "unknown"
  4419. if FyrMM.SV.MapSizes == nil then
  4420. FyrMM.SV.MapSizes = {}
  4421. FyrMM.SV.MapSizes[CurrentMap.filename] = 1
  4422. CurrentMap.TrueMapSize = 1
  4423. else
  4424. if FyrMM.SV.MapSizes[CurrentMap.filename] ~= nil then
  4425. CurrentMap.TrueMapSize = FyrMM.SV.MapSizes[CurrentMap.filename]
  4426. end
  4427. end
  4428. end
  4429.  
  4430. CurrentMap.ready = true
  4431. if FyrMM.DebugMode then
  4432. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "FyrMM.UpdateMapInfo " .. tostring(GetGameTimeMilliseconds() - t))
  4433. end
  4434. CALLBACK_MANAGER:FireCallbacks("OnFyrMiniMapChanged")
  4435. end
  4436.  
  4437. function FyrMM.GetTileDimensions() -- gets tile scale for map
  4438. local texW, texH = Fyr_MM_Scroll_Map_0:GetTextureFileDimensions() or ((texW < 256 or texH < 256) or (texW > 1024 or texH > 1024) or texW == nil or texH == nil) and CurrentMap.filename and mr and mr[1] or 256, 256 -- 256 = unknown map
  4439.  
  4440. local id = FyrMM.GetMapId()
  4441. local dx, dy = GetMapNumTilesForMapId(id)
  4442. local zoomlevel = CurrentMap.ZoomLevel or FYRMM_DEFAULT_ZOOM_LEVEL
  4443.  
  4444. local tileX = math.floor(zo_round(((zoomlevel / 10) * texW * dx) / dx) / 2) * 2
  4445. local tileY = math.floor(zo_round(((zoomlevel / 10) * texW * dy) / dy) / 2) * 2
  4446.  
  4447. return tileX, tileY
  4448. end
  4449.  
  4450. local Tiles = false
  4451. function FyrMM.UpdateMapTiles(stealth)
  4452. local needRescale = false
  4453. if not stealth and ((not FyrMM.Visible or Fyr_MM:IsHidden()) and not FyrMM.Initialized) then
  4454. return
  4455. end
  4456. if not CurrentMap.ready then
  4457. return
  4458. end
  4459. if string.lower(CurrentMap.filename) == "tamriel_0" then
  4460. return
  4461. end
  4462.  
  4463. local MM_TileSizeW, MM_TileSizeH = FyrMM.GetTileDimensions()
  4464. if Fyr_MM_Scroll_Map_0:GetTextureFileName():lower() == CurrentMap.tiles[1]:lower() and
  4465. zo_round(Fyr_MM_Scroll_Map_0:GetWidth()) == zo_round(MM_TileSizeW) and zo_round(Fyr_MM_Scroll_Map_0:GetHeight()) ==
  4466. zo_round(MM_TileSizeH) then
  4467. if stealth == GetFrameTimeMilliseconds() then
  4468. return
  4469. end
  4470. else
  4471. if zo_round(Fyr_MM_Scroll_Map_0:GetWidth()) ~= zo_round(MM_TileSizeW) or
  4472. zo_round(Fyr_MM_Scroll_Map_0:GetHeight()) ~= zo_round(MM_TileSizeH) then
  4473. CurrentMap.needRescale = true
  4474. end
  4475. end -- nothing to update if same map
  4476.  
  4477. if Tiles then
  4478. return
  4479. end
  4480. Tiles = true
  4481. if FyrMM.DebugMode then
  4482. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "FyrMM.UpdateMapTiles " .. tostring(stealth))
  4483. end
  4484. local sa, sb, centerSize
  4485. local i = 0
  4486.  
  4487. local MM_TileSizeW, MM_TileSizeH = FyrMM.GetTileDimensions()
  4488. local mWidth, mHeight = MM_TileSizeW * CurrentMap.Dx, MM_TileSizeH * CurrentMap.Dy
  4489. Fyr_MM_Scroll_Map:SetDimensions(mWidth, mHeight)
  4490. Fyr_MM_Scroll_Map:SetDrawLayer(0) -- 1
  4491.  
  4492. if not FyrMM.SV.WheelMap then
  4493. Fyr_MM_Bg:SetColor(0, 0, 0, 1)
  4494. Fyr_MM_Scroll_WheelNS:SetHidden(true)
  4495. Fyr_MM_Scroll_WheelCenter:SetHidden(true)
  4496. Fyr_MM_Scroll_WheelWE:SetHidden(true)
  4497. else
  4498. Fyr_MM_Bg:SetColor(1, 1, 1, 0)
  4499. Fyr_MM_Border:SetHidden(true)
  4500. sa = Fyr_MM:GetWidth() - ((50 / 512) * Fyr_MM:GetWidth())
  4501. sb = (220 / 512) * Fyr_MM:GetWidth()
  4502. Fyr_MM_Scroll_WheelWE:SetDimensions(sa, sb)
  4503. Fyr_MM_Scroll_WheelNS:SetDimensions(sb, sa)
  4504. Fyr_MM_Frame_Control:SetDimensions(Fyr_MM:GetWidth(), Fyr_MM:GetWidth())
  4505. Fyr_MM_Frame_Wheel:SetDimensions(Fyr_MM:GetWidth() + 8, Fyr_MM:GetWidth() + 8)
  4506.  
  4507. if FyrMM.SV.RotateMap and CurrentMap.Heading then
  4508. Fyr_MM_Frame_Wheel:SetTextureCoordsRotation(CurrentMap.Heading)
  4509. end
  4510.  
  4511. centerSize = math.sqrt(2 * Fyr_MM:GetWidth() * Fyr_MM:GetWidth()) / 2
  4512. Fyr_MM_Scroll_WheelCenter:SetDimensions(centerSize, centerSize)
  4513.  
  4514. if not CurrentMap.PlayerX or not CurrentMap.PlayerY or not CurrentMap.Heading then
  4515. local x, y, pheading = GetMapPlayerPosition("player")
  4516. CurrentMap.PlayerNX = x
  4517. CurrentMap.PlayerNY = y
  4518. CurrentMap.PlayerX, CurrentMap.PlayerY = Fyr_MM_Scroll_Map:GetDimensions()
  4519. CurrentMap.PlayerX = CurrentMap.PlayerX * x
  4520. CurrentMap.PlayerY = CurrentMap.PlayerY * y
  4521. CurrentMap.Heading = smoothHeadingRotation()
  4522. end
  4523. end
  4524. local tilec, tilens, tilewe
  4525. local tileposX, tileposY, x, y
  4526. for a = 1, CurrentMap.Dy do
  4527. for b = 1, CurrentMap.Dx do
  4528. i = i + 1
  4529. local tileControl = GetControl("Fyr_MM_Scroll_Map_" .. tostring(i - 1))
  4530. if tileControl == nil then
  4531. tileControl = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_" .. tostring(i - 1), Fyr_MM_Scroll_Map,
  4532. CT_TEXTURE)
  4533. end
  4534. local tilens = GetControl("Fyr_MM_Scroll_WNS_Map_" .. tostring(i - 1)) -- top & bottom
  4535. if tilens == nil then
  4536. tilens = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_WNS_Map_" .. tostring(i - 1),
  4537. Fyr_MM_Scroll_WheelNS, CT_TEXTURE)
  4538. end
  4539. local tilec = GetControl("Fyr_MM_Scroll_CW_Map_" .. tostring(i - 1)) -- corners
  4540. if tilec == nil then
  4541. tilec = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_CW_Map_" .. tostring(i - 1),
  4542. Fyr_MM_Scroll_WheelCenter, CT_TEXTURE)
  4543. end
  4544. local tilewe = GetControl("Fyr_MM_Scroll_WWE_Map_" .. tostring(i - 1)) -- left and right
  4545. if tilewe == nil then
  4546. tilewe = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_WWE_Map_" .. tostring(i - 1),
  4547. Fyr_MM_Scroll_WheelWE, CT_TEXTURE)
  4548. end
  4549. tileControl:SetHidden(FyrMM.SV.WheelMap)
  4550. tilens:SetHidden(not FyrMM.SV.WheelMap)
  4551. tilec:SetHidden(not FyrMM.SV.WheelMap)
  4552. tilewe:SetHidden(not FyrMM.SV.WheelMap)
  4553. if tileControl:GetTextureFileName():lower() ~= CurrentMap.tiles[i]:lower() then
  4554. tileControl:SetTexture(CurrentMap.tiles[i])
  4555. tilens:SetTexture(CurrentMap.tiles[i])
  4556. tilec:SetTexture(CurrentMap.tiles[i])
  4557. tilewe:SetTexture(CurrentMap.tiles[i])
  4558. end
  4559. tileControl:SetDimensions(FyrMM.GetTileDimensions())
  4560. tilens:SetDimensions(FyrMM.GetTileDimensions())
  4561. tilec:SetDimensions(FyrMM.GetTileDimensions())
  4562. tilewe:SetDimensions(FyrMM.GetTileDimensions())
  4563. tileControl:SetDrawLayer(0)
  4564. tilens:SetDrawLayer(0)
  4565. tilec:SetDrawLayer(0)
  4566. tilewe:SetDrawLayer(0)
  4567. tilens:ClearAnchors()
  4568. tilec:ClearAnchors()
  4569. tilewe:ClearAnchors()
  4570. tileControl:ClearAnchors()
  4571. if FyrMM.SV.RotateMap then
  4572. if not CurrentMap.PlayerX or not CurrentMap.PlayerY or not CurrentMap.Heading then
  4573. local x, y, pheading = GetMapPlayerPosition("player")
  4574. CurrentMap.PlayerNX = x
  4575. CurrentMap.PlayerNY = y
  4576. CurrentMap.PlayerX, CurrentMap.PlayerY = Fyr_MM_Scroll_Map:GetDimensions()
  4577. CurrentMap.PlayerX = CurrentMap.PlayerX * x
  4578. CurrentMap.PlayerY = CurrentMap.PlayerY * y
  4579. CurrentMap.Heading = smoothHeadingRotation()
  4580. end
  4581. x = ((b - 0.5) * mWidth / CurrentMap.Dx) - CurrentMap.PlayerX
  4582. y = ((a - 0.5) * mHeight / CurrentMap.Dy) - CurrentMap.PlayerY
  4583. tileposX = (math.cos(-CurrentMap.Heading) * x) - (math.sin(-CurrentMap.Heading) * y)
  4584. tileposY = (math.sin(-CurrentMap.Heading) * x) + (math.cos(-CurrentMap.Heading) * y)
  4585. tileControl:SetTextureRotation(CurrentMap.Heading, 0.5, 0.5);
  4586. tilens:SetTextureRotation(CurrentMap.Heading, 0.5, 0.5);
  4587. tilec:SetTextureRotation(CurrentMap.Heading, 0.5, 0.5);
  4588. tilewe:SetTextureRotation(CurrentMap.Heading, 0.5, 0.5);
  4589. if FyrMM.SV.MapAlpha > 80 then
  4590. tilens:SetScale(1.0055)
  4591. tilec:SetScale(1.0055)
  4592. tilewe:SetScale(1.0055)
  4593. tileControl:SetScale(1.0055)
  4594. else
  4595. tilens:SetScale(1)
  4596. tilec:SetScale(1)
  4597. tilewe:SetScale(1)
  4598. tileControl:SetScale(1)
  4599. end
  4600. tileControl:SetAnchor(CENTER, Fyr_MM_Scroll, CENTER, tileposX, tileposY)
  4601. tilens:SetAnchor(CENTER, Fyr_MM_Scroll_WheelNS, CENTER, tileposX, tileposY)
  4602. tilec:SetAnchor(CENTER, Fyr_MM_Scroll_WheelCenter, CENTER, tileposX, tileposY)
  4603. tilewe:SetAnchor(CENTER, Fyr_MM_Scroll_WheelWE, CENTER, tileposX, tileposY)
  4604. else
  4605. tileposX = ((b - 0.5) * mWidth / CurrentMap.Dx) - mWidth / 2
  4606. tileposY = ((a - 0.5) * mHeight / CurrentMap.Dy) - mHeight / 2
  4607. tileControl:SetScale(1)
  4608. tilens:SetScale(1)
  4609. tilec:SetScale(1)
  4610. tilewe:SetScale(1)
  4611. tileControl:SetTextureRotation(0)
  4612. tilens:SetTextureRotation(0)
  4613. tilec:SetTextureRotation(0)
  4614. tilewe:SetTextureRotation(0)
  4615. tileControl:SetAnchor(CENTER, Fyr_MM_Scroll_Map, CENTER, tileposX, tileposY)
  4616. tilens:SetAnchor(CENTER, Fyr_MM_Scroll_Map, CENTER, tileposX, tileposY)
  4617. tilec:SetAnchor(CENTER, Fyr_MM_Scroll_Map, CENTER, tileposX, tileposY)
  4618. tilewe:SetAnchor(CENTER, Fyr_MM_Scroll_Map, CENTER, tileposX, tileposY)
  4619. tileControl:SetAnchor(CENTER, Fyr_MM_Scroll_Map, CENTER, tileposX, tileposY)
  4620. tilens:SetAnchor(CENTER, Fyr_MM_Scroll_Map, CENTER, tileposX, tileposY)
  4621. tilec:SetAnchor(CENTER, Fyr_MM_Scroll_Map, CENTER, tileposX, tileposY)
  4622. tilewe:SetAnchor(CENTER, Fyr_MM_Scroll_Map, CENTER, tileposX, tileposY)
  4623. end
  4624. end
  4625. end
  4626. for j = i, Fyr_MM_Scroll_Map:GetNumChildren() do
  4627. tileControl = GetControl("Fyr_MM_Scroll_Map_" .. tostring(j))
  4628. tilens = GetControl("Fyr_MM_Scroll_WNS_Map_" .. tostring(j))
  4629. tilec = GetControl("Fyr_MM_Scroll_CW_Map_" .. tostring(j))
  4630. tilewe = GetControl("Fyr_MM_Scroll_WWE_Map_" .. tostring(j))
  4631. if (tileControl) then
  4632. tileControl:ClearAnchors()
  4633. tileControl:SetHidden(true)
  4634. end
  4635. if (tilens) then
  4636. tilens:ClearAnchors()
  4637. tilens:SetHidden(true)
  4638. end
  4639. if (tilec) then
  4640. tilec:ClearAnchors()
  4641. tilec:SetHidden(true)
  4642. end
  4643. if (tilewe) then
  4644. tilewe:ClearAnchors()
  4645. tilewe:SetHidden(true)
  4646. end
  4647. end
  4648. if FyrMM.SV.WheelMap then
  4649. CurrentMap.TextureAngle = CurrentMap.Heading
  4650. else
  4651. CurrentMap.TextureAngle = 0
  4652. end
  4653. Tiles = false
  4654. end
  4655.  
  4656. function FyrMM.GetScrollObject(control)
  4657. if not FyrMM.SV.WheelMap then
  4658. return Fyr_MM_Scroll_WheelCenter
  4659. end
  4660.  
  4661. local xl = control:GetLeft()
  4662. local xr = control:GetRight()
  4663. local yt = control:GetTop()
  4664. local yb = control:GetBottom()
  4665. local scrollWheels = {
  4666. Fyr_MM_Scroll_WheelCenter,
  4667. Fyr_MM_Scroll_WheelNS,
  4668. Fyr_MM_Scroll_WheelWE,
  4669. }
  4670.  
  4671. for _, scrollWheel in ipairs(scrollWheels) do
  4672. if (xr >= scrollWheel:GetLeft() + 6 and xl <= scrollWheel:GetRight() - 10 and yb >=
  4673. scrollWheel:GetTop() + 6 and yt <= scrollWheel:GetBottom() - 10) then
  4674. return scrollWheel
  4675. end
  4676. end
  4677.  
  4678. return Fyr_MM_Scroll_Map
  4679. end
  4680.  
  4681. -----------------------------------------------------------------
  4682. -- Map Pins
  4683. -----------------------------------------------------------------
  4684. local function GetPinTexture(pinType, control)
  4685. if type(ZO_MapPin.PIN_DATA[pinType].texture) == 'string' then
  4686. return ZO_MapPin.PIN_DATA[pinType].texture
  4687. end
  4688.  
  4689. if not type(ZO_MapPin.PIN_DATA[pinType].texture) == 'function' then
  4690. return
  4691. end
  4692.  
  4693. if (control.m_PinTag.isBreadcrumb) then
  4694. return breadcrumbQuestPinTextures[pinType]
  4695. end
  4696.  
  4697. return questPinTextures[pinType]
  4698. end
  4699.  
  4700. local function GetCustomPin()
  4701. local p
  4702. if IsTableEmpty(FreeCustomPinIndex) then
  4703. LastCustomPinIndex = LastCustomPinIndex + 1
  4704. p = GetControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(LastCustomPinIndex))
  4705. if p == nil then
  4706. p = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(LastCustomPinIndex),
  4707. Fyr_MM_Scroll_Map_Pins, CT_TEXTURE)
  4708. p:SetHandler("OnMouseEnter", PinOnMouseEnter)
  4709. p:SetHandler("OnMouseExit", PinOnMouseExit)
  4710. end
  4711. p.Index = LastCustomPinIndex
  4712. return p
  4713. else
  4714. for i, n in pairs(FreeCustomPinIndex) do
  4715. p = GetControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(n))
  4716. if p == nil then
  4717. p = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(n), Fyr_MM_Scroll_Map_Pins,
  4718. CT_TEXTURE)
  4719. p:SetHandler("OnMouseEnter", PinOnMouseEnter)
  4720. p:SetHandler("OnMouseExit", PinOnMouseExit)
  4721. end
  4722. p.Index = n
  4723. FreeCustomPinIndex[i] = nil
  4724. return p
  4725. end
  4726. end
  4727. end
  4728.  
  4729. local function ClearCustomPinReminder() -- never called
  4730. if CustomPinsCopying then
  4731. return
  4732. end
  4733. for i = FyrMM.CustomPinCount + 1, Fyr_MM_Scroll_Map_Pins:GetNumChildren() do
  4734. local l = GetControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(i))
  4735. if l ~= nil then
  4736. if l.BorderPin ~= nil then
  4737. RemoveBorderPin(l.BorderPin)
  4738. end
  4739. l:ClearAnchors()
  4740. l:SetHidden(true)
  4741. l.nX = nil
  4742. l.nY = nil
  4743. l.IsTreasure = nil
  4744. l.IsAvailableQuest = nil
  4745. l.pinTexture = nil
  4746. end
  4747. end
  4748. end
  4749.  
  4750. local ci = 0
  4751. function InsertCustomPin(p, key)
  4752. if p == nil or FyrMM.Reloading then
  4753. return
  4754. end
  4755. if p.m_PinType == nil then
  4756. return
  4757. end
  4758. if ZOpinData == nil then
  4759. return
  4760. end
  4761. if ZOpinData[p.m_PinType] == nil then
  4762. return
  4763. end
  4764. local j = 1
  4765. -- local mapId = CurrentMap.MapId
  4766. local pin, texture, pScalePercent
  4767. pScalePercent = FyrMM.pScalePercent
  4768. if pScalePercent == nil then
  4769. pScalePercent = 1
  4770. end
  4771.  
  4772. local enabled
  4773. if type(p) == "table" then
  4774. if p.IsMapPing then
  4775. -- d("!!!!!!!")
  4776. end
  4777.  
  4778. enabled = true
  4779. if PinRef ~= nil then
  4780. if PRCustomPins ~= nil and p.m_PinType >= MAP_PIN_TYPE_INVALID then
  4781. enabled = PRCustomPins[p.m_PinType].enabled
  4782. end
  4783. else
  4784. if p.m_PinType >= MAP_PIN_TYPE_INVALID then
  4785. enabled = ZO_WorldMap_IsCustomPinEnabled(p.m_PinType) -- checks filter for custom pin
  4786. end
  4787. end
  4788.  
  4789. if CustomPinIndex[p.m_PinType] == nil then
  4790. CustomPinIndex[p.m_PinType] = {}
  4791. end
  4792.  
  4793. if CustomPinKeyIndex[p.m_PinType] == nil then
  4794. CustomPinKeyIndex[p.m_PinType] = {}
  4795. end
  4796.  
  4797. if FyrMM.CustomPinList[p.m_PinType] == nil then
  4798. FyrMM.CustomPinList[p.m_PinType] = {}
  4799. end
  4800.  
  4801. if enabled then
  4802. pin = GetCustomPin()
  4803. if pin.mpin == nil then
  4804. pin.mpin = ZO_MapPin:New(ZO_WorldMapContainer)
  4805. end
  4806.  
  4807. if FyrMM.CustomPinList[p.m_PinType][key] ~= nil then
  4808. FyrMM.CustomPinList[p.m_PinType][key].pin = pin
  4809. end
  4810. j = pin.Index
  4811.  
  4812. if key ~= nil then
  4813. CustomPinKeyIndex[p.m_PinType][key] = j
  4814. end
  4815.  
  4816. FyrMM.CustomPinCount = FyrMM.CustomPinCount + 1
  4817. CustomPinIndex[p.m_PinType][j] = pin
  4818. pin:SetHidden(true) -- updating...
  4819. if pin.BorderPin ~= nil then
  4820. RemoveBorderPin(pin.BorderPin)
  4821. end
  4822. texture = ""
  4823. pin.m_PinType = p.m_PinType
  4824. pin.m_PinTag = p.m_PinTag
  4825. pin.mpin.m_PinType = p.m_PinType
  4826. pin.mpin.m_PinTag = p.m_PinTag
  4827. pin.mpin.normalizedX = p.normalizedX
  4828. pin.mpin.normalizedY = p.normalizedY
  4829. pin.nX = p.normalizedX
  4830. pin.nY = p.normalizedY
  4831. pin.radius = p.radius
  4832. pin.MapId = CurrentMap.MapId
  4833. pin.Index = j
  4834. pin.Key = key
  4835. pin.tint = p.tint
  4836. CustomPinCrossReference[pin.mpin] = pin
  4837. -- pin.GetPinTypeAndTag = function(self) return self.m_PinType, self.m_PinTag end
  4838.  
  4839. if FyrMM.SV.autoResizePin and CurrentMap.MapId ~= 16 and CurrentMap.MapId ~= 660 and GetMapContentType() ~=
  4840. MAP_CONTENT_BATTLEGROUND then
  4841. -- zoom: 1 to 50 default: 10
  4842. FyrMM.pinZoomScale = (CurrentMap.ZoomLevel) / 10
  4843. else
  4844. FyrMM.pinZoomScale = 1
  4845. end
  4846.  
  4847. if not ZO_MapPin.FAST_TRAVEL_WAYSHRINE_PIN_TYPES[pin.m_PinType] and
  4848. not ZO_MapPin.POI_PIN_TYPES[pin.m_PinType] and not pin.m_PinType == MAP_PIN_TYPE_LOCATION then
  4849. pin.noZoomResize = true
  4850. end
  4851.  
  4852. if ZOpinData[p.m_PinType].size ~= nil then
  4853. FyrMM.SetPinSize(pin, ZOpinData[p.m_PinType].size * pScalePercent * FyrMM.pinZoomScale)
  4854. end
  4855.  
  4856. if type(ZOpinData[p.m_PinType].texture) == 'string' then
  4857. texture = ZOpinData[p.m_PinType].texture
  4858. elseif type(ZOpinData[p.m_PinType].texture) == 'function' then
  4859. texture = ZOpinData[p.m_PinType].texture(pin.mpin)
  4860. end
  4861.  
  4862. if p.m_PinType == MAP_PIN_TYPE_PLAYER_WAYPOINT then
  4863. texture = "EsoUI/Art/MapPins/UI_Worldmap_pin_customDestination.dds"
  4864. FyrMM.IsWaypoint = true
  4865. FyrMM.SetPinSize(pin, ZOpinData[p.m_PinType].minSize * pScalePercent)
  4866. if FyrMM.Waypoint ~= nil then
  4867. if FyrMM.Waypoint.BorderPin ~= nil then
  4868. RemoveBorderPin(FyrMM.Waypoint.BorderPin)
  4869. end
  4870. end
  4871. FyrMM.Waypoint = pin
  4872. end
  4873.  
  4874. if p.m_PinType == MAP_PIN_TYPE_RALLY_POINT then
  4875. texture = "MiniMap/Textures/rally.dds"
  4876. FyrMM.SetPinSize(pin, (ZOpinData[MAP_PIN_TYPE_RALLY_POINT].minSize / 3) * pScalePercent)
  4877. FyrMM.IsRally = true
  4878. if FyrMM.Rally ~= nil then
  4879. if FyrMM.Rally.BorderPin ~= nil then
  4880. RemoveBorderPin(FyrMM.Rally.BorderPin)
  4881. end
  4882. end
  4883. FyrMM.Rally = pin
  4884. end
  4885.  
  4886. if p.m_PinType == MAP_PIN_TYPE_PING then
  4887. texture = "MiniMap/Textures/ping.dds"
  4888. FyrMM.SetPinSize(pin, ZOpinData[p.m_PinType].minSize * pScalePercent)
  4889. FyrMM.IsPing = true
  4890. if FyrMM.Ping ~= nil then
  4891. if FyrMM.Ping.BorderPin ~= nil then
  4892. RemoveBorderPin(FyrMM.Ping.BorderPin)
  4893. end
  4894. end
  4895. FyrMM.Ping = pin
  4896. end
  4897.  
  4898. pin.pinTexture = texture
  4899. pin:SetTexture(texture)
  4900.  
  4901. if (PRCustomPins and PRCustomPins[p.m_PinType] and PRCustomPins[p.m_PinType].pinTypeString and
  4902. string.find(PRCustomPins[p.m_PinType].pinTypeString, "LostTreasure")) or
  4903. string.find(texture, "MapPins/Treasure_") then
  4904. pin.IsTreasure = true
  4905. -- pin.MapId = p.m_PinTag.mapId -- was a bad idea
  4906. pin.noZoomResize = true
  4907. table.insert(Treasures, pin)
  4908. end
  4909.  
  4910. if string.find(texture, "dragonNextLocation") then
  4911. pin.IsDragonNextLocation = true
  4912. table.insert(DragonNextLocation, pin)
  4913. end
  4914.  
  4915. pin:SetColor(1, 1, 1, 1)
  4916.  
  4917. if ZOpinData[p.m_PinType].tint ~= nil then -- compatibility with addons which modify pin colors by type
  4918. if type(ZOpinData[p.m_PinType].tint) ~= "function" then
  4919. pin:SetColor(ZOpinData[p.m_PinType].tint:UnpackRGBA())
  4920. else
  4921. local c = ZOpinData[p.m_PinType].tint(pin.mpin)
  4922. if type(c) == "table" then
  4923. pin:SetColor(c.r, c.g, c.b, c.a)
  4924. end
  4925. end
  4926. end
  4927.  
  4928. if p.tint then -- compatibility with addons which modify pin colors by pin
  4929. if type(p.tint) ~= "function" then
  4930. pin:SetColor(p.tint:UnpackRGBA())
  4931. else
  4932. if type(p.tint) == "table" then
  4933. pin:SetColor(p.tint.r, p.tint.g, p.tint.b, p.tint.a)
  4934. end
  4935. end
  4936. end
  4937.  
  4938. if type(p.m_PinTag) == "table" then -- suggested
  4939. if p.m_PinTag.IsAvailableQuest or p.m_PinTag.isZoneStory or ZO_MapPin.SUGGESTION_PIN_TYPES[p.m_PinType] then
  4940. pin.m_PinTag.IsAvailableQuest = true
  4941. pin.IsAvailableQuest = true
  4942. if ZO_MapPin.SUGGESTION_PIN_TYPES[p.m_PinType] and
  4943. not IsZoneStoryComplete(GetZoneId(GetUnitZoneIndex("player"))) then
  4944. pin.m_PinTag.isZoneStory = true
  4945. local _, _, activityId = GetTrackedZoneStoryActivityInfo()
  4946. pin.m_PinTag.activityId = activityId
  4947. FyrMM.ZoneStoryPin = pin
  4948. end
  4949. table.insert(FyrMM.AvailableQuestGivers, pin)
  4950.  
  4951. if p.radius and p.radius > 0 and p.m_PinType then
  4952. local properType, pinTexture, size = FyrMM.GetQuestPinInfo(p.m_PinType, false, false, p.radius)
  4953. local areaPin = pin
  4954. areaPin:SetTexture(pinTexture)
  4955. areaPin:SetDimensions(size, size)
  4956. local color = ZO_MAP_PIN_NORMAL_COLOR
  4957. areaPin:SetColor(color:UnpackRGBA())
  4958. if FyrMM.SV.WheelMap then
  4959. areaPin:SetParent(Fyr_MM_Scroll_CW_Map_Pins)
  4960. FyrMM.CreateSuggestedAreaSidePins(areaPin, p.radius)
  4961. end
  4962. table.insert(FyrMM.AvailableQuestGivers, areaPin)
  4963. end
  4964. end
  4965. end
  4966.  
  4967. FyrMM.SetPinAnchor(pin, pin.nX, pin.nY, Fyr_MM_Scroll_Map_Pins)
  4968. local pinHidden = true
  4969. if FyrMM.SV.WheelMap then
  4970. pin:SetHidden(not Is_PinInsideWheel(pin) and pinHidden)
  4971. else
  4972. pin:SetHidden(not pinHidden)
  4973. end
  4974. pin:SetMouseEnabled(true)
  4975. if (FyrMM.IsWaypoint or FyrMM.IsRally or FyrMM.IsPing) and FyrMM.SV.BorderPinsWaypoint then
  4976. FyrMM.PlaceWaypointBorderPins()
  4977. end
  4978. else
  4979. if pin ~= nil then
  4980. if pin.BorderPin ~= nil then
  4981. RemoveBorderPin(pin.BorderPin)
  4982. end
  4983. pin:ClearAnchors()
  4984. pin:SetHidden(true)
  4985. pin.nX = nil
  4986. pin.nY = nil
  4987. pin.MapId = nil
  4988. pin.Index = nil
  4989. pin.IsTreasure = nil
  4990. pin.IsAvailableQuest = nil
  4991. pin.pinTexture = nil
  4992. PinsList[pin:GetName()] = nil
  4993. end
  4994. end
  4995. end
  4996. end
  4997.  
  4998. function FyrMM.CustomPins()
  4999. if FyrMM.Halted or not FyrMM.Visible or Fyr_MM:IsHidden() or FyrMM.worldMapShowing then
  5000. return
  5001. end
  5002.  
  5003. local gameTime = GetGameTimeMilliseconds()
  5004.  
  5005. local function DebugMessage()
  5006. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  5007. "FyrMM.CustomPins " .. tostring(GetGameTimeMilliseconds() - gameTime))
  5008. end
  5009.  
  5010. if IsTableEmpty(FyrMM.CustomPinList) or IsCustomPinsLoading() then
  5011. if FyrMM.DebugMode then
  5012. DebugMessage()
  5013. end
  5014. return
  5015. end
  5016.  
  5017. Treasures = {}
  5018. DragonNextLocation = {}
  5019. FyrMM.AvailableQuestGivers = {}
  5020. FyrMM.CustomPinCount = 0
  5021. -- FreeCustomPinIndex = {}
  5022. CustomPinIndex = {}
  5023. -- LastCustomPinIndex = 0
  5024. local function ProcessPin(t, n, i, v)
  5025. if v.pin == nil then
  5026. InsertCustomPin(v, i)
  5027. return
  5028. end
  5029.  
  5030. local pin = v.pin
  5031. local pinType = pin.m_PinType
  5032.  
  5033. if not pinType then
  5034. return
  5035. end
  5036.  
  5037. local Index = pin.Index
  5038. Index = CustomPinKeyIndex[pinType][i] -- TEST there was a bug here especially with square maps 02/01/2023
  5039. local Key = pin.Key or i -- TEST there was a bug here especially with square maps 02/01/2023
  5040. pin.Key = Key
  5041. pin.Index = Index
  5042.  
  5043. if FyrMM.UpdatingCustomPins[pinType] then
  5044. return
  5045. end
  5046.  
  5047. if CustomPinIndex[pinType] == nil then
  5048. CustomPinIndex[pinType] = {}
  5049. end
  5050.  
  5051. CustomPinIndex[pinType][Index] = pin
  5052. CustomPinKeyIndex[pinType][Key] = Index
  5053. FyrMM.CustomPinCount = FyrMM.CustomPinCount + 1
  5054.  
  5055. if type(pin.m_PinTag) == "table" and
  5056. (pin.m_PinTag.IsAvailableQuest or pin.m_PinTag.isZoneStory or ZO_MapPin.SUGGESTION_PIN_TYPES[pin.m_PinType]) then
  5057. pin.m_PinTag.IsAvailableQuest = true
  5058. pin.IsAvailableQuest = true
  5059. if pin.m_PinTag.isZoneStory and CanZoneStoryContinueTrackingActivities(GetZoneId(GetCurrentMapZoneIndex())) then
  5060. local _, _, activityId = GetTrackedZoneStoryActivityInfo()
  5061. if pin.m_PinTag.activityId == activityId or pin.m_PinTag[3] == activityId then
  5062. FyrMM.ZoneStoryPin = pin
  5063. else
  5064. if pin == FyrMM.ZoneStoryPin then
  5065. if pin.tertiaryPin then
  5066. RemoveCustomPin(pin.tertiaryPin)
  5067. end
  5068. if pin.secondaryPin then
  5069. RemoveCustomPin(pin.secondaryPin)
  5070. end
  5071. if pin.primaryPin then
  5072. RemoveCustomPin(pin.primaryPin)
  5073. end
  5074. RemoveCustomPin(pin)
  5075. FyrMM.ZoneStoryPin = nil
  5076. end
  5077. end
  5078. else
  5079. if pin == FyrMM.ZoneStoryPin then
  5080. if pin.tertiaryPin then
  5081. RemoveCustomPin(pin.tertiaryPin)
  5082. end
  5083. if pin.secondaryPin then
  5084. RemoveCustomPin(pin.secondaryPin)
  5085. end
  5086. if pin.primaryPin then
  5087. RemoveCustomPin(pin.primaryPin)
  5088. end
  5089. RemoveCustomPin(pin)
  5090. FyrMM.ZoneStoryPin = nil
  5091. end
  5092. end
  5093. table.insert(FyrMM.AvailableQuestGivers, pin)
  5094. end
  5095.  
  5096. if (pin.pinTexture and string.find(pin.pinTexture, "MapPins/Treasure_")) or
  5097. (PRCustomPins and PRCustomPins[pin.m_PinType] and PRCustomPins[pin.m_PinType].pinTypeString and
  5098. string.find(PRCustomPins[pin.m_PinType].pinTypeString, "LostTreasure")) then
  5099. table.insert(Treasures, pin)
  5100. end
  5101. if pin.pinTexture and string.find(pin.pinTexture, "dragonNextLocation") then
  5102. table.insert(DragonNextLocation, pin)
  5103. end
  5104. end
  5105.  
  5106. for t, n in pairs(FyrMM.CustomPinList) do
  5107. if not FyrMM.UpdatingCustomPins[t] then
  5108. for i, v in pairs(n) do
  5109. ProcessPin(t, n, i, v)
  5110. end
  5111. end
  5112. end
  5113.  
  5114. if FyrMM.DebugMode then
  5115. DebugMessage()
  5116. end
  5117. end
  5118.  
  5119. ------------------------------------------------------------
  5120. -- Waypoint/Rally Pins
  5121. -----------------------------------------------------------
  5122. function FyrMM.WaypointPins()
  5123. local wpx, wpy = GetMapPlayerWaypoint()
  5124. if wpx ~= 0 or wpy ~= 0 then
  5125. local waypointPin
  5126. waypointPin = GetControl("Fyr_MM_Scroll_Map_Pins_PlayerWaypoint")
  5127. if waypointPin == nil then
  5128. waypointPin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_Pins_PlayerWaypoint", Fyr_MM_Scroll_Map_Pins,
  5129. CT_TEXTURE)
  5130. waypointPin.nDistance = function(self)
  5131. if self.nX == nil then
  5132. return 1
  5133. end
  5134. return math.sqrt((zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nX * 10000)) *
  5135. (zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nX * 10000)) +
  5136. (zo_round(CurrentMap.PlayerNY * 10000) - zo_round(self.nY * 10000)) *
  5137. (zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nY * 10000))) / 10000
  5138. end
  5139. waypointPin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  5140. waypointPin:SetHandler("OnMouseExit", PinOnMouseExit)
  5141. waypointPin:SetHandler("OnMouseUp", PinOnMouseUp)
  5142. end
  5143. local pin
  5144. local pinSize = ZOpinData[MAP_PIN_TYPE_PLAYER_WAYPOINT].minSize * FyrMM.pScalePercent
  5145. if waypointPin.m_Pin then
  5146. pin = waypointPin.m_Pin
  5147. else
  5148. pin = ZO_Object.New(ZO_MapPin)
  5149. end
  5150. pin.m_PinType = MAP_PIN_TYPE_PLAYER_WAYPOINT
  5151. pin.m_PinTag = "waypoint"
  5152. pin.nX = wpx
  5153. pin.nY = wpy
  5154. waypointPin.m_Pin = pin
  5155. waypointPin.MapId = CurrentMap.MapId
  5156. waypointPin.nX = wpx
  5157. waypointPin.nY = wpy
  5158. waypointPin.m_PinType = MAP_PIN_TYPE_PLAYER_WAYPOINT
  5159. waypointPin:SetDrawLayer(1)
  5160. FyrMM.SetPinSize(waypointPin, pinSize, 0)
  5161. waypointPin:SetTexture("EsoUI/Art/MapPins/UI_WorldMap_pin_customDestination.dds")
  5162. waypointPin:SetHidden(false)
  5163. FyrMM.SetPinAnchor(waypointPin, wpx, wpy, Fyr_MM_Scroll_Map_Pins)
  5164. waypointPin:SetMouseEnabled(true)
  5165. FyrMM.Waypoint = waypointPin
  5166. FyrMM.IsWaypoint = true
  5167. else
  5168. FyrMM.Waypoint = nil
  5169. FyrMM.IsWaypoint = false
  5170. local waypointPin
  5171. waypointPin = GetControl("Fyr_MM_Scroll_Map_Pins_PlayerWaypoint")
  5172. if waypointPin then
  5173. waypointPin.m_Pin = nil
  5174. waypointPin.MapId = 0
  5175. waypointPin.nX = 0
  5176. waypointPin.nY = 0
  5177. waypointPin.m_PinType = 0
  5178. waypointPin:SetTexture("")
  5179. waypointPin:SetHidden(true)
  5180. end
  5181. end
  5182. wpx, wpy = GetMapRallyPoint()
  5183. if wpx ~= 0 or wpy ~= 0 then
  5184. local RallyPin
  5185. RallyPin = GetControl("Fyr_MM_Scroll_Map_Pins_RallyPoint")
  5186. if RallyPin == nil then
  5187. RallyPin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_Pins_RallyPoint", Fyr_MM_Scroll_Map_Pins,
  5188. CT_TEXTURE)
  5189. RallyPin.nDistance = function(self)
  5190. if self.nX == nil then
  5191. return 1
  5192. end
  5193. return math.sqrt((zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nX * 10000)) *
  5194. (zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nX * 10000)) +
  5195. (zo_round(CurrentMap.PlayerNY * 10000) - zo_round(self.nY * 10000)) *
  5196. (zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nY * 10000))) / 10000
  5197. end
  5198. RallyPin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  5199. RallyPin:SetHandler("OnMouseExit", PinOnMouseExit)
  5200. RallyPin:SetHandler("OnMouseUp", PinOnMouseUp)
  5201. end
  5202. local pin
  5203. local pinSize = (ZOpinData[MAP_PIN_TYPE_RALLY_POINT].minSize / 3) * FyrMM.pScalePercent
  5204. if RallyPin.m_Pin then
  5205. pin = RallyPin.m_Pin
  5206. else
  5207. pin = ZO_Object.New(ZO_MapPin)
  5208. end
  5209. pin.m_PinType = MAP_PIN_TYPE_RALLY_POINT
  5210. pin.m_PinTag = "rally"
  5211. pin.nX = wpx
  5212. pin.nY = wpy
  5213. RallyPin.m_Pin = pin
  5214. RallyPin.MapId = CurrentMap.MapId
  5215. RallyPin.nX = wpx
  5216. RallyPin.nY = wpy
  5217. RallyPin.m_PinType = MAP_PIN_TYPE_RALLY_POINT
  5218. RallyPin:SetDrawLayer(1)
  5219. FyrMM.SetPinSize(RallyPin, pinSize, 0)
  5220. RallyPin:SetTexture("MiniMap/Textures/rally.dds")
  5221. RallyPin:SetHidden(false)
  5222. FyrMM.SetPinAnchor(RallyPin, wpx, wpy, Fyr_MM_Scroll_Map_Pins)
  5223. RallyPin:SetMouseEnabled(true)
  5224. FyrMM.Rally = RallyPin
  5225. FyrMM.IsRally = true
  5226. else
  5227. FyrMM.Rally = nil
  5228. FyrMM.IsRally = false
  5229. local RallyPin
  5230. RallyPin = GetControl("Fyr_MM_Scroll_Map_Pins_RallyPoint")
  5231. if RallyPin then
  5232. RallyPin.m_Pin = nil
  5233. RallyPin.MapId = 0
  5234. RallyPin.nX = 0
  5235. RallyPin.nY = 0
  5236. RallyPin.m_PinType = 0
  5237. RallyPin:SetTexture("")
  5238. RallyPin:SetHidden(true)
  5239. end
  5240. end
  5241. wpx, wpy = GetMapPing()
  5242. if wpx ~= 0 or wpy ~= 0 then
  5243. local PingPin
  5244. PingPin = GetControl("Fyr_MM_Scroll_Map_Pins_Ping")
  5245. if PingPin == nil then
  5246. PingPin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_Pins_Ping", Fyr_MM_Scroll_Map_Pins, CT_TEXTURE)
  5247. PingPin.nDistance = function(self)
  5248. if self.nX == nil then
  5249. return 1
  5250. end
  5251. return math.sqrt((zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nX * 10000)) *
  5252. (zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nX * 10000)) +
  5253. (zo_round(CurrentMap.PlayerNY * 10000) - zo_round(self.nY * 10000)) *
  5254. (zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nY * 10000))) / 10000
  5255. end
  5256. PingPin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  5257. PingPin:SetHandler("OnMouseExit", PinOnMouseExit)
  5258. PingPin:SetHandler("OnMouseUp", PinOnMouseUp)
  5259. end
  5260. local pin
  5261. local pinSize = ZOpinData[MAP_PIN_TYPE_PING].minSize * FyrMM.pScalePercent
  5262. if PingPin.m_Pin then
  5263. pin = PingPin.m_Pin
  5264. else
  5265. pin = ZO_Object.New(ZO_MapPin)
  5266. end
  5267. pin.m_PinType = MAP_PIN_TYPE_PING
  5268. pin.m_PinTag = "rally"
  5269. pin.nX = wpx
  5270. pin.nY = wpy
  5271. PingPin.m_Pin = pin
  5272. PingPin.MapId = CurrentMap.MapId
  5273. PingPin.nX = wpx
  5274. PingPin.nY = wpy
  5275. PingPin.m_PinType = MAP_PIN_TYPE_PING
  5276. PingPin:SetDrawLayer(1)
  5277. FyrMM.SetPinSize(PingPin, pinSize, 0)
  5278. PingPin:SetTexture("MiniMap/Textures/ping.dds")
  5279. PingPin:SetHidden(false)
  5280. FyrMM.SetPinAnchor(PingPin, wpx, wpy, Fyr_MM_Scroll_Map_Pins)
  5281. PingPin:SetMouseEnabled(true)
  5282. FyrMM.Ping = PingPin
  5283. FyrMM.IsPing = true
  5284. else
  5285. FyrMM.Ping = nil
  5286. FyrMM.IsPing = false
  5287. local PingPin
  5288. PingPin = GetControl("Fyr_MM_Scroll_Map_Pins_Ping")
  5289. if PingPin then
  5290. PingPin.m_Pin = nil
  5291. PingPin.MapId = 0
  5292. PingPin.nX = 0
  5293. PingPin.nY = 0
  5294. PingPin.m_PinType = 0
  5295. PingPin:SetTexture("")
  5296. PingPin:SetHidden(true)
  5297. end
  5298. end
  5299. end
  5300.  
  5301. ------------------------------------------------------------
  5302. -- Wayshrine Pins
  5303. -----------------------------------------------------------
  5304. function FyrMM.UpdateWayshrinePinPositions()
  5305. if not FyrMM.Visible or Fyr_MM:IsHidden() or FyrMM.worldMapShowing then
  5306. return
  5307. end
  5308. local currentZone = CurrentMap.MapId
  5309. for i = 1, FyrMM.currentWayshrineCount do
  5310. local l = GetControl("Fyr_MM_Scroll_Map_WayshrinePins_Pin" .. tostring(i))
  5311. if l ~= nil then
  5312. if l.MapId == currentZone then
  5313. l:SetHidden(not ZO_WorldMap_IsPinGroupShown(MAP_FILTER_WAYSHRINES))
  5314. FyrMM.SetPinAnchor(l, l.nX, l.nY, Fyr_MM_Scroll_Map_WayshrinePins)
  5315. else
  5316. l:SetHidden(true)
  5317. l:ClearAnchors()
  5318. end
  5319. end
  5320. end
  5321. end
  5322.  
  5323. local function CreateWayshrinePin(pinType, tag, nX, nY, isRealWayshrine)
  5324. local wayshrinePin
  5325. wayshrinePin = GetControl("Fyr_MM_Scroll_Map_WayshrinePins_Pin" .. tostring(FyrMM.currentWayshrineCount))
  5326. if wayshrinePin == nil then
  5327. wayshrinePin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_WayshrinePins_Pin" ..
  5328. tostring(FyrMM.currentWayshrineCount),
  5329. Fyr_MM_Scroll_Map_WayshrinePins, CT_TEXTURE)
  5330.  
  5331. wayshrinePin.nDistance = function(self)
  5332. if self.nX == nil then
  5333. return 1
  5334. end
  5335. return math.sqrt((zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nX * 10000)) *
  5336. (zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nX * 10000)) +
  5337. (zo_round(CurrentMap.PlayerNY * 10000) - zo_round(self.nY * 10000)) *
  5338. (zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nY * 10000))) / 10000
  5339. end
  5340. wayshrinePin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  5341. wayshrinePin:SetHandler("OnMouseExit", PinOnMouseExit)
  5342. wayshrinePin:SetHandler("OnMouseUp", PinOnMouseUp)
  5343. end
  5344. local pin = ZO_Object.New(ZO_MapPin)
  5345. local pinSize = 40 * FyrMM.pScalePercent * FyrMM.pinZoomScale
  5346. pin.m_PinType = pinType
  5347. pin.m_PinTag = tag
  5348. pin.nX = nX
  5349. pin.nY = nY
  5350. wayshrinePin.m_Pin = pin
  5351. wayshrinePin.MapId = CurrentMap.MapId
  5352. wayshrinePin.nX = nX
  5353. wayshrinePin.nY = nY
  5354. wayshrinePin.m_PinType = pinType
  5355. wayshrinePin:SetDrawLayer(1)
  5356. FyrMM.SetPinSize(wayshrinePin, pinSize, 0)
  5357. wayshrinePin:SetTexture(tag[2])
  5358. wayshrinePin.isRealWayshrine = isRealWayshrine
  5359.  
  5360. local wayshrinePinData = ZOpinData[pinType]
  5361. if wayshrinePinData.tint then -- compatibility with addons which modifies wayshrines colors
  5362. if type(wayshrinePinData.tint) ~= "function" then
  5363. wayshrinePin:SetColor(wayshrinePinData.tint:UnpackRGBA())
  5364. else
  5365. if wayshrinePin.m_Pin ~= nil then
  5366. wayshrinePin:SetColor(wayshrinePinData.tint(wayshrinePin.m_Pin):UnpackRGBA())
  5367. else
  5368. wayshrinePin:SetColor(wayshrinePinData.tint(wayshrinePin):UnpackRGBA())
  5369. end
  5370. end
  5371. else
  5372. wayshrinePin:SetColor(1, 1, 1, 1)
  5373. end
  5374.  
  5375. wayshrinePin:SetHidden(not ZO_WorldMap_IsPinGroupShown(MAP_FILTER_WAYSHRINES))
  5376. FyrMM.SetPinAnchor(wayshrinePin, nX, nY, Fyr_MM_Scroll_Map_WayshrinePins)
  5377. wayshrinePin:SetMouseEnabled(true)
  5378. Wayshrines[FyrMM.currentWayshrineCount] = {
  5379. Closest = false,
  5380. nDistance = 1,
  5381. tag = tag,
  5382. nX = nX,
  5383. nY = nY,
  5384. MapId = CurrentMap.MapId,
  5385. pin = wayshrinePin,
  5386. isRealWayshrine = isRealWayshrine
  5387. }
  5388. end
  5389.  
  5390. function FyrMM.Wayshrines()
  5391. if FyrMM.Halted or GetNumFastTravelNodes() == 0 then
  5392. return
  5393. end
  5394. if not FyrMM.Visible or Fyr_MM:IsHidden() or FyrMM.worldMapShowing then
  5395. return
  5396. end
  5397. local t = GetGameTimeMilliseconds()
  5398. FyrMM.SetMapToPlayerLocation()
  5399. FyrMM.currentWayshrineCount = 0
  5400. Wayshrines = {}
  5401. if string.lower(CurrentMap.filename) ~= "giantsrun_base_0" then
  5402. for nodeIndex = 1, GetNumFastTravelNodes() do
  5403. local known, name, nX, nY, icon, glowIcon, poiType, isShownInCurrentMap = GetFastTravelNodeInfo(nodeIndex)
  5404. if known or FyrMM.SV.ShowUnexploredPins then
  5405. local isRealWayshrine = false
  5406. if poiType == POI_TYPE_WAYSHRINE and isShownInCurrentMap then
  5407. isRealWayshrine = true
  5408. end -- and icon and string.find(icon, "wayshrine")
  5409. if not known and poiType ~= POI_TYPE_HOUSE and poiType ~= POI_TYPE_GROUP_DUNGEON then
  5410. icon = "/esoui/art/icons/poi/poi_wayshrine_incomplete.dds"
  5411. glowIcon = "/esoui/art/icons/poi/poi_wayshrine_glow.dds"
  5412. end
  5413. if not known and poiType == POI_TYPE_HOUSE then
  5414. icon = "/esoui/art/icons/poi/poi_group_house_unowned.dds"
  5415. glowIcon = "/esoui/art/icons/poi/poi_group_house_unowned_glow.dds"
  5416. end
  5417. if not known and poiType == POI_TYPE_GROUP_DUNGEON then
  5418. icon = "/esoui/art/icons/poi/poi_groupinstance_incomplete.dds"
  5419. glowIcon = "/esoui/art/icons/poi/poi_groupinstance_incomplete_glow.dds"
  5420. end
  5421. local tag = ZO_MapPin.CreateTravelNetworkPinTag(nodeIndex, icon, glowIcon)
  5422. local pinType = MAP_PIN_TYPE_FAST_TRAVEL_WAYSHRINE
  5423. if nX > 0 and nX < 1.0001 and nY > 0 and nY < 1.0001 and isShownInCurrentMap then
  5424. FyrMM.currentWayshrineCount = FyrMM.currentWayshrineCount + 1
  5425. CreateWayshrinePin(pinType, tag, nX, nY, isRealWayshrine)
  5426. end
  5427. end
  5428. end
  5429. end
  5430. if FyrMM.DebugMode then
  5431. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  5432. "FyrMM.Wayshrines (" .. tostring(GetNumFastTravelNodes()) .. ") " .. tostring(GetGameTimeMilliseconds() - t))
  5433. end
  5434. CleanupWayshrines()
  5435. end
  5436.  
  5437. ------------------------------------------------------------
  5438. -- POI Pins
  5439. ------------------------------------------------------------
  5440. function FyrMM.UpdatePOIPinPositions()
  5441. for i = 1, FyrMM.currentPOICount do
  5442. local l = GetControl("Fyr_MM_Scroll_Map_POIPins_Pin" .. tostring(i))
  5443. if l ~= nil then
  5444. if l.MapId == CurrentMap.MapId then
  5445. l:SetHidden(not ZO_WorldMap_IsPinGroupShown(MAP_FILTER_OBJECTIVES))
  5446. FyrMM.SetPinAnchor(l, l.nX, l.nY, Fyr_MM_Scroll_Map_POIPins)
  5447. else
  5448. l:SetHidden(true)
  5449. l:ClearAnchors()
  5450. end
  5451. end
  5452. end
  5453. end
  5454.  
  5455. local function CreatePOIPin(poiIndex)
  5456. local POIPin
  5457. local nX, nY, iconType, icon = MM_GetPOIMapInfo(CurrentMap.ZoneIndex, poiIndex)
  5458.  
  5459. if CraftingStations ~= nil and icon and zo_strfind(icon, "icons/poi/poi_crafting_") then
  5460. return
  5461. end -- Crafting stations mix-up fix by Garkin
  5462. if not (ZO_MapPin.POI_PIN_TYPES[iconType]) and FyrMM.SV.ShowUnexploredPins then
  5463. icon = "/esoui/art/inventory/newitem_icon.dds"
  5464. iconType = MAP_PIN_TYPE_POI_SEEN
  5465. end
  5466. if nX > 0 and nX < 1.0001 and nY > 0 and nY < 1.0001 and (ZO_MapPin.POI_PIN_TYPES[iconType]) then
  5467. if (not IsPOIWayshrine(CurrentMap.ZoneIndex, poiIndex) or iconType == MAP_PIN_TYPE_POI_SEEN) then
  5468. FyrMM.currentPOICount = FyrMM.currentPOICount + 1
  5469. local tag = ZO_MapPin.CreatePOIPinTag(CurrentMap.ZoneIndex, poiIndex, icon)
  5470. POIPin = GetControl("Fyr_MM_Scroll_Map_POIPins_Pin" .. tostring(FyrMM.currentPOICount))
  5471. if POIPin == nil then
  5472. POIPin = WINDOW_MANAGER:CreateControl(
  5473. "Fyr_MM_Scroll_Map_POIPins_Pin" .. tostring(FyrMM.currentPOICount), Fyr_MM_Scroll_Map_POIPins,
  5474. CT_TEXTURE)
  5475. POIPin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  5476. POIPin:SetHandler("OnMouseExit", PinOnMouseExit)
  5477. end
  5478. local pin = ZO_Object.New(ZO_MapPin)
  5479. local pinSize = 40 * FyrMM.pScalePercent * FyrMM.pinZoomScale
  5480. if icon == "/esoui/art/inventory/newitem_icon.dds" then
  5481. pinSize = 32 * FyrMM.pScalePercent * FyrMM.pinZoomScale
  5482. POIPin:SetColor(FyrMM.SV.UndiscoveredPOIPinColor.r, FyrMM.SV.UndiscoveredPOIPinColor.g,
  5483. FyrMM.SV.UndiscoveredPOIPinColor.b, FyrMM.SV.UndiscoveredPOIPinColor.a)
  5484. else
  5485. POIPin:SetColor(1, 1, 1, 1)
  5486. end
  5487. POIPin.poiIndex = poiIndex
  5488. pin.m_PinType = iconType
  5489. pin.m_PinTag = tag
  5490. POIPin.m_Pin = pin
  5491. POIPin.MapId = CurrentMap.MapId
  5492. POIPin.nX = nX
  5493. POIPin.nY = nY
  5494. POIPin.m_PinType = iconType
  5495. POIPin:SetDrawLayer(1)
  5496. FyrMM.SetPinSize(POIPin, pinSize, 0)
  5497. POIPin:SetTexture(icon)
  5498.  
  5499. local POIPinData = ZOpinData[iconType]
  5500. if POIPinData.tint then -- compatibility with addons which modifies POI colors
  5501. if type(POIPinData.tint) ~= "function" then
  5502. POIPin:SetColor(POIPinData.tint:UnpackRGBA())
  5503. else
  5504. if POIPin.m_Pin ~= nil then
  5505. POIPin:SetColor(POIPinData.tint(POIPin.m_Pin):UnpackRGBA())
  5506. else
  5507. POIPin:SetColor(POIPinData.tint(POIPin):UnpackRGBA())
  5508. end
  5509. end
  5510. else
  5511. POIPin:SetColor(1, 1, 1, 1)
  5512. end
  5513.  
  5514. POIPin:SetHidden(not ZO_WorldMap_IsPinGroupShown(MAP_FILTER_OBJECTIVES))
  5515. FyrMM.SetPinAnchor(POIPin, nX, nY, Fyr_MM_Scroll_Map_POIPins)
  5516. POIPin:SetMouseEnabled(true)
  5517. end
  5518. end
  5519. end
  5520.  
  5521. function FyrMM.POIPins()
  5522. if FyrMM.Halted or MM_GetNumPOIs(CurrentMap.ZoneIndex) == 0 then
  5523. return
  5524. end
  5525. local t = GetGameTimeMilliseconds()
  5526. FyrMM.currentPOICount = 0
  5527. FyrMM.API_Check()
  5528. FyrMM.SetMapToPlayerLocation()
  5529. if string.lower(CurrentMap.filename) ~= "giantsrun_base_0" then
  5530. for i = 1, MM_GetNumPOIs(CurrentMap.ZoneIndex) do
  5531. if FyrMM.Reloading then
  5532. return
  5533. end
  5534. CreatePOIPin(i)
  5535. end
  5536. end
  5537. if FyrMM.DebugMode then
  5538. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  5539. "FyrMM.POIPins (" .. tostring(MM_GetNumPOIs(CurrentMap.ZoneIndex)) .. ") " ..
  5540. tostring(GetGameTimeMilliseconds() - t))
  5541. end
  5542. if FyrMM.currentPOICount == 0 and Fyr_MM_Scroll_Map_POIPins:GetNumChildren() == CleanPOIs then
  5543. return
  5544. end
  5545. CleanPOIs = 0
  5546. CleanupPOIs()
  5547. -- EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapPOIPinsD")
  5548. end
  5549.  
  5550. local function DelayedPOIPins()
  5551. zo_callLater(FyrMM.POIPins, 300) -- WORKAROUND 18/07/2022
  5552. -- EVENT_MANAGER:RegisterForUpdate("FyrMiniMapPOIPinsD", 300, FyrMM.POIPins)
  5553. end
  5554. ------------------------------------------------------------
  5555. -- Location Pins
  5556. ------------------------------------------------------------
  5557.  
  5558. function FyrMM.UpdateLocationPinPositions()
  5559. if FyrMM.DebugMode then
  5560. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "MM_UpdateLocationPinPositions (" ..
  5561. tostring(FyrMM.currentLocationsCount) .. ") ")
  5562. end
  5563. for i = 1, FyrMM.currentLocationsCount do
  5564. local l = GetControl("Fyr_MM_Scroll_Map_LocationPins_Pin" .. tostring(i))
  5565. if l ~= nil then
  5566. if l.MapId == CurrentMap.MapId then
  5567. if FyrMM.SV.ShowUnexploredPins then
  5568. l:SetHidden(false)
  5569. else
  5570. if l:IsHidden() then
  5571. l:SetHidden(not MM_IsMapLocationVisible(i))
  5572. end
  5573. end
  5574. FyrMM.SetPinAnchor(l, l.nX, l.nY, Fyr_MM_Scroll_Map_LocationPins)
  5575. else
  5576. l:SetHidden(true)
  5577. l:ClearAnchors()
  5578. end
  5579. end
  5580. end
  5581. end
  5582.  
  5583. local function AddLocation(locationIndex)
  5584. local locationPin, isExperienceBoost
  5585. local ll = GetNumMapLocationTooltipLines(locationIndex)
  5586. if ll >= 1 then
  5587. local c1, c2, c3, cN = GetMapLocationTooltipLineInfo(locationIndex, 1)
  5588. if cN == "Experience Boost" then
  5589. return
  5590. end
  5591. end
  5592. if (MM_IsMapLocationVisible(locationIndex) or FyrMM.SV.ShowUnexploredPins) then
  5593. local icon, x, y = MM_GetMapLocationIcon(locationIndex)
  5594. if icon ~= "" and x > 0 and x < 1.0001 and y > 0 and y < 1.0001 then
  5595. FyrMM.currentLocationsCount = FyrMM.currentLocationsCount + 1
  5596. local tag = ZO_MapPin.CreateLocationPinTag(locationIndex, icon)
  5597. locationPin = GetControl("Fyr_MM_Scroll_Map_LocationPins_Pin" .. tostring(FyrMM.currentLocationsCount))
  5598. if locationPin == nil then
  5599. locationPin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_LocationPins_Pin" ..
  5600. tostring(FyrMM.currentLocationsCount),
  5601. Fyr_MM_Scroll_Map_LocationPins, CT_TEXTURE)
  5602. locationPin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  5603. locationPin:SetHandler("OnMouseExit", PinOnMouseExit)
  5604. end
  5605.  
  5606. local pinSize = 36 * FyrMM.pScalePercent * FyrMM.pinZoomScale
  5607. local pin = ZO_Object.New(ZO_MapPin)
  5608. locationPin.locationIndex = locationIndex
  5609. pin.m_PinType = MAP_PIN_TYPE_LOCATION
  5610. pin.m_PinTag = tag
  5611. locationPin.m_Pin = pin
  5612. locationPin.m_PinType = MAP_PIN_TYPE_LOCATION
  5613. locationPin.m_PinTag = tag
  5614. locationPin.MapId = CurrentMap.MapId
  5615. locationPin.nX = x
  5616. locationPin.nY = y
  5617. FyrMM.SetPinSize(locationPin, pinSize, 0)
  5618. locationPin:SetDrawLayer(1)
  5619. locationPin:SetTexture(icon)
  5620. locationPin.IsCraftingServicePin = IsCraftingService(locationPin)
  5621. if tag[2] ~= nil then
  5622. if string.sub(tag[2], -8) == "bank.dds" then
  5623. locationPin.IsBankPin = true
  5624. else
  5625. locationPin.IsBankPin = false
  5626. end
  5627. if string.sub(tag[2], -10) == "stable.dds" then
  5628. locationPin.IsStablePin = true
  5629. else
  5630. locationPin.IsStablePin = false
  5631. end
  5632. end
  5633. if string.sub(icon, 1, 5) ~= "ZGESO" then -- string.sub(icon, 1, 17) ~= "ZygorGuidesViewer"
  5634. if FyrMM.SV.ShowUnexploredPins then
  5635. locationPin:SetHidden(false)
  5636. else
  5637. if locationPin:IsHidden() then
  5638. locationPin:SetHidden(not MM_IsMapLocationVisible(i))
  5639. end
  5640. end
  5641. else
  5642. locationPin:SetHidden(false)
  5643. locationPin.isZGESO = true
  5644. end
  5645.  
  5646. local locationPinData = ZOpinData[locationPin.m_PinType]
  5647. if locationPinData.tint then -- compatibility with addons which modifies locations colors
  5648. if type(locationPinData.tint) ~= "function" then
  5649. locationPin:SetColor(locationPinData.tint:UnpackRGBA())
  5650. else
  5651. if locationPin.m_Pin ~= nil then
  5652. locationPin:SetColor(locationPinData.tint(locationPin.m_Pin):UnpackRGBA())
  5653. else
  5654. locationPin:SetColor(locationPinData.tint(locationPin):UnpackRGBA())
  5655. end
  5656. end
  5657. else
  5658. locationPin:SetColor(1, 1, 1, 1)
  5659. end
  5660.  
  5661. FyrMM.SetPinAnchor(locationPin, x, y, Fyr_MM_Scroll_Map_LocationPins)
  5662. locationPin:SetMouseEnabled(true)
  5663. end
  5664. end
  5665. end
  5666.  
  5667. function FyrMM.LocationPins()
  5668. if FyrMM.Halted or MM_GetNumMapLocations() == 0 then
  5669. return
  5670. end -- delay if still halted
  5671. local t = GetGameTimeMilliseconds()
  5672. FyrMM.currentLocationsCount = 0
  5673. FyrMM.API_Check()
  5674. FyrMM.SetMapToPlayerLocation()
  5675. if string.lower(CurrentMap.filename) ~= "giantsrun_base_0" then
  5676. for i = 1, MM_GetNumMapLocations() do
  5677. if FyrMM.Reloading then
  5678. return
  5679. end
  5680. AddLocation(i)
  5681. end
  5682. end
  5683. if FyrMM.DebugMode then
  5684. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  5685. "FyrMM.LocationPins (" .. tostring(MM_GetNumMapLocations()) .. ") " ..
  5686. tostring(GetGameTimeMilliseconds() - t))
  5687. end
  5688. CleanupMapLocations()
  5689. end
  5690.  
  5691. ------------------------------------------------------------
  5692. -- Event Units (Dragons, Cartoklepts)
  5693. ------------------------------------------------------------
  5694. local function RemoveEventUnitPins()
  5695. local num = Fyr_MM_Scroll_Map_EventUnits:GetNumChildren()
  5696. local i, pin
  5697. for i = 1, num do
  5698. pin = Fyr_MM_Scroll_Map_EventUnits:GetChild(i)
  5699. if pin ~= nil then
  5700. pin:SetHidden(true)
  5701. pin:SetMouseEnabled(false)
  5702. pin:ClearAnchors()
  5703. pin.nX = nil
  5704. pin.nY = nil
  5705. pin.unitTag = nil
  5706. pin.nTag = nil
  5707. pin.context = nil
  5708. pin.m_PinType = nil
  5709. if pin.textureAntl then
  5710. pin.textureAntl:Stop()
  5711. pin.textureAntl = nil
  5712. end
  5713. if pin.OnBorder then
  5714. if pin.BorderPin then
  5715. if pin.BorderPin.textureAntl then
  5716. pin.BorderPin.textureAntl:Stop()
  5717. pin.BorderPin.textureAntl = nil
  5718. end
  5719. pin.BorderPin:ClearAnchors()
  5720. pin.BorderPin:SetHidden()
  5721. pin.BorderPin.pin = nil
  5722. pin.BorderPin = nil
  5723. end
  5724. pin.OnBorder = nil
  5725. end
  5726. end
  5727. end
  5728. end
  5729.  
  5730. local function GetNextWorldEventInstanceIdIter(state, var1)
  5731. return GetNextWorldEventInstanceId(var1)
  5732. end
  5733.  
  5734. local function AddWorldEvent(worldEventInstanceId)
  5735. if ZO_WorldMap_DoesMapHideWorldEventPins() then
  5736. return
  5737. end
  5738.  
  5739. local context = GetWorldEventLocationContext(worldEventInstanceId)
  5740. if context == WORLD_EVENT_LOCATION_CONTEXT_UNIT then
  5741. local numUnits = GetNumWorldEventInstanceUnits(worldEventInstanceId)
  5742. for i = 1, numUnits do
  5743. local unitTag = GetWorldEventInstanceUnitTag(worldEventInstanceId, i)
  5744. local pinType = GetWorldEventInstanceUnitPinType(worldEventInstanceId, unitTag)
  5745. local zoneIndex, poiIndex = GetWorldEventPOIInfo(worldEventInstanceId)
  5746.  
  5747. local pin
  5748. if pinType ~= MAP_PIN_TYPE_INVALID then
  5749. local xLoc, yLoc, _, isInCurrentMap = GetMapPlayerPosition(unitTag)
  5750. if isInCurrentMap then
  5751. local tag = ZO_MapPin.CreateWorldEventUnitPinTag(worldEventInstanceId, unitTag)
  5752. if GetControl("Fyr_MM_Scroll_Map_EventUnits_" .. unitTag) == nil then
  5753. pin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_EventUnits_" .. unitTag,
  5754. Fyr_MM_Scroll_Map_EventUnits, CT_TEXTURE)
  5755. pin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  5756. pin:SetHandler("OnMouseExit", PinOnMouseExit)
  5757. end
  5758. FyrMM.SetEventPin(pinType, unitTag, tag, context)
  5759. end
  5760. end
  5761. end
  5762. elseif context == WORLD_EVENT_LOCATION_CONTEXT_POINT_OF_INTEREST then
  5763. local zoneIndex, poiIndex = GetWorldEventPOIInfo(worldEventInstanceId)
  5764. local nX, nY, pinType, icon, isOnMap, _, discovered, nearby = MM_GetPOIMapInfo(CurrentMap.ZoneIndex, poiIndex)
  5765.  
  5766. local tag = ZO_MapPin.CreateWorldEventPOIPinTag(worldEventInstanceId, CurrentMap.ZoneIndex, poiIndex)
  5767. local pin
  5768.  
  5769. if pinType ~= MAP_PIN_TYPE_INVALID and isOnMap then
  5770. if GetControl("Fyr_MM_Scroll_Map_EventPOIs_" .. poiIndex) == nil then
  5771. pin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_EventPOIs_" .. poiIndex,
  5772. Fyr_MM_Scroll_Map_EventUnits, CT_TEXTURE)
  5773. pin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  5774. pin:SetHandler("OnMouseExit", PinOnMouseExit)
  5775. end
  5776. FyrMM.SetEventPOIPin(pinType, tag, poiIndex, context)
  5777. end
  5778. end
  5779. end
  5780.  
  5781. function FyrMM.SetEventPin(pinType, tag, ntag, context) -- moving world events (dragons, cartoklepts)
  5782. local pin, nX, nY
  5783. local pdata = ZO_MapPin.PIN_DATA[pinType]
  5784. local isDead = IsUnitDead(tag)
  5785. pin = GetControl("Fyr_MM_Scroll_Map_EventUnits_" .. tag)
  5786.  
  5787. if not (DoesUnitExist(tag) and not AreUnitsEqual("player", tag)) then
  5788. if pin ~= nil then
  5789. pin:SetHidden(true)
  5790. pin:SetMouseEnabled(false)
  5791. pin:ClearAnchors()
  5792. pin.nX = nil
  5793. pin.nY = nil
  5794. pin.unitTag = nil
  5795. pin.nTag = nil
  5796. pin.m_PinType = nil
  5797. pin.context = nil
  5798. if pin.textureAntl then
  5799. pin.textureAntl:Stop()
  5800. pin.textureAntl = nil
  5801. end
  5802. if pin.OnBorder then
  5803. if pin.BorderPin then
  5804. if pin.BorderPin.textureAntl then
  5805. pin.BorderPin.textureAntl:Stop()
  5806. pin.BorderPin.textureAntl = nil
  5807. end
  5808. pin.BorderPin:ClearAnchors()
  5809. pin.BorderPin:SetHidden()
  5810. pin.BorderPin.pin = nil
  5811. pin.BorderPin = nil
  5812. end
  5813. pin.OnBorder = nil
  5814. end
  5815. end
  5816. return
  5817. end
  5818.  
  5819. if pin == nil then
  5820. return
  5821. end
  5822. nX, nY = GetMapPlayerPosition(tag)
  5823. pin.m_PinType = pinType
  5824. local distance = CurrentMap.TrueMapSize *
  5825. math.sqrt(
  5826. (nX - CurrentMap.PlayerNX) * (nX - CurrentMap.PlayerNX) + (nY - CurrentMap.PlayerNY) *
  5827. (nY - CurrentMap.PlayerNY))
  5828.  
  5829. local texturetest = GetWorldEventInstanceUnitPinIcon(ntag[1], tag, false) or "not"
  5830.  
  5831. local texture = "esoui/art/icons/mapkey/mapkey_dragon.dds"
  5832.  
  5833. if string.find(texturetest, "dragon") then -- It's a dragon!
  5834. texture = "esoui/art/icons/mapkey/mapkey_dragon.dds" -- /esoui/art/mappins/dragon_fly.dds
  5835. elseif string.find(texturetest, "cartoklept") then -- it's a cartoklept!
  5836. texture = "esoui/art/compass/compass_cartoklept.dds"
  5837. end
  5838.  
  5839. pin:SetTexture(texture)
  5840. pin.pinTexture = texture
  5841.  
  5842. local pinsize = pdata.size
  5843. if pinsize == nil then
  5844. pinsize = 32
  5845. end
  5846.  
  5847. FyrMM.SetPinSize(pin, pinsize * FyrMM.pScalePercent, 0)
  5848. pin.nX = nX
  5849. pin.nY = nY
  5850. pin.unitTag = tag
  5851. pin.nTag = ntag
  5852. pin.context = context
  5853. pin.weDistance = distance
  5854. pin.noZoomResize = true
  5855. pin:SetDrawLayer(3)
  5856. pin:SetMouseEnabled(true)
  5857. FyrMM.SetPinAnchor(pin, nX, nY, Fyr_MM_Scroll_Map_EventUnits)
  5858.  
  5859. if IsUnitInCombat(tag) then
  5860. FyrMM.CheapAnimation(pin)
  5861. pin:SetColor(1, 0, 0, 1)
  5862. pin.m_textureAnimTimeline = "yes"
  5863. else
  5864. pin:SetColor(1, 1, 1, 1)
  5865. pin:SetTransformRotationZ(0)
  5866. pin.m_textureAnimTimeline = nil
  5867. end
  5868.  
  5869. -- if pdata.isAnimated then
  5870. -- --pin:PlayTextureAnimation(pdata.framesWide, pdata.framesHigh, pdata.framesPerSecond)
  5871. -- --pin:StopTextureAnimation()
  5872.  
  5873. -- if not pin.textureAntl then
  5874. -- local an
  5875. -- an, pin.textureAntl = CreateSimpleAnimation(ANIMATION_TEXTURE, pin)
  5876. -- an:SetHandler("OnStop", function() pin:SetTextureCoords(0, 1, 0, 1) end)
  5877. -- end
  5878. -- local anim = pin.textureAntl:GetAnimation(1)
  5879. -- anim:SetImageData(pdata.framesWide, pdata.framesHigh)
  5880. -- anim:SetFramerate(pdata.framesPerSecond)
  5881. -- pin.textureAntl:SetPlaybackType(ANIMATION_PLAYBACK_LOOP, LOOP_INDEFINITELY)
  5882. -- pin.textureAntl:PlayFromStart()
  5883. -- end
  5884.  
  5885. if FyrMM.SV.WheelMap then
  5886. pin:SetHidden(not Is_PinInsideWheel(pin))
  5887. else
  5888. pin:SetHidden(false)
  5889. end
  5890.  
  5891. if FyrMM.IsValidBorderPin(pin) then
  5892. FyrMM.CreateBorderPin(pin)
  5893. end
  5894. end
  5895.  
  5896. function FyrMM.SetEventPOIPin(pinType, tag, poiIndex, context) -- world events (dolmens, harrow storms etc)
  5897. local pin
  5898. local pdata = ZO_MapPin.PIN_DATA[pinType]
  5899.  
  5900. pin = GetControl("Fyr_MM_Scroll_Map_EventPOIs_" .. poiIndex)
  5901.  
  5902. if pin == nil then
  5903. return
  5904. end
  5905. local nX, nY, pinType, icon, isOnMap, _, discovered, nearby = MM_GetPOIMapInfo(GetCurrentMapZoneIndex(), poiIndex)
  5906.  
  5907. local distance = CurrentMap.TrueMapSize *
  5908. math.sqrt(
  5909. (nX - CurrentMap.PlayerNX) * (nX - CurrentMap.PlayerNX) + (nY - CurrentMap.PlayerNY) *
  5910. (nY - CurrentMap.PlayerNY))
  5911.  
  5912. if not isOnMap then
  5913. if pin ~= nil then
  5914. pin:SetHidden(true)
  5915. pin:SetMouseEnabled(false)
  5916. pin:ClearAnchors()
  5917. pin.nX = nil
  5918. pin.nY = nil
  5919. pin.unitTag = nil
  5920. pin.nTag = nil
  5921. pin.m_PinType = nil
  5922. pin.context = nil
  5923. if pin.textureAntl then
  5924. pin.textureAntl:Stop()
  5925. pin.textureAntl = nil
  5926. end
  5927. if pin.OnBorder then
  5928. if pin.BorderPin then
  5929. if pin.BorderPin.textureAntl then
  5930. pin.BorderPin.textureAntl:Stop()
  5931. pin.BorderPin.textureAntl = nil
  5932. end
  5933. pin.BorderPin:ClearAnchors()
  5934. pin.BorderPin:SetHidden()
  5935. pin.BorderPin.pin = nil
  5936. pin.BorderPin = nil
  5937. end
  5938. pin.OnBorder = nil
  5939. end
  5940. end
  5941. return
  5942. end
  5943.  
  5944. pin.m_PinType = pinType
  5945.  
  5946. -- if pin.m_PinType == MAP_PIN_TYPE_POI_COMPLETE then
  5947. -- pin:SetTexture("EsoUI/Art/MapPins/worldEvent_poi_active_complete.dds")
  5948. -- elseif pin.m_PinType == MAP_PIN_TYPE_POI_SEEN then
  5949. -- pin:SetTexture("EsoUI/Art/MapPins/worldEvent_poi_active_incomplete.dds")
  5950. -- end
  5951.  
  5952. local texture = "esoui/art/zonestories/completiontypeicon_worldevents.dds"
  5953. pin:SetTexture(texture)
  5954. pin.pinTexture = texture
  5955.  
  5956. pin:SetColor(1, 1, 1, 1)
  5957. local pinsize = pdata.size
  5958. if pinsize == nil then
  5959. pinsize = 32
  5960. end
  5961. FyrMM.SetPinSize(pin, pinsize * FyrMM.pScalePercent, 0)
  5962. pin.nX = nX
  5963. pin.nY = nY
  5964. pin.unitTag = tag
  5965. pin.nTag = tag
  5966. pin.context = context
  5967. pin.weDistance = distance
  5968. pin:SetDrawLayer(3)
  5969. pin:SetMouseEnabled(true)
  5970. FyrMM.SetPinAnchor(pin, nX, nY, Fyr_MM_Scroll_Map_EventUnits)
  5971.  
  5972. FyrMM.CheapAnimation(pin, true)
  5973. pin.m_textureAnimTimeline = "yes"
  5974.  
  5975. -- if pdata.isAnimated then
  5976. -- --pin:PlayTextureAnimation(pdata.framesWide, pdata.framesHigh, pdata.framesPerSecond)
  5977. -- --pin:StopTextureAnimation()
  5978. -- if not pin.textureAntl then
  5979. -- local an
  5980. -- an, pin.textureAntl = CreateSimpleAnimation(ANIMATION_TEXTURE, pin)
  5981. -- an:SetHandler("OnStop", function() pin:SetTextureCoords(0, 1, 0, 1) end)
  5982. -- end
  5983. -- local anim = pin.textureAntl:GetAnimation(1)
  5984. -- anim:SetImageData(pdata.framesWide, pdata.framesHigh)
  5985. -- anim:SetFramerate(pdata.framesPerSecond)
  5986. -- pin.textureAntl:SetPlaybackType(ANIMATION_PLAYBACK_LOOP, LOOP_INDEFINITELY)
  5987. -- pin.textureAntl:PlayFromStart()
  5988. -- end
  5989.  
  5990. if FyrMM.SV.WheelMap then
  5991. pin:SetHidden(not Is_PinInsideWheel(pin))
  5992. else
  5993. pin:SetHidden(false)
  5994. end
  5995.  
  5996. if FyrMM.IsValidBorderPin(pin) then
  5997. FyrMM.CreateBorderPin(pin)
  5998. end
  5999. end
  6000.  
  6001. function FyrMM.RefreshEventUnits()
  6002. RemoveEventUnitPins()
  6003. for worldEventInstanceId in GetNextWorldEventInstanceIdIter do
  6004. AddWorldEvent(worldEventInstanceId)
  6005. end
  6006. end
  6007.  
  6008. function FyrMM.CheapAnimation(pin, rotate) -- added by @Masteroshi430
  6009. local pinsize = 64
  6010. local pinsizeMax = pinsize + 8
  6011. local pinsizeMin = pinsize - 8
  6012.  
  6013. if FyrMM.animatedPinSize then
  6014. if FyrMM.animatedPinSize == pinsizeMax then
  6015. FyrMM.goDown = true
  6016.  
  6017. FyrMM.animatedPinSize = FyrMM.animatedPinSize - 1
  6018. elseif FyrMM.animatedPinSize == pinsizeMin then
  6019. FyrMM.goDown = false
  6020. FyrMM.animatedPinSize = FyrMM.animatedPinSize + 1
  6021. elseif FyrMM.animatedPinSize > pinsizeMin and FyrMM.goDown == true then
  6022. FyrMM.animatedPinSize = FyrMM.animatedPinSize - 1
  6023. elseif FyrMM.animatedPinSize < pinsizeMax then
  6024. FyrMM.animatedPinSize = FyrMM.animatedPinSize + 1
  6025. end
  6026. else
  6027. FyrMM.animatedPinSize = pinsizeMax
  6028. end
  6029.  
  6030. if rotate then
  6031. if not FyrMM.radians then
  6032. FyrMM.radians = 0
  6033. end
  6034. FyrMM.radians = math.min(pi * 2, FyrMM.radians + 0.1)
  6035. if FyrMM.radians == pi * 2 then
  6036. FyrMM.radians = 0
  6037. end
  6038. pin:SetTransformRotationZ(FyrMM.radians)
  6039. else
  6040. pin:SetTransformRotationZ(0)
  6041. end
  6042.  
  6043. local properSize = math.floor(FyrMM.animatedPinSize * FyrMM.pScalePercent / 2) * 2
  6044. pin:SetDimensions(properSize, properSize)
  6045. end
  6046.  
  6047. ------------------------------------------------------------
  6048. -- Group Pins
  6049. ------------------------------------------------------------
  6050. function FyrMM.GroupEvent()
  6051. FyrMM.GroupRefreshNeeded = true
  6052. FyrMM.RefreshGroup()
  6053. end
  6054.  
  6055. function FyrMM.SetGroupPinTexture(gmPin, odyTexture)
  6056. local Multiplier = 1
  6057. local gmPinTexture = ""
  6058. if gmPin.unitTag == "companion" then
  6059. gmPinTexture = "EsoUI/Art/MapPins/activeCompanion_pin.dds"
  6060. if odyTexture then
  6061. gmPinTexture = odyTexture
  6062. end
  6063.  
  6064. if gmPin.isMounted then
  6065. gmPinTexture = "MiniMap/Textures/mountedMember.dds"
  6066. Multiplier = 1.25
  6067. elseif gmPin.isStealthed then
  6068. gmPinTexture = "MiniMap/Textures/stealthed.dds"
  6069. Multiplier = 0.1
  6070. elseif gmPin.isSwimming then -- in case companions are able to swim in the future
  6071. gmPinTexture = "MiniMap/Textures/swimming.dds"
  6072. Multiplier = 0.1
  6073. end
  6074. FyrMM.SetPinSize(gmPin, FyrMM.SV.MemberPinSize * FyrMM.pScalePercent * Multiplier, 0)
  6075. else
  6076. if gmPin.isLeader then
  6077. if FyrMM.SV.LeaderPin == "Default" then
  6078. gmPinTexture = "EsoUI/Art/Compass/groupLeader.dds"
  6079. elseif FyrMM.SV.LeaderPin == "Class" then
  6080. gmPinTexture = GetClassIcon(gmPin.ClassId)
  6081. elseif gmPin.isDps then
  6082. gmPinTexture = "EsoUI/Art/LFG/LFG_dps_down.dds"
  6083. elseif gmPin.isHeal then
  6084. gmPinTexture = "EsoUI/Art/LFG/LFG_healer_down.dds"
  6085. elseif gmPin.isTank then
  6086. gmPinTexture = "EsoUI/Art/LFG/LFG_tank_down.dds"
  6087. else
  6088. gmPinTexture = "EsoUI/Art/Compass/groupLeader.dds"
  6089. end
  6090.  
  6091. if odyTexture then
  6092. gmPinTexture = odyTexture
  6093. end
  6094. if FyrMM.GetTargetMarkerPicture(gmPin.unitTag) then
  6095. gmPinTexture = FyrMM.GetTargetMarkerPicture(gmPin.unitTag)
  6096. Multiplier = 0.5
  6097. end
  6098.  
  6099. if gmPin.isMounted and not gmPin.engaged then
  6100. gmPinTexture = "MiniMap/Textures/mountedLeader.dds"
  6101. Multiplier = 1.5
  6102. elseif gmPin.isStealthed and not gmPin.engaged then
  6103. gmPinTexture = "MiniMap/Textures/stealthed.dds"
  6104. Multiplier = 0.1
  6105. elseif gmPin.isSwimming and not gmPin.engaged then
  6106. gmPinTexture = "MiniMap/Textures/swimming.dds"
  6107. Multiplier = 0.1
  6108. end
  6109.  
  6110. if gmPin.isBreadcrumb then
  6111. gmPinTexture = "EsoUI/Art/Compass/groupLeader_door.dds"
  6112. end
  6113.  
  6114. FyrMM.SetPinSize(gmPin, FyrMM.SV.LeaderPinSize * FyrMM.pScalePercent * Multiplier, 0)
  6115. else
  6116. if FyrMM.SV.MemberPin == "Default" then
  6117. gmPinTexture =
  6118. "EsoUI/Art/MapPins/UI-WorldMapGroupPip.dds" -- "esoui/art/icons/mapkey/mapkey_groupmember.dds"
  6119. elseif FyrMM.SV.MemberPin == "Class" then
  6120. gmPinTexture = GetClassIcon(gmPin.ClassId)
  6121. elseif gmPin.isDps then
  6122. gmPinTexture = "EsoUI/Art/LFG/LFG_dps_down.dds"
  6123. elseif gmPin.isHeal then
  6124. gmPinTexture = "EsoUI/Art/LFG/LFG_healer_down.dds"
  6125. elseif gmPin.isTank then
  6126. gmPinTexture = "EsoUI/Art/LFG/LFG_tank_down.dds"
  6127. else
  6128. gmPinTexture =
  6129. "EsoUI/Art/MapPins/UI-WorldMapGroupPip.dds" -- "esoui/art/icons/mapkey/mapkey_groupmember.dds"
  6130. end
  6131.  
  6132. if odyTexture then
  6133. gmPinTexture = odyTexture
  6134. end
  6135. if FyrMM.GetTargetMarkerPicture(gmPin.unitTag) then
  6136. gmPinTexture = FyrMM.GetTargetMarkerPicture(gmPin.unitTag)
  6137. Multiplier = 0.5
  6138. end
  6139.  
  6140. if gmPin.isMounted and not gmPin.engaged then
  6141. gmPinTexture = "MiniMap/Textures/mountedMember.dds"
  6142. Multiplier = 1.5
  6143. elseif gmPin.isStealthed and not gmPin.engaged then
  6144. gmPinTexture = "MiniMap/Textures/stealthed.dds"
  6145. Multiplier = 0.1
  6146. elseif gmPin.isSwimming and not gmPin.engaged then
  6147. gmPinTexture = "MiniMap/Textures/swimming.dds"
  6148. Multiplier = 0.1
  6149. end
  6150.  
  6151. if gmPin.isBreadcrumb then
  6152. gmPinTexture = "esoui/art/compass/groupmember_door.dds"
  6153. end
  6154.  
  6155. FyrMM.SetPinSize(gmPin, FyrMM.SV.MemberPinSize * FyrMM.pScalePercent * Multiplier, 0)
  6156. end
  6157. end
  6158. gmPin:SetTexture(gmPinTexture)
  6159. gmPin.pinTexture = gmPinTexture -- we set that here to avoid resetting it for borderpins
  6160. end
  6161.  
  6162. function FyrMM.GetTargetMarkerPicture(tag)
  6163. if not FyrMM.SV.GroupTargetMarkers then
  6164. return nil
  6165. end
  6166.  
  6167. local targetMarkerTexture = {
  6168. [TARGET_MARKER_TYPE_ONE] = "EsoUI/Art/TargetMarkers/Target_Blue_Square_64.dds",
  6169. [TARGET_MARKER_TYPE_TWO] = "EsoUI/Art/TargetMarkers/Target_Gold_Star_64.dds",
  6170. [TARGET_MARKER_TYPE_THREE] = "EsoUI/Art/TargetMarkers/Target_Green_Circle_64.dds",
  6171. [TARGET_MARKER_TYPE_FOUR] = "EsoUI/Art/TargetMarkers/Target_Orange_Triangle_64.dds",
  6172. [TARGET_MARKER_TYPE_FIVE] = "EsoUI/Art/TargetMarkers/Target_Pink_Moons_64.dds",
  6173. [TARGET_MARKER_TYPE_SIX] = "EsoUI/Art/TargetMarkers/Target_Purple_Oblivion_64.dds",
  6174. [TARGET_MARKER_TYPE_SEVEN] = "EsoUI/Art/TargetMarkers/Target_Red_Weapons_64.dds",
  6175. [TARGET_MARKER_TYPE_EIGHT] = "EsoUI/Art/TargetMarkers/Target_White_Skull_64.dds",
  6176. }
  6177.  
  6178. return targetMarkerTexture[GetUnitTargetMarkerType(tag)]
  6179. end
  6180.  
  6181. function FyrMM.SetGroupPin(tag)
  6182. local pin, pin_ic, text, nX, nY
  6183. local isDps, isHeal, isTank = GetGroupMemberRoles(tag)
  6184. local isDead = IsUnitDead(tag)
  6185. pin = GetControl("Fyr_MM_Scroll_Map_GroupPins_" .. tag)
  6186. pin_ic = GetControl("Fyr_MM_Scroll_Map_GroupPins_" .. tag .. "_incombat")
  6187. text = GetControl("Fyr_MM_Scroll_Map_GroupPins_" .. tag .. "_label")
  6188. if not (DoesUnitExist(tag) and not AreUnitsEqual("player", tag) and IsUnitOnline(tag)) then
  6189. if pin ~= nil then
  6190. pin:SetHidden(true)
  6191. pin:SetMouseEnabled(false)
  6192. pin:ClearAnchors()
  6193. pin.isDps = nil
  6194. pin.isHeal = nil
  6195. pin.isTank = nil
  6196. pin.ClassId = nil
  6197. pin.isLeader = nil
  6198. pin.nX = nil
  6199. pin.nY = nil
  6200. pin_ic.nX = nil
  6201. pin_ic.nY = nil
  6202. pin_ic:SetHidden(true)
  6203. pin_ic:ClearAnchors()
  6204. PinsList["Fyr_MM_Scroll_Map_GroupPins_" .. tag] = nil
  6205. PinsList["Fyr_MM_Scroll_Map_GroupPins_" .. tag .. "_incombat"] = nil
  6206. if pin.OnBorder then
  6207. if pin.BorderPin then
  6208. pin.BorderPin:ClearAnchors()
  6209. pin.BorderPin:SetHidden()
  6210. pin.BorderPin.pin = nil
  6211. pin.BorderPin = nil
  6212. end
  6213. pin.OnBorder = nil
  6214. end
  6215. end
  6216. return
  6217. end
  6218.  
  6219. if pin == nil then
  6220. return
  6221. end
  6222. nX, nY, _, isInCurrentMap = GetMapPlayerPosition(tag)
  6223. pin.isDps = isDps
  6224. pin.isHeal = isHeal
  6225. pin.isTank = isTank
  6226. pin.isLeader = IsUnitGroupLeader(tag)
  6227. pin.isBreadcrumb = false
  6228. pin.isMounted = GetTargetMountedStateInfo(GetRawUnitName(tag)) ~= MOUNTED_STATE_NOT_MOUNTED
  6229. pin.isStealthed = GetUnitStealthState(tag) ~= STEALTH_STATE_NONE
  6230. pin.isSwimming = IsUnitSwimming(tag)
  6231.  
  6232. if DoesUnitExist(tag) and not AreUnitsEqual("player", tag) and IsUnitOnline(tag) then
  6233. local isGroupMemberHiddenByInstance = false
  6234. -- If we're in an instance and it has its own map, it's going to be a dungeon map or house. Don't show on the map if we're on different instances/layers
  6235. -- If it doesn't have its own map, we're okay to show the group member regardless of instance
  6236. if DoesCurrentMapMatchMapForPlayerLocation() and IsGroupMemberInSameWorldAsPlayer(tag) and
  6237. (GetMapContentType() == MAP_CONTENT_DUNGEON or GetCurrentZoneHouseId() ~= 0) then
  6238. if not IsGroupMemberInSameInstanceAsPlayer(tag) then
  6239. -- We're in the same world as the group member, but a different instance
  6240. isGroupMemberHiddenByInstance = true
  6241. elseif not IsGroupMemberInSameLayerAsPlayer(tag) then
  6242. -- We're in the same instance as the group member, but a different layer
  6243. isGroupMemberHiddenByInstance = not IsUnitWorldMapPositionBreadcrumbed(tag)
  6244. end
  6245. end
  6246.  
  6247. if not isGroupMemberHiddenByInstance then
  6248. if isInCurrentMap then
  6249. if IsUnitWorldMapPositionBreadcrumbed(tag) then
  6250. pin.isBreadcrumb = true
  6251. end
  6252. end
  6253. end
  6254. end
  6255.  
  6256. if pin.isLeader then
  6257. pin.m_PinType = MAP_PIN_TYPE_GROUP_LEADER
  6258. if FyrMM.SV.LeaderPinColor ~= nil and FyrMM.SV.LeaderDeadPinColor ~= nil then
  6259. if isDead then
  6260. pin:SetColor(FyrMM.SV.LeaderDeadPinColor.r, FyrMM.SV.LeaderDeadPinColor.g,
  6261. FyrMM.SV.LeaderDeadPinColor.b, FyrMM.SV.LeaderDeadPinColor.a)
  6262. text:SetColor(255 - FyrMM.SV.LeaderDeadPinColor.r, 255 - FyrMM.SV.LeaderDeadPinColor.g,
  6263. 255 - FyrMM.SV.LeaderDeadPinColor.b, FyrMM.SV.LeaderDeadPinColor.a)
  6264. else
  6265. pin:SetColor(FyrMM.SV.LeaderPinColor.r, FyrMM.SV.LeaderPinColor.g, FyrMM.SV.LeaderPinColor.b,
  6266. FyrMM.SV.LeaderPinColor.a)
  6267. text:SetColor(255 - FyrMM.SV.LeaderPinColor.r, 255 - FyrMM.SV.LeaderPinColor.g,
  6268. 255 - FyrMM.SV.LeaderPinColor.b, FyrMM.SV.LeaderPinColor.a)
  6269. end
  6270. else
  6271. text:SetColor(0, 0, 0, 1)
  6272. end
  6273. else
  6274. if tag == "companion" then
  6275. pin.m_PinType = MAP_PIN_TYPE_ACTIVE_COMPANION
  6276. else
  6277. pin.m_PinType = MAP_PIN_TYPE_GROUP
  6278. end
  6279. if FyrMM.SV.MemberPinColor ~= nil and FyrMM.SV.MemberDeadPinColor ~= nil then
  6280. if isDead then
  6281. pin:SetColor(FyrMM.SV.MemberDeadPinColor.r, FyrMM.SV.MemberDeadPinColor.g,
  6282. FyrMM.SV.MemberDeadPinColor.b, FyrMM.SV.MemberDeadPinColor.a)
  6283. if not tag == "companion" then
  6284. text:SetColor(255 - FyrMM.SV.MemberDeadPinColor.r, 255 - FyrMM.SV.MemberDeadPinColor.g,
  6285. 255 - FyrMM.SV.MemberDeadPinColor.b, FyrMM.SV.MemberDeadPinColor.a)
  6286. end
  6287. else
  6288. pin:SetColor(FyrMM.SV.MemberPinColor.r, FyrMM.SV.MemberPinColor.g, FyrMM.SV.MemberPinColor.b,
  6289. FyrMM.SV.MemberPinColor.a)
  6290. if not tag == "companion" then
  6291. text:SetColor(255 - FyrMM.SV.MemberPinColor.r, 255 - FyrMM.SV.MemberPinColor.g,
  6292. 255 - FyrMM.SV.MemberPinColor.b, FyrMM.SV.MemberPinColor.a)
  6293. end
  6294. end
  6295. else
  6296. text:SetColor(0, 0, 0, 1)
  6297. end
  6298. end
  6299.  
  6300. pin.noZoomResize = true
  6301. pin.ClassId = GetUnitClassId(tag)
  6302. pin.nX = nX
  6303. pin.nY = nY
  6304. pin.unitTag = tag
  6305.  
  6306. if IsUnitActivelyEngaged(tag) and FyrMM.SV.InCombatState and not isDead and IsUnitOnline(tag) then -- IsUnitActivelyEngaged instead of IsUnitInCombat to get individual combat state instead of group combat state
  6307. pin_ic.nX = nX
  6308. pin_ic.nY = nY
  6309. pin_ic:SetHidden(false)
  6310.  
  6311. if pin.isLeader then
  6312. pin_ic:SetAlpha(0.66)
  6313. else
  6314. pin_ic:SetColor(255, 0, 0, 0.5)
  6315. end
  6316.  
  6317. FyrMM.SetPinAnchor(pin_ic, nX, nY, Fyr_MM_Scroll_Map_GroupPins)
  6318. else
  6319. PinsList["Fyr_MM_Scroll_Map_GroupPins_" .. tag .. "_incombat"] = nil
  6320. pin_ic.nX = nil
  6321. pin_ic.nY = nil
  6322. -- pin_ic:SetColor(0,0,0,0)
  6323. pin_ic:SetHidden(true)
  6324. pin_ic:ClearAnchors()
  6325. end
  6326.  
  6327. if not tag == "companion" then
  6328. if FyrMM.SV.ShowGroupLabels then
  6329. text:SetText(tostring(GetGroupIndexByUnitTag(tag)))
  6330. text:SetHidden(false)
  6331. else
  6332. text:SetText("")
  6333. end
  6334. end
  6335.  
  6336. if IsUnitActivelyEngaged(tag) then
  6337. pin.engaged = true
  6338. else
  6339. pin.engaged = false
  6340. end
  6341.  
  6342. if OSI then -- support for OdySupportIcons
  6343. local OPTIONS = OPTIONS or ZO_SavedVars:NewAccountWide("OSIStore", 1, nil, DEFAULT)
  6344. local wmConfig = {
  6345. ["dead"] = OPTIONS.wmdead,
  6346. ["mechanic"] = false,
  6347. ["raid"] = OPTIONS.raidallow,
  6348. ["leader"] = OPTIONS.wmroles,
  6349. ["tank"] = OPTIONS.wmroles,
  6350. ["healer"] = OPTIONS.wmroles,
  6351. ["dps"] = OPTIONS.wmroles,
  6352. ["bg"] = OPTIONS.wmroles,
  6353. ["custom"] = OPTIONS.wmuse,
  6354. ["unique"] = OPTIONS.wmunique,
  6355. ["anim"] = false
  6356. }
  6357.  
  6358. local tex, col, _, hodor = OSI.GetIconDataForPlayer(GetUnitDisplayName(tag), wmConfig, tag)
  6359. if tex then
  6360. FyrMM.SetGroupPinTexture(pin, tex)
  6361. if col then
  6362. pin:SetColor(col[1], col[2], col[3], 1)
  6363. pin.color = col
  6364. end
  6365. else
  6366. FyrMM.SetGroupPinTexture(pin)
  6367. end
  6368. else
  6369. FyrMM.SetGroupPinTexture(pin)
  6370. end
  6371.  
  6372. FyrMM.SetPinSize(pin_ic, pin:GetDesiredHeight() + 10, 0) -- +6
  6373.  
  6374. pin:SetDrawLayer(3)
  6375. pin:SetDrawLevel(ZO_MapPin.PIN_DATA[pin.m_PinType].level)
  6376. pin_ic:SetDrawLayer(2)
  6377. pin:SetMouseEnabled(true)
  6378. FyrMM.SetPinAnchor(pin, nX, nY, Fyr_MM_Scroll_Map_GroupPins)
  6379. PinsList["Fyr_MM_Scroll_Map_GroupPins_" .. tag .. "_incombat"] = nil
  6380.  
  6381. if FyrMM.SV.WheelMap then
  6382. pin:SetHidden(not Is_PinInsideWheel(pin))
  6383. else
  6384. pin:SetHidden(false)
  6385. end
  6386.  
  6387. if FyrMM.IsValidBorderPin(pin) then
  6388. FyrMM.CreateBorderPin(pin)
  6389. end
  6390. end
  6391.  
  6392. local function ClearGroupPins()
  6393. local pin, pin_ic, tag
  6394. for i = 1, 24 do
  6395. tag = "group" .. tostring(i)
  6396. local pin = GetControl("Fyr_MM_Scroll_Map_GroupPins_" .. tag)
  6397. local pin_ic = GetControl("Fyr_MM_Scroll_Map_GroupPins_" .. tag .. "_incombat")
  6398. if pin ~= nil then
  6399. pin:SetHidden(true)
  6400. pin:SetMouseEnabled(false)
  6401. pin:ClearAnchors()
  6402. pin.isDps = nil
  6403. pin.isHeal = nil
  6404. pin.isTank = nil
  6405. pin.ClassId = nil
  6406. pin.isLeader = nil
  6407. pin.isBreadcrumb = nil
  6408. pin.nX = nil
  6409. pin.nY = nil
  6410. pin_ic.nX = nil
  6411. pin_ic.nY = nil
  6412. pin_ic:SetHidden(true)
  6413. pin_ic:ClearAnchors()
  6414. PinsList["Fyr_MM_Scroll_Map_GroupPins_" .. tag] = nil
  6415. PinsList["Fyr_MM_Scroll_Map_GroupPins_" .. tag .. "_incombat"] = nil
  6416. if pin.OnBorder then
  6417. if pin.BorderPin then
  6418. pin.BorderPin:ClearAnchors()
  6419. pin.BorderPin:SetHidden()
  6420. pin.BorderPin.pin = nil
  6421. pin.BorderPin = nil
  6422. end
  6423. pin.OnBorder = nil
  6424. end
  6425. end
  6426. end
  6427.  
  6428. if not DoesUnitExist("companion") then
  6429. local pin = GetControl("Fyr_MM_Scroll_Map_GroupPins_companion")
  6430. local pin_ic = GetControl("Fyr_MM_Scroll_Map_GroupPins_companion_incombat")
  6431. if pin ~= nil then
  6432. pin:SetHidden(true)
  6433. pin:SetMouseEnabled(false)
  6434. pin:ClearAnchors()
  6435. pin.isDps = nil
  6436. pin.isHeal = nil
  6437. pin.isTank = nil
  6438. pin.ClassId = nil
  6439. pin.isLeader = nil
  6440. pin.isBreadcrumb = nil
  6441. pin.nX = nil
  6442. pin.nY = nil
  6443. pin_ic.nX = nil
  6444. pin_ic.nY = nil
  6445. pin_ic:SetHidden(true)
  6446. pin_ic:ClearAnchors()
  6447. PinsList["Fyr_MM_Scroll_Map_GroupPins_companion"] = nil
  6448. PinsList["Fyr_MM_Scroll_Map_GroupPins_companion_incombat"] = nil
  6449. if pin.OnBorder then
  6450. if pin.BorderPin then
  6451. pin.BorderPin:ClearAnchors()
  6452. pin.BorderPin:SetHidden()
  6453. pin.BorderPin.pin = nil
  6454. pin.BorderPin = nil
  6455. end
  6456. pin.OnBorder = nil
  6457. end
  6458. end
  6459. end
  6460. end
  6461.  
  6462. function FyrMM.RefreshGroup()
  6463. if not FyrMM.GroupRefreshNeeded and not IsCompanionAround then
  6464. return
  6465. end
  6466. local maxgroupsize = 24
  6467. local tag, pin, pin_ic
  6468.  
  6469. if not IsUnitGrouped("player") and not DoesUnitExist("companion") then
  6470. ClearGroupPins()
  6471. return
  6472. end
  6473.  
  6474. if IsUnitGrouped("player") and not DoesUnitExist("companion") then -- fix for companion icons staying when he/she leaves while grouped
  6475. local pin = GetControl("Fyr_MM_Scroll_Map_GroupPins_companion")
  6476. local pin_ic = GetControl("Fyr_MM_Scroll_Map_GroupPins_companion_incombat")
  6477. if pin ~= nil then
  6478. pin:SetHidden(true)
  6479. pin:SetMouseEnabled(false)
  6480. pin:ClearAnchors()
  6481. pin.isDps = nil
  6482. pin.isHeal = nil
  6483. pin.isTank = nil
  6484. pin.ClassId = nil
  6485. pin.isLeader = nil
  6486. pin.isBreadcrumb = nil
  6487. pin.nX = nil
  6488. pin.nY = nil
  6489. pin_ic.nX = nil
  6490. pin_ic.nY = nil
  6491. pin_ic:SetHidden(true)
  6492. pin_ic:ClearAnchors()
  6493. PinsList["Fyr_MM_Scroll_Map_GroupPins_companion"] = nil
  6494. PinsList["Fyr_MM_Scroll_Map_GroupPins_companion_incombat"] = nil
  6495. if pin.OnBorder then
  6496. if pin.BorderPin then
  6497. pin.BorderPin:ClearAnchors()
  6498. pin.BorderPin:SetHidden()
  6499. pin.BorderPin.pin = nil
  6500. pin.BorderPin = nil
  6501. end
  6502. pin.OnBorder = nil
  6503. end
  6504. end
  6505. end
  6506.  
  6507. local nogroup = GetGroupSize() == 0
  6508. local gameTime = GetGameTimeMilliseconds()
  6509.  
  6510. if GetGroupSize() > 24 then
  6511. maxgroupsize = GetGroupSize()
  6512. end -- Crazy wishfull thinking :)
  6513.  
  6514. for index = 1, maxgroupsize do
  6515. if FyrMM.Reloading then
  6516. return
  6517. end
  6518. tag = "group" .. tostring(index) -- GetGroupUnitTagByIndex(i)
  6519. if maxgroupsize > 24 then -- Very crazy wishfull thinking :)
  6520. if GetControl("Fyr_MM_Scroll_Map_GroupPins_" .. tag) == nil then
  6521. pin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_GroupPins_" .. tag, Fyr_MM_Scroll_Map_GroupPins,
  6522. CT_TEXTURE)
  6523. pin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  6524. pin:SetHandler("OnMouseExit", PinOnMouseExit)
  6525. end
  6526. if GetControl("Fyr_MM_Scroll_Map_GroupPins_" .. tag .. "_incombat") == nil then
  6527. pin_ic = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_GroupPins_" .. tag .. "_incombat",
  6528. Fyr_MM_Scroll_Map_GroupPins, CT_TEXTURE)
  6529. pin_ic:SetTexture("esoui/art/mappins/ava_attackburst_32.dds")
  6530. end
  6531. end
  6532. FyrMM.SetGroupPin(tag)
  6533. end
  6534.  
  6535. if DoesUnitExist("companion") then
  6536. tag = "companion"
  6537. if GetControl("Fyr_MM_Scroll_Map_GroupPins_" .. tag) == nil then
  6538. pin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_GroupPins_" .. tag, Fyr_MM_Scroll_Map_GroupPins,
  6539. CT_TEXTURE)
  6540. pin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  6541. pin:SetHandler("OnMouseExit", PinOnMouseExit)
  6542. end
  6543. if GetControl("Fyr_MM_Scroll_Map_GroupPins_" .. tag .. "_incombat") == nil then
  6544. pin_ic = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_GroupPins_" .. tag .. "_incombat",
  6545. Fyr_MM_Scroll_Map_GroupPins, CT_TEXTURE)
  6546. pin_ic:SetTexture("esoui/art/mappins/ava_attackburst_32.dds")
  6547. pin_ic:SetColor(255, 0, 0, 0.5)
  6548. end
  6549. FyrMM.SetGroupPin(tag)
  6550. end
  6551.  
  6552. if GetGroupSize() == 0 and not DoesUnitExist("companion") then
  6553. FyrMM.GroupRefreshNeeded = false
  6554. end
  6555.  
  6556. if FyrMM.DebugMode then
  6557. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "FyrMM.RefreshGroup " .. tostring(GetGameTimeMilliseconds() - gameTime))
  6558. end
  6559. end
  6560.  
  6561. ---------------------------------------------------
  6562. -- Quest pin updates
  6563. ---------------------------------------------------
  6564. function FyrMM.GetQuestPinInfo(pinType, isassited, isBreadcrumb, radius)
  6565. if radius == nil then
  6566. radius = 0
  6567. end
  6568. local mWidth, mHeight = Fyr_MM_Scroll_Map:GetDimensions()
  6569. local Diameter = radius * 2 * mHeight
  6570. local texture
  6571. if Diameter < 16 then
  6572. Diameter = 16
  6573. end
  6574. local properType, properTexture
  6575. if (pinType == MAP_PIN_TYPE_ASSISTED_QUEST_CONDITION or pinType == MAP_PIN_TYPE_TRACKED_QUEST_CONDITION) then
  6576. if isassited then
  6577. properType = MAP_PIN_TYPE_ASSISTED_QUEST_CONDITION
  6578. else
  6579. properType = MAP_PIN_TYPE_TRACKED_QUEST_CONDITION
  6580. end
  6581. end
  6582. if (pinType == MAP_PIN_TYPE_ASSISTED_QUEST_OPTIONAL_CONDITION or pinType ==
  6583. MAP_PIN_TYPE_TRACKED_QUEST_OPTIONAL_CONDITION) then
  6584. if isassited then
  6585. properType = MAP_PIN_TYPE_ASSISTED_QUEST_OPTIONAL_CONDITION
  6586. else
  6587. properType = MAP_PIN_TYPE_TRACKED_QUEST_OPTIONAL_CONDITION
  6588. end
  6589. end
  6590. if (pinType == MAP_PIN_TYPE_ASSISTED_QUEST_ENDING or pinType == MAP_PIN_TYPE_TRACKED_QUEST_ENDING) then
  6591. if isassited then
  6592. properType = MAP_PIN_TYPE_ASSISTED_QUEST_ENDING
  6593. else
  6594. properType = MAP_PIN_TYPE_TRACKED_QUEST_ENDING
  6595. end
  6596. end
  6597. if not properType then
  6598. properType = pinType
  6599. end
  6600. if radius == 0 then
  6601. texture = isBreadcrumb and breadcrumbQuestPinTextures[properType] or questPinTextures[properType]
  6602. return properType, texture, 32 * FyrMM.pScalePercent
  6603. else
  6604. if Diameter > 24 then
  6605. texture = isassited and "EsoUI/Art/MapPins/map_assistedAreaPin.dds" or "EsoUI/Art/MapPins/map_areaPin.dds"
  6606. return properType, texture, Diameter, true
  6607. else
  6608. texture = isassited and "EsoUI/Art/MapPins/map_assistedAreaPin_32.dds" or "EsoUI/Art/MapPins/map_areaPin_32.dds"
  6609. return properType, texture, Diameter, true
  6610. end
  6611. end
  6612. end
  6613.  
  6614. function FyrMM.ApplyProperQuestPinTextures() -- Discrepancy fix
  6615. local questPin, pinType
  6616.  
  6617. local function applyTextures(index, a)
  6618. questPin = GetControl("Fyr_MM_Scroll_Map_QuestPins_Pin" .. tostring(a))
  6619. if not questPin or questPin.questIndex ~= index or questPin:IsHidden(true) or IsAssisted(questPin.m_PinType) == FyrMM.GetQuestPinInfo(GetTrackedByIndex(index)) then
  6620. return
  6621. end
  6622. local properType, pinTexture, size =
  6623. FyrMM.GetQuestPinInfo(questPin.m_PinType,
  6624. GetTrackedIsAssisted(TRACK_TYPE_QUEST, questPin.questIndex),
  6625. questPin.m_PinTag.isBreadcrumb, questPin.radius)
  6626. questPin.m_PinType = properType
  6627. questPin:SetTexture(pinTexture)
  6628. FyrMM.SetPinSize(questPin, size, 0)
  6629. local drawLayerIndex = GetTrackedIsAssisted(TRACK_TYPE_QUEST, questPin.questIndex) and 3 or 2
  6630. questPin:SetDrawLayer(drawLayerIndex)
  6631. end
  6632.  
  6633. for index = 1, MAX_JOURNAL_QUESTS do
  6634. if (IsValidQuestIndex(index)) then
  6635. for a = 1, FyrMM.questPinCount do
  6636. applyTextures(index, a)
  6637. end
  6638. end
  6639. end
  6640. end
  6641.  
  6642. local function UpdateQuestPinPosition(questPin)
  6643. if not questPin then
  6644. return
  6645. end
  6646.  
  6647. if questPin.MapId ~= CurrentMap.MapId or not questPin.m_PinTag or not questPin.m_PinTag then
  6648. questPin:SetHidden(true)
  6649. questPin:ClearAnchors()
  6650. return
  6651. end
  6652.  
  6653. local properType, pinTexture, size = FyrMM.GetQuestPinInfo(questPin.m_PinType, GetTrackedIsAssisted(TRACK_TYPE_QUEST, questPin.questIndex), questPin.m_PinTag.isBreadcrumb, questPin.radius)
  6654.  
  6655. questPin.m_PinType = properType
  6656. questPin:SetTexture(pinTexture)
  6657. FyrMM.SetPinSize(questPin, size, 0)
  6658. questPin:SetHidden(not ZO_WorldMap_IsPinGroupShown(MAP_FILTER_QUESTS))
  6659.  
  6660. local drawLayerIndex = GetTrackedIsAssisted(TRACK_TYPE_QUEST, questPin.questIndex) and 3 or 2
  6661. questPin:SetDrawLayer(drawLayerIndex)
  6662.  
  6663. FyrMM.SetPinAnchor(questPin, questPin.normalizedX, questPin.normalizedY, Fyr_MM_Scroll_Map_QuestPins)
  6664. if FyrMM.SV.WheelMap and questPin.radius > 0 and not questPin.MM_Tag then
  6665. questPin:SetParent(Fyr_MM_Scroll_CW_Map_Pins)
  6666. elseif questPin.MM_Tag == 1 and not FyrMM.SV.WheelMap then
  6667. questPin:SetParent(Fyr_MM_Scroll_Map_QuestPins)
  6668. elseif questPin.MM_Tag == 1 and questPin.radius > 0 then
  6669. questPin:SetParent(Fyr_MM_Scroll_CW_Map_Pins)
  6670. if questPin.secondaryPin then
  6671. questPin.secondaryPin:SetTexture(pinTexture)
  6672. end
  6673. if questPin.tertiaryPin then
  6674. questPin.tertiaryPin:SetTexture(pinTexture)
  6675. end
  6676. elseif questPin.MM_Tag == 2 then
  6677. questPin:SetParent(Fyr_MM_Scroll_NS_Map_Pins)
  6678. elseif questPin.MM_Tag == 3 then
  6679. questPin:SetParent(Fyr_MM_Scroll_WE_Map_Pins)
  6680. elseif questPin.MM_Tag then
  6681. questPin.MM_Tag = nil
  6682. questPin:SetParent(Fyr_MM_Scroll_Map_QuestPins)
  6683. end
  6684.  
  6685. if FyrMM.IsValidBorderPin(questPin) then
  6686. FyrMM.CreateBorderPin(questPin)
  6687. end
  6688. end
  6689.  
  6690. function FyrMM.UpdateQuestPinPositions()
  6691. if QuestPinsUpdating then
  6692. return
  6693. end
  6694. for _, v in pairs(QuestPins) do
  6695. UpdateQuestPinPosition(v.Pin)
  6696. if v.Pin.secondaryPin then
  6697. UpdateQuestPinPosition(v.Pin.secondaryPin)
  6698. end
  6699. if v.Pin.tertiaryPin then
  6700. UpdateQuestPinPosition(v.Pin.tertiaryPin)
  6701. end
  6702. end
  6703. end
  6704.  
  6705. local function PlayTextureAnimation(pin, loopCount)
  6706. if not pin.m_textureAnimTimeline then
  6707. local anim
  6708. anim, pin.m_textureAnimTimeline = CreateSimpleAnimation(ANIMATION_TEXTURE, pin)
  6709. anim:SetImageData(32, 1)
  6710. anim:SetFramerate(32)
  6711. anim:SetHandler("OnStop", function()
  6712. pin:SetTextureCoords(0, 1, 0, 1)
  6713. end)
  6714. end
  6715. pin.m_textureAnimTimeline:SetPlaybackType(ANIMATION_PLAYBACK_LOOP, loopCount)
  6716. pin.m_textureAnimTimeline:PlayFromStart()
  6717. end
  6718.  
  6719. local function ResetAnimation(pin, resetOptions, loopCount, pulseIcon, overlayIcon, postPulseCallback, min, max)
  6720. resetOptions = resetOptions or RESET_ANIM_PREVENT_PLAY
  6721.  
  6722. -- The animated control
  6723. local pulseControl = pin
  6724.  
  6725. if (resetOptions == RESET_ANIM_ALLOW_PLAY) then
  6726. pulseControl:SetHidden(pulseIcon == nil)
  6727. if (pulseIcon) then
  6728. pulseControl:SetTexture(pulseIcon)
  6729. postPulseCallback = postPulseCallback or ZO_MapPin.DoFinalFadeOutAfterPing
  6730. ZO_AlphaAnimation_GetAnimation(pulseControl):PingPong(.3, 1, 750, loopCount, postPulseCallback)
  6731. end
  6732. elseif (resetOptions == RESET_ANIM_HIDE_CONTROL) then
  6733. ZO_AlphaAnimation_GetAnimation(pulseControl):Stop()
  6734. pulseControl:SetHidden(true)
  6735. pulseControl:StopTextureAnimation()
  6736. elseif (resetOptions == RESET_ANIM_PREVENT_PLAY) then
  6737. ZO_AlphaAnimation_GetAnimation(pulseControl):FadeOut(0, 300, ZO_ALPHA_ANIMATION_OPTION_USE_CURRENT_ALPHA,
  6738. ZO_MapPin.HidePulseAfterFadeOut)
  6739. end
  6740. end
  6741.  
  6742. local function CreateQuestAreaSidePins(pin, assisted)
  6743. local index
  6744. local properType, pinTexture, size = FyrMM.GetQuestPinInfo(pinType,
  6745. GetTrackedIsAssisted(TRACK_TYPE_QUEST, pin.m_PinTag[1]), pin.m_PinTag.isBreadcrumb, pin.radius)
  6746. FyrMM.questPinCount = FyrMM.questPinCount + 1
  6747. local questPinNS
  6748. index = GetQuestFreePinIndex()
  6749. questPinNS = GetControl("Fyr_MM_Scroll_Map_QuestPins_Pin" .. tostring(index))
  6750. if questPinNS == nil then
  6751. questPinNS = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_QuestPins_Pin" .. tostring(index),
  6752. Fyr_MM_Scroll_NS_Map_Pins, CT_TEXTURE)
  6753. else
  6754. questPinNS:SetParent(Fyr_MM_Scroll_NS_Map_Pins)
  6755. end
  6756. questPinNS.m_PinTag = pin.m_PinTag
  6757. questPinNS.questIndex = pin.questIndex
  6758. questPinNS.m_PinType = properType
  6759. questPinNS.PinToolTipText = pin.PinToolTipText
  6760. questPinNS.questName = pin.questName
  6761. questPinNS.normalizedX = pin.normalizedX
  6762. questPinNS.normalizedY = pin.normalizedY
  6763. questPinNS.radius = pin.radius
  6764. questPinNS.MapId = pin.MapId
  6765. questPinNS:SetTexture(pinTexture)
  6766. -- FyrMM.SetPinSize(questPinNS, size, 0)
  6767. questPinNS:SetDimensions(size, size)
  6768. questPinNS.pinAge = pin.pinAge
  6769. questPinNS:SetHidden(not ZO_WorldMap_IsPinGroupShown(MAP_FILTER_QUESTS))
  6770. questPinNS.MM_Tag = 2
  6771. questPinNS.primaryPin = pin
  6772. pin.secondaryPin = questPinNS
  6773.  
  6774. if assisted then
  6775. local assistedColor = ZO_MAP_PIN_ASSISTED_COLOR
  6776. questPinNS:SetColor(assistedColor:UnpackRGBA())
  6777. else
  6778. local color = ZO_MAP_PIN_NORMAL_COLOR
  6779. questPinNS:SetColor(color:UnpackRGBA())
  6780. end
  6781.  
  6782. questPinNS:SetDrawLayer(3)
  6783.  
  6784. FyrMM.SetPinAnchor(questPinNS, questPinNS.normalizedX, questPinNS.normalizedY, Fyr_MM_Scroll_Map_QuestPins)
  6785. questPinNS:SetHandler("OnMouseUp", PinOnMouseUp)
  6786. questPinNS:SetHandler("OnMouseEnter", PinOnMouseEnter)
  6787. questPinNS:SetHandler("OnMouseExit", PinOnMouseExit)
  6788.  
  6789. FyrMM.questPinCount = FyrMM.questPinCount + 1
  6790. local questPinWE
  6791. index = GetQuestFreePinIndex()
  6792. questPinWE = GetControl("Fyr_MM_Scroll_Map_QuestPins_Pin" .. tostring(index))
  6793. if questPinWE == nil then
  6794. questPinWE = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_QuestPins_Pin" .. tostring(index),
  6795. Fyr_MM_Scroll_WE_Map_Pins, CT_TEXTURE)
  6796. else
  6797. questPinWE:SetParent(Fyr_MM_Scroll_WE_Map_Pins)
  6798. end
  6799. questPinWE.m_PinTag = pin.m_PinTag
  6800. questPinWE.questIndex = pin.questIndex
  6801. questPinWE.m_PinType = properType
  6802. questPinWE.PinToolTipText = pin.PinToolTipText
  6803. questPinWE.questName = pin.questName
  6804. questPinWE.normalizedX = pin.normalizedX
  6805. questPinWE.normalizedY = pin.normalizedY
  6806. questPinWE.radius = pin.radius
  6807. questPinWE.MapId = pin.MapId
  6808. questPinWE:SetTexture(pinTexture)
  6809. -- FyrMM.SetPinSize(questPinWE, size, 0)
  6810. questPinWE:SetDimensions(size, size)
  6811. questPinWE.pinAge = pin.pinAge
  6812. questPinWE:SetHidden(not ZO_WorldMap_IsPinGroupShown(MAP_FILTER_QUESTS))
  6813. questPinWE.MM_Tag = 3
  6814. questPinWE.primaryPin = pin
  6815. pin.tertiaryPin = questPinWE
  6816.  
  6817. if assisted then
  6818. local assistedColor = ZO_MAP_PIN_ASSISTED_COLOR
  6819. questPinWE:SetColor(assistedColor:UnpackRGBA())
  6820. else
  6821. local color = ZO_MAP_PIN_NORMAL_COLOR
  6822. questPinWE:SetColor(color:UnpackRGBA())
  6823. end
  6824. questPinWE:SetDrawLayer(3)
  6825. FyrMM.SetPinAnchor(questPinWE, questPinWE.normalizedX, questPinWE.normalizedY, Fyr_MM_Scroll_Map_QuestPins)
  6826. questPinWE:SetHandler("OnMouseUp", PinOnMouseUp)
  6827. questPinWE:SetHandler("OnMouseEnter", PinOnMouseEnter)
  6828. questPinWE:SetHandler("OnMouseExit", PinOnMouseExit)
  6829. end
  6830.  
  6831. function FyrMM.CreateSuggestedAreaSidePins(pin, radius)
  6832. local index = pin.Index
  6833. local properType, pinTexture, size = FyrMM.GetQuestPinInfo(pin.m_PinType, false, false, radius)
  6834.  
  6835. local suggestedPinNS
  6836. suggestedPinNS = GetControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(index) .. "_NS")
  6837. if suggestedPinNS == nil then
  6838. suggestedPinNS = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(index) .. "_NS",
  6839. Fyr_MM_Scroll_NS_Map_Pins, CT_TEXTURE)
  6840. else
  6841. suggestedPinNS:SetParent(Fyr_MM_Scroll_NS_Map_Pins)
  6842. end
  6843. suggestedPinNS.m_PinTag = pin.m_PinTag
  6844. suggestedPinNS.questIndex = pin.questIndex
  6845. suggestedPinNS.m_PinType = pin.m_PinType
  6846. suggestedPinNS.PinToolTipText = pin.PinToolTipText
  6847. suggestedPinNS.questName = pin.questName
  6848. suggestedPinNS.normalizedX = pin.nX
  6849. suggestedPinNS.normalizedY = pin.nY
  6850. suggestedPinNS.radius = pin.radius
  6851. suggestedPinNS.MapId = pin.MapId
  6852. suggestedPinNS:SetTexture(pinTexture)
  6853. suggestedPinNS:SetDimensions(size, size)
  6854. suggestedPinNS.pinAge = pin.pinAge
  6855. suggestedPinNS:SetHidden(false)
  6856. suggestedPinNS.MM_Tag = 2
  6857. suggestedPinNS.primaryPin = pin
  6858. pin.secondaryPin = suggestedPinNS
  6859.  
  6860. local color = ZO_MAP_PIN_NORMAL_COLOR
  6861. suggestedPinNS:SetColor(color:UnpackRGBA())
  6862. suggestedPinNS:SetDrawLayer(3)
  6863.  
  6864. FyrMM.SetPinAnchor(suggestedPinNS, suggestedPinNS.normalizedX, suggestedPinNS.normalizedY,
  6865. Fyr_MM_Scroll_Map_QuestPins)
  6866. suggestedPinNS:SetHandler("OnMouseUp", PinOnMouseUp)
  6867. suggestedPinNS:SetHandler("OnMouseEnter", PinOnMouseEnter)
  6868. suggestedPinNS:SetHandler("OnMouseExit", PinOnMouseExit)
  6869.  
  6870. local suggestedPinWE
  6871. suggestedPinWE = GetControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(index) .. "_WE")
  6872. if suggestedPinWE == nil then
  6873. suggestedPinWE = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(index) .. "_WE",
  6874. Fyr_MM_Scroll_WE_Map_Pins, CT_TEXTURE)
  6875. else
  6876. suggestedPinWE:SetParent(Fyr_MM_Scroll_WE_Map_Pins)
  6877. end
  6878. suggestedPinWE.m_PinTag = pin.m_PinTag
  6879. suggestedPinWE.questIndex = pin.questIndex
  6880. suggestedPinWE.m_PinType = pin.m_PinType
  6881. suggestedPinWE.PinToolTipText = pin.PinToolTipText
  6882. suggestedPinWE.questName = pin.questName
  6883. suggestedPinWE.normalizedX = pin.nX
  6884. suggestedPinWE.normalizedY = pin.nY
  6885. suggestedPinWE.radius = pin.radius
  6886. suggestedPinWE.MapId = pin.MapId
  6887. suggestedPinWE:SetTexture(pinTexture)
  6888. suggestedPinWE:SetDimensions(size, size)
  6889. suggestedPinWE.pinAge = pin.pinAge
  6890. suggestedPinWE:SetHidden(false)
  6891. suggestedPinWE.MM_Tag = 3
  6892. suggestedPinWE.primaryPin = pin
  6893. pin.tertiaryPin = suggestedPinWE
  6894.  
  6895. local color = ZO_MAP_PIN_NORMAL_COLOR
  6896. suggestedPinWE:SetColor(color:UnpackRGBA())
  6897. suggestedPinWE:SetDrawLayer(3)
  6898.  
  6899. FyrMM.SetPinAnchor(suggestedPinWE, suggestedPinWE.normalizedX, suggestedPinWE.normalizedY,
  6900. Fyr_MM_Scroll_Map_QuestPins)
  6901. suggestedPinWE:SetHandler("OnMouseUp", PinOnMouseUp)
  6902. suggestedPinWE:SetHandler("OnMouseEnter", PinOnMouseEnter)
  6903. suggestedPinWE:SetHandler("OnMouseExit", PinOnMouseExit)
  6904. end
  6905.  
  6906. local function CreateForwardCampAreaSidePins(pin, size, usable)
  6907. local pinTexture = "esoui/art/mappins/map_areapin.dds"
  6908.  
  6909. local ForwardCampPinNS
  6910. ForwardCampPinNS = GetControl(
  6911. "Fyr_MM_Scroll_Map_ForwardCamps_Pin" .. tostring(FyrMM.currentForwardCamps) .. "_Blob" .. "_NS")
  6912. if ForwardCampPinNS == nil then
  6913. ForwardCampPinNS = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_ForwardCamps_Pin" ..
  6914. tostring(FyrMM.currentForwardCamps) .. "_Blob" .. "_NS",
  6915. Fyr_MM_Scroll_NS_Map_Pins, CT_TEXTURE)
  6916. else
  6917. ForwardCampPinNS:SetParent(Fyr_MM_Scroll_NS_Map_Pins)
  6918. end
  6919.  
  6920. ForwardCampPinNS.m_PinTag = pin.m_PinTag
  6921. ForwardCampPinNS.questIndex = pin.questIndex
  6922. ForwardCampPinNS.m_PinType = pin.m_PinType
  6923. ForwardCampPinNS.PinToolTipText = pin.PinToolTipText
  6924. ForwardCampPinNS.questName = pin.questName
  6925. ForwardCampPinNS.normalizedX = pin.normalizedX
  6926. ForwardCampPinNS.normalizedY = pin.normalizedY
  6927. ForwardCampPinNS.radius = pin.radius
  6928. ForwardCampPinNS.MapId = pin.MapId
  6929. ForwardCampPinNS:SetTexture(pinTexture)
  6930. -- FyrMM.SetPinSize(ForwardCampPinNS, size, 0)
  6931. ForwardCampPinNS:SetDimensions(size, size)
  6932. ForwardCampPinNS.pinAge = pin.pinAge
  6933. ForwardCampPinNS:SetHidden(not usable)
  6934. ForwardCampPinNS.MM_Tag = 2
  6935. ForwardCampPinNS.primaryPin = pin
  6936. pin.secondaryPin = ForwardCampPinNS
  6937.  
  6938. local color = ZO_MAP_PIN_NORMAL_COLOR
  6939. ForwardCampPinNS:SetColor(color:UnpackRGBA())
  6940. ForwardCampPinNS:SetDrawLayer(3)
  6941.  
  6942. FyrMM.SetPinAnchor(ForwardCampPinNS, ForwardCampPinNS.normalizedX, ForwardCampPinNS.normalizedY,
  6943. Fyr_MM_Scroll_Map_Pins) -- Fyr_MM_Scroll_Map_QuestPins
  6944. ForwardCampPinNS:SetHandler("OnMouseUp", PinOnMouseUp)
  6945. ForwardCampPinNS:SetHandler("OnMouseEnter", PinOnMouseEnter)
  6946. ForwardCampPinNS:SetHandler("OnMouseExit", PinOnMouseExit)
  6947.  
  6948. local ForwardCampPinWE
  6949. ForwardCampPinWE = GetControl(
  6950. "Fyr_MM_Scroll_Map_ForwardCamps_Pin" .. tostring(FyrMM.currentForwardCamps) .. "_Blob" .. "_WE")
  6951. if ForwardCampPinWE == nil then
  6952. ForwardCampPinWE = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_ForwardCamps_Pin" ..
  6953. tostring(FyrMM.currentForwardCamps) .. "_Blob" .. "_WE",
  6954. Fyr_MM_Scroll_WE_Map_Pins, CT_TEXTURE)
  6955. else
  6956. ForwardCampPinWE:SetParent(Fyr_MM_Scroll_WE_Map_Pins)
  6957. end
  6958. ForwardCampPinWE.m_PinTag = pin.m_PinTag
  6959. ForwardCampPinWE.questIndex = pin.questIndex
  6960. ForwardCampPinWE.m_PinType = pin.m_PinType
  6961. ForwardCampPinWE.PinToolTipText = pin.PinToolTipText
  6962. ForwardCampPinWE.questName = pin.questName
  6963. ForwardCampPinWE.normalizedX = pin.normalizedX
  6964. ForwardCampPinWE.normalizedY = pin.normalizedY
  6965. ForwardCampPinWE.radius = pin.radius
  6966. ForwardCampPinWE.MapId = pin.MapId
  6967. ForwardCampPinWE:SetTexture(pinTexture)
  6968. -- FyrMM.SetPinSize(ForwardCampPinWE, size, 0)
  6969. ForwardCampPinWE:SetDimensions(size, size)
  6970. ForwardCampPinWE.pinAge = pin.pinAge
  6971. ForwardCampPinWE:SetHidden(not usable)
  6972. ForwardCampPinWE.MM_Tag = 3
  6973. ForwardCampPinWE.primaryPin = pin
  6974. pin.tertiaryPin = ForwardCampPinWE
  6975.  
  6976. ForwardCampPinWE:SetColor(color:UnpackRGBA())
  6977. ForwardCampPinWE:SetDrawLayer(3)
  6978. FyrMM.SetPinAnchor(ForwardCampPinWE, ForwardCampPinWE.normalizedX, ForwardCampPinWE.normalizedY,
  6979. Fyr_MM_Scroll_Map_Pins) -- Fyr_MM_Scroll_Map_QuestPins
  6980. ForwardCampPinWE:SetHandler("OnMouseUp", PinOnMouseUp)
  6981. ForwardCampPinWE:SetHandler("OnMouseEnter", PinOnMouseEnter)
  6982. ForwardCampPinWE:SetHandler("OnMouseExit", PinOnMouseExit)
  6983. end
  6984.  
  6985. local function QuestPinExists(pinType, tag, xLoc, yLoc, radius)
  6986. local l
  6987. for i, v in pairs(QuestPins) do
  6988. if v.Pin ~= nil then
  6989. l = v.Pin
  6990. if l.m_PinTag then
  6991. if l.m_PinTag[1] == tag[1] and l.m_PinTag[2] == tag[2] and l.m_PinTag[3] == tag[3] and l.m_PinType ==
  6992. pinType and l.radius == radius and l.normalizedX == xLoc and l.normalizedY == yLoc then
  6993. RemoveQuestPin(l)
  6994. end
  6995. end
  6996. end
  6997. end
  6998. return false
  6999. end
  7000.  
  7001. function FyrMM.CreateQuestPin(pinType, tag, xLoc, yLoc, radius)
  7002. if QuestPinExists(pinType, tag, xLoc, yLoc, radius) then
  7003. return
  7004. end -- dupe elimination
  7005. FyrMM.questPinCount = FyrMM.questPinCount + 1
  7006. local questPin
  7007. local pinData = {}
  7008. local index = GetQuestFreePinIndex()
  7009.  
  7010. questPin = GetControl("Fyr_MM_Scroll_Map_QuestPins_Pin" .. tostring(index))
  7011.  
  7012. if FyrMM.SV.WheelMap and radius > 0 then
  7013. if questPin == nil then
  7014. questPin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_QuestPins_Pin" .. tostring(index),
  7015. Fyr_MM_Scroll_CW_Map_Pins, CT_TEXTURE)
  7016. else
  7017. questPin:SetParent(Fyr_MM_Scroll_CW_Map_Pins)
  7018. end
  7019. else
  7020. if questPin == nil then
  7021. questPin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_QuestPins_Pin" .. tostring(index),
  7022. Fyr_MM_Scroll_Map_QuestPins, CT_TEXTURE)
  7023. else
  7024. questPin:SetParent(Fyr_MM_Scroll_Map_QuestPins)
  7025. end
  7026. end
  7027.  
  7028. local properType, pinTexture, size, isAreaPin = FyrMM.GetQuestPinInfo(pinType, GetTrackedIsAssisted(
  7029. TRACK_TYPE_QUEST, tag[1]), tag.isBreadcrumb, radius)
  7030. pinType = properType
  7031. questPin.m_PinTag = tag
  7032. questPin.questIndex = tag[1]
  7033. questPin.m_PinType = properType
  7034. questPin.PinToolTipText = GenerateQuestConditionTooltipLine(tag[1], tag[3], tag[2])
  7035. questPin.questName = GetJournalQuestName(tag[1])
  7036. questPin.normalizedX = xLoc
  7037. questPin.normalizedY = yLoc
  7038. questPin.radius = radius
  7039. questPin.MapId = CurrentMap.MapId
  7040.  
  7041. questPin.pinAge = GetFrameTimeMilliseconds()
  7042.  
  7043. pinData.questIndex = tag[1]
  7044. pinData.questName = GetJournalQuestName(tag[1])
  7045. pinData.conditionText = GenerateQuestConditionTooltipLine(tag[1], tag[3], tag[2])
  7046. pinData.stepIndex = tag[3]
  7047. pinData.conditionIndex = tag[2]
  7048. pinData.pinIndex = index
  7049. pinData.normalizedX = xLoc
  7050. pinData.normalizedY = yLoc
  7051. pinData.radius = radius
  7052. pinData.isBreadcrumb = tag.isBreadcrumb
  7053. pinData.isAssisted = GetTrackedIsAssisted(TRACK_TYPE_QUEST, tag[1])
  7054. pinData.MapId = CurrentMap.MapId
  7055. pinData.Pin = questPin
  7056. pinData.tag = tag
  7057.  
  7058. local questdataIndex = questpinDataExists(pinData, QuestPins)
  7059. if questdataIndex == nil then
  7060. table.insert(QuestPins, pinData)
  7061. questdataIndex = questpinDataExists(pinData, QuestPins)
  7062. else
  7063. QuestPins[questdataIndex] = pinData
  7064. end
  7065. questPin.questdataIndex = questdataIndex
  7066. local questPinData = ZOpinData[pinType]
  7067. if (questPinData ~= nil) then
  7068. local _, pulseTexture, glowTexture = GetPinTexture(pinType, questPin)
  7069.  
  7070. questPin:SetTexture(pinTexture)
  7071.  
  7072. FyrMM.SetPinSize(questPin, size, 0)
  7073.  
  7074. if (pulseTexture) then
  7075. ResetAnimation(questPin, RESET_ANIM_ALLOW_PLAY, LONG_LOOP_COUNT, pulseTexture, overlayTexture,
  7076. ZO_MapPin.DoFinalFadeInAfterPing)
  7077. else
  7078. if (glowTexture) then
  7079. ResetAnimation(questPin, RESET_ANIM_HIDE_CONTROL)
  7080. end
  7081. end
  7082. questPin:SetDrawLevel(zo_max(questPinData.level, 1))
  7083. if (questPinData.isAnimated) then
  7084. PlayTextureAnimation(questPin, LOOP_INDEFINITELY)
  7085. end
  7086.  
  7087. if FyrMM.SV.WheelMap and questPin.radius > 0 then
  7088. questPin.MM_Tag = 1
  7089. CreateQuestAreaSidePins(questPin, pinData.isAssisted)
  7090. else
  7091. if questPin.secondaryPin ~= nil then
  7092. questPin.secondaryPin.MM_Tag = nil
  7093. RemoveQuestPin(questPin.secondaryPin)
  7094. end
  7095. if questPin.tertiaryPin ~= nil then
  7096. questPin.tertiaryPin.MM_Tag = nil
  7097. RemoveQuestPin(questPin.tertiaryPin)
  7098. end
  7099. questPin.MM_Tag = nil
  7100. questPin.primaryPin = nil
  7101. questPin.secondaryPin = nil
  7102. questPin.tertiaryPin = nil
  7103. questPin:SetParent(Fyr_MM_Scroll_Map_QuestPins)
  7104. end
  7105.  
  7106. if questPinData.tint then -- compatibility with addons which modifies questpins colors
  7107. if type(questPinData.tint) ~= "function" then
  7108. questPin:SetColor(questPinData.tint:UnpackRGBA())
  7109. else
  7110. if questPin.m_Pin ~= nil then
  7111. questPin:SetColor(questPinData.tint(questPin.m_Pin):UnpackRGBA())
  7112. else
  7113. questPin:SetColor(questPinData.tint(questPin):UnpackRGBA())
  7114. end
  7115. end
  7116. else
  7117. questPin:SetColor(1, 1, 1, 1)
  7118. end
  7119.  
  7120. if isAreaPin then -- apply modified areapin colors from other addons
  7121. if pinData.isAssisted then
  7122. local assistedColor = ZO_MAP_PIN_ASSISTED_COLOR
  7123. questPin:SetColor(assistedColor:UnpackRGBA())
  7124. else
  7125. local color = ZO_MAP_PIN_NORMAL_COLOR
  7126. questPin:SetColor(color:UnpackRGBA())
  7127. end
  7128. end
  7129.  
  7130. questPin:SetHidden(not ZO_WorldMap_IsPinGroupShown(MAP_FILTER_QUESTS))
  7131. FyrMM.SetPinAnchor(questPin, questPin.normalizedX, questPin.normalizedY, Fyr_MM_Scroll_Map_QuestPins)
  7132.  
  7133. if FyrMM.IsValidBorderPin(questPin) then
  7134. FyrMM.CreateBorderPin(questPin)
  7135. end
  7136. if GetTrackedIsAssisted(TRACK_TYPE_QUEST, tag[1]) then
  7137. questPin:SetDrawLayer(3)
  7138. else
  7139. questPin:SetDrawLayer(2)
  7140. end
  7141. questPin:SetHandler("OnMouseUp", PinOnMouseUp)
  7142. questPin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  7143. questPin:SetHandler("OnMouseExit", PinOnMouseExit)
  7144. questPin:SetMouseEnabled(true)
  7145. end
  7146. end
  7147.  
  7148. local function OnQuestPositionRequestComplete(eventCode, taskId, pinType, xLoc, yLoc, radius, insideCurrentMapWorld,
  7149. isBreadcrumb)
  7150. -- xLoc = zo_round(xLoc * 10000) / 10000
  7151. -- yLoc = zo_round(yLoc * 10000) / 10000
  7152. local tag = CurrentTasks[taskId]
  7153. if (tag and insideCurrentMapWorld) then
  7154. if CurrentTasks[taskId].Fetched then
  7155. zo_callLater(FyrMM.RequestQuestPinUpdate, 100)
  7156. if CurrentTasks[taskId].MapId ~= CurrentMap.MapId then
  7157. CurrentTasks[taskId] = nil
  7158. return
  7159. end
  7160. else
  7161. if CurrentTasks[taskId].ZO_MapVisible then
  7162. return
  7163. end
  7164. local pinData = {}
  7165. pinData.questIndex = tag[1]
  7166. pinData.questName = GetJournalQuestName(tag[1])
  7167. pinData.conditionText = GenerateQuestConditionTooltipLine(tag[1], tag[3], tag[2])
  7168. pinData.stepIndex = tag[3]
  7169. pinData.conditionIndex = tag[2]
  7170. pinData.normalizedX = xLoc
  7171. pinData.normalizedY = yLoc
  7172. pinData.radius = radius
  7173. pinData.isBreadcrumb = isBreadcrumb
  7174. pinData.isAssisted = GetTrackedIsAssisted(TRACK_TYPE_QUEST, tag[1])
  7175. pinData.MapId = CurrentMap.MapId
  7176. pinData.tag = tag
  7177. local requestedquestdataIndex = questpinDataExists(pinData, RequestedQuestPins)
  7178. if requestedquestdataIndex == nil then
  7179. table.insert(RequestedQuestPins, pinData)
  7180. else
  7181. RequestedQuestPins[requestedquestdataIndex] = pinData
  7182. end
  7183. pinData = {}
  7184. end
  7185. if tag.MapId == CurrentMap.MapId then
  7186. tag.isBreadcrumb = isBreadcrumb
  7187. FyrMM.CreateQuestPin(pinType, tag, xLoc, yLoc, radius)
  7188. end
  7189. else
  7190. if isBreadcrumb then
  7191. NeedQuestPinUpdate = true
  7192. end
  7193. end
  7194. if tag then
  7195. CurrentTasks[taskId] = nil
  7196. end
  7197. if IsTableEmpty(CurrentTasks) then
  7198. QuestTasksPending = false
  7199. else
  7200. QuestTasksPending = true
  7201. end
  7202. end
  7203.  
  7204. local function AddQuestPins(questIndex)
  7205. if (ZO_WorldMap_IsPinGroupShown(MAP_FILTER_QUESTS)) then
  7206. local assisted = GetTrackedIsAssisted(TRACK_TYPE_QUEST, questIndex)
  7207. if (GetJournalQuestIsComplete(questIndex)) then
  7208. local tag = ZO_MapPin.CreateQuestPinTag(questIndex, QUEST_MAIN_STEP_INDEX, 1)
  7209. if not TaskExists(tag) then
  7210. local taskId = FyrMM.RequestJournalQuestConditionAssistance(questIndex, QUEST_MAIN_STEP_INDEX, 1,
  7211. assisted)
  7212. if taskId ~= nil then
  7213. FyrMM.LastQuestPinRequest = GetFrameTimeMilliseconds()
  7214. CurrentTasks[taskId] = {}
  7215. tag.MapId = CurrentMap.MapId
  7216. CurrentTasks[taskId] = tag
  7217. CurrentTasks[taskId].RequestTimeStamp = FyrMM.LastQuestPinRequest
  7218. end
  7219. end
  7220. else
  7221. for stepIndex = QUEST_MAIN_STEP_INDEX, GetJournalQuestNumSteps(questIndex) do
  7222. for conditionIndex = 1, GetJournalQuestNumConditions(questIndex, stepIndex) do
  7223. local _, _, isFailCondition, isComplete =
  7224. GetJournalQuestConditionValues(questIndex, stepIndex, conditionIndex)
  7225. if (not (isFailCondition or isComplete)) then
  7226. local tag = ZO_MapPin.CreateQuestPinTag(questIndex, stepIndex, conditionIndex)
  7227. if not TaskExists(tag) then
  7228. local taskId = FyrMM.RequestJournalQuestConditionAssistance(questIndex, stepIndex,
  7229. conditionIndex, assisted)
  7230. if taskId ~= nil then
  7231. FyrMM.LastQuestPinRequest = GetFrameTimeMilliseconds()
  7232. CurrentTasks[taskId] = {}
  7233. tag.MapId = CurrentMap.MapId
  7234. CurrentTasks[taskId] = tag
  7235. CurrentTasks[taskId].RequestTimeStamp = FyrMM.LastQuestPinRequest
  7236. end
  7237. end
  7238. end
  7239. end
  7240. end
  7241. end
  7242. end
  7243. end
  7244.  
  7245. function FyrMM.UpdateQuestPins()
  7246. if FyrMM.Halted then
  7247. return
  7248. end
  7249. if not IsTableEmpty(CurrentTasks) and GetFrameTimeMilliseconds() - FyrMM.LastQuestPinRequest >
  7250. FYRMM_QUEST_PIN_REQUEST_TIMEOUT then
  7251. DestroyTasks()
  7252. end
  7253. if not IsTableEmpty(CurrentTasks) then
  7254. return
  7255. end
  7256. if IsTableEmpty(CurrentTasks) and GetFrameTimeMilliseconds() - FyrMM.LastQuestPinRequest <
  7257. FYRMM_QUEST_PIN_REQUEST_MINIMUM_DELAY then
  7258. return
  7259. end -- anti spam
  7260. FyrMM.questPinCount = GetQuestPinCount()
  7261. QuestPinsUpdating = true
  7262. QuestTasksPending = true
  7263. for i = 1, MAX_JOURNAL_QUESTS do
  7264. if (IsValidQuestIndex(i)) then
  7265. if FyrMM.Reloading then
  7266. return
  7267. end
  7268. AddQuestPins(i)
  7269. end
  7270. end
  7271. end
  7272.  
  7273. function FyrMM.RequestQuestPinUpdate()
  7274. if Fyr_MM:IsHidden() then
  7275. return
  7276. end -- test 03/05/2023
  7277. NeedQuestPinUpdate = true
  7278. FyrMM.RegisterUpdates() -- fix for questpins not updating after completing quest
  7279. end
  7280.  
  7281. ---------------------------------------------------
  7282. -- Keep Network updates
  7283. ---------------------------------------------------
  7284. local function AvAPinOnMouseExit(pin)
  7285. FyrMM.SetTargetScale(pin, 1)
  7286. if pin.tooltipId == 4 then
  7287. ZO_Tooltips_HideTextTooltip()
  7288. else
  7289. ZO_KeepTooltip:SetHidden(true)
  7290. end
  7291. end
  7292.  
  7293. local function AvAPinOnMouseEnter(pin)
  7294. FyrMM.SetTargetScale(pin, 1.3)
  7295. if not FyrMM.SV.PinTooltips then
  7296. return
  7297. end
  7298. if pin == nil then
  7299. return
  7300. end
  7301. -- if pin.m_PinType == nil then return end
  7302. -- if ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType] == nil then return end
  7303. -- if not ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType].tooltip then return end
  7304. -- if ZO_MapPin.TOOLTIP_CREATORS[pin.m_PinType].tooltip ~= ZO_KeepTooltip then return end
  7305. if pin.tooltipId == nil then
  7306. return
  7307. end
  7308. if pin.tooltipId == 1 then
  7309. ZO_KeepTooltip:SetKeep(pin.keepId, ZO_WorldMap_GetBattlegroundQueryType(), 95)
  7310. ZO_KeepTooltip:SetHidden(false)
  7311. ZO_KeepTooltip:ClearAnchors()
  7312. ZO_KeepTooltip:SetAnchor(TOPLEFT, Fyr_MM, TOPRIGHT, 0, 0)
  7313. return
  7314. end
  7315. if pin.tooltipId == 2 then
  7316. ZO_KeepTooltip:SetForwardCamp(pin.m_Pin:GetForwardCampIndex())
  7317. ZO_KeepTooltip:SetHidden(false)
  7318. ZO_KeepTooltip:ClearAnchors()
  7319. ZO_KeepTooltip:SetAnchor(TOPLEFT, Fyr_MM, TOPRIGHT, 0, 0)
  7320. return
  7321. end
  7322. if pin.tooltipId == 3 then
  7323. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  7324. InformationTooltip:AddLine(zo_strformat(SI_AVA_OBJECTIVE_ARTIFACT_TOOLTIP, GetAvAObjectiveInfo(pin.keepId,
  7325. pin.objectiveId, ZO_WorldMap_GetBattlegroundQueryType())))
  7326. return
  7327. end
  7328. if pin.tooltipId == 4 then
  7329. ZO_Tooltips_ShowTextTooltip(self, nil,
  7330. zo_strformat(SI_TOOLTIP_ALLIANCE_RESTRICTED_LINK, GetAllianceName(pin.alliance)))
  7331. end
  7332. end
  7333.  
  7334. function FyrMM.UpdateKeepNetworkPositions()
  7335. if not IsInAvAZone() or Fyr_MM:IsHidden() or not CurrentMap.ready then
  7336. return
  7337. end
  7338. local mWidth, mHeight = Fyr_MM_Scroll_Map:GetDimensions()
  7339. local Count, l, startX, startY, endX, endY
  7340. for i = 1, 100 do
  7341. l = GetControl("Fyr_MM_Scroll_Map_Links_Link" .. tostring(i))
  7342. if l ~= nil then
  7343. if FyrMM.SV.WheelMap then
  7344. l:SetParent(Fyr_MM_Scroll_CW_Map_Pins)
  7345. else
  7346. l:SetParent(Fyr_MM_Scroll_Map_Links)
  7347. end
  7348. if FyrMM.SV.RotateMap then
  7349. l:ClearAnchors()
  7350. l:SetAnchor(TOPLEFT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(l.startNX, l.startNY))
  7351. l:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(l.endNX, l.endNY))
  7352. else
  7353. startX, startY, endX, endY = zo_round(l.startNX * mWidth - mWidth / 2),
  7354. zo_round(l.startNY * mHeight - mHeight / 2), zo_round(l.endNX * mWidth - mWidth / 2),
  7355. zo_round(l.endNY * mHeight - mHeight / 2)
  7356. l:ClearAnchors()
  7357. l:SetAnchor(TOPLEFT, Fyr_MM_Scroll_Map_Links, CENTER, startX, startY)
  7358. l:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll_Map_Links, CENTER, endX, endY)
  7359. end
  7360. end
  7361. l = GetControl("Fyr_MM_Scroll_Map_LinksNS_Link" .. tostring(i))
  7362. if l ~= nil then
  7363. if FyrMM.SV.RotateMap then
  7364. l:ClearAnchors()
  7365. l:SetAnchor(TOPLEFT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(l.startNX, l.startNY))
  7366. l:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(l.endNX, l.endNY))
  7367. else
  7368. startX, startY, endX, endY = l.startNX * mWidth - mWidth / 2, l.startNY * mHeight - mHeight / 2,
  7369. l.endNX * mWidth - mWidth / 2, l.endNY * mHeight - mHeight / 2
  7370. l:ClearAnchors()
  7371. l:SetAnchor(TOPLEFT, Fyr_MM_Scroll_Map_Links, CENTER, startX, startY)
  7372. l:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll_Map_Links, CENTER, endX, endY)
  7373. end
  7374. end
  7375. l = GetControl("Fyr_MM_Scroll_Map_LinksWE_Link" .. tostring(i))
  7376. if l ~= nil then
  7377. if FyrMM.SV.RotateMap then
  7378. l:ClearAnchors()
  7379. l:SetAnchor(TOPLEFT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(l.startNX, l.startNY))
  7380. l:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(l.endNX, l.endNY))
  7381. else
  7382. startX, startY, endX, endY = l.startNX * mWidth - mWidth / 2, l.startNY * mHeight - mHeight / 2,
  7383. l.endNX * mWidth - mWidth / 2, l.endNY * mHeight - mHeight / 2
  7384. l:ClearAnchors()
  7385. l:SetAnchor(TOPLEFT, Fyr_MM_Scroll_Map_Links, CENTER, startX, startY)
  7386. l:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll_Map_Links, CENTER, endX, endY)
  7387. end
  7388. end
  7389. end
  7390.  
  7391. Count = Fyr_MM_Scroll_Map_Kill_Locations:GetNumChildren()
  7392. for i = 1, Count do
  7393. l = Fyr_MM_Scroll_Map_Kill_Locations:GetChild(i)
  7394. if l ~= nil then
  7395. if l.normalizedX ~= nil and l.normalizedY ~= nil then
  7396. FyrMM.SetPinAnchor(l, l.normalizedX, l.normalizedY, Fyr_MM_Scroll_Map_Kill_Locations)
  7397. end
  7398. end
  7399. end
  7400. Count = Fyr_MM_Scroll_Map_ForwardCamps:GetNumChildren()
  7401. for i = 1, Count do
  7402. l = Fyr_MM_Scroll_Map_ForwardCamps:GetChild(i)
  7403. if l ~= nil then
  7404. if l.normalizedX ~= nil and l.normalizedY ~= nil then
  7405. FyrMM.SetPinAnchor(l, l.normalizedX, l.normalizedY, Fyr_MM_Scroll_Map_ForwardCamps)
  7406. end
  7407. end
  7408. end
  7409. Count = Fyr_MM_Scroll_Map_Objectives:GetNumChildren()
  7410. for i = 1, Count do
  7411. l = Fyr_MM_Scroll_Map_Objectives:GetChild(i)
  7412. if l ~= nil then
  7413. if l.normalizedX ~= nil and l.normalizedY ~= nil then
  7414. FyrMM.SetPinAnchor(l, l.normalizedX, l.normalizedY, Fyr_MM_Scroll_Map_Objectives)
  7415. end
  7416. end
  7417. end
  7418. for i, v in pairs(KeepIndex) do
  7419. l = GetControl("Fyr_MM_Scroll_Map_Keeps_Keep" .. tostring(v))
  7420. if l ~= nil then
  7421. if l.normalizedX ~= nil and l.normalizedY ~= nil then
  7422. FyrMM.SetPinAnchor(l, l.normalizedX, l.normalizedY, Fyr_MM_Scroll_Map_Keeps)
  7423. end
  7424. end
  7425. l = GetControl("Fyr_MM_Scroll_Map_Keeps_Under_Attack_Keep" .. tostring(i))
  7426. if l ~= nil then
  7427. if l.normalizedX ~= nil and l.normalizedY ~= nil then
  7428. FyrMM.SetPinAnchor(l, l.normalizedX, l.normalizedY, Fyr_MM_Scroll_Map_Keeps)
  7429. end
  7430. end
  7431. end
  7432. end
  7433.  
  7434. function FyrMM.KeepNetworkCleanupReminder(from, parent)
  7435. if parent == nil then
  7436. return
  7437. end
  7438. local t = GetGameTimeMilliseconds()
  7439. local Count = parent:GetNumChildren()
  7440. for i = from, Count do
  7441. l = parent:GetChild(i)
  7442. if l ~= nil then
  7443. l:ClearAnchors()
  7444. l.nX = nil
  7445. l.nY = nil
  7446. l.m_PinType = nil
  7447. l.tooltipId = nil
  7448. l.continuousUpdate = nil
  7449. l.objectiveId = nil
  7450. l:SetHidden(true)
  7451. l:SetMouseEnabled(false)
  7452. l:SetTexture(nil)
  7453. l:SetDimensions(0, 0)
  7454. PinsList[l:GetName()] = nil
  7455. end
  7456. end
  7457. if FyrMM.DebugMode then
  7458. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "FyrMM.KeepNetworkCleanupReminder " .. parent:GetName() .. " " ..
  7459. tostring(GetGameTimeMilliseconds() - t))
  7460. end
  7461. end
  7462.  
  7463. function FyrMM.UpdateKeepNetwork()
  7464. if FyrMM.Halted then
  7465. return
  7466. end
  7467.  
  7468. if CurrentMap.MapId < 578 and CurrentMap.MapId > 571 and FyrMM.dirtyLinks then -- clean links once when arriving at base
  7469. KeepIndex = {}
  7470. local LinksDone = false
  7471. local LinksNSDone = false
  7472. local LinksWEDone = false
  7473. local LocksDone = false
  7474. for i = 1, 100 do
  7475. l = GetControl("Fyr_MM_Scroll_Map_Links_Link" .. tostring(i))
  7476. if l ~= nil then
  7477. l:ClearAnchors()
  7478. l:SetHidden(true)
  7479. l:SetMouseEnabled(false)
  7480. else
  7481. LinksDone = true
  7482. end
  7483. l = GetControl("Fyr_MM_Scroll_Map_LinksNS_Link" .. tostring(i))
  7484. if l ~= nil then
  7485. l:ClearAnchors()
  7486. l:SetHidden(true)
  7487. l:SetMouseEnabled(false)
  7488. else
  7489. LinksNSDone = true
  7490. end
  7491. l = GetControl("Fyr_MM_Scroll_Map_LinksWE_Link" .. tostring(i))
  7492. if l ~= nil then
  7493. l:ClearAnchors()
  7494. l:SetHidden(true)
  7495. l:SetMouseEnabled(false)
  7496. else
  7497. LinksWEDone = true
  7498. end
  7499. l = GetControl("Fyr_MM_Scroll_Map_Locks_Lock" .. tostring(i))
  7500. if l ~= nil then
  7501. l:ClearAnchors()
  7502. l.normalizedX = nil
  7503. l.normalizedY = nil
  7504. l:SetHidden(true)
  7505. l:SetMouseEnabled(false)
  7506. -- l:SetTexture(nil)
  7507. l:SetDimensions(0, 0)
  7508. else
  7509. LocksDone = true
  7510. end
  7511. if LinksDone and LinksNSDone and LinksWEDone and LocksDone then
  7512. i = 100
  7513. end
  7514. end
  7515. FyrMM.dirtyLinks = false
  7516. end
  7517.  
  7518. if CurrentMap.MapId == 16 then
  7519. FyrMM.dirtyLinks = true
  7520. end -- set links as dirty when on the Cyrodiil big map
  7521.  
  7522. if CurrentMap.MapId ~= 16 and CurrentMap.MapId ~= 660 and (CurrentMap.MapId > 577 or CurrentMap.MapId < 572) then -- no links & keep display when not on Cyrodiil map, Imperial city, or the 6 bases
  7523. KeepIndex = {}
  7524. local LinksDone = false
  7525. local LinksNSDone = false
  7526. local LinksWEDone = false
  7527. local LocksDone = false
  7528. for i = 1, 100 do
  7529. l = GetControl("Fyr_MM_Scroll_Map_Links_Link" .. tostring(i))
  7530. if l ~= nil then
  7531. l:ClearAnchors()
  7532. l:SetHidden(true)
  7533. l:SetMouseEnabled(false)
  7534. else
  7535. LinksDone = true
  7536. end
  7537. l = GetControl("Fyr_MM_Scroll_Map_LinksNS_Link" .. tostring(i))
  7538. if l ~= nil then
  7539. l:ClearAnchors()
  7540. l:SetHidden(true)
  7541. l:SetMouseEnabled(false)
  7542. else
  7543. LinksNSDone = true
  7544. end
  7545. l = GetControl("Fyr_MM_Scroll_Map_LinksWE_Link" .. tostring(i))
  7546. if l ~= nil then
  7547. l:ClearAnchors()
  7548. l:SetHidden(true)
  7549. l:SetMouseEnabled(false)
  7550. else
  7551. LinksWEDone = true
  7552. end
  7553. l = GetControl("Fyr_MM_Scroll_Map_Locks_Lock" .. tostring(i))
  7554. if l ~= nil then
  7555. l:ClearAnchors()
  7556. l.normalizedX = nil
  7557. l.normalizedY = nil
  7558. l:SetHidden(true)
  7559. l:SetMouseEnabled(false)
  7560. -- l:SetTexture(nil)
  7561. l:SetDimensions(0, 0)
  7562. else
  7563. LocksDone = true
  7564. end
  7565. if LinksDone and LinksNSDone and LinksWEDone and LocksDone then
  7566. i = 100
  7567. end
  7568. end
  7569.  
  7570. if not IsActiveWorldBattleground() then -- if in battleground we continue to display the objectives
  7571. FyrMM.KeepRefreshNeeded = false
  7572. return
  7573. end
  7574. end
  7575.  
  7576. if not IsInAvAZone() or (not FyrMM.Visible or Fyr_MM:IsHidden()) or
  7577. (not CurrentMap.ready and not CurrentMap.mapBuilt) then
  7578. return
  7579. end
  7580. if not FyrMM.KeepRefreshNeeded then
  7581. return
  7582. end
  7583.  
  7584. local t = GetGameTimeMilliseconds()
  7585. local historyPercent = 100.0
  7586. local playerAlliance = GetUnitAlliance("player")
  7587. local bgContext = ZO_WorldMap_GetBattlegroundQueryType()
  7588. local mWidth, mHeight = Fyr_MM_Scroll_Map:GetDimensions()
  7589. FyrMM.KeepNetworkCleanupReminder(1, Fyr_MM_Scroll_Map_Keeps)
  7590. FyrMM.KeepNetworkCleanupReminder(1, Fyr_MM_Scroll_Map_Keeps_Under_Attack)
  7591.  
  7592. for i = 1, GetNumKeeps() do
  7593. if FyrMM.Reloading then
  7594. return
  7595. end
  7596. local keepId, kbgContext = GetKeepKeysByIndex(i)
  7597. KeepIndex[keepId] = nil
  7598. if IsLocalBattlegroundContext(kbgContext) then
  7599. KeepIndex[keepId] = i
  7600. local pinType, normalizedX, normalizedY = GetHistoricalKeepPinInfo(keepId, bgContext, historyPercent)
  7601. -- normalizedX = zo_round(normalizedX * 10000) / 10000
  7602. -- normalizedY = zo_round(normalizedY * 10000) / 10000
  7603. local keepAlliance = GetKeepAlliance(keepId, bgContext)
  7604. local keepUnderAttack = GetKeepUnderAttack(keepId, bgContext)
  7605. local keepUnderAttackPinType = ZO_WorldMap_GetUnderAttackPinForKeepPin(pinType)
  7606. if FyrMM.IsCoordinatesInMap(normalizedX, normalizedY) then
  7607. local uakeepControl = GetControl("Fyr_MM_Scroll_Map_Keeps_Under_Attack_Keep" .. tostring(keepId))
  7608. if keepUnderAttack then
  7609. if uakeepControl == nil then
  7610. uakeepControl = WINDOW_MANAGER:CreateControl(
  7611. "Fyr_MM_Scroll_Map_Keeps_Under_Attack_Keep" .. tostring(keepId),
  7612. Fyr_MM_Scroll_Map_Keeps_Under_Attack, CT_TEXTURE)
  7613. end
  7614. uakeepControl:SetTexture(GetPinTexture(keepUnderAttackPinType, uakeepControl))
  7615. uakeepControl.nX = normalizedX
  7616. uakeepControl.nY = normalizedY
  7617. uakeepControl.keepId = keepId
  7618. uakeepControl.m_PinType = keepUnderAttackPinType
  7619. uakeepControl:SetHidden(false)
  7620. uakeepControl:SetDrawLayer(1)
  7621. FyrMM.SetPinSize(uakeepControl,
  7622. ZO_MapPin.PIN_DATA[keepUnderAttackPinType].size * FyrMM.pScalePercent, 0)
  7623. FyrMM.SetPinAnchor(uakeepControl, normalizedX, normalizedY, Fyr_MM_Scroll_Map_Keeps_Under_Attack)
  7624. else
  7625. if uakeepControl ~= nil then
  7626. uakeepControl:ClearAnchors()
  7627. uakeepControl.nX = nil
  7628. uakeepControl.nY = nil
  7629. uakeepControl.m_PinType = nil
  7630. uakeepControl:SetHidden(true)
  7631. uakeepControl:SetMouseEnabled(false)
  7632. uakeepControl:SetTexture(nil)
  7633. uakeepControl:SetDimensions(0, 0)
  7634. PinsList[uakeepControl:GetName()] = nil
  7635. end
  7636. end
  7637.  
  7638. local keepControl = GetControl("Fyr_MM_Scroll_Map_Keeps_Keep" .. tostring(i))
  7639. if keepControl == nil then
  7640. keepControl = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_Keeps_Keep" .. tostring(i),
  7641. Fyr_MM_Scroll_Map_Keeps, CT_TEXTURE)
  7642. keepControl:SetHandler("OnMouseEnter", AvAPinOnMouseEnter)
  7643. keepControl:SetHandler("OnMouseExit", AvAPinOnMouseExit)
  7644. end
  7645. keepControl.nX = normalizedX
  7646. keepControl.nY = normalizedY
  7647. keepControl:SetTexture(GetPinTexture(pinType, keepControl))
  7648. keepControl.keepId = keepId
  7649. keepControl.m_PinType = pinType
  7650. keepControl:SetDrawLayer(3)
  7651. FyrMM.SetPinSize(keepControl, ZO_MapPin.PIN_DATA[pinType].size * FyrMM.pScalePercent, 0)
  7652. keepControl:SetHidden(false)
  7653. FyrMM.SetPinAnchor(keepControl, normalizedX, normalizedY, Fyr_MM_Scroll_Map_Keeps)
  7654. local pinTooltipInfo = ZO_MapPin.TOOLTIP_CREATORS[pinType]
  7655. keepControl.tooltipId = 1 -- Keeps
  7656. keepControl:SetMouseEnabled(true)
  7657. else
  7658. keepControl = GetControl("Fyr_MM_Scroll_Map_Keeps_Keep" .. tostring(keepId))
  7659. uakeepControl = GetControl("Fyr_MM_Scroll_Map_Keeps_Keep" .. tostring(keepId))
  7660. if keepControl ~= nil then
  7661. keepControl:SetHidden(true)
  7662. end
  7663. if uakeepControl ~= nil then
  7664. uakeepControl:SetHidden(true)
  7665. end
  7666. end
  7667. end
  7668. end
  7669.  
  7670. local numForwardCamps = GetNumForwardCamps(bgContext)
  7671. FyrMM.currentForwardCamps = 0
  7672. FyrMM.KeepNetworkCleanupReminder(numForwardCamps + 1, Fyr_MM_Scroll_Map_ForwardCamps)
  7673. for i = 1, numForwardCamps do
  7674. local pinType, normalizedX, normalizedY, radius, usable = GetForwardCampPinInfo(bgContext, i)
  7675. -- normalizedX = zo_round(normalizedX * 10000) / 10000
  7676. -- normalizedY = zo_round(normalizedY * 10000) / 10000
  7677. if (normalizedX > 0 and normalizedX < 1.0001 and normalizedY > 0 and normalizedY < 1.0001) then
  7678. if not usable then
  7679. radius = 0
  7680. end
  7681. FyrMM.currentForwardCamps = FyrMM.currentForwardCamps + 1
  7682. local forwardCampControl = GetControl("Fyr_MM_Scroll_Map_ForwardCamps_Pin" ..
  7683. tostring(FyrMM.currentForwardCamps))
  7684. if forwardCampControl == nil then
  7685. forwardCampControl = WINDOW_MANAGER:CreateControl(
  7686. "Fyr_MM_Scroll_Map_ForwardCamps_Pin" .. tostring(FyrMM.currentForwardCamps),
  7687. Fyr_MM_Scroll_Map_ForwardCamps, CT_TEXTURE)
  7688. forwardCampControl:SetHandler("OnMouseEnter", AvAPinOnMouseEnter)
  7689. forwardCampControl:SetHandler("OnMouseExit", AvAPinOnMouseExit)
  7690. end
  7691.  
  7692. local forwardCampBlobControl = GetControl("Fyr_MM_Scroll_Map_ForwardCamps_Pin" ..
  7693. tostring(FyrMM.currentForwardCamps) .. "_Blob")
  7694. if forwardCampBlobControl == nil then
  7695. forwardCampBlobControl = WINDOW_MANAGER:CreateControl(
  7696. "Fyr_MM_Scroll_Map_ForwardCamps_Pin" .. tostring(FyrMM.currentForwardCamps) .. "_Blob",
  7697. Fyr_MM_Scroll_Map_ForwardCamps, CT_TEXTURE)
  7698. end
  7699.  
  7700. local pin = ZO_Object.New(ZO_MapPin)
  7701. forwardCampControl.nX = normalizedX
  7702. forwardCampControl.nY = normalizedY
  7703. forwardCampBlobControl.nX = normalizedX
  7704. forwardCampBlobControl.nY = normalizedY
  7705. pin.normalizedX = normalizedX
  7706. pin.normalizedY = normalizedY
  7707. pin.radius = radius
  7708. pin.m_PinType = pinType
  7709. pin.m_PinTag = ZO_MapPin.CreateForwardCampPinTag(i)
  7710. forwardCampBlobControl.m_Pin = pin
  7711. forwardCampBlobControl:SetDrawLayer(3)
  7712. forwardCampBlobControl:SetTexture("esoui/art/mappins/map_areapin.dds")
  7713. local color = ZO_MAP_PIN_NORMAL_COLOR
  7714. forwardCampBlobControl:SetColor(color:UnpackRGBA())
  7715. forwardCampControl.m_Pin = pin
  7716. forwardCampControl.m_PinType = pinType
  7717. forwardCampControl:SetDrawLayer(3)
  7718. forwardCampControl:SetTexture(ZO_MapPin.PIN_DATA[pinType].texture)
  7719. local campIconSize = 64 * FyrMM.pScalePercent
  7720. local campBlobSize = mHeight * radius * 2
  7721. FyrMM.SetPinSize(forwardCampControl, campIconSize, 0)
  7722. forwardCampBlobControl:SetDimensions(campBlobSize, campBlobSize)
  7723. if FyrMM.SV.WheelMap then
  7724. forwardCampBlobControl:SetParent(Fyr_MM_Scroll_CW_Map_Pins)
  7725. CreateForwardCampAreaSidePins(pin, campBlobSize, usable)
  7726. end
  7727.  
  7728. forwardCampControl:SetHidden(false)
  7729. forwardCampBlobControl:SetHidden(not usable)
  7730. FyrMM.SetPinAnchor(forwardCampControl, normalizedX, normalizedY, Fyr_MM_Scroll_Map_ForwardCamps)
  7731. FyrMM.SetPinAnchor(forwardCampBlobControl, normalizedX, normalizedY, Fyr_MM_Scroll_Map_ForwardCamps)
  7732. forwardCampControl.tooltipId = 2
  7733. forwardCampControl:SetMouseEnabled(true)
  7734. end
  7735. end
  7736.  
  7737. --- Kill Locations (Battles)
  7738. ---
  7739. local killPinCount = 0
  7740. FyrMM.KeepNetworkCleanupReminder(GetNumKillLocations() + 1, Fyr_MM_Scroll_Map_Kill_Locations)
  7741. for i = 1, GetNumKillLocations() do
  7742. local pinType, normalizedX, normalizedY = GetKillLocationPinInfo(i)
  7743. -- normalizedX = zo_round(normalizedX * 10000) / 10000
  7744. -- normalizedY = zo_round(normalizedY * 10000) / 10000
  7745. if (pinType ~= MAP_PIN_TYPE_INVALID) then
  7746. if (ZO_WorldMap_IsPinGroupShown(MAP_FILTER_KILL_LOCATIONS)) then
  7747. if ((normalizedX < 1.001 or normalizedY < 1.001) and (normalizedX > -.001 or normalizedY > -.001)) then
  7748. killPinCount = killPinCount + 1
  7749. local killPin = GetControl("Fyr_MM_Scroll_Map_Kill_Locations_Pin" .. tostring(killPinCount))
  7750. if killPin == nil then
  7751. killPin = WINDOW_MANAGER:CreateControl(
  7752. "Fyr_MM_Scroll_Map_Kill_Locations_Pin" .. tostring(killPinCount),
  7753. Fyr_MM_Scroll_Map_Kill_Locations, CT_TEXTURE)
  7754. end
  7755. local killPinSize = ZO_MapPin.PIN_DATA[pinType].size * FyrMM.pScalePercent
  7756. killPin:SetTexture(ZO_MapPin.PIN_DATA[pinType].texture)
  7757. FyrMM.SetPinSize(killPin, killPinSize, 0)
  7758. local pin = ZO_Object.New(ZO_MapPin)
  7759. pin.normalizedX = normalizedX
  7760. pin.normalizedY = normalizedY
  7761. pin.m_PinType = pinType
  7762. pin.m_PinTag = i
  7763. killPin.m_Pin = pin
  7764. killPin.m_PinType = pinType
  7765. killPin.nX = normalizedX
  7766. killPin.nY = normalizedY
  7767. killPin:SetDrawLayer(3)
  7768. killPin:SetHidden(false)
  7769. FyrMM.SetPinAnchor(killPin, normalizedX, normalizedY, Fyr_MM_Scroll_Map_Kill_Locations)
  7770. end
  7771. end
  7772. end
  7773. end
  7774.  
  7775. local r, g, b
  7776. local numLinks = GetNumKeepTravelNetworkLinks(bgContext)
  7777. local linkControl, linkControlNS, linkControlWE
  7778.  
  7779. for linkIndex = 1, numLinks do
  7780. local linkType, linkOwner, restrictedToAlliance, startNX, startNY, endNX, endNY =
  7781. GetHistoricalKeepTravelNetworkLinkInfo(linkIndex, bgContext, historyPercent)
  7782. -- startNX = zo_round(startNX * 10000) / 10000
  7783. -- startNY = zo_round(startNY * 10000) / 10000
  7784. -- endNX = zo_round(endNX * 10000) / 10000
  7785. -- endNY = zo_round(endNY * 10000) / 10000
  7786. if startNX < 1 or startNY < 1 or endNX < 1 or endNY < 1 then
  7787. local startX, startY, endX, endY = zo_round(startNX * mWidth - mWidth / 2),
  7788. zo_round(startNY * mHeight - mHeight / 2), zo_round(endNX * mWidth - mWidth / 2),
  7789. zo_round(endNY * mHeight - mHeight / 2)
  7790. local linkControl = GetControl("Fyr_MM_Scroll_Map_Links_Link" .. tostring(linkIndex))
  7791. if linkControl == nil then
  7792. linkControl = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_Links_Link" .. tostring(linkIndex),
  7793. Fyr_MM_Scroll_Map_Links, CT_LINE)
  7794. end
  7795. local linkControlNS = GetControl("Fyr_MM_Scroll_Map_LinksNS_Link" .. tostring(linkIndex))
  7796. if linkControlNS == nil then
  7797. linkControlNS = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_LinksNS_Link" .. tostring(linkIndex),
  7798. Fyr_MM_Scroll_NS_Map_Pins, CT_LINE)
  7799. end
  7800. local linkControlWE = GetControl("Fyr_MM_Scroll_Map_LinksWE_Link" .. tostring(linkIndex))
  7801. if GetControl("Fyr_MM_Scroll_Map_LinksWE_Link" .. tostring(linkIndex)) == nil then
  7802. linkControlWE = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_LinksWE_Link" .. tostring(linkIndex),
  7803. Fyr_MM_Scroll_WE_Map_Pins, CT_LINE)
  7804. end
  7805. linkControl.startNX = startNX
  7806. linkControl.startNY = startNY
  7807. linkControl.endNX = endNX
  7808. linkControl.endNY = endNY
  7809. linkControl:SetHidden(false)
  7810. linkControl:SetDrawLayer(1)
  7811.  
  7812. linkControlNS.startNX = startNX
  7813. linkControlNS.startNY = startNY
  7814. linkControlNS.endNX = endNX
  7815. linkControlNS.endNY = endNY
  7816. linkControlNS:SetHidden(false)
  7817. linkControlNS:SetDrawLayer(1)
  7818.  
  7819. linkControlWE.startNX = startNX
  7820. linkControlWE.startNY = startNY
  7821. linkControlWE.endNX = endNX
  7822. linkControlWE.endNY = endNY
  7823. linkControlWE:SetHidden(false)
  7824. linkControlWE:SetDrawLayer(1)
  7825.  
  7826. local linkThickness = math.floor((zo_round(80 * FyrMM.pScalePercent) / 10) / 2) * 2
  7827. if linkThickness < 6 then
  7828. linkThickness = 6
  7829. end
  7830. linkControl:SetThickness(linkThickness)
  7831. linkControlNS:SetThickness(linkThickness)
  7832. linkControlWE:SetThickness(linkThickness)
  7833.  
  7834. if (GetKeepFastTravelInteraction()) then
  7835. if (linkOwner == playerAlliance) then
  7836. if (linkType == FAST_TRAVEL_LINK_ACTIVE) then
  7837. linkControl:SetColor(ZO_KeepNetwork.LINK_READY_COLOR:UnpackRGBA())
  7838. linkControlNS:SetColor(ZO_KeepNetwork.LINK_READY_COLOR:UnpackRGBA())
  7839. linkControlWE:SetColor(ZO_KeepNetwork.LINK_READY_COLOR:UnpackRGBA())
  7840. else
  7841. linkControl:SetColor(ZO_KeepNetwork.LINK_NOT_READY_COLOR:UnpackRGBA())
  7842. linkControlNS:SetColor(ZO_KeepNetwork.LINK_NOT_READY_COLOR:UnpackRGBA())
  7843. linkControlWE:SetColor(ZO_KeepNetwork.LINK_NOT_READY_COLOR:UnpackRGBA())
  7844. end
  7845. else
  7846. r, g, b = GetAllianceColor(linkOwner):UnpackRGB()
  7847. linkControl:SetColor(r, g, b, ZO_KeepNetwork.ALLIANCE_OWNER_ALPHA[linkOwner])
  7848. linkControlNS:SetColor(r, g, b, ZO_KeepNetwork.ALLIANCE_OWNER_ALPHA[linkOwner])
  7849. linkControlWE:SetColor(r, g, b, ZO_KeepNetwork.ALLIANCE_OWNER_ALPHA[linkOwner])
  7850. end
  7851. else
  7852. r, g, b = GetAllianceColor(linkOwner):UnpackRGB()
  7853. linkControl:SetColor(r, g, b, ZO_KeepNetwork.ALLIANCE_OWNER_ALPHA[linkOwner])
  7854. linkControlNS:SetColor(r, g, b, ZO_KeepNetwork.ALLIANCE_OWNER_ALPHA[linkOwner])
  7855. linkControlWE:SetColor(r, g, b, ZO_KeepNetwork.ALLIANCE_OWNER_ALPHA[linkOwner])
  7856. end
  7857. if (linkType == FAST_TRAVEL_LINK_IN_COMBAT) then
  7858. linkControl:SetTexture("EsoUI/Art/AvA/AvA_transitLine_dashed.dds")
  7859. linkControlNS:SetTexture("EsoUI/Art/AvA/AvA_transitLine_dashed.dds")
  7860. linkControlWE:SetTexture("EsoUI/Art/AvA/AvA_transitLine_dashed.dds")
  7861. else
  7862. linkControl:SetTexture("EsoUI/Art/AvA/AvA_transitLine.dds")
  7863. linkControlNS:SetTexture("EsoUI/Art/AvA/AvA_transitLine.dds")
  7864. linkControlWE:SetTexture("EsoUI/Art/AvA/AvA_transitLine.dds")
  7865. end
  7866. if FyrMM.SV.WheelMap then
  7867. linkControl:SetParent(Fyr_MM_Scroll_CW_Map_Pins)
  7868. else
  7869. linkControl:SetParent(Fyr_MM_Scroll_Map_Links)
  7870. end
  7871.  
  7872. linkControl:ClearAnchors()
  7873. linkControlNS:ClearAnchors()
  7874. linkControlWE:ClearAnchors()
  7875.  
  7876. if FyrMM.SV.RotateMap then
  7877. linkControl:SetAnchor(TOPLEFT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(startNX, startNY))
  7878. linkControl:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(endNX, endNY))
  7879. linkControlNS:SetAnchor(TOPLEFT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(startNX, startNY))
  7880. linkControlNS:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(endNX, endNY))
  7881. linkControlWE:SetAnchor(TOPLEFT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(startNX, startNY))
  7882. linkControlWE:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll, CENTER, GetRotatedPosition(endNX, endNY))
  7883. else
  7884. linkControl:SetAnchor(TOPLEFT, Fyr_MM_Scroll_Map_Links, CENTER, startX, startY)
  7885. linkControl:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll_Map_Links, CENTER, endX, endY)
  7886. linkControlNS:SetAnchor(TOPLEFT, Fyr_MM_Scroll_Map_Links, CENTER, startX, startY)
  7887. linkControlNS:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll_Map_Links, CENTER, endX, endY)
  7888. linkControlWE:SetAnchor(TOPLEFT, Fyr_MM_Scroll_Map_Links, CENTER, startX, startY)
  7889. linkControlWE:SetAnchor(BOTTOMRIGHT, Fyr_MM_Scroll_Map_Links, CENTER, endX, endY)
  7890. end
  7891.  
  7892. -- Link Locks
  7893. if (linkOwner == ALLIANCE_NONE and restrictedToAlliance ~= ALLIANCE_NONE) then
  7894. local lockControl = GetControl("Fyr_MM_Scroll_Map_Locks_Lock" .. tostring(linkIndex))
  7895. if lockControl == nil then
  7896. lockControl = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_Locks_Lock" .. tostring(linkIndex),
  7897. Fyr_MM_Scroll_Map_Locks, CT_TEXTURE)
  7898. lockControl:SetAlpha(0.4)
  7899. end
  7900. lockControl:SetTexture("/esoui/art/ava/ava_transitlocked.dds")
  7901. FyrMM.SetPinSize(lockControl, 16 * FyrMM.pScalePercent, 0)
  7902. lockControl:SetHidden(false)
  7903. r, g, b = GetAllianceColor(restrictedToAlliance):UnpackRGB()
  7904. lockControl:SetColor(r, g, b, 1)
  7905. lockControl.alliance = restrictedToAlliance
  7906. lockControl:SetDrawLayer(2)
  7907.  
  7908. if FyrMM.SV.WheelMap then
  7909. lockControl:SetParent(Fyr_MM_Scroll_CW_Map_Pins)
  7910. else
  7911. lockControl:SetParent(Fyr_MM_Scroll_Map_Links)
  7912. end
  7913. lockControl:ClearAnchors()
  7914. lockControl:SetAnchor(CENTER, linkControl, CENTER, 0, 0)
  7915.  
  7916. lockControl.Lock = true
  7917. lockControl.tooltipId = 4
  7918. lockControl:SetHandler("OnMouseEnter", AvAPinOnMouseEnter)
  7919. lockControl:SetHandler("OnMouseExit", AvAPinOnMouseExit)
  7920. lockControl:SetMouseEnabled(true)
  7921. end
  7922. end
  7923. end
  7924.  
  7925. if FyrMM.DebugMode then
  7926. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  7927. "FyrMM.UpdateKeepNetwork " .. tostring(GetGameTimeMilliseconds() - t))
  7928. end
  7929. FyrMM.KeepRefreshNeeded = false
  7930. end
  7931.  
  7932. function FyrMM.RequestKeepRefresh()
  7933. FyrMM.KeepRefreshNeeded = true
  7934. FyrMM.lastKeepRefresh = FyrMM.lastKeepRefresh or 0
  7935. if not IsInAvAZone() or FyrMM.SV.HidePvPPins then
  7936. return
  7937. end
  7938. if FyrMM.lastKeepRefresh ~= GetSecondsSinceMidnight() or FyrMM.lastKeepRefresh == 0 then
  7939. FyrMM.UpdateKeepNetwork()
  7940. FyrMM.lastKeepRefresh = GetSecondsSinceMidnight()
  7941. -- d("refreshing keep network "..GetTimeString())
  7942. end
  7943. if FyrMM.DebugMode then
  7944. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "Keep refresh request ")
  7945. end
  7946. end
  7947.  
  7948. function FyrMM.UpdateAVABGobjectives()
  7949. if FyrMM.Halted or FyrMM.SV.HidePvPPins then
  7950. return
  7951. end
  7952. if (not IsInAvAZone() and not IsActiveWorldBattleground()) or (not FyrMM.Visible or Fyr_MM:IsHidden()) or
  7953. (not CurrentMap.ready and not CurrentMap.mapBuilt) then
  7954. return
  7955. end
  7956. if FyrMM.UpdateAVABGobjectivesBusy then
  7957. return
  7958. end
  7959.  
  7960. FyrMM.UpdateAVABGobjectivesBusy = true
  7961.  
  7962. local bgContext = ZO_WorldMap_GetBattlegroundQueryType()
  7963. local numObjectives = GetNumObjectives()
  7964. FyrMM.KeepNetworkCleanupReminder(1, Fyr_MM_Scroll_Map_Objectives)
  7965.  
  7966. for i = 1, numObjectives do
  7967. local okeepId, objectiveId, obgContext = GetAvAObjectiveKeysByIndex(i)
  7968. if (IsLocalBattlegroundContext(obgContext)) then
  7969. if ZO_WorldMap_IsObjectiveShown(okeepId, objectiveId, obgContext) and
  7970. DoesObjectiveExist(okeepId, objectiveId, obgContext) then
  7971. local opinType, currentX, currentY, continuousUpdate =
  7972. GetAvAObjectivePinInfo(okeepId, objectiveId, bgContext)
  7973. local spawnPinType, spawnX, spawnY = GetObjectiveSpawnPinInfo(okeepId, objectiveId, bgContext)
  7974. local returnPinType, returnX, returnY, returnContinuousUpdate =
  7975. GetObjectiveReturnPinInfo(okeepId, objectiveId, bgContext)
  7976. local visible = IsObjectiveObjectVisible(okeepId, objectiveId, bgContext)
  7977.  
  7978. local alliance = GetCarryableObjectiveHoldingAllianceInfo(okeepId, objectiveId, bgContext)
  7979. local auraR, auraG, auraB, auraA = GetAllianceColor(alliance):UnpackRGBA()
  7980.  
  7981. if spawnPinType ~= MAP_PIN_TYPE_INVALID and visible then
  7982. local objectiveSpawnControl = GetControl(
  7983. "Fyr_MM_Scroll_Map_Objectives_ObjectiveSpawn" .. tostring(objectiveId))
  7984. if objectiveSpawnControl == nil then
  7985. objectiveSpawnControl = WINDOW_MANAGER:CreateControl(
  7986. "Fyr_MM_Scroll_Map_Objectives_ObjectiveSpawn" .. tostring(objectiveId),
  7987. Fyr_MM_Scroll_Map_Objectives, CT_TEXTURE)
  7988. objectiveSpawnControl:SetHandler("OnMouseEnter", AvAPinOnMouseEnter)
  7989. objectiveSpawnControl:SetHandler("OnMouseExit", PinOnMouseExit)
  7990. end
  7991. objectiveSpawnControl.nX = spawnX
  7992. objectiveSpawnControl.nY = spawnY
  7993. objectiveSpawnControl.m_PinType = spawnPinType
  7994. objectiveSpawnControl:SetDrawLayer(3)
  7995. objectiveSpawnControl:SetDrawLevel(ZO_MapPin.PIN_DATA[spawnPinType].level)
  7996. objectiveSpawnControl:SetTexture(GetPinTexture(spawnPinType, objectiveSpawnControl))
  7997. FyrMM.SetPinSize(objectiveSpawnControl, ZO_MapPin.PIN_DATA[spawnPinType].size * FyrMM.pScalePercent,
  7998. 0)
  7999. objectiveSpawnControl:SetHidden(false)
  8000. FyrMM.SetPinAnchor(objectiveSpawnControl, spawnX, spawnY, Fyr_MM_Scroll_Map_Objectives)
  8001. objectiveSpawnControl.keepId = okeepId
  8002. objectiveSpawnControl.objectiveId = objectiveId
  8003. objectiveSpawnControl.tooltipId = 3
  8004. objectiveSpawnControl:SetMouseEnabled(true)
  8005.  
  8006. if FyrMM.SV.borderAVABG then -- create borderpin
  8007. AVABGobjectivesToBorderPins = AVABGobjectivesToBorderPins or {}
  8008.  
  8009. local playerBGalliance = GetUnitBattlegroundAlliance("player")
  8010.  
  8011. -- chaosball base & your "capture the relic" base
  8012. local display = false
  8013. if spawnPinType == MAP_PIN_TYPE_BGPIN_MURDERBALL_SPAWN_NEUTRAL then
  8014. display = true
  8015. elseif spawnPinType == MAP_PIN_TYPE_BGPIN_FLAG_SPAWN_FIRE_DRAKES and playerBGalliance == 1 then
  8016. display = true
  8017. elseif spawnPinType == MAP_PIN_TYPE_BGPIN_FLAG_SPAWN_PIT_DAEMONS and playerBGalliance == 2 then
  8018. display = true
  8019. elseif spawnPinType == MAP_PIN_TYPE_BGPIN_FLAG_SPAWN_STORM_LORDS and playerBGalliance == 3 then
  8020. display = true
  8021. end
  8022.  
  8023. if objectiveSpawnControl and display then
  8024. objectiveSpawnControl.AVABGtype = "spawn"
  8025. AVABGobjectivesToBorderPins["spawn" .. tostring(objectiveId)] = objectiveSpawnControl
  8026. end
  8027. end
  8028. end
  8029.  
  8030. if returnPinType ~= MAP_PIN_TYPE_INVALID and visible then -- Diamond shape icon
  8031. local objectiveReturnControl = GetControl(
  8032. "Fyr_MM_Scroll_Map_Objectives_ObjectiveReturn" .. tostring(objectiveId))
  8033. if objectiveReturnControl == nil then
  8034. objectiveReturnControl = WINDOW_MANAGER:CreateControl(
  8035. "Fyr_MM_Scroll_Map_Objectives_ObjectiveReturn" .. tostring(objectiveId),
  8036. Fyr_MM_Scroll_Map_Objectives, CT_TEXTURE)
  8037. objectiveReturnControl:SetHandler("OnMouseEnter", AvAPinOnMouseEnter)
  8038. objectiveReturnControl:SetHandler("OnMouseExit", PinOnMouseExit)
  8039. end
  8040. objectiveReturnControl.nX = currentX
  8041. objectiveReturnControl.nY = currentY
  8042. objectiveReturnControl.m_PinType = returnPinType
  8043. objectiveReturnControl.continuousUpdate = returnContinuousUpdate
  8044. objectiveReturnControl:SetDrawLayer(3)
  8045. objectiveReturnControl:SetDrawLevel(ZO_MapPin.PIN_DATA[returnPinType].level)
  8046. objectiveReturnControl:SetTexture(GetPinTexture(returnPinType, objectiveReturnControl))
  8047. FyrMM.SetPinSize(objectiveReturnControl,
  8048. ZO_MapPin.PIN_DATA[returnPinType].size * FyrMM.pScalePercent, 0)
  8049. objectiveReturnControl:SetHidden(false)
  8050. FyrMM.SetPinAnchor(objectiveReturnControl, currentX, currentY, Fyr_MM_Scroll_Map_Objectives)
  8051. objectiveReturnControl.keepId = okeepId
  8052. objectiveReturnControl.objectiveId = objectiveId
  8053. objectiveReturnControl.tooltipId = 3
  8054. objectiveReturnControl:SetMouseEnabled(true)
  8055.  
  8056. -- if FyrMM.SV.borderAVABG then -- create borderpin
  8057. -- AVABGobjectivesToBorderPins = AVABGobjectivesToBorderPins or {}
  8058. -- if objectiveReturnControl then
  8059. -- objectiveReturnControl.AVABGtype = "return"
  8060. -- AVABGobjectivesToBorderPins["return"..tostring(objectiveId)] = objectiveReturnControl
  8061. -- end
  8062. -- end
  8063. end
  8064.  
  8065. if opinType ~= MAP_PIN_TYPE_INVALID and visible then
  8066. local objectiveControl = GetControl("Fyr_MM_Scroll_Map_Objectives_Objective" ..
  8067. tostring(objectiveId))
  8068. if objectiveControl == nil then
  8069. objectiveControl = WINDOW_MANAGER:CreateControl(
  8070. "Fyr_MM_Scroll_Map_Objectives_Objective" .. tostring(objectiveId),
  8071. Fyr_MM_Scroll_Map_Objectives, CT_TEXTURE)
  8072. objectiveControl:SetHandler("OnMouseEnter", AvAPinOnMouseEnter)
  8073. objectiveControl:SetHandler("OnMouseExit", PinOnMouseExit)
  8074. end
  8075. objectiveControl.nX = currentX
  8076. objectiveControl.nY = currentY
  8077. objectiveControl.m_PinType = opinType
  8078. objectiveControl.continuousUpdate = continuousUpdate
  8079. objectiveControl:SetDrawLayer(3)
  8080. objectiveControl:SetDrawLevel(ZO_MapPin.PIN_DATA[opinType].level)
  8081. objectiveControl:SetTexture(GetPinTexture(opinType, objectiveControl))
  8082. FyrMM.SetPinSize(objectiveControl, (ZO_MapPin.PIN_DATA[opinType].size * FyrMM.pScalePercent), 0)
  8083. objectiveControl:SetHidden(false)
  8084. FyrMM.SetPinAnchor(objectiveControl, currentX, currentY, Fyr_MM_Scroll_Map_Objectives)
  8085. objectiveControl.keepId = okeepId
  8086. objectiveControl.objectiveId = objectiveId
  8087. objectiveControl.tooltipId = 3
  8088. objectiveControl:SetMouseEnabled(true)
  8089.  
  8090. if FyrMM.SV.borderAVABG then -- create borderpin
  8091. AVABGobjectivesToBorderPins = AVABGobjectivesToBorderPins or {}
  8092. if objectiveControl then
  8093. objectiveControl.AVABGtype = "objective"
  8094. AVABGobjectivesToBorderPins["objective" .. tostring(objectiveId)] = objectiveControl
  8095. end
  8096. end
  8097.  
  8098. if objectiveControl then
  8099. local auraPinType, red, green, blue = GetObjectiveAuraPinInfo(okeepId, objectiveId, bgContext)
  8100. if auraPinType ~= MAP_PIN_TYPE_INVALID and visible then
  8101. local objectiveAuraControl = GetControl(
  8102. "Fyr_MM_Scroll_Map_Objectives_ObjectiveAura" .. tostring(objectiveId))
  8103. if objectiveAuraControl == nil then
  8104. objectiveAuraControl = WINDOW_MANAGER:CreateControl(
  8105. "Fyr_MM_Scroll_Map_Objectives_ObjectiveAura" .. tostring(objectiveId),
  8106. Fyr_MM_Scroll_Map_Objectives, CT_TEXTURE)
  8107. objectiveAuraControl:SetHandler("OnMouseEnter", AvAPinOnMouseEnter)
  8108. objectiveAuraControl:SetHandler("OnMouseExit", PinOnMouseExit)
  8109. end
  8110. local auraTag = ZO_MapPin.CreateObjectivePinTag(okeepId, objectiveId, bgContext)
  8111. objectiveAuraControl.nX = currentX
  8112. objectiveAuraControl.nY = currentY
  8113. objectiveAuraControl.m_PinType = auraPinType
  8114. objectiveAuraControl.m_PinTag = auraTag
  8115. objectiveAuraControl.continuousUpdate = continuousUpdate
  8116. objectiveAuraControl:SetDrawLayer(3)
  8117. objectiveAuraControl:SetDrawLevel(ZO_MapPin.PIN_DATA[auraPinType].level)
  8118. objectiveAuraControl:SetTexture(GetPinTexture(auraPinType, objectiveAuraControl))
  8119. FyrMM.SetPinSize(objectiveAuraControl,
  8120. (ZO_MapPin.PIN_DATA[auraPinType].size * FyrMM.pScalePercent), 0)
  8121. objectiveAuraControl:SetHidden(false)
  8122. FyrMM.SetPinAnchor(objectiveAuraControl, currentX, currentY, Fyr_MM_Scroll_Map_Objectives)
  8123. objectiveAuraControl.keepId = okeepId
  8124. objectiveAuraControl.objectiveId = objectiveId
  8125. objectiveAuraControl.tooltipId = 3
  8126. objectiveAuraControl:SetColor(red, green, blue)
  8127. objectiveAuraControl.tint = ZO_ColorDef:New(red, green, blue)
  8128. objectiveAuraControl:SetMouseEnabled(true)
  8129.  
  8130. if FyrMM.SV.borderAVABG then -- create borderpin
  8131. AVABGobjectivesToBorderPins = AVABGobjectivesToBorderPins or {}
  8132. if objectiveAuraControl then
  8133. objectiveAuraControl.AVABGtype = "aura"
  8134. AVABGobjectivesToBorderPins["aura" .. tostring(objectiveId)] = objectiveAuraControl
  8135. end
  8136. end
  8137. elseif visible and ZO_MapPin.PIN_DATA[opinType].level == 105 and alliance ~= ALLIANCE_NONE then -- let's make an aura pin for elder scrolls which doesn't exist in game :)
  8138. local objectiveAuraControl = GetControl(
  8139. "Fyr_MM_Scroll_Map_Objectives_ObjectiveAura" .. tostring(objectiveId))
  8140. if objectiveAuraControl == nil then
  8141. objectiveAuraControl = WINDOW_MANAGER:CreateControl(
  8142. "Fyr_MM_Scroll_Map_Objectives_ObjectiveAura" .. tostring(objectiveId),
  8143. Fyr_MM_Scroll_Map_Objectives, CT_TEXTURE)
  8144. objectiveAuraControl:SetHandler("OnMouseEnter", AvAPinOnMouseEnter)
  8145. objectiveAuraControl:SetHandler("OnMouseExit", PinOnMouseExit)
  8146. end
  8147. local auraTag = ZO_MapPin.CreateObjectivePinTag(okeepId, objectiveId, bgContext)
  8148. objectiveAuraControl.nX = currentX
  8149. objectiveAuraControl.nY = currentY
  8150. objectiveAuraControl.m_PinType = 9999
  8151. objectiveAuraControl.m_PinTag = auraTag
  8152. objectiveAuraControl.continuousUpdate = continuousUpdate
  8153. objectiveAuraControl:SetDrawLayer(3)
  8154. objectiveAuraControl:SetDrawLevel(104)
  8155. objectiveAuraControl:SetTexture("MiniMap/Textures/scroll_aura.dds")
  8156. FyrMM.SetPinSize(objectiveAuraControl, (64 * FyrMM.pScalePercent), 0)
  8157. objectiveAuraControl:SetHidden(false)
  8158. FyrMM.SetPinAnchor(objectiveAuraControl, currentX, currentY, Fyr_MM_Scroll_Map_Objectives)
  8159. objectiveAuraControl.keepId = okeepId
  8160. objectiveAuraControl.objectiveId = objectiveId
  8161. objectiveAuraControl.tooltipId = 3
  8162. objectiveAuraControl:SetColor(auraR, auraG, auraB, auraA)
  8163. objectiveAuraControl.tint = ZO_ColorDef:New(auraR, auraG, auraB, auraA)
  8164. objectiveAuraControl:SetMouseEnabled(true)
  8165.  
  8166. if FyrMM.SV.borderAVABG then -- create borderpin
  8167. AVABGobjectivesToBorderPins = AVABGobjectivesToBorderPins or {}
  8168. if objectiveAuraControl then
  8169. objectiveAuraControl.AVABGtype = "aura"
  8170. AVABGobjectivesToBorderPins["aura" .. tostring(objectiveId)] = objectiveAuraControl
  8171. end
  8172. end
  8173. end
  8174. end
  8175. end
  8176. end
  8177. end
  8178. end
  8179. FyrMM.UpdateAVABGobjectivesBusy = false
  8180. end
  8181.  
  8182. -------------------------------------------------------------
  8183. -- Miscelaneous functions
  8184. -------------------------------------------------------------
  8185. function FyrMM.IsCoordinatesInMap(nX, nY)
  8186. if nX <= 1 and nX >= 0 and nY <= 1 and nY >= 0 then
  8187. return true
  8188. else
  8189. return false
  8190. end
  8191. end
  8192.  
  8193. function FyrMM.SetCurrentMapZoom(newZoom)
  8194. CurrentMap.ZoomLevel = newZoom
  8195. if FyrMM.SV.ZoomTable ~= nil then
  8196. if not CurrentMap.filename or CurrentMap.filename == "" then
  8197. local filename, _, _ = GetCurrentMapTextureFileInfo()
  8198. CurrentMap.filename = string.lower(filename)
  8199. end
  8200.  
  8201. FyrMM.SV.ZoomTable[CurrentMap.filename] = newZoom
  8202. -- d("set new zoom to "..newZoom.." for "..CurrentMap.filename )
  8203. end
  8204. Fyr_MM_ZoomLevel:SetText(newZoom)
  8205. end
  8206.  
  8207. function FyrMM.UnregisterUpdates(fromRegister)
  8208. if FyrMM.HaltTimeOffset + 1000 > GetFrameTimeMilliseconds() then
  8209. return
  8210. end
  8211. -- if not fromRegister then d("unregister updates") end
  8212. FyrMM.Halted = true
  8213. FyrMM.HaltTimeOffset = GetFrameTimeMilliseconds()
  8214. -- EVENT_MANAGER:UnregisterForUpdate("OnUpdateFyrMMMapView")
  8215. EVENT_MANAGER:UnregisterForUpdate("OnUpdateFyrMMMapPins")
  8216. EVENT_MANAGER:UnregisterForUpdate("OnUpdateFyrMMMapGroupPins")
  8217. -- EVENT_MANAGER:UnregisterForUpdate("OnUpdateFyrMMMapZone")
  8218. EVENT_MANAGER:UnregisterForUpdate("OnUpdateFyrMMMapPosition")
  8219. -- EVENT_MANAGER:UnregisterForUpdate("OnUpdateFyrMMMapKeepNetwork")
  8220. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapMovingObjectivesUpdate")
  8221. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapRWUpdate")
  8222. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapRescale")
  8223. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapWayshrineDistances")
  8224. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapQuestGiverDistances")
  8225. EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapBorderPins")
  8226. end
  8227.  
  8228. function FyrMM.RegisterUpdates()
  8229. if not FyrMM.Halted then
  8230. return
  8231. end
  8232. FyrMM.UnregisterUpdates(true)
  8233. CancelUpdates()
  8234. FyrMM.Halted = false
  8235. FyrMM.HaltTimeOffset = 0
  8236. -- EVENT_MANAGER:RegisterForUpdate("OnUpdateFyrMMMapView", FyrMM.SV.ViewRefreshRate, FyrMM.UpdateMapTiles)
  8237. -- d("register updates")
  8238.  
  8239. EVENT_MANAGER:RegisterForUpdate("OnUpdateFyrMMMapPins", FyrMM.SV.PinRefreshRate, FyrMM.PinUpdate)
  8240. EVENT_MANAGER:RegisterForUpdate("OnUpdateFyrMMMapGroupPins", FyrMM.SV.MapRefreshRate, FyrMM.RefreshGroup)
  8241. -- EVENT_MANAGER:RegisterForUpdate("OnUpdateFyrMMMapZone", FyrMM.SV.ZoneRefreshRate, FyrMM.ZoneUpdate)
  8242. EVENT_MANAGER:RegisterForUpdate("OnUpdateFyrMMMapPosition", FyrMM.SV.MapRefreshRate, FyrMM.PositionUpdate)
  8243. -- EVENT_MANAGER:RegisterForUpdate("OnUpdateFyrMMMapKeepNetwork", FyrMM.SV.KeepNetworkRefreshRate, FyrMM.UpdateKeepNetwork)
  8244. EVENT_MANAGER:RegisterForUpdate("FyrMiniMapMovingObjectivesUpdate", FyrMM.SV.MapRefreshRate,
  8245. FyrMM.UpdateAVABGobjectives)
  8246. EVENT_MANAGER:RegisterForUpdate("FyrMiniMapRWUpdate", 1001, UpdateWheelPins)
  8247. EVENT_MANAGER:RegisterForUpdate("FyrMiniMapRescale", 60, RescalePinPositions)
  8248. EVENT_MANAGER:RegisterForUpdate("FyrMiniMapWayshrineDistances", 5000, WayshrineDistances)
  8249. EVENT_MANAGER:RegisterForUpdate("FyrMiniMapQuestGiverDistances", 2000, QuestGiverDistances)
  8250. EVENT_MANAGER:RegisterForUpdate("FyrMiniMapBorderPins", 2000, FyrMM.PlaceBorderPins)
  8251. end
  8252.  
  8253. -------------------------------------------------------------
  8254. -- On Initialized
  8255. -------------------------------------------------------------
  8256. function FyrMM.LoadScreen() -- Initialize Player group events
  8257. if not FyrMM.SV.StartupInfo then
  8258. d("|ceeeeeeMiniMap by Fyrakin continued by |c3CB371@Masteroshi430|r |ceeeeee v" .. FyrMM.Panel.version .. "|r")
  8259. end
  8260.  
  8261. FyrMM.SV.PanelVersion = FyrMM.Panel.version
  8262.  
  8263. if FYRMM_ZOOM_INCREMENT_AMOUNT == nil then
  8264. FYRMM_ZOOM_INCREMENT_AMOUNT = 1
  8265. end
  8266.  
  8267. EVENT_MANAGER:RegisterForEvent("MiniMapOnUnitCreated", EVENT_UNIT_CREATED, FyrMM.GroupEvent)
  8268. EVENT_MANAGER:RegisterForEvent("MiniMapOnUnitDestroyed", EVENT_UNIT_DESTROYED, FyrMM.GroupEvent)
  8269. EVENT_MANAGER:RegisterForEvent("MiniMapOnGroupDisbanded", EVENT_GROUP_DISBANDED, FyrMM.GroupEvent)
  8270. EVENT_MANAGER:RegisterForEvent("MiniMapOnLeaderUpdated", EVENT_LEADER_UPDATE, FyrMM.GroupEvent)
  8271. FyrMM.GroupEvent()
  8272. FyrMM.UpdateQuestPins()
  8273. FyrMM.getHouseStatus()
  8274.  
  8275. local pinTooltipInfo = ZO_MapPin.TOOLTIP_CREATORS[MAP_PIN_TYPE_PLAYER]
  8276. Fyr_MM_Player:SetHandler("OnMouseEnter", function(Fyr_MM_Player)
  8277. FyrMM.SetTargetScale(Fyr_MM_Player, 1.3)
  8278. if not FyrMM.SV.PinTooltips then
  8279. return
  8280. end
  8281. InitializeTooltip(InformationTooltip, Fyr_MM, TOPLEFT, 0, 0)
  8282. InformationTooltip:AppendUnitName("player")
  8283. end)
  8284. Fyr_MM_Player:SetHandler("OnMouseExit", function(Fyr_MM_Player)
  8285. FyrMM.SetTargetScale(Fyr_MM_Player, 1)
  8286. ClearTooltip(InformationTooltip)
  8287. end)
  8288. Fyr_MM_Player:SetMouseEnabled(true)
  8289. EVENT_MANAGER:UnregisterForEvent("MiniMap", EVENT_PLAYER_ACTIVATED)
  8290. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_PLAYER_ACTIVATED, FyrMM.getHouseStatus)
  8291. end
  8292.  
  8293. function FyrMM.InitialPreload(task)
  8294. if FyrMM.DebugMode then
  8295. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "FyrMM.InitialPreload Start:")
  8296. end
  8297. task = task or 0
  8298.  
  8299. if task == 0 then
  8300. -- d("go")
  8301. FyrMM.InitialPreloadTimeStamp = GetFrameTimeMilliseconds()
  8302. FyrMM.SV.DebugLog = nil
  8303. if FyrMM.Reloading then
  8304. return
  8305. end
  8306. end
  8307.  
  8308. local time = task + 30
  8309.  
  8310. if task == 0 then
  8311. FyrMM.SetMapToPlayerLocation()
  8312. CurrentMap.ZoneIndex = GetCurrentMapZoneIndex()
  8313. zo_callLater(function()
  8314. FyrMM.InitialPreload(task + 1)
  8315. end, time)
  8316. return
  8317. elseif task == 1 then
  8318. FyrMM.UpdateMapInfo()
  8319. zo_callLater(function()
  8320. FyrMM.InitialPreload(task + 1)
  8321. end, time)
  8322. return
  8323. elseif task == 2 then
  8324. FyrMM.UpdateMapTiles(true)
  8325. zo_callLater(function()
  8326. FyrMM.InitialPreload(task + 1)
  8327. end, time)
  8328. return
  8329. elseif task == 3 then
  8330. FyrMM.Show()
  8331. zo_callLater(function()
  8332. FyrMM.InitialPreload(task + 1)
  8333. end, time)
  8334. return
  8335. elseif task == 4 then
  8336. FyrMM.MapHalfDiagonal()
  8337. zo_callLater(function()
  8338. FyrMM.InitialPreload(task + 1)
  8339. end, time)
  8340. return
  8341. elseif task == 5 then
  8342. FyrMM.PositionUpdate()
  8343. zo_callLater(function()
  8344. FyrMM.InitialPreload(task + 1)
  8345. end, time)
  8346. return
  8347. elseif task == 6 then
  8348. FyrMM.GroupEvent()
  8349. zo_callLater(function()
  8350. FyrMM.InitialPreload(task + 1)
  8351. end, time)
  8352. return
  8353. elseif task == 7 then
  8354. FyrMM.UpdateQuestPins()
  8355. zo_callLater(function()
  8356. FyrMM.InitialPreload(task + 1)
  8357. end, time)
  8358. return
  8359. elseif task == 8 then
  8360. CurrentMap.needRescale = true
  8361. RescalePinPositions()
  8362. zo_callLater(function()
  8363. FyrMM.InitialPreload(task + 1)
  8364. end, time)
  8365. return
  8366. elseif task == 9 then
  8367. if FyrMM.SV.BorderPins then
  8368. FyrMM.PlaceBorderPins()
  8369. end
  8370. zo_callLater(function()
  8371. FyrMM.InitialPreload(task + 1)
  8372. end, time)
  8373. return
  8374. elseif task == 10 then
  8375. if IsInAvAZone() then
  8376. FyrMM.RequestKeepRefresh()
  8377. end
  8378. zo_callLater(function()
  8379. FyrMM.InitialPreload(task + 1)
  8380. end, time)
  8381. return
  8382. elseif task == 11 then
  8383. FyrMM.PinUpdate()
  8384. FyrMM.UpdateAntiquityDigSites()
  8385. zo_callLater(function()
  8386. FyrMM.InitialPreload(task + 1)
  8387. end, time)
  8388. return
  8389. elseif task >= 12 then
  8390. if FyrMM.DebugMode then
  8391. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "FyrMM.InitialPreload Done." ..
  8392. tostring(GetGameTimeMilliseconds() - FyrMM.InitialPreloadTimeStamp))
  8393. end
  8394. FyrMM.RegisterUpdates()
  8395. end
  8396. -- d("preload time ="..GetFrameTimeMilliseconds()-FyrMM.InitialPreloadTimeStamp) -- 450/500ms is too much!
  8397. end
  8398.  
  8399. function FyrMM.CheckForNewCustomPins()
  8400. if not IsTableEmpty(FyrMM.CustomPinCheckList) then
  8401. for i, n in pairs(FyrMM.CustomPinCheckList) do
  8402. for p, j in pairs(n) do
  8403. if j.Id == 0 then
  8404. if j.m_PinType ~= nil and j.normalizedX ~= nil and j.normalizedY ~= nil then
  8405. local r = {
  8406. m_PinType = i,
  8407. m_PinTag = j.m_PinTag,
  8408. normalizedX = j.normalizedX,
  8409. normalizedY = j.normalizedY,
  8410. radius = j.radius
  8411. }
  8412. table.insert(FyrMM.CustomPinList[i], r)
  8413. FyrMM.CustomPinCheckList[i][p].Id = #FyrMM.CustomPinList[i]
  8414. end
  8415. end
  8416. end
  8417. end
  8418. end
  8419. detectedNewCustomPin = false
  8420. end
  8421.  
  8422. function FyrMM.FastTravelInteraction(Interacting, Index, EventCode)
  8423. if FyrMM.DebugMode then
  8424. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "FyrMM.FastTravelInteraction (" .. tostring(Interacting) .. ") " ..
  8425. tostring(Index))
  8426. end
  8427. if Interacting then
  8428. FyrMM.FastTravelOpen = true
  8429. FyrMM.UnregisterUpdates()
  8430. CancelUpdates()
  8431. FyrMM.Reloading = true
  8432. else
  8433. -- CurrentTasks = {}
  8434. FyrMM.Reloading = false
  8435. FyrMM.FastTravelOpen = false
  8436.  
  8437. -- CurrentMap.filename = "reset" -- test 15/11/2022
  8438. -- if FyrMM.CheckingZone == false then FyrMM.ZoneCheck() end -- test 15/11/2022
  8439. end
  8440. end
  8441.  
  8442. function FyrMM.LoadCustomPinList()
  8443. if Fyr_MM:IsHidden() then
  8444. return
  8445. end
  8446. -- d("Load custom pins")
  8447. if PRCustomPins then
  8448. if not IsTableEmpty(PRCustomPins) then
  8449. FyrMM.CustomPinList = {}
  8450. FyrMM.CustomPinCheckList = {}
  8451. local t = 0
  8452. for i, n in pairs(PRCustomPins) do
  8453. t = t + 1
  8454.  
  8455. zo_callLater(function()
  8456. FyrMM.LoadCustomPinGroup(i)
  8457. end, t)
  8458. end
  8459. end
  8460. end
  8461. end
  8462.  
  8463. function FyrMM.ResetCustomPinList()
  8464. if Fyr_MM:IsHidden() then
  8465. return
  8466. end
  8467.  
  8468. if PRCustomPins and not IsTableEmpty(PRCustomPins) then
  8469. FyrMM.CustomPinList = {}
  8470. FyrMM.CustomPinCheckList = {}
  8471.  
  8472. for i, n in pairs(PRCustomPins) do
  8473. zo_callLater(function()
  8474. FyrMM.UpdateCustomPinGroup(i)
  8475. end, i)
  8476. end
  8477. end
  8478. end
  8479.  
  8480. local _FindPin = _G["ZO_WorldMapPins"].FindPin
  8481.  
  8482. local function FindPin(obj, pinTypeString, pinType, pinIndex)
  8483. if FyrMM.LoadingCustomPins then
  8484. if FyrMM.LoadingCustomPins[pinType] then
  8485. return nil
  8486. end
  8487. end
  8488. return _FindPin(obj, pinTypeString, pinType, pinIndex)
  8489. end
  8490. _G["ZO_WorldMapPins"].FindPin = FindPin
  8491.  
  8492. local _CreatePin = _G["ZO_WorldMapPins"].CreatePin
  8493.  
  8494. local function CreatePin(obj, pinType, pinTag, x, y, radius, borderInformation)
  8495. if not obj or not pinType then
  8496. return
  8497. end
  8498.  
  8499. if not PinRef then
  8500. PinRef = obj
  8501. FyrMM.PinRef = obj
  8502. PRCustomPins = obj.customPins
  8503. if PinRef and PinRef.playerPin and PinRef.playerPin.PIN_DATA then
  8504. ZOpinData = PinRef.playerPin.PIN_DATA
  8505. FyrMM.ZOpinData = ZOpinData
  8506. end
  8507. end
  8508.  
  8509. local mapId = FyrMM.GetMapId()
  8510. if CurrentMap.MapId ~= mapId and not Fyr_MM:IsHidden() and FyrMM.CheckingZone == false then
  8511. FyrMM.ZoneCheck()
  8512. -- if MapId ~= "unknown" then
  8513. -- CurrentMap.MapId = mapId
  8514. -- end
  8515. if FyrMM.DebugMode then
  8516. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "CreatePin detected New Map ID:" .. tostring(mapId))
  8517. end
  8518. end
  8519.  
  8520. CustomPinMapId = CurrentMap.MapId
  8521.  
  8522. if not FyrMM.FastTravelOpen and x ~= nil and y ~= nil and CustomWaypoints[pinType] and CustomPinMapId ~= 0 then -- "unknown"
  8523. if pinType == MAP_PIN_TYPE_PING and FyrMM.Ping ~= nil then
  8524. FyrMM.Ping.nX = x
  8525. FyrMM.Ping.nY = y
  8526. FyrMM.Ping:RefreshAnchor()
  8527. end
  8528. if pinType == MAP_PIN_TYPE_RALLY_POINT and FyrMM.Rally ~= nil then
  8529. FyrMM.Rally.nX = x
  8530. FyrMM.Rally.nY = y
  8531. FyrMM.Rally:RefreshAnchor()
  8532. end
  8533. if pinType == MAP_PIN_TYPE_PLAYER_WAYPOINT and FyrMM.Waypoint ~= nil then
  8534. FyrMM.Waypoint.nX = x
  8535. FyrMM.Waypoint.nY = y
  8536. FyrMM.Waypoint:RefreshAnchor()
  8537. end
  8538. end
  8539.  
  8540. local newPin = false
  8541. local key = ""
  8542. local r = {}
  8543.  
  8544. if PRCustomPins[pinType] or ZONE_EXPLORATION_PIN_TYPES[pinType] then
  8545. key = tostring(x) .. ":" .. tostring(y) .. ":" .. tostring(radius)
  8546. r = {
  8547. m_PinType = pinType,
  8548. m_PinTag = pinTag,
  8549. normalizedX = x,
  8550. normalizedY = y,
  8551. radius = radius
  8552. }
  8553.  
  8554. if FyrMM.CustomPinCheckList[pinType] == nil then
  8555. FyrMM.CustomPinCheckList[pinType] = {}
  8556. end
  8557.  
  8558. if CurrentMap.MapId == mapId and not FyrMM.FastTravelOpen then
  8559. if not FyrMM.LoadingCustomPins[pinType] then
  8560. if FyrMM.CustomPinCheckList[pinType][key] == nil then
  8561. if FyrMM.DebugMode then
  8562. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "Detected new Pin:" .. tostring(pinTag) .. " " ..
  8563. tostring(pinType))
  8564. end
  8565. if pinType ~= nil then
  8566. if FyrMM.CustomPinList[pinType] == nil then
  8567. FyrMM.CustomPinList[pinType] = {}
  8568. end
  8569. table.insert(FyrMM.CustomPinList[pinType], r)
  8570. FyrMM.CustomPinCheckList[pinType][key] = r
  8571. FyrMM.CustomPinCheckList[pinType][key].Id = #FyrMM.CustomPinList[pinType]
  8572. detectedNewCustomPin = true
  8573. end
  8574. end
  8575. end
  8576. end
  8577. end
  8578.  
  8579. if FyrMM.LoadingCustomPins[pinType] then
  8580. key = tostring(x) .. ":" .. tostring(y) .. ":" .. tostring(radius) -- added to test
  8581. r = {
  8582. m_PinType = pinType,
  8583. m_PinTag = pinTag,
  8584. normalizedX = x,
  8585. normalizedY = y,
  8586. radius = radius
  8587. } -- added to test
  8588.  
  8589. if FyrMM.DebugMode then
  8590. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug", "Create Pin:" .. tostring(pinTag) .. " " .. tostring(pinType))
  8591. end
  8592. if pinType then
  8593. if FyrMM.CustomPinList[pinType] == nil then
  8594. FyrMM.CustomPinList[pinType] = {}
  8595. end
  8596. table.insert(FyrMM.CustomPinList[pinType], r)
  8597. FyrMM.CustomPinCheckList[pinType][key] = r
  8598. FyrMM.CustomPinCheckList[pinType][key].Id = #FyrMM.CustomPinList[pinType]
  8599. end
  8600.  
  8601. local timeout = 100
  8602. if string.sub(PRCustomPins[pinType].pinTypeString, 1, 4) == "DEST" then -- destinations addon pintypes
  8603. timeout = 200
  8604. end
  8605.  
  8606. zo_callLater(function()
  8607. FyrMM.LoadingCustomPins[pinType] = false
  8608. end, timeout) -- was 100
  8609.  
  8610. -- Compatibility with WaypointIt code:
  8611. if WaypointIt then
  8612. local func = function()
  8613. return false
  8614. end
  8615. r.IsGroup = func
  8616. r.IsPOI = func
  8617. r.IsLocation = func
  8618. r.IsQuest = func
  8619. r.IsAvAObjective = func
  8620. r.IsKeep = func
  8621. r.IsMapPing = func
  8622. r.IsKillLocation = func
  8623. r.IsFastTravelKeep = func
  8624. r.IsFastTravelWayShrine = func
  8625. r.IsForwardCamp = func
  8626. r.IsAvARespawn = func
  8627. r.UpdateLocation = function()
  8628. end
  8629. r.GetNormalizedPosition = function(self)
  8630. return self.normalizedX, self.normalizedY
  8631. end
  8632. r.GetPinTypeAndTag = function(self)
  8633. return self.m_PinType, self.m_PinTag
  8634. end
  8635. r.PIN_DATA = ZOpinData
  8636. end
  8637. --
  8638. return r
  8639. else
  8640. if FyrMM.DebugMode then
  8641. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  8642. "Passed Create Pin:" .. tostring(pinTag) .. " " .. tostring(pinType))
  8643. end
  8644. local pin = _CreatePin(obj, pinType, pinTag, x, y, radius, borderInformation)
  8645. return pin
  8646. end
  8647. end
  8648. _G["ZO_WorldMapPins"].CreatePin = CreatePin
  8649.  
  8650. function FyrMM.LoadCustomPinGroup(Type)
  8651. if Fyr_MM:IsHidden() then
  8652. return
  8653. end
  8654. if PRCustomPins and PRCustomPins[Type] and PRCustomPins[Type].enabled and PRCustomPins[Type].layoutCallback and type(PRCustomPins[Type].layoutCallback) == "function" then
  8655. local gameTime = GetGameTimeMilliseconds()
  8656.  
  8657. if FyrMM.LoadingCustomPins[Type] then
  8658. zo_callLater(function()
  8659. FyrMM.LoadCustomPinGroup(Type)
  8660. end, 100)
  8661. return
  8662. end
  8663. if FyrMM.UpdatingCustomPins[Type] or Fyr_MM:IsHidden() then
  8664. return
  8665. end
  8666. if FyrMM.CustomPinList == nil then
  8667. FyrMM.CustomPinList = {}
  8668. end
  8669. FyrMM.CustomPinList[Type] = {}
  8670. FyrMM.LoadingCustomPins[Type] = true
  8671. PRCustomPins[Type].layoutCallback(PinRef)
  8672. zo_callLater(function()
  8673. FyrMM.LoadingCustomPins[Type] = false
  8674. end, 100) -- 500
  8675. if FyrMM.DebugMode then
  8676. CALLBACK_MANAGER:FireCallbacks("FyrMMDebug",
  8677. "FyrMM.LoadCustomPinGroup " .. tostring(Type) .. " Done. " ..
  8678. tostring(GetGameTimeMilliseconds() - gameTime))
  8679. end
  8680. end
  8681. end
  8682.  
  8683. local function InitFinish()
  8684. FyrMM.Initialized = true
  8685. if FyrMM.SV.MenuAutoHide then
  8686. zo_callLater(FyrMM.MenuFadeOut, 3000)
  8687. end
  8688. end
  8689.  
  8690. function FyrMM.UpdateCustomPinGroup(pinType)
  8691. --[[ d("UpdateCustomPinGroup triggered for "..pinType) --]]
  8692. if pinType >= MAP_PIN_TYPE_INVALID then
  8693. -- d("UpdateCustomPinGroup "..pinType)
  8694. if FyrMM.UpdatingCustomPins[pinType] then --[[ d("UpdateCustomPinGroup "..pinType.." not done because FyrMM.UpdatingCustomPins[pinType]") --]]
  8695. return
  8696. end
  8697. if Fyr_MM:IsHidden() then --[[ d("UpdateCustomPinGroup "..pinType.." not done because Fyr_MM:IsHidden()") --]]
  8698. return
  8699. end
  8700.  
  8701. if FyrMM.CustomPinList[pinType] then
  8702. if #FyrMM.CustomPinList[pinType] == 0 then --[[ d("UpdateCustomPinGroup "..pinType.." FyrMM.CustomPinList[pinType] is empty")--]]
  8703. return
  8704. end
  8705.  
  8706. FyrMM.UpdatingCustomPins[pinType] = true
  8707. for i, n in pairs(FyrMM.CustomPinList[pinType]) do
  8708. if n.pin then
  8709. local pin = GetControl(n.pin:GetName())
  8710. -- d("method 1: removing pin "..n.pin:GetName())
  8711. RemoveCustomPin(pin)
  8712. else
  8713. local Index = n.Index or i
  8714. if CustomPinKeyIndex[pinType] then
  8715. local pin = GetControl("Fyr_MM_Scroll_Map_Pins_Pin" ..
  8716. tostring(CustomPinKeyIndex[pinType][Index]))
  8717. -- d("method 2: removing pin Fyr_MM_Scroll_Map_Pins_Pin"..tostring(CustomPinKeyIndex[pinType][Index]))
  8718. RemoveCustomPin(pin)
  8719. end
  8720. end
  8721. end
  8722.  
  8723. zo_callLater(function()
  8724. FyrMM.CustomPinList[pinType] = {}
  8725. FyrMM.UpdatingCustomPins[pinType] = false
  8726. FyrMM.LoadCustomPinGroup(pinType)
  8727. CheckCustomPinConsistence(pinType)
  8728. FyrMM.customPinsUpdateCount = nil
  8729. end, 30)
  8730. else
  8731. --[[ d("UpdateCustomPinGroup FyrMM.CustomPinList[pinType] is nil") --]]
  8732. return
  8733. end
  8734. end
  8735. end
  8736.  
  8737. local function SetPinLocation(pin, nX, nY, radius)
  8738. pin.nX = nX
  8739. pin.nY = nY
  8740. pin.radius = radius
  8741. if CustomPinCrossReference[pin] then
  8742. CustomPinCrossReference[pin].nX = nX
  8743. CustomPinCrossReference[pin].nY = nY
  8744. CustomPinCrossReference[pin].radius = radius
  8745. FyrMM.SetPinAnchor(CustomPinCrossReference[pin], nX, nY, Fyr_MM_Scroll_Map_Pins)
  8746. end
  8747. end
  8748.  
  8749. function FyrMM.getHouseStatus() -- we check if we are in a house
  8750. if GetCurrentZoneHouseId() > 0 then
  8751. FyrMM.isInHouse = true
  8752. else
  8753. FyrMM.isInHouse = false
  8754. end
  8755. end
  8756.  
  8757. local function OnInit() -- Initialize Map and Update events after add-on load
  8758. Fyr_MM_Frame_Control:SetAnchor(CENTER, Fyr_MM, CENTER, 0, 0)
  8759. Fyr_MM_Wheel_Background:SetAnchor(CENTER, Fyr_MM, CENTER, 0, 0)
  8760. Fyr_MM_Wheel_Background:SetTexture("MiniMap/Textures/wheelbackground.dds")
  8761. Fyr_MM_Scroll_WheelNS:SetAnchor(CENTER, Fyr_MM_Scroll, CENTER, 0, 0)
  8762. Fyr_MM_Scroll_WheelWE:SetAnchor(CENTER, Fyr_MM_Scroll, CENTER, 0, 0)
  8763. Fyr_MM_Scroll_WheelCenter:SetAnchor(CENTER, Fyr_MM_Scroll, CENTER, 0, 0)
  8764. MenuAnimation = ZO_AlphaAnimation:New(Fyr_MM_Menu)
  8765.  
  8766. FyrMM.LAM = LibAddonMenu2
  8767. FyrMM.CPL = FyrMM.LAM:RegisterAddonPanel("FyrMiniMap", FyrMM.Panel)
  8768. FyrMM.SettingsPanel = FyrMM.LAM:RegisterOptionControls("FyrMiniMap", FyrMM.Options)
  8769.  
  8770. Fyr_MM:SetHandler("OnMouseWheel", function(self, delta, ctrl, alt, shift)
  8771. if not FyrMM.SV.MouseWheel then
  8772. return
  8773. end
  8774. if delta < 0 then
  8775. FyrMM.ZoomOut()
  8776. elseif delta > 0 then
  8777. FyrMM.ZoomIn()
  8778. end
  8779. end)
  8780.  
  8781. Fyr_MM_Time:SetHandler("OnMouseUp", function(self, button, upInside, ctrl, alt, shift, command) -- not working
  8782. if upInside then
  8783. FyrMM.TimeFormat = FyrMM.TimeFormat + 1
  8784. if FyrMM.TimeFormat > 2 then
  8785. FyrMM.TimeFormat = 0
  8786. end
  8787. FyrMM.SV.TimeFormat = FyrMM.TimeFormat
  8788. end
  8789. end)
  8790.  
  8791. if not FyrMM.SV.HideZoneLabel then
  8792. FyrMM.UpdateLabels()
  8793. end
  8794.  
  8795. EVENT_MANAGER:RegisterForUpdate("OnUpdateFyrMMHideCheck", 100, FyrMM.HideCheck)
  8796. EVENT_MANAGER:RegisterForUpdate("OnUpdateFyrMMLogPosition", 30, LogPosition)
  8797. EVENT_MANAGER:RegisterForUpdate("OnUpdateFyrMMSpeedMeasure", 301, SpeedMeasure)
  8798. EVENT_MANAGER:RegisterForUpdate("OnUpdateFyrMMRefreshEventUnits", 100, FyrMM.RefreshEventUnits)
  8799.  
  8800. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_QUEST_ADDED, function(_, questIndex)
  8801. if IsJournalQuestIndexInTrackedZoneStory(questIndex) then
  8802. RemoveCustomPin(FyrMM.ZoneStoryPin)
  8803. FyrMM.ZoneStoryPin = nil
  8804. end
  8805. FyrMM.RequestQuestPinUpdate()
  8806. end) -- testing 27/11/2022
  8807. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_QUEST_ADVANCED, FyrMM.RequestQuestPinUpdate)
  8808. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_QUEST_COMPLETE_DIALOG, FyrMM.RequestQuestPinUpdate)
  8809. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_QUEST_COMPLETE, FyrMM.RequestQuestPinUpdate)
  8810. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_QUEST_CONDITION_COUNTER_CHANGED, FyrMM.RequestQuestPinUpdate)
  8811. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_QUEST_LIST_UPDATED, FyrMM.RequestQuestPinUpdate)
  8812. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_QUEST_OFFERED, FyrMM.RequestQuestPinUpdate)
  8813. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_QUEST_OPTIONAL_STEP_ADVANCED, FyrMM.RequestQuestPinUpdate)
  8814. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_MOUSE_REQUEST_ABANDON_QUEST, FyrMM.RequestQuestPinUpdate)
  8815. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_QUEST_REMOVED, FyrMM.RequestQuestPinUpdate)
  8816. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_QUEST_TOOL_UPDATED, FyrMM.RequestQuestPinUpdate)
  8817. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_ACTIVE_QUEST_TOOL_CLEARED, FyrMM.RequestQuestPinUpdate)
  8818. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_ACTIVE_QUEST_TOOL_CHANGED, FyrMM.RequestQuestPinUpdate)
  8819. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_OBJECTIVES_UPDATED, FyrMM.RequestQuestPinUpdate)
  8820. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_POI_UPDATED, DelayedPOIPins)
  8821. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_DISCOVERY_EXPERIENCE, function()
  8822. FyrMM.Wayshrines()
  8823. end)
  8824.  
  8825. -- ava
  8826. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_KEEPS_INITIALIZED, FyrMM.RequestKeepRefresh)
  8827. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_KEEP_ALLIANCE_OWNER_CHANGED, FyrMM.RequestKeepRefresh)
  8828. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_KEEP_END_INTERACTION, FyrMM.RequestKeepRefresh)
  8829. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_KEEP_GATE_STATE_CHANGED, FyrMM.RequestKeepRefresh)
  8830. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_KEEP_GUILD_CLAIM_UPDATE, FyrMM.RequestKeepRefresh)
  8831. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_KEEP_INITIALIZED, FyrMM.RequestKeepRefresh)
  8832. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_KEEP_OWNERSHIP_CHANGED_NOTIFICATION, FyrMM.RequestKeepRefresh)
  8833. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_KEEP_RESOURCE_UPDATE, FyrMM.RequestKeepRefresh)
  8834. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_KEEP_START_INTERACTION, FyrMM.RequestKeepRefresh)
  8835. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_KEEP_UNDER_ATTACK_CHANGED, FyrMM.RequestKeepRefresh)
  8836. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_KILL_LOCATIONS_UPDATED, FyrMM.RequestKeepRefresh)
  8837. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_FORWARD_CAMPS_UPDATED, FyrMM.RequestKeepRefresh)
  8838.  
  8839. FOCUSED_QUEST_TRACKER:RegisterCallback("QuestTrackerAssistStateChanged", function()
  8840. FyrMM.UpdateQuestPinPositions()
  8841. end)
  8842. FOCUSED_QUEST_TRACKER:RegisterCallback("QuestTrackerRefreshedMapPins", function()
  8843. FyrMM.RequestQuestPinUpdate()
  8844. end)
  8845. CALLBACK_MANAGER:RegisterCallback("OnFyrMiniNewMapEntered", DelayedReload)
  8846. CALLBACK_MANAGER:RegisterCallback("OnFyrMiniMapChanged", FyrMM.UpdateLabels)
  8847. CALLBACK_MANAGER:RegisterCallback("FyrMMDebug", function(value)
  8848. if FyrMM.DebugMode then
  8849. FyrMM.Debug_d(value)
  8850. end
  8851. end)
  8852.  
  8853. CALLBACK_MANAGER:RegisterCallback("OnWorldMapChanged", function(manual)
  8854. local filename, _, _ = GetCurrentMapTextureFileInfo()
  8855. if manual == nil and string.lower(CurrentMap.filename) ~= string.lower(filename) and not FyrMM.FastTravelOpen then
  8856. FyrMM.Refresh = true
  8857. FyrMM.UpdateLabels()
  8858. FyrMM.ZoneCheck()
  8859. return false
  8860. elseif manual == nil and FyrMM.SV.ZoneNameContents ~= "Classic (Map only)" and not FyrMM.FastTravelOpen then -- update zone name for Map & Area and Area only option
  8861. if not FyrMM.SV.HideZoneLabel then
  8862. FyrMM.UpdateLabels()
  8863. end
  8864. return false
  8865. else -- change is manual
  8866. FyrMM.Refresh = false
  8867. end
  8868. end)
  8869.  
  8870. CALLBACK_MANAGER:RegisterCallback("OnWorldMapModeChanged", function(mode)
  8871. zo_callLater(function()
  8872. if ZO_WorldMap:IsHidden() then
  8873. if SetMapToPlayerLocation() ~= SET_MAP_RESULT_CURRENT_MAP_UNCHANGED then
  8874. CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
  8875. end
  8876. FyrMM.ZoneCheck()
  8877. else
  8878. FyrMM.UnregisterUpdates()
  8879. CancelUpdates()
  8880. end
  8881. -- EVENT_MANAGER:UnregisterForUpdate("FyrMiniMapOnWorldMapModeChanged")
  8882. end, 20)
  8883. end)
  8884.  
  8885. function ZO_WorldMapPins_Manager:RefreshCustomPins(optionalPinType)
  8886. for pinTypeId, pinData in pairs(self.customPins) do
  8887. if optionalPinType == nil or optionalPinType == pinTypeId then
  8888. self:RemovePins(pinData.pinTypeString)
  8889.  
  8890. if optionalPinType == pinTypeId and not Fyr_MM:IsHidden() then
  8891. FyrMM.UpdateCustomPinGroup(optionalPinType)
  8892. end -- and not Fyr_MM:IsHidden() is aworkaround for destinations addon's pins disapearing when opening world map 21/12/2022
  8893.  
  8894. if pinData.enabled then
  8895. pinData.layoutCallback(self)
  8896. end
  8897. elseif optionalPinType == pinData.pinTypeString and not Fyr_MM:IsHidden() then
  8898. FyrMM.UpdateCustomPinGroup(pinTypeId) -- compatibility with map pins addon and other addons using pinTypeString to remove pins
  8899. end
  8900. end
  8901. end
  8902.  
  8903. ZO_PreHook(ZO_MapPin, "SetLocation", function(ref, xLoc, yLoc, radius)
  8904. SetPinLocation(ref, xLoc, yLoc, radius)
  8905. end)
  8906. -- ZO_PreHook(ZO_WorldMapPins, "RemovePins", function(ref, PinTypeStr, majorIndex, keyIndex) if PinTypeStr ~= nil and majorIndex ~= nil and keyIndex ~= nil then RemoveCustomPins(PinTypeStr, majorIndex, keyIndex) end end) -- totally unnecessary
  8907. -- SecurePostHook(ZO_WorldMapPins, "RefreshCustomPins", function(ref, pinType) if pinType then FyrMM.UpdateCustomPinGroup(pinType) end end) -- FyrMM.DelayedResetCustomPinGroup(pinType)
  8908.  
  8909. -- this was causing huge lags 03/05/2023
  8910. -- ZO_PreHook(FISHING_MANAGER or INTERACTIVE_WHEEL_MANAGER, "StopInteraction", function() zo_callLater(FyrMM.RequestQuestPinUpdate,1000) return false end)
  8911.  
  8912. ZO_PreHook(COMPASS, "PerformFullAreaQuestUpdate", FyrMM.RequestQuestPinUpdate)
  8913. ZO_PreHook(ZO_WorldMap, "SetHidden", FyrMM.WorldMapShowHide)
  8914.  
  8915. -- ZO_PreHookHandler(ZO_GameMenu_InGame, "OnShow", function() zo_callLater(FyrMM.HideCheck,10) end)
  8916. -- ZO_PreHookHandler(ZO_GameMenu_InGame, "OnHide", function() zo_callLater(FyrMM.HideCheck,10) end)
  8917. -- ZO_PreHookHandler(ZO_InteractWindow, "OnShow", function() zo_callLater(FyrMM.HideCheck,10) end)
  8918. -- ZO_PreHookHandler(ZO_InteractWindow, "OnHide", function() zo_callLater(FyrMM.HideCheck,10) end)
  8919. -- ZO_PreHookHandler(ZO_KeybindStripControl, "OnShow", function() zo_callLater(FyrMM.HideCheck,10) end)
  8920. -- ZO_PreHookHandler(ZO_KeybindStripControl, "OnHide", function() zo_callLater(FyrMM.HideCheck,10) end)
  8921. -- ZO_PreHookHandler(ZO_MainMenuCategoryBar, "OnShow", function() zo_callLater(FyrMM.HideCheck,10) end)
  8922. -- ZO_PreHookHandler(ZO_MainMenuCategoryBar, "OnHide", function() zo_callLater(FyrMM.HideCheck,10) end)
  8923.  
  8924. if FyrMM.CustomPinsEnabled then
  8925. for i = 1, 1200 do -- 1200
  8926. local pin = GetControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(i))
  8927. if pin == nil then
  8928. pin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_Pins_Pin" .. tostring(i), Fyr_MM_Scroll_Map_Pins,
  8929. CT_TEXTURE)
  8930. pin:SetDrawLayer(1)
  8931. pin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  8932. pin:SetHandler("OnMouseExit", PinOnMouseExit)
  8933. SetPinFunctions(pin)
  8934. end
  8935. end
  8936. end
  8937.  
  8938. for i = 1, 50 do -- 50
  8939. local pin = GetControl("Fyr_MM_Scroll_Map_WayshrinePins_Pin" .. tostring(i))
  8940. if pin == nil then
  8941. pin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_WayshrinePins_Pin" .. tostring(i),
  8942. Fyr_MM_Scroll_Map_WayshrinePins, CT_TEXTURE)
  8943. pin.nDistance = function(self)
  8944. if self.nX == nil then
  8945. return 1
  8946. end
  8947. return math.sqrt((zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nX * 10000)) *
  8948. (zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nX * 10000)) +
  8949. (zo_round(CurrentMap.PlayerNY * 10000) - zo_round(self.nY * 10000)) *
  8950. (zo_round(CurrentMap.PlayerNX * 10000) - zo_round(self.nY * 10000))) / 10000
  8951. end
  8952. pin:SetDrawLayer(1)
  8953. pin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  8954. pin:SetHandler("OnMouseExit", PinOnMouseExit)
  8955. pin:SetHandler("OnMouseUp", PinOnMouseUp)
  8956. SetPinFunctions(pin)
  8957. end
  8958. end
  8959. for i = 1, 50 do -- 50
  8960. local pin = GetControl("Fyr_MM_Scroll_Map_LocationPins_Pin" .. tostring(i))
  8961. if pin == nil then
  8962. pin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_LocationPins_Pin" .. tostring(i),
  8963. Fyr_MM_Scroll_Map_LocationPins, CT_TEXTURE)
  8964. pin:SetDrawLayer(1)
  8965. pin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  8966. pin:SetHandler("OnMouseExit", PinOnMouseExit)
  8967. SetPinFunctions(pin)
  8968. end
  8969. end
  8970.  
  8971. for i = 1, 100 do -- 100
  8972. local pin = GetControl("Fyr_MM_Scroll_Map_POIPins_Pin" .. tostring(i))
  8973. if pin == nil then
  8974. pin = WINDOW_MANAGER:CreateControl("Fyr_MM_Scroll_Map_POIPins_Pin" .. tostring(i),
  8975. Fyr_MM_Scroll_Map_POIPins, CT_TEXTURE)
  8976. pin:SetDrawLayer(1)
  8977. pin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  8978. pin:SetHandler("OnMouseExit", PinOnMouseExit)
  8979. SetPinFunctions(pin)
  8980. end
  8981. end
  8982.  
  8983. for i = 1, 100 do -- 100
  8984. local pin = GetControl("Fyr_MM_Axis_Border_Pin" .. tostring(i))
  8985. if pin == nil then
  8986. pin = WINDOW_MANAGER:CreateControl("Fyr_MM_Axis_Border_Pin" .. tostring(i), Fyr_MM_Axis_Border_Pins,
  8987. CT_TEXTURE)
  8988. pin:SetDrawLayer(1)
  8989. SetBorderPinHandlers(pin)
  8990. end
  8991. end
  8992.  
  8993. for i = 1, 24 do -- 24
  8994. local pin = GetControl("Fyr_MM_Scroll_Map_GroupPins_group" .. tostring(i))
  8995. if pin then
  8996. pin:SetDrawLayer(1)
  8997. pin:SetHandler("OnMouseEnter", PinOnMouseEnter)
  8998. pin:SetHandler("OnMouseExit", PinOnMouseExit)
  8999. SetPinFunctions(pin)
  9000. end
  9001. end
  9002.  
  9003. zo_callLater(InitFinish, 100)
  9004. end
  9005.  
  9006. function FyrMM.MenuFadeIn()
  9007. if Fyr_MM_Menu:GetAlpha() > 0 or FyrMM.SV.MenuDisabled or FyrMM.MenuFadingIn or Fyr_MM:IsHidden() then
  9008. return
  9009. end
  9010. FyrMM.MenuFadingIn = true
  9011. if FyrMM.SV.ZoneFrameLocationOption == "Default" then
  9012. Fyr_MM_ZoneFrame:ClearAnchors()
  9013. if FyrMM.SV.WheelMap then
  9014. Fyr_MM_ZoneFrame:SetAnchor(TOP, Fyr_MM_Menu, BOTTOM, 0, -Fyr_MM_Menu:GetHeight() / 5)
  9015. else
  9016. Fyr_MM_ZoneFrame:SetAnchor(TOP, Fyr_MM_Menu, BOTTOM, 0, -Fyr_MM_Menu:GetHeight() / 2.5)
  9017. end
  9018. Fyr_MM_ZoneFrame:SetMovable(false)
  9019. end
  9020. if FyrMM.OverMiniMap or FyrMM.OverMenu then
  9021. MenuAnimation:FadeIn(0, 1000, ZO_ALPHA_ANIMATION_OPTION_FORCE_ALPHA, function()
  9022. FyrMM.MenuFadingIn = false
  9023. end)
  9024. end
  9025. end
  9026.  
  9027. function FyrMM.MenuFadeOut()
  9028. if not FyrMM.SV.MenuAutoHide or FyrMM.OverMiniMap or FyrMM.OverMenu or Fyr_MM_Menu:GetAlpha() == 0 or
  9029. FyrMM.SV.MenuDisabled or FyrMM.MenuFadingOut then
  9030. return
  9031. end
  9032. FyrMM.MenuFadingOut = true
  9033. MenuAnimation:FadeOut(0, 1000, ZO_ALPHA_ANIMATION_OPTION_FORCE_ALPHA, function()
  9034. FyrMM.MenuFadingOut = false
  9035. if FyrMM.SV.ZoneFrameLocationOption == "Default" then
  9036. Fyr_MM_ZoneFrame:ClearAnchors()
  9037. Fyr_MM_ZoneFrame:SetAnchor(TOP, Fyr_MM_Border, BOTTOM)
  9038. Fyr_MM_ZoneFrame:SetMovable(false)
  9039. end
  9040. end)
  9041. end
  9042.  
  9043. local function UpdateZoomTable()
  9044. if FyrMM.SV.ZoomTable then
  9045. local t = {}
  9046. for i, n in pairs(FyrMM.SV.ZoomTable) do
  9047. t[i] = n
  9048. end
  9049. FyrMM.SV.ZoomTable = t
  9050. FyrMM.SV.MapTable = nil
  9051. end
  9052. if FyrMM.SV.MapTable then
  9053. FyrMM.SV.ZoomTable = {}
  9054. for i, n in pairs(FyrMM.SV.MapTable) do
  9055. FyrMM.SV.ZoomTable[i] = n.ZoomLevel
  9056. end
  9057. FyrMM.SV.MapTable = nil
  9058. end
  9059. end
  9060.  
  9061. local function OnLoaded(eventCode, addOnName)
  9062. if addOnName ~= "MiniMap" then
  9063. return
  9064. end
  9065. FyrMM.Initialized = false
  9066. MM_CreateDataTables()
  9067. FyrMM.SV = ZO_SavedVars:NewAccountWide("FyrMMSV", 5, nil, FyrMM.Defaults, nil)
  9068. if FyrMM.SV then
  9069. UpdateZoomTable()
  9070. MM_LoadSavedVars()
  9071. end
  9072. FyrMM.API_Check()
  9073. Fyr_MM:SetResizeHandleSize(MOUSE_CURSOR_RESIZE_NS)
  9074. Fyr_MM:SetHandler("OnMouseEnter", function()
  9075. FyrMM.OverMiniMap = true
  9076. FyrMM.MenuFadeIn()
  9077. Fyr_MM_Close:SetAlpha(1)
  9078. end)
  9079. Fyr_MM:SetHandler("OnMouseExit", function()
  9080. FyrMM.OverMiniMap = false
  9081. zo_callLater(FyrMM.MenuFadeOut, 3000)
  9082. Fyr_MM_Close:SetAlpha(0)
  9083. end)
  9084. Fyr_MM_Menu:SetHandler("OnMouseEnter", function()
  9085. FyrMM.OverMenu = true
  9086. FyrMM.MenuFadeIn()
  9087. Fyr_MM_Close:SetAlpha(1)
  9088. end)
  9089. Fyr_MM_Menu:SetHandler("OnMouseExit", function()
  9090. FyrMM.OverMenu = false
  9091. zo_callLater(FyrMM.MenuFadeOut, 3000)
  9092. Fyr_MM_Close:SetAlpha(0)
  9093. end)
  9094. Fyr_MM:SetHandler("OnMouseUp", function(self)
  9095. if not FyrMM.SV.LockPosition then
  9096. local width = Fyr_MM:GetWidth()
  9097. local height = Fyr_MM:GetHeight()
  9098. MM_SetMapWidth(width)
  9099. MM_SetMapHeight(height)
  9100. FyrMM.SV.position.offsetX = Fyr_MM:GetLeft()
  9101. FyrMM.SV.position.offsetY = Fyr_MM:GetTop()
  9102. FyrMM.MapHalfDiagonal()
  9103. MM_RefreshPanel()
  9104. else
  9105. local pos = {}
  9106. pos.anchorTo = GetControl(pos.anchorTo)
  9107. Fyr_MM:SetAnchor(FyrMM.SV.position.point, pos.anchorTo, FyrMM.SV.position.relativePoint,
  9108. FyrMM.SV.position.offsetX, FyrMM.SV.position.offsetY)
  9109. Fyr_MM:SetDimensions(FyrMM.SV.MapWidth, FyrMM.SV.MapHeight)
  9110. end
  9111. end)
  9112. Fyr_MM_Coordinates:SetHandler("OnMouseUp", function(self)
  9113. local pos = {}
  9114. _, pos[1], pos[2], pos[3], pos[4], pos[5] = Fyr_MM_Coordinates:GetAnchor()
  9115. if pos[2] then
  9116. pos[2] = pos[2]:GetName()
  9117. end
  9118. FyrMM.SV.CoordinatesAnchor = pos
  9119. end)
  9120. Fyr_MM_ZoneFrame:SetHandler("OnMouseUp", function(self)
  9121. local pos = {}
  9122. _, pos[1], pos[2], pos[3], pos[4], pos[5] = Fyr_MM_ZoneFrame:GetAnchor()
  9123. if pos[1] == nil then
  9124. return
  9125. end
  9126. if pos[2] then
  9127. pos[2] = pos[2]:GetName()
  9128. end
  9129. pos[1] = 1
  9130. local zoneFrameX, _ = Fyr_MM_ZoneFrame:GetCenter()
  9131. pos[4] = zoneFrameX
  9132. FyrMM.SV.ZoneFrameAnchor = pos
  9133. d("Zone frame anchor set to: " .. pos[1] .. " " .. pos[2] .. " " .. pos[3] .. " " .. pos[4] .. " " .. pos[5])
  9134. end)
  9135. Fyr_MM_Scroll:SetScrollBounding(0)
  9136. Fyr_MM_Player_incombat:SetTexture("esoui/art/mappins/ava_attackburst_32.dds")
  9137. Fyr_MM_Player_incombat:SetAlpha(0.50)
  9138. AxisSwitch()
  9139. zo_callLater(OnInit, 1000)
  9140. end
  9141.  
  9142. -----------------------------------------
  9143. -- Key bind functions
  9144. -----------------------------------------
  9145.  
  9146. function FyrMM.ZoomOut()
  9147. if not FyrMM.Visible or Fyr_MM:IsHidden() or ZoomAnimating then
  9148. return
  9149. end
  9150. local zoomLevel = CurrentMap.ZoomLevel
  9151. zoomLevel = zoomLevel - FYRMM_ZOOM_INCREMENT_AMOUNT
  9152. if zoomLevel < FYRMM_ZOOM_MIN then
  9153. zoomLevel = FYRMM_ZOOM_MIN
  9154. end
  9155. PlaySound(SOUNDS.MAP_ZOOM_OUT)
  9156. if FyrMM.SV.RotateMap then
  9157. Fyr_MM_Scroll:SetHorizontalScroll(0)
  9158. Fyr_MM_Scroll:SetVerticalScroll(0)
  9159. FyrMM.WheelScroll(0, 0)
  9160. end
  9161. if not ZoomAnimating and zoomLevel ~= CurrentMap.ZoomLevel then
  9162. AnimateZoom(zoomLevel)
  9163. end
  9164. end
  9165.  
  9166. function FyrMM.ZoomIn()
  9167. if not FyrMM.Visible or Fyr_MM:IsHidden() or ZoomAnimating then
  9168. return
  9169. end
  9170. local zoomLevel = CurrentMap.ZoomLevel
  9171. zoomLevel = zoomLevel + FYRMM_ZOOM_INCREMENT_AMOUNT
  9172. if zoomLevel > FYRMM_ZOOM_MAX then
  9173. zoomLevel = FYRMM_ZOOM_MAX
  9174. end
  9175. PlaySound(SOUNDS.MAP_ZOOM_IN)
  9176. if FyrMM.SV.RotateMap then
  9177. Fyr_MM_Scroll:SetHorizontalScroll(0)
  9178. Fyr_MM_Scroll:SetVerticalScroll(0)
  9179. FyrMM.WheelScroll(0, 0)
  9180. end
  9181. if not ZoomAnimating and zoomLevel ~= CurrentMap.ZoomLevel then
  9182. AnimateZoom(zoomLevel)
  9183. end
  9184. end
  9185.  
  9186. function FyrMM.ToggleVisible()
  9187. if not FyrMM.worldMapShowing and ZO_InteractWindow:IsHidden() and ZO_KeybindStripControl:IsHidden() then
  9188. if FyrMM.Visible then
  9189. PlaySound(SOUNDS.MAP_WINDOW_CLOSE)
  9190. FyrMM.manuallyHidden = true
  9191. else
  9192. PlaySound(SOUNDS.MAP_WINDOW_OPEN)
  9193. FyrMM.manuallyHidden = false
  9194. end
  9195. FyrMM.Visible = not FyrMM.Visible
  9196. end
  9197. end
  9198.  
  9199. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_QUEST_POSITION_REQUEST_COMPLETE, OnQuestPositionRequestComplete)
  9200. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_ADD_ON_LOADED, OnLoaded)
  9201. -- EVENT_MANAGER:RegisterForEvent( "MiniMap", EVENT_ZONE_CHANGED, FyrMM.UpdateLabels)
  9202. -- EVENT_MANAGER:RegisterForEvent( "MiniMap", EVENT_ZONE_UPDATE, function (eventCode, unitTag, newZoneName) d(eventCode) d(unitTag) d(newZoneName) end)
  9203. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_PLAYER_ACTIVATED, FyrMM.LoadScreen)
  9204. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_START_FAST_TRAVEL_INTERACTION, function(eventCode, index)
  9205. FyrMM.FastTravelInteraction(true, index, eventCode)
  9206. end)
  9207. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_END_FAST_TRAVEL_INTERACTION, function(eventCode)
  9208. FyrMM.FastTravelInteraction(false, nil, eventCode)
  9209. end)
  9210. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_START_FAST_TRAVEL_KEEP_INTERACTION, function(eventCode, index)
  9211. FyrMM.FastTravelInteraction(true, index, eventCode)
  9212. end)
  9213. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_END_FAST_TRAVEL_KEEP_INTERACTION, function(eventCode)
  9214. FyrMM.FastTravelInteraction(false, nil, eventCode)
  9215. end)
  9216. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_MOUNTED_STATE_CHANGED, function(eventCode, mounted)
  9217. CurrentMap.PlayerMounted = mounted
  9218. end)
  9219. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_PLAYER_NOT_SWIMMING, function(eventCode)
  9220. CurrentMap.PlayerSwimming = false
  9221. end)
  9222. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_PLAYER_SWIMMING, function(eventCode)
  9223. CurrentMap.PlayerSwimming = true
  9224. end)
  9225. EVENT_MANAGER:RegisterForEvent("MiniMap", EVENT_ANTIQUITY_DIG_SITES_UPDATED, function(eventCode, antiquityId)
  9226. FyrMM.UpdateAntiquityDigSites()
  9227. end)
  9228.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement