Advertisement
Guest User

Untitled

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