-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprovider.lua
111 lines (92 loc) · 2.9 KB
/
provider.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
local _, addon = ...
local showAzeroth
addon:RegisterOptionCallback('showAzeroth', function(value)
showAzeroth = value
end)
local provider = CreateFromMixins(WorldMap_WorldQuestDataProviderMixin)
provider:SetMatchWorldMapFilters(true)
provider:SetUsesSpellEffect(true)
provider:SetCheckBounties(true)
-- override GetPinTemplate to use our custom pin
function provider:GetPinTemplate()
return 'BetterWorldQuestPinTemplate'
end
-- override ShouldOverrideShowQuest method to show pins on continent maps
function provider:ShouldOverrideShowQuest()
-- just nop so we don't hit the default
end
-- override ShouldShowQuest method to show pins on parent maps
function provider:ShouldShowQuest(questInfo)
local mapID = self:GetMap():GetMapID()
if mapID == 947 then
-- TODO: change option to only show when there's few?
return showAzeroth
end
if WorldQuestDataProviderMixin.ShouldShowQuest(self, questInfo) then -- super
return true
end
local mapInfo = C_Map.GetMapInfo(mapID)
if mapInfo.mapType == Enum.UIMapType.Continent then
return true
end
return addon:IsChildMap(mapID, questInfo.mapID)
end
-- remove the default provider
for dp in next, WorldMapFrame.dataProviders do
if not dp.GetPinTemplates and type(dp.GetPinTemplate) == 'function' then
if dp:GetPinTemplate() == 'WorldMap_WorldQuestPinTemplate' then
WorldMapFrame:RemoveDataProvider(dp)
break
end
end
end
-- add our own
WorldMapFrame:AddDataProvider(provider)
-- hook into changes
local function updateVisuals()
-- update pins on changes
if WorldMapFrame:IsShown() then
provider:RefreshAllData()
for pin in WorldMapFrame:EnumeratePinsByTemplate(provider:GetPinTemplate()) do
pin:RefreshVisuals()
pin:ApplyCurrentScale()
end
end
end
addon:RegisterOptionCallback('mapScale', updateVisuals)
addon:RegisterOptionCallback('parentScale', updateVisuals)
addon:RegisterOptionCallback('zoomFactor', updateVisuals)
addon:RegisterOptionCallback('showAzeroth', updateVisuals)
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
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)