Advertisement
Guest User

Untitled

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