-
Notifications
You must be signed in to change notification settings - Fork 3
/
poi.lua
97 lines (79 loc) · 2.48 KB
/
poi.lua
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
local _, addon = ...
local SPECIAL_ASSIGNMENT_WIDGET_SET = 1108
local provider = CreateFromMixins(AreaPOIDataProviderMixin)
function provider:GetPinTemplate()
return 'BetterWorldQuestPOITemplate'
end
function provider:RefreshAllData()
self:RemoveAllData()
local map = self:GetMap()
local mapID = map:GetMapID()
if mapID == 947 then
return
end
if addon:IsParentMap(mapID) then
for _, mapInfo in next, C_Map.GetMapChildrenInfo(mapID, Enum.UIMapType.Zone, true) do
if mapInfo.flags == 6 or mapInfo.flags == 4 then -- TODO: do bitwise compare with 0x04
-- copy from AreaPOIDataProviderMixin
for _, poiID in next, GetAreaPOIsForPlayerByMapIDCached(mapInfo.mapID) do
local poiInfo = C_AreaPoiInfo.GetAreaPOIInfo(mapInfo.mapID, poiID)
if poiInfo and poiInfo.tooltipWidgetSet == SPECIAL_ASSIGNMENT_WIDGET_SET then
poiInfo.dataProvider = self
-- translate position
poiInfo.position = addon:TranslatePosition(poiInfo.position, mapInfo.mapID, mapID)
if poiInfo.position then
map:AcquirePin(self:GetPinTemplate(), poiInfo)
end
end
end
end
end
end
end
WorldMapFrame:AddDataProvider(provider)
-- hook into changes
local function updateVisuals()
-- update pins on changes
if WorldMapFrame:IsShown() then
provider:RefreshAllData()
end
end
addon:RegisterOptionCallback('showEvents', updateVisuals)
-- change visibility
local modifier
local function toggleVisibility()
local state = true
if modifier == 'ALT' then
state = not IsAltKeyDown()
elseif modifier == 'SHIFT' then
state = not IsShiftKeyDown()
elseif modifier == 'CTRL' then
state = not IsControlKeyDown()
end
for pin in WorldMapFrame:EnumeratePinsByTemplate(provider:GetPinTemplate()) do
pin:SetShown(state)
end
for pin in WorldMapFrame:EnumeratePinsByTemplate('AreaPOIPinTemplate') do
local poiInfo = pin:GetPoiInfo()
if poiInfo and poiInfo.tooltipWidgetSet == SPECIAL_ASSIGNMENT_WIDGET_SET then
pin:SetShown(state)
end
end
end
WorldMapFrame:HookScript('OnHide', function()
toggleVisibility()
end)
addon:RegisterOptionCallback('hideModifier', function(value)
if value == 'NEVER' then
if addon:IsEventRegistered('MODIFIER_STATE_CHANGED', toggleVisibility) then
addon:UnregisterEvent('MODIFIER_STATE_CHANGED', toggleVisibility)
end
modifier = nil
toggleVisibility()
else
if not addon:IsEventRegistered('MODIFIER_STATE_CHANGED', toggleVisibility) then
addon:RegisterEvent('MODIFIER_STATE_CHANGED', toggleVisibility)
end
modifier = value
end
end)