Back to Home

ESO Lua File v101041

ingame/map/mappin_manager.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
local function GetValueOrExecute(value, ...)
    if type(value) == "function" then
        return value(...)
    end
    return value
end
local function DefaultCompareNilable(first, second)
    if first and second then
        return first < second
    elseif first then
        return true
    else
        return false
    end
end
------------------
-- Pins Manager --
------------------
ZO_WorldMapPins_Manager = ZO_ObjectPool:Subclass()
function ZO_WorldMapPins_Manager:Initialize(parentControl)
    local mouseInputGroup = ZO_MouseInputGroup:New(parentControl)
    local function CreatePin(pool)
        local pin = ZO_MapPin:New(parentControl)
        mouseInputGroup:Add(pin:GetControl(), ZO_MOUSE_INPUT_GROUP_MOUSE_OVER)
        return pin
    end
    local function ResetPin(pin)
        self:OnMouseOverPinReset(pin)
        pin:Reset()
    end
    ZO_ObjectPool.Initialize(self, CreatePin, ResetPin)
    self.mouseInputGroup = mouseInputGroup
    -- Each of these tables holds a method of mapping pin lookup indices to the actual object pool keys needed to release the pins later
    -- The reason this exists is because the game events will hold info like "remove this specific quest index", and at that point we
    -- need to be able to lookup a pin for game-event data rather than pinTag data, without iterating over every single pin in the
    -- active objects list.
    self.m_keyToPinMapping =
    {
        ["poi"] = {},       -- { [zone index 1] = { [objective index 1] = pinKey1, [objective index 2] = pinKey2, ... }, ... }
        ["loc"] = {},
        ["quest"] = {},     -- { [quest index 1] = { [quest pin tag 1] = pinKey1, [quest pin tag 2] = pinKey2, ... }, ... }
        ["objective"] = {},
        ["keep"] = {},
        ["pings"] = {},
        ["killLocation"] = {},
        ["fastTravelKeep"] = {},
        ["fastTravelWayshrine"] = {},
        ["forwardCamp"] = {},
        ["AvARespawn"] = {},
        ["group"] = {},
        ["restrictedLink"] = {},
        ["suggestion"] = {},
        ["worldEventUnit"] = {},
        ["worldEventPOI"] = {},
        ["antiquityDigSite"] = {},
        ["companion"] = {},
        ["skyshard"] = {},
    }
    self.nextCustomPinType = MAP_PIN_TYPE_INVALID
    self.customPins = {}
    self.objectiveMovingPins = {}
    self.movingPins = {}
    self.currentMouseOverPins = {}
    self.previousMouseOverPins = {}
    self.mousedOverPinWasReset = false
    self.invalidateTooltip = false
    self.mouseExitPins = {}
    self.foundTooltipMouseOverPins = {}
    self.pinBlobPool = ZO_ControlPool:New("ZO_PinBlob", parentControl, "PinBlob")
    self.pinBlobPool:SetCustomResetBehavior(function(blobControl)
        blobControl:SetAlpha(1)
    end)
    self.pinPolygonBlobPool = ZO_ControlPool:New("ZO_PinPolygonBlob", parentControl, "PinPolygonBlob")
    self.pinPolygonBlobPool:SetCustomFactoryBehavior(function(blobControl)
        mouseInputGroup:Add(blobControl, ZO_MOUSE_INPUT_GROUP_MOUSE_OVER)
    end)
    self.pinPolygonBlobPool:SetCustomResetBehavior(function(blobControl)
        blobControl:SetHandler("OnMouseUp", nil)
        blobControl:SetHandler("OnMouseDown", nil)
        blobControl:SetAlpha(1)
    end)
    self.pinFadeInAnimationPool = ZO_AnimationPool:New("ZO_WorldMapPinFadeIn")
    local function OnAnimationTimelineStopped(timeline)
        self.pinFadeInAnimationPool:ReleaseObject(timeline.key)
    end
    local function SetupTimeline(timeline)
        timeline:SetHandler("OnStop", OnAnimationTimelineStopped)
    end
    self.pinFadeInAnimationPool:SetCustomFactoryBehavior(SetupTimeline)
    local function ResetTimeline(animationTimeline)
        local pinAnimation = animationTimeline:GetAnimation(1)
        pinAnimation:SetAnimatedControl(nil)
        local areaAnimation = animationTimeline:GetAnimation(2)
        areaAnimation:SetAnimatedControl(nil)
    end
    self.pinFadeInAnimationPool:SetCustomResetBehavior(ResetTimeline)
    --Wait until the map mode has been set before fielding these updates since adding a pin depends on the map having a mode.
    local OnWorldMapModeChanged
    OnWorldMapModeChanged = function(modeData)
        if modeData then
            WORLD_MAP_QUEST_BREADCRUMBS:RegisterCallback("QuestAvailable", function(...) self:OnQuestAvailable(...) end)
            WORLD_MAP_QUEST_BREADCRUMBS:RegisterCallback("QuestRemoved", function(...) self:OnQuestRemoved(...) end)
            CALLBACK_MANAGER:UnregisterCallback("OnWorldMapModeChanged", OnWorldMapModeChanged)
        end
    end
    CALLBACK_MANAGER:RegisterCallback("OnWorldMapModeChanged", OnWorldMapModeChanged)
    FOCUSED_QUEST_TRACKER:RegisterCallback("QuestTrackerAssistStateChanged", function(...) self:OnAssistStateChanged(...) end)
end
function ZO_WorldMapPins_Manager:AcquirePinBlob()
    return self.pinBlobPool:AcquireObject()
end
function ZO_WorldMapPins_Manager:ReleasePinBlob(pinBlobKey)
    self.pinBlobPool:ReleaseObject(pinBlobKey)
end
function ZO_WorldMapPins_Manager:AcquirePinPolygonBlob()
    return self.pinPolygonBlobPool:AcquireObject()
end
function ZO_WorldMapPins_Manager:ReleasePinPolygonBlob(pinBlobKey)
    self.pinPolygonBlobPool:ReleaseObject(pinBlobKey)
end
function ZO_WorldMapPins_Manager:AcquirePinFadeInAnimation()
    local animation, key = self.pinFadeInAnimationPool:AcquireObject()
    animation.key = key
    return animation
end
function ZO_WorldMapPins_Manager:OnQuestAvailable(questIndex)
    self:AddQuestPin(questIndex)
end
function ZO_WorldMapPins_Manager:OnQuestRemoved(questIndex)
    self:RemovePins("quest", questIndex)
    local questPingData = ZO_WorldMap_GetQuestPingData()
    if questPingData and questPingData.questIndex == questIndex then
         self:RemovePins("pings", MAP_PIN_TYPE_QUEST_PING)
    end
end
function ZO_WorldMapPins_Manager:OnAssistStateChanged(unassistedData, assistedData)
    if unassistedData then
        self:SetQuestPinsAssisted(unassistedData:GetJournalIndex(), false)
    end
    if assistedData then
        self:SetQuestPinsAssisted(assistedData:GetJournalIndex(), true)
    end
end
function ZO_WorldMapPins_Manager:SetQuestPinsAssisted(questIndex, assisted)
    local pins = self:GetActiveObjects()
    for pinKey, pin in pairs(pins) do
        local currentIndex = pin:GetQuestIndex()
        if currentIndex == questIndex then
            local currentPinType = pin:GetPinType()
            local trackingLevel = GetTrackingLevel(TRACK_TYPE_QUEST, questIndex)
            local newPinType = GetQuestPinTypeForTrackingLevel(currentPinType, trackingLevel)
            pin:ChangePinType(newPinType)
        end
    end
end
function ZO_WorldMapPins_Manager:PingQuest(questIndex, animation)
    local pins = self:GetActiveObjects()
    for pinKey, pin in pairs(pins) do
        local pinQuestIndex = pin:GetQuestIndex()
        if pinQuestIndex > -1 then
            if pinQuestIndex == questIndex then
                pin:PingMapPin(animation)
            else
                pin:ResetAnimation(ZO_MapPin.ANIM_CONSTANTS.RESET_ANIM_HIDE_CONTROL)
            end
        end
    end
end
do
    local MAPS_WITHOUT_QUEST_PINS =
    {
        [MAPTYPE_WORLD] = true,
        [MAPTYPE_COSMIC] = true,
    }
    function ZO_WorldMapPins_Manager.DoesCurrentMapHideQuestPins()
        return MAPS_WITHOUT_QUEST_PINS[GetMapType()]
    end
end
function ZO_WorldMapPins_Manager:AddQuestPin(questIndex)
    if self.DoesCurrentMapHideQuestPins() then
        return
    end
    if not ZO_WorldMap_IsPinGroupShown(MAP_FILTER_QUESTS) then
        return
    end
    local questSteps = WORLD_MAP_QUEST_BREADCRUMBS:GetSteps(questIndex)
    if questSteps then
        for stepIndex, questConditions in pairs(questSteps) do
            for conditionIndex, conditionData in pairs(questConditions) do
                local xLoc, yLoc = conditionData.xLoc, conditionData.yLoc
                if conditionData.insideCurrentMapWorld and ZO_WorldMap_IsNormalizedPointInsideMapBounds(xLoc, yLoc) then
                    local tag = ZO_MapPin.CreateQuestPinTag(questIndex, stepIndex, conditionIndex)
                    tag.isBreadcrumb = conditionData.isBreadcrumb
                    local pin = self:CreatePin(conditionData.pinType, tag, xLoc, yLoc, conditionData.areaRadius)
                    if pin:DoesQuestDataMatchQuestPingData() then
                        local questPinTag = ZO_MapPin.CreateQuestPinTag(questIndex, stepIndex, conditionIndex)
                        self:CreatePin(MAP_PIN_TYPE_QUEST_PING, questPinTag, xLoc, yLoc)
                    end
                end
            end
        end
    end
end
function ZO_WorldMapPins_Manager:GetNextCustomPinType()
    self.nextCustomPinType = self.nextCustomPinType + 1
    return self.nextCustomPinType
end
function ZO_WorldMapPins_Manager:CreateCustomPinType(pinTypeString)
    local pinTypeId = self:GetNextCustomPinType()
    _G[pinTypeString] = pinTypeId
    return pinTypeId
end
function ZO_WorldMapPins_Manager:AddCustomPin(pinTypeString, pinTypeAddCallback, pinTypeOnResizeCallback, pinLayoutData, pinTooltipCreator)
    if _G[pinTypeString] ~= nil then return end
    local pinTypeId = self:CreateCustomPinType(pinTypeString)
    self.m_keyToPinMapping[pinTypeString] = {}
    self.customPins[pinTypeId] = 
    { 
        enabled = false,
        layoutCallback = pinTypeAddCallback,
        resizeCallback = pinTypeOnResizeCallback,
        pinTypeString = pinTypeString
    }
    ZO_MapPin.TOOLTIP_CREATORS[pinTypeId] = pinTooltipCreator
    ZO_MapPin.PIN_DATA[pinTypeId] = pinLayoutData
end
function ZO_WorldMapPins_Manager:SetCustomPinEnabled(pinType, enabled)
    local pinData = self.customPins[pinType]
    if pinData then
        pinData.enabled = enabled
    end
end
function ZO_WorldMapPins_Manager:IsCustomPinEnabled(pinType)
    local pinData = self.customPins[pinType]
    if pinData then
        return pinData.enabled
    end
end
function ZO_WorldMapPins_Manager:RefreshCustomPins(optionalPinType)
    for pinTypeId, pinData in pairs(self.customPins) do
        if optionalPinType == nil or optionalPinType == pinTypeId then
            self:RemovePins(pinData.pinTypeString)
            if pinData.enabled then
                pinData.layoutCallback(self)
            end
        end
    end
end
function ZO_WorldMapPins_Manager:MapPinLookupToPinKey(lookupType, majorIndex, keyIndex, pinKey)
    local lookupTable = self.m_keyToPinMapping[lookupType]
    local keys = lookupTable[majorIndex]
    if not keys then
        keys = {}
        lookupTable[majorIndex] = keys
    end
    keys[keyIndex] = pinKey
end
function ZO_WorldMapPins_Manager:CreatePin(pinType, pinTag, xLoc, yLoc, radius, borderInformation)
    local pin, pinKey = self:AcquireObject()
    pin:SetData(pinType, pinTag)
    pin:SetLocation(xLoc, yLoc, radius, borderInformation)
    if pinType == MAP_PIN_TYPE_PLAYER then
        pin:PingMapPin(ZO_MapPin.PulseAnimation)
        self.playerPin = pin
    end
    if not pin:ValidatePvPPinAllowed() then
        self:ReleaseObject(pinKey)
        return
    end
    if pin:IsPOI() then
        self:MapPinLookupToPinKey("poi", pin:GetPOIZoneIndex(), pin:GetPOIIndex(), pinKey)
    elseif pin:IsLocation() then
        self:MapPinLookupToPinKey("loc", pin:GetLocationIndex(), pin:GetLocationIndex(), pinKey)
    elseif pin:IsQuest() then
        self:MapPinLookupToPinKey("quest", pin:GetQuestIndex(), pinTag, pinKey)
    elseif pin:IsObjective() then
        self:MapPinLookupToPinKey("objective", pin:GetObjectiveKeepId(), pinTag, pinKey)
    elseif pin:IsKeepOrDistrict() then
        self:MapPinLookupToPinKey("keep", pin:GetKeepId(), pin:IsUnderAttackPin(), pinKey)
    elseif pin:IsMapPing() then
        self:MapPinLookupToPinKey("pings", pinType, pinTag, pinKey)
    elseif pin:IsKillLocation() then
        self:MapPinLookupToPinKey("killLocation", pinType, pinTag, pinKey)
    elseif pin:IsFastTravelKeep() then
        self:MapPinLookupToPinKey("fastTravelKeep", pin:GetFastTravelKeepId(), pin:GetFastTravelKeepId(), pinKey)
    elseif pin:IsFastTravelWayShrine() then
        self:MapPinLookupToPinKey("fastTravelWayshrine", pinType, pinTag, pinKey)
    elseif pin:IsForwardCamp() then
        self:MapPinLookupToPinKey("forwardCamp", pinType, pinTag, pinKey)
    elseif pin:IsAvARespawn() then
        self:MapPinLookupToPinKey("AvARespawn", pinType, pinTag, pinKey)
    elseif pin:IsGroup() then
        self:MapPinLookupToPinKey("group", pinType, pinTag, pinKey)
    elseif pin:IsRestrictedLink() then
        self:MapPinLookupToPinKey("restrictedLink", pinType, pinTag, pinKey)
    elseif pin:IsSuggestion() then
        self:MapPinLookupToPinKey("suggestion", pinType, pinTag, pinKey)
    elseif pin:IsWorldEventUnitPin() then
        self:MapPinLookupToPinKey("worldEventUnit", pin:GetWorldEventInstanceId(), pin:GetUnitTag(), pinKey)
    elseif pin:IsWorldEventPOIPin() then
        self:MapPinLookupToPinKey("worldEventPOI", pin:GetWorldEventInstanceId(), pinTag, pinKey)
    elseif pin:IsAntiquityDigSitePin() then
        self:MapPinLookupToPinKey("antiquityDigSite", pinType, pinTag, pinKey)
    elseif pin:IsCompanion() then
        self:MapPinLookupToPinKey("companion", pinType, pinTag, pinKey)
    elseif pin:IsSkyshard() then
        self:MapPinLookupToPinKey("skyshard", pinType, pinTag, pinKey)
    else
        local customPinData = self.customPins[pinType]
        if customPinData then
            self:MapPinLookupToPinKey(customPinData.pinTypeString, pinType, pinTag, pinKey)
        end
    end
    return pin
end
function ZO_WorldMapPins_Manager:FindPin(lookupType, majorIndex, keyIndex)
    local lookupTable = self.m_keyToPinMapping[lookupType]
    local keys
    if majorIndex then
        keys = lookupTable[majorIndex]
    else
        keys = select(2, next(lookupTable))
    end
    if keys then
        local pinKey
        if keyIndex then
            pinKey = keys[keyIndex]
        else
            pinKey = select(2, next(keys))
        end
        if pinKey then
            return self:GetActiveObject(pinKey)
        end
    end
end
function ZO_WorldMapPins_Manager:AddPinsToArray(pins, lookupType, majorIndex)
    local lookupTable = self.m_keyToPinMapping[lookupType]
    local function AddPinsForKeys(keysTable)
        if keysTable then
            for _, pinKey in pairs(keysTable) do
                local pin = self:GetActiveObject(pinKey)
                if pin then
                    table.insert(pins, pin)
                end
            end
        end
    end
    if majorIndex then
        local keys = lookupTable[majorIndex]
        AddPinsForKeys(keys)
    else
        for _, keys in pairs(lookupTable) do
            AddPinsForKeys(keys)
        end
    end
    return pins
end
function ZO_WorldMapPins_Manager:RemovePins(lookupType, majorIndex, keyIndex)
    local lookupTable = self.m_keyToPinMapping[lookupType]
    if majorIndex then
        local keys = lookupTable[majorIndex]
        if keys then
            if keyIndex then
                 --Remove a specific pin
                local pinKey = keys[keyIndex]
                if pinKey then
                    self:ReleaseObject(pinKey)
                    keys[keyIndex] = nil
                end
            else
                --Remove all pins in the major index
                for _, pinKey in pairs(keys) do
                    self:ReleaseObject(pinKey)
                end
                self.m_keyToPinMapping[lookupType][majorIndex] = {}
            end
        end
    else
        --Remove all pins of the lookup type
        for _, keys in pairs(lookupTable) do
            for _, pinKey in pairs(keys) do
                self:ReleaseObject(pinKey)
            end
        end
        self.m_keyToPinMapping[lookupType] = {}
    end
end
function ZO_WorldMapPins_Manager:UpdatePinsForMapSizeChange()
    local pins = self:GetActiveObjects()
    for pinKey, pin in pairs(pins) do
        pin:UpdateLocation()
        pin:UpdateSize()
    end
    for pinTypeId, pinData in pairs(self.customPins) do
        if pinData.enabled and pinData.resizeCallback then
            pinData.resizeCallback(self, ZO_MAP_CONSTANTS.MAP_WIDTH, ZO_MAP_CONSTANTS.MAP_HEIGHT)
        end
    end
end
function ZO_WorldMapPins_Manager:GetWayshrinePin(nodeIndex)
    local pins = self:GetActiveObjects()
    for pinKey, pin in pairs(pins) do
        local currentIndex = pin:GetFastTravelNodeIndex()
        if currentIndex == nodeIndex then
            return pin
        end
    end
end
function ZO_WorldMapPins_Manager:GetQuestConditionPin(questIndex)
    local pins = self:GetActiveObjects()
    for pinKey, pin in pairs(pins) do
        local currentIndex = pin:GetQuestIndex()
        if currentIndex == questIndex then
            return pin
        end
    end
end
function ZO_WorldMapPins_Manager:GetPlayerPin()
    return self.playerPin
end
do
    local function IsMapShowingBattlegroundContext(bgContext)
        local _, queryType = ZO_WorldMap_GetCampaign()
        return (queryType == BGQUERY_LOCAL and IsLocalBattlegroundContext(bgContext))
                or (queryType == BGQUERY_ASSIGNED_CAMPAIGN and IsAssignedBattlegroundContext(bgContext))
    end
    function ZO_WorldMapPins_Manager:RefreshObjectives()
        self:RemovePins("objective")
        ZO_ClearNumericallyIndexedTable(self.objectiveMovingPins)
        local mapFilterType = GetMapFilterType()
        if mapFilterType ~= MAP_FILTER_TYPE_AVA_CYRODIIL and mapFilterType ~= MAP_FILTER_TYPE_BATTLEGROUND then
            return
        end
        local numObjectives = GetNumObjectives()
        local worldMapAvAPinsShown = ZO_WorldMap_IsPinGroupShown(MAP_FILTER_AVA_OBJECTIVES)
        for i = 1, numObjectives do
            local keepId, objectiveId, bgContext = GetObjectiveIdsForIndex(i)
            local isEnabled = IsObjectiveEnabled(keepId, objectiveId, bgContext)
            if isEnabled then
                local isVisible = IsObjectiveObjectVisible(keepId, objectiveId, bgContext)
                if ZO_WorldMap_IsObjectiveShown(keepId, objectiveId, bgContext) and IsMapShowingBattlegroundContext(bgContext) then
                    --spawn locations
                    local spawnPinType, spawnX, spawnY = GetObjectiveSpawnPinInfo(keepId, objectiveId, bgContext)
                    if spawnPinType ~= MAP_PIN_TYPE_INVALID then
                        if worldMapAvAPinsShown then
                            if ZO_WorldMap_IsNormalizedPointInsideMapBounds(spawnX, spawnY) then
                                local spawnTag = ZO_MapPin.CreateObjectivePinTag(keepId, objectiveId, bgContext)
                                self:CreatePin(spawnPinType, spawnTag, spawnX, spawnY)
                            end
                        end
                    end
                    --return locations
                    local returnPinType, returnX, returnY, returnContinuousUpdate = GetObjectiveReturnPinInfo(keepId, objectiveId, bgContext)
                    if returnPinType ~= MAP_PIN_TYPE_INVALID then
                        local returnTag = ZO_MapPin.CreateObjectivePinTag(keepId, objectiveId, bgContext)
                        local returnPin = self:CreatePin(returnPinType, returnTag, returnX, returnY)
                        if returnContinuousUpdate then
                            table.insert(self.objectiveMovingPins, returnPin)
                        end
                    end
                    -- current locations
                    local pinType, currentX, currentY, continuousUpdate = GetObjectivePinInfo(keepId, objectiveId, bgContext)
                    if isVisible and pinType ~= MAP_PIN_TYPE_INVALID then
                        if worldMapAvAPinsShown then
                            if ZO_WorldMap_IsNormalizedPointInsideMapBounds(currentX, currentY) then
                                local objectiveTag = ZO_MapPin.CreateObjectivePinTag(keepId, objectiveId, bgContext)
                                local objectivePin = self:CreatePin(pinType, objectiveTag, currentX, currentY)
                                if objectivePin then
                                    local auraPinType = GetObjectiveAuraPinInfo(keepId, objectiveId, bgContext)
                                    local auraPin
                                    if auraPinType ~= MAP_PIN_TYPE_INVALID then
                                        local auraTag = ZO_MapPin.CreateObjectivePinTag(keepId, objectiveId, bgContext)
                                        auraPin = self:CreatePin(auraPinType, auraTag, currentX, currentY)
                                        objectivePin:AddScaleChild(auraPin)
                                    end
                                    if continuousUpdate then
                                        table.insert(self.objectiveMovingPins, objectivePin)
                                        if auraPin then
                                            table.insert(self.objectiveMovingPins, auraPin)
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end
function ZO_WorldMapPins_Manager:RefreshGroupPins()
    self:RemovePins("group")
    if ZO_WorldMap_IsPinGroupShown(MAP_FILTER_GROUP_MEMBERS) and GetMapType() ~= MAPTYPE_COSMIC then
        local isInDungeon = GetMapContentType() == MAP_CONTENT_DUNGEON
        local isInHouse = GetCurrentZoneHouseId() ~= 0
        for i = 1, MAX_GROUP_SIZE_THRESHOLD do
            local groupTag = ZO_Group_GetUnitTagForGroupIndex(i)
            local isBreadcrumbed = IsUnitWorldMapPositionBreadcrumbed(groupTag)
            if DoesUnitExist(groupTag) and not AreUnitsEqual("player", groupTag) and IsUnitOnline(groupTag) then
                local isGroupMemberHiddenByInstance = false
                -- 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
                -- If it doesn't have its own map, we're okay to show the group member regardless of instance
                if DoesCurrentMapMatchMapForPlayerLocation() and IsGroupMemberInSameWorldAsPlayer(groupTag) and (isInDungeon or isInHouse) then
                    if not IsGroupMemberInSameInstanceAsPlayer(groupTag) then
                        -- We're in the same world as the group member, but a different instance
                        isGroupMemberHiddenByInstance = true
                    elseif not IsGroupMemberInSameLayerAsPlayer(groupTag) then
                        -- We're in the same instance as the group member, but a different layer
                        isGroupMemberHiddenByInstance = not isBreadcrumbed 
                    end
                end
                if not isGroupMemberHiddenByInstance then
                    local x, y, _, isInCurrentMap = GetMapPlayerPosition(groupTag)
                    if isInCurrentMap then
                        local isLeader = IsUnitGroupLeader(groupTag)
                        local tagData = groupTag
                        if isBreadcrumbed then
                            tagData =
                            {
                                groupTag = groupTag,
                                isBreadcrumb = true
                            }
                        end
                        local groupPin = self:CreatePin(isLeader and MAP_PIN_TYPE_GROUP_LEADER or MAP_PIN_TYPE_GROUP, tagData)
                        if groupPin then
                            groupPin:SetLocation(x, y)
                        end
                    end
                end
            end
        end
    end
end
function ZO_WorldMapPins_Manager:UpdateMovingPins()
    do
        local playerPin = self:GetPlayerPin()
        local xLoc, yLoc, _, isShownInCurrentMap = GetMapPlayerPosition("player")
        playerPin:SetLocation(xLoc, yLoc)
        -- Design rule, don't show player pin on cosmic, even if they're in the map
        if isShownInCurrentMap and GetMapType() ~= MAPTYPE_COSMIC then
            playerPin:SetHidden(false)
            playerPin:SetRotation(GetPlayerCameraHeading())
        else
            playerPin:SetHidden(true)
        end
    end
    local movingPins = self.movingPins
    self:AddPinsToArray(movingPins, "group")
    for _, groupPin in ipairs(movingPins) do
        local xLoc, yLoc = GetMapPlayerPosition(groupPin:GetUnitTag())
        groupPin:SetLocation(xLoc, yLoc)
    end
    ZO_ClearNumericallyIndexedTable(movingPins)
    local companionPin = self:FindPin("companion")
    if companionPin then
        local xLoc, yLoc = GetMapPlayerPosition(companionPin:GetUnitTag())
        companionPin:SetLocation(xLoc, yLoc)
    end
    
    for _, objectivePin in ipairs(self.objectiveMovingPins) do
        local _, currentX, currentY = GetObjectivePinInfo(objectivePin:GetObjectiveKeepId(), objectivePin:GetObjectiveObjectiveId(), objectivePin:GetBattlegroundContext())
        objectivePin:SetLocation(currentX, currentY)
    end
    self:AddPinsToArray(movingPins, "worldEventUnit")
    for _, worldEventPin in ipairs(movingPins) do
        local xLoc, yLoc = GetMapPlayerPosition(worldEventPin:GetUnitTag())
        worldEventPin:SetLocation(xLoc, yLoc)
    end
    ZO_ClearNumericallyIndexedTable(movingPins)
end
--[[
Utilities to build lists of pins the mouse is currently over and was previously over so the world map knows how
to properly call the OnMouseExit and OnMouseEnter events on the pins.
--]]
function ZO_WorldMapPins_Manager:BuildMouseOverPinLists(cursorPositionX, cursorPositionY)
    -- Determine if the mouse is even over the world map
    local isMouseOverWorldMap = ZO_WorldMap_IsMouseOverMap()
    -- Swap lists
    self.previousMouseOverPins, self.currentMouseOverPins = self.currentMouseOverPins, self.previousMouseOverPins
    local currentMouseOverPins = self.currentMouseOverPins
    -- Update any pins that were moused over in the current list that may no longer be in the active pins
    for pin, isMousedOver in pairs(currentMouseOverPins) do
        if isMousedOver then
            currentMouseOverPins[pin] = isMouseOverWorldMap and pin:MouseIsOver(cursorPositionX, cursorPositionY)
        end
    end
    local stickyPin = ZO_WorldMap_GetStickyPin()
    -- Update active list and determine the sticky pin!
    stickyPin:ClearNearestCandidate()
    local pins = self:GetActiveObjects()
    for _, pin in pairs(pins) do
        currentMouseOverPins[pin] = isMouseOverWorldMap and pin:MouseIsOver(cursorPositionX, cursorPositionY)
        stickyPin:ConsiderPin(pin, cursorPositionX, cursorPositionY)
    end
    -- Determine which pins need to have their mouse enter called and which need to have their mouse exit called.
    -- Return whether or not the lists for current and previous changed so that nothing is updated unecessarily
    local wasPreviouslyMousedOver, doMouseEnter, doMouseExit
    local listsChanged = false
    local needsContinuousTooltipUpdates = false
    for pin, isMousedOver in pairs(currentMouseOverPins) do
        wasPreviouslyMousedOver = self.previousMouseOverPins[pin]
        doMouseEnter = isMousedOver and not wasPreviouslyMousedOver
        doMouseExit = not isMousedOver and wasPreviouslyMousedOver
        self.mouseExitPins[pin] = doMouseExit
        listsChanged = listsChanged or doMouseEnter or doMouseExit
        needsContinuousTooltipUpdates = needsContinuousTooltipUpdates or (isMousedOver and pin:NeedsContinuousTooltipUpdates())
    end
    return listsChanged, needsContinuousTooltipUpdates
end
function ZO_WorldMapPins_Manager:DoMouseExitForPin(pin)
    if pin:IsPOI() or pin:IsFastTravelWayShrine() then
        --reset the status to show what part of the map we're over (except if it's the name of this zone)
        local currentLocation = ZO_WorldMap_GetMouseOverMapBlobManager().m_currentLocation
        if currentLocation ~= ZO_WorldMap.zoneName then
            ZO_WorldMapMouseoverName:SetText(zo_strformat(SI_WORLD_MAP_LOCATION_NAME, currentLocation))
            ZO_WorldMapMouseoverName.owner = "map"
        else
            ZO_WorldMapMouseoverName:SetText("")
            ZO_WorldMapMouseoverName.owner = ""
        end
        ZO_WorldMapMouseOverDescription:SetText("")
    end
    local pinType = pin:GetPinType()
    WORLD_MAP_MANAGER:DoMouseExitForPinType(pinType)
end
function ZO_WorldMapPins_Manager:ResetMouseOverPins()
    for pin, mousedOver in pairs(self.currentMouseOverPins) do
        if mousedOver then
            pin:SetTargetScale(1)
        end
    end
    ZO_ClearTable(self.currentMouseOverPins)
    ZO_ClearTable(self.previousMouseOverPins)
end
function ZO_WorldMapPins_Manager:OnMouseOverPinReset(pin)
    if self.currentMouseOverPins[pin] then
        self.mousedOverPinWasReset = true
        self:DoMouseExitForPin(pin)
    end
    self.currentMouseOverPins[pin] = nil
    self.previousMouseOverPins[pin] = nil
    --If we are showing a menu to choose a pin action and one of those pins is removed from the map then we need to handle that here
    WORLD_MAP_CHOICE_DIALOG_GAMEPAD:OnPinRemovedFromMap(pin)
    if ZO_MapPin.pinsInKeyboardMapChoiceDialog and ZO_MapPin.pinsInKeyboardMapChoiceDialog[pin] then
        ClearMenu()
    end
end
function ZO_WorldMapPins_Manager:GetFoundTooltipMouseOverPins()
    return self.foundTooltipMouseOverPins
end
do
    local function TooltipPinSortFunction(firstPin, secondPin)
        local firstPinType = firstPin:GetPinType()
        local secondPinType = secondPin:GetPinType()
        local firstTooltipInfo = ZO_MapPin.TOOLTIP_CREATORS[firstPinType]
        local secondTooltipInfo = ZO_MapPin.TOOLTIP_CREATORS[secondPinType]
        -- If either tooltip info is nil, that pin has no tooltip, and we just need
        -- to make sure it sorts to a consistant place.
        if not firstTooltipInfo then
            return false
        elseif not secondTooltipInfo then
            return true
        end
        local firstCategoryId = GetValueOrExecute(firstTooltipInfo.categoryId, firstPin)
        local secondCategoryId = GetValueOrExecute(secondTooltipInfo.categoryId, secondPin)
        local compareResult = DefaultCompareNilable(firstCategoryId, secondCategoryId)
        if compareResult ~= nil then
            return compareResult
        end
        local firstEntryName = GetValueOrExecute(firstTooltipInfo.entryName, firstPin)
        local secondEntryName = GetValueOrExecute(secondTooltipInfo.entryName, secondPin)
        compareResult = DefaultCompareNilable(firstEntryName, secondEntryName)
        if compareResult ~= nil then
            return compareResult
        end
        return false
    end
    local function GamepadTooltipPinSortFunction(firstPin, secondPin)
        local firstPinType = firstPin:GetPinType()
        local secondPinType = secondPin:GetPinType()
        local firstTooltipInfo = ZO_MapPin.TOOLTIP_CREATORS[firstPinType]
        local secondTooltipInfo = ZO_MapPin.TOOLTIP_CREATORS[secondPinType]
        -- If either tooltip info is nil, that pin has no tooltip, and we just need
        -- to make sure it sorts to a consistant place.
        if not firstTooltipInfo then
            return false
        elseif not secondTooltipInfo then
            return true
        end
        local firstCategoryId = GetValueOrExecute(firstTooltipInfo.categoryId, firstPin) or GetValueOrExecute(firstTooltipInfo.gamepadCategory, firstPin)
        local secondCategoryId = GetValueOrExecute(secondTooltipInfo.categoryId, secondPin) or GetValueOrExecute(secondTooltipInfo.gamepadCategory, secondPin)
        local compareResult = DefaultCompareNilable(firstCategoryId, secondCategoryId)
        if compareResult ~= nil then
            return compareResult
        end
        local firstCategory = GetValueOrExecute(firstTooltipInfo.gamepadCategory, firstPin)
        local secondCategory = GetValueOrExecute(secondTooltipInfo.gamepadCategory, secondPin)
        compareResult = DefaultCompareNilable(firstCategory, secondCategory)
        if compareResult ~= nil then
            return compareResult
        end
        local firstEntryName = GetValueOrExecute(firstTooltipInfo.entryName, firstPin)
        local secondEntryName = GetValueOrExecute(secondTooltipInfo.entryName, secondPin)
        compareResult = DefaultCompareNilable(firstEntryName, secondEntryName)
        if compareResult ~= nil then
            return compareResult
        end
        return false
    end
    function ZO_WorldMapPins_Manager:UpdateMouseOverPins(usedTooltips)
        local isCurrentSceneGamepad = SCENE_MANAGER:IsCurrentSceneGamepad()
        local isInGamepadPreferredMode = IsInGamepadPreferredMode()
        local cursorPositionX
        local cursorPositionY
        if isCurrentSceneGamepad then
            cursorPositionX, cursorPositionY = ZO_WorldMapScroll:GetCenter()
        else
            cursorPositionX, cursorPositionY = GetUIMousePosition()
        end
        local mouseOverListChanged, needsContinuousTooltipUpdates = self:BuildMouseOverPinLists(cursorPositionX, cursorPositionY)
        local needsTooltipUpdate = mouseOverListChanged or self.mousedOverPinWasReset or needsContinuousTooltipUpdates or self.invalidateTooltip
        local needsTooltipScrollReset = mouseOverListChanged or self.mousedOverPinWasReset
        self.invalidateTooltip = false
        self.mousedOverPinWasReset = false
        if not needsTooltipUpdate then
            return false
        end
        -- Iterate over the current pins, using the key as the actual pin to facilitate looking up whether or not it's appropriate to call mouseEnter/mouseExit
        -- for the pins.
        local foundTooltipMouseOverPins = self.foundTooltipMouseOverPins
        ZO_ClearNumericallyIndexedTable(foundTooltipMouseOverPins)
        for pin, isMousedOver in pairs(self.currentMouseOverPins) do
            if pin then
                -- Do the exit pins first (so that ZO_WorldMapMouseoverName gets cleared then set in the correct order)
                if self.mouseExitPins[pin] then
                    self:DoMouseExitForPin(pin)
                end
            
                -- Verify that control is still moused over due to OnUpdate/OnShow handler issues (prevents tooltip popping)
                if isMousedOver and pin:MouseIsOver(cursorPositionX, cursorPositionY) then
                    table.insert(foundTooltipMouseOverPins, pin)
                else
                    pin:SetTargetScale(1)
                end
            end
        end
        if isInGamepadPreferredMode then
            table.sort(foundTooltipMouseOverPins, GamepadTooltipPinSortFunction)
        else
            table.sort(foundTooltipMouseOverPins, TooltipPinSortFunction)
            if #foundTooltipMouseOverPins > 0 then
                WORLD_MAP_MANAGER:HidePinPointerBox()
            end
        end
        local MAX_QUEST_PINS = 10
        local currentQuestPins = 0
        local missedQuestPins = 0
        local maxKeepTooltipPinLevel = 0
        local informationTooltipAppendedTo = false
        local lastGamepadCategory = nil
        local informationTooltip = isInGamepadPreferredMode and ZO_MapLocationTooltip_Gamepad or InformationTooltip
        local tooltipOrder = ZO_WORLD_MAP_TOOLTIP_ORDER
        for index, pin in ipairs(foundTooltipMouseOverPins) do
            local pinType = pin:GetPinType()
            local pinTooltipInfo = ZO_MapPin.TOOLTIP_CREATORS[pinType]
            if pinTooltipInfo then
                local layoutPinTooltip = true
                --always allow assisted pins through
                if pin:IsQuest() and not pin:IsAssisted() then
                    if currentQuestPins < MAX_QUEST_PINS then
                        currentQuestPins = currentQuestPins + 1
                    else
                        layoutPinTooltip = false
                        missedQuestPins = missedQuestPins + 1
                    end
                end
                if layoutPinTooltip then
                    if not pin:IsAreaPin() or pin:ShowsPinAndArea() then
                        pin:SetTargetScale(1.3)
                    end
                    local layoutTooltip = true
                    local usedTooltip = pinTooltipInfo.tooltip
                    if not isCurrentSceneGamepad and usedTooltip == ZO_MAP_TOOLTIP_MODE.KEEP then
                        local pinLevel = pin:GetLevel()
                        if pinLevel > maxKeepTooltipPinLevel then
                            maxKeepTooltipPinLevel = pinLevel
                        else
                            layoutTooltip = false
                        end
                    end
                    if layoutTooltip and pinTooltipInfo.hasTooltip then
                        layoutTooltip = pinTooltipInfo.hasTooltip(pin)
                    end
                    if layoutTooltip then
                        if usedTooltip then
                            if not isCurrentSceneGamepad then
                                for i = 1, #tooltipOrder do
                                    if tooltipOrder[i] == usedTooltip then
                                        if not usedTooltips[i] then
                                            usedTooltips[i] = true
                                            if usedTooltip == ZO_MAP_TOOLTIP_MODE.KEEP then
                                                ZO_WorldMap_GetTooltipForMode(ZO_MAP_TOOLTIP_MODE.KEEP):SetHidden(false)
                                            else
                                                InitializeTooltip(ZO_WorldMap_GetTooltipForMode(usedTooltip), pin:GetControl())
                                            end
                                        end
                                    end
                                end
                            else
                                if not ZO_WorldMap_IsWorldMapInfoShowing() and not ZO_WorldMap_IsKeepInfoShowing() then
                                    -- We'll fire the callback later
                                    local SUPPRESS_CALLBACK = true
                                    ZO_WorldMap_ShowGamepadTooltip(needsTooltipScrollReset, SUPPRESS_CALLBACK)
                                end
                            end
                        end
                        if isCurrentSceneGamepad then
                            local nextCategoryText = GetValueOrExecute(pinTooltipInfo.gamepadCategory, pin)
                            if type(nextCategoryText) == "number" then
                                nextCategoryText = GetString(nextCategoryText)
                            end
                            local nextCategory = nextCategoryText
                            if not nextCategory then
                                nextCategory = pinTooltipInfo.categoryId
                            end
                            local isDifferentCategory = (lastGamepadCategory ~= nextCategory)
                            if nextCategoryText and isDifferentCategory then
                                local categoryIcon = GetValueOrExecute(pinTooltipInfo.gamepadCategoryIcon, pin)
                                local titleStyleName = pinTooltipInfo.gamepadCategoryStyleName
                                titleStyleName = titleStyleName and informationTooltip.tooltip:GetStyle(titleStyleName)
                                local groupSection = informationTooltip.tooltip:AcquireSection(titleStyleName, informationTooltip.tooltip:GetStyle("mapKeepCategorySpacing"))
                                local mapIconTitleStyle = categoryIcon and informationTooltip.tooltip:GetStyle("mapIconTitle") or nil
                                informationTooltip:LayoutGroupHeader(groupSection, categoryIcon, nextCategoryText, titleStyleName, mapIconTitleStyle, informationTooltip.tooltip:GetStyle("mapTitle"))
                                informationTooltip.tooltip:AddSection(groupSection)
                            elseif pinTooltipInfo.gamepadSpacing or isDifferentCategory then
                                local groupSection = informationTooltip.tooltip:AcquireSection(informationTooltip.tooltip:GetStyle("mapKeepCategorySpacing"))
                                informationTooltip.tooltip:AddSectionEvenIfEmpty(groupSection)
                            end
                            lastGamepadCategory = nextCategory
                        end
                        pinTooltipInfo.creator(pin)
                        WORLD_MAP_MANAGER:DoMouseEnterForPinType(pinType)
                        --space out the appended lines in the information tooltip
                        if usedTooltip == ZO_MAP_TOOLTIP_MODE.INFORMATION and not isCurrentSceneGamepad then
                            informationTooltipAppendedTo = true
                            informationTooltip:AddVerticalPadding(5)
                        end
                    end
                end
            end
        
            -- For POIs, add name to the top of the map
            if pinType == MAP_PIN_TYPE_POI_COMPLETE or pinType == MAP_PIN_TYPE_POI_SEEN then
                local poiIndex = pin:GetPOIIndex()
                local zoneIndex = pin:GetPOIZoneIndex()
                local poiName, _, poiStartDesc, poiFinishedDesc = GetPOIInfo(zoneIndex, poiIndex)
                ZO_WorldMapMouseoverName.owner = "poi"
                ZO_WorldMapMouseoverName:SetText(zo_strformat(SI_WORLD_MAP_LOCATION_NAME, poiName))
                if pinType == MAP_PIN_TYPE_POI_COMPLETE then
                    ZO_WorldMapMouseOverDescription:SetText(poiFinishedDesc)
                else
                    ZO_WorldMapMouseOverDescription:SetText(poiStartDesc)
                end
            end
        end
        if missedQuestPins > 0 then
            local text = string.format(zo_strformat(SI_TOOLTIP_MAP_MORE_QUESTS, missedQuestPins))
            if isInGamepadPreferredMode then
                local lineSection = informationTooltip.tooltip:AcquireSection(informationTooltip.tooltip:GetStyle("mapMoreQuestsContentSection"))
                lineSection:AddLine(text, informationTooltip.tooltip:GetStyle("mapLocationTooltipContentLabel"), informationTooltip.tooltip:GetStyle("gamepadElderScrollTooltipContent"))
                informationTooltip.tooltip:AddSection(lineSection)
            else
                informationTooltip:AddLine(text)
            end
        end
        --Remove the last bit of extra padding on the end
        if informationTooltipAppendedTo and not isCurrentSceneGamepad then
            informationTooltip:AddVerticalPadding(-5)
        end
        return true
    end
end
function ZO_WorldMapPins_Manager:InvalidateTooltip()
    self.invalidateTooltip = true
end
--[[
Pin Click Handlers
--]]
do
    local function GetShownHandlersForPin(pin, mouseButton)
        if pin and ZO_MapPin.PIN_CLICK_HANDLERS[mouseButton] then
            local handlers = ZO_MapPin.PIN_CLICK_HANDLERS[mouseButton][pin:GetPinType()]
            if handlers then
                for i = 1, #handlers do
                    local handler = handlers[i]
                    if handler.show == nil or handler.show(pin) then
                        if handler.GetDynamicHandlers then
                            return handler.GetDynamicHandlers(pin)
                        else
                            return { handler }
                        end
                    end
                end
            end
        end
        return nil
    end
    local function GetFirstShownHandlerForPin(pin, mouseButton)
        local handlers = GetShownHandlersForPin(pin, mouseButton)
        if handlers then
            return handlers[1]
        end
        return nil
    end
    function ZO_WorldMapPins_Manager:WouldPinHandleClick(pinControl, button, ctrl, alt, shift)
        if ctrl or alt then
            return false
        end
        if pinControl then
            local pin = ZO_MapPin.GetMapPinForControl(pinControl)
            local validPinHandler = GetFirstShownHandlerForPin(pin, button)
            if validPinHandler then
                return true
            end
        end
        for pin, isMousedOver in pairs(self.currentMouseOverPins) do
            if isMousedOver then
                local validHandler = GetFirstShownHandlerForPin(pin, button)
                if validHandler then
                    return true
                end
            end
        end
    end
    function ZO_WorldMapPins_Manager:GetPinHandlers(mouseButton)
        local pinDatas = ZO_MapPin.pinDatas
        ZO_ClearNumericallyIndexedTable(pinDatas)
        for pin, isMousedOver in pairs(self.currentMouseOverPins) do
            if isMousedOver then
                local shownHandlers = GetShownHandlersForPin(pin, mouseButton)
                if shownHandlers then
                    for _, handler in ipairs(shownHandlers) do
                        local duplicate = false
                        local duplicatesFunction = handler.duplicates
                        if duplicatesFunction then
                            for _, pinData in ipairs(pinDatas) do
                                --if these handlers are of the same type
                                if handler == pinData.handler then
                                    if duplicatesFunction(pin, pinData.pin) then
                                        duplicate = true
                                        break
                                    end
                                end
                            end
                        end
                        if not duplicate then
                            table.insert(pinDatas, {handler = handler, pin = pin})
                        end
                    end
                end
            end
        end
        return pinDatas
    end
end
function ZO_WorldMapPins_Manager.ChoosePinOption(pin, handler)
    if handler.show and not handler.show(pin) then
        --If something changed and we shouldn't be showing this option anymore then...
        if handler.failedAfterBeingShownError then
            --If we have some error text for this case then show it in a dialog
            local text
            if type(handler.failedAfterBeingShownError) == "function" then
                text = handler.failedAfterBeingShownError(pin)
            else
                text = handler.failedAfterBeingShownError
            end
            ZO_Dialogs_ShowPlatformDialog("WORLD_MAP_CHOICE_FAILED", nil, { mainTextParams = { text } })
        end
        --Then skip doing the action
        return
    end
    handler.callback(pin)
end
do
    local function SortPinDatas(firstData, secondData)
        local firstEntryName = GetValueOrExecute(firstData.handler.name, firstData.pin)
        local secondEntryName = GetValueOrExecute(secondData.handler.name, secondData.pin)
        local compareResult = DefaultCompareNilable(firstEntryName, secondEntryName)
        if compareResult ~= nil then
            return compareResult
        end
        return false
    end
    local function OnMenuHiddenCallback()
        ZO_MapPin.pinsInKeyboardMapChoiceDialog = nil
    end
    function ZO_WorldMapPins_Manager:HandlePinClicked(pinControl, mouseButton, ctrl, alt, shift)
        if ctrl or alt then
            return
        end
        local pinDatas = self:GetPinHandlers(mouseButton)
        self:RemoveInvalidSpawnLocations(pinDatas)
        if #pinDatas == 1 then
            pinDatas[1].handler.callback(pinDatas[1].pin)
        elseif #pinDatas > 1 then
            if IsInGamepadPreferredMode() then
                ZO_Dialogs_ShowGamepadDialog("WORLD_MAP_CHOICE_GAMEPAD", { mouseOverPinHandlers = pinDatas })
            else
                ClearMenu()
                ZO_MapPin.pinsInKeyboardMapChoiceDialog = { }
                table.sort(pinDatas, SortPinDatas)
                for _, pinData in ipairs(pinDatas) do
                    local handler = pinData.handler
                    local pin = pinData.pin
                    local name = handler.name
                    if type(name) == "function" then
                        name = name(pin)
                    end
                    AddMenuItem(name, function()
                        self.ChoosePinOption(pin, handler)
                    end)
                    ZO_MapPin.pinsInKeyboardMapChoiceDialog[pin] = true
                end
                SetMenuHiddenCallback(OnMenuHiddenCallback)
                ShowMenu(pinControl)
            end
        end
    end
end
function ZO_WorldMapPins_Manager:RemoveInvalidSpawnLocations(pinDatas)
    for i, pinData in ZO_NumericallyIndexedTableReverseIterator(pinDatas) do
        if ZO_MapPin.IsReviveLocation(pinData.handler) and not ZO_MapPin.CanReviveAtPin(pinData.pin, pinData.handler) then
            table.remove(pinDatas, i)
        end
    end
end
-----------------------
-- Locations Manager --
-----------------------
-- Set up the place names text that appears on the map...
ZO_MapLocationPins_Manager = ZO_ControlPool:Subclass()
function ZO_MapLocationPins_Manager:Initialize(container)
    ZO_ControlPool.Initialize(self, "ZO_MapLocation", container, "Landmark")
    self.m_minFontSize = 17
    self.m_maxFontSize = 32
    self.m_cachedFontStrings = {}
    self:SetFontScale(1)
end
function ZO_MapLocationPins_Manager:SetFontScale(scale)
    if scale ~= self.m_fontScale then
        self.m_fontScale = scale
        self.m_cachedFontStrings = {}
    end
end
function ZO_MapLocationPins_Manager:GetFontString(size)
    -- apply scale to the (unscaled) input size, clamp it, and arive at final font string.
    -- unscale by global ui scale because we want the font to get a little bigger at smaller ui scales to approximately cover the same map area...
    local fontString = self.m_cachedFontStrings[size]
    if not fontString then
        fontString = string.format("$(BOLD_FONT)|%d|soft-shadow-thin", zo_round(size / GetUIGlobalScale()))
        self.m_cachedFontStrings[size] = fontString
    end
    return fontString
end
function ZO_MapLocationPins_Manager:AddLocation(locationIndex)
    if IsMapLocationVisible(locationIndex) then
        local icon, x, y = GetMapLocationIcon(locationIndex)
        if icon ~= "" and ZO_WorldMap_IsNormalizedPointInsideMapBounds(x, y) then
            local tag = ZO_MapPin.CreateLocationPinTag(locationIndex, icon)
            ZO_WorldMap_GetPinManager():CreatePin(MAP_PIN_TYPE_LOCATION, tag, x, y)
        end
    end
end
function ZO_MapLocationPins_Manager:RefreshLocations()
    for i = 1, GetNumMapLocations() do
        self:AddLocation(i)
    end
end
----------------
-- Sticky Pin --
----------------
--[[
Sticky Pin Utilities for gamepad map control (utilized by mouse over list construction)
--]]
local BASE_STICKY_DISTANCE_UNITS =
{
    MIN = 50,
    MAX = 75,
}
ZO_WorldMapStickyPin = ZO_InitializingObject:Subclass()
function ZO_WorldMapStickyPin:Initialize()
    self.thresholdDistanceSq = BASE_STICKY_DISTANCE_UNITS.MIN * BASE_STICKY_DISTANCE_UNITS.MIN
    self.enabled = true
end
function ZO_WorldMapStickyPin:SetEnabled(enabled)
    self.enabled = enabled
end
function ZO_WorldMapStickyPin:UpdateThresholdDistance(currentNormalizedZoom)
    local stickyDistance = zo_lerp(BASE_STICKY_DISTANCE_UNITS.MIN, BASE_STICKY_DISTANCE_UNITS.MAX, currentNormalizedZoom)
    self.thresholdDistanceSq = stickyDistance * stickyDistance
end
function ZO_WorldMapStickyPin:SetStickyPin(pin)
    self.pin = pin
end
function ZO_WorldMapStickyPin:GetStickyPin()
    return self.pin
end
function ZO_WorldMapStickyPin:ClearStickyPin(mover)
    if self.movingToPin and self:GetStickyPin() then
        mover:ClearTargetOffset()
    end
    self:SetStickyPin(nil)
end
function ZO_WorldMapStickyPin:MoveToStickyPin(mover)
    local movingToPin = self:GetStickyPin()
    if movingToPin then
        self.movingToPin = movingToPin
        local useCurrentZoom = true
        mover:PanToPin(movingToPin, useCurrentZoom)
    end
end
function ZO_WorldMapStickyPin:SetStickyPinFromNearestCandidate()
    self:SetStickyPin(self.nearestCandidate)
end
function ZO_WorldMapStickyPin:ClearNearestCandidate()
    self.nearestCandidate = nil
    self.nearestCandidateDistanceSq = 0
end
function ZO_WorldMapStickyPin:ConsiderPin(pin, x, y)
    if self.enabled then
        local pinGroup = pin:GetPinGroup()
        if pinGroup == nil or WORLD_MAP_MANAGER:AreStickyPinsEnabledForPinGroup(pinGroup) then
            local distanceSq = pin:DistanceToSq(x, y)
            if distanceSq < self.thresholdDistanceSq then
                if not self.nearestCandidate or distanceSq < self.nearestCandidateDistanceSq then
                    self.nearestCandidate = pin
                    self.nearestCandidateDistanceSq = distanceSq
                end
            end
        end
    end
end