comparison WorldPlan.lua @ 36:21bcff08b0f4

WorldPlan: - Quest pins are now placed on the flight map. Their visibility rules will mirror the filter options from the world map. - Filter controls polish: - First click negates other reward type filters. Subsequent clicks will then toggle individual reward types until the filters are reset via Right-click. - Adheres to the Blizzard CVars added in patch 7.1 - Numerous optimizations to how data and visual updates are handled; should see an even better load time, and snappier world map interaction. ClassPlan: - The 'Available Missions' list is now recorded. It can be reviewed by clicking on the mission list heading. - Information filtering by character and realm.
author Nenue
date Fri, 04 Nov 2016 01:40:39 -0400
parents 26dfa661daa7
children 589c444d4837
comparison
equal deleted inserted replaced
35:26dfa661daa7 36:21bcff08b0f4
9 UsedFilters = {}, 9 UsedFilters = {},
10 QuestsByZone = {}, 10 QuestsByZone = {},
11 QuestsByID = {}, 11 QuestsByID = {},
12 TaskQueue = {}, 12 TaskQueue = {},
13 } 13 }
14 WorldPlanQuestsMixin = {
15 QuestsByZone = {},
16 QuestsByID = {},
17 freePins = {},
18 }
14 WorldPlanPOIMixin = {} 19 WorldPlanPOIMixin = {}
15 local WorldPlan = WorldPlanCore
16
17 local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end 20 local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
18
19 local mprint = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end
20 local WP_VERSION = "1.0" 21 local WP_VERSION = "1.0"
21 local tinsert, pairs, floor = table.insert, pairs, floor 22 local tinsert, pairs, floor = table.insert, pairs, floor
22 local ITEM_QUALITY_COLORS = ITEM_QUALITY_COLORS 23 local ITEM_QUALITY_COLORS = ITEM_QUALITY_COLORS
23 local BROKEN_ISLES_ID = 1007 24 local BROKEN_ISLES_ID = 1007
24 local GetCurrentMapAreaID, GetMapNameByID, GetSuperTrackedQuestID = GetCurrentMapAreaID, GetMapNameByID, GetSuperTrackedQuestID 25 local GetCurrentMapAreaID, GetMapNameByID, GetSuperTrackedQuestID = GetCurrentMapAreaID, GetMapNameByID, GetSuperTrackedQuestID
33 rewardMask = "Interface\\Minimap\\UI-Minimap-Background", 34 rewardMask = "Interface\\Minimap\\UI-Minimap-Background",
34 texture = "Interface\\BUTTONS\\YELLOWORANGE64", 35 texture = "Interface\\BUTTONS\\YELLOWORANGE64",
35 continent = { 36 continent = {
36 PinSize = 14, 37 PinSize = 14,
37 Border = 2, 38 Border = 2,
38 TrackingBorder = 1, 39 highlightWidth = 1,
39 TagSize = 6, 40 TagSize = 6,
40 TimeleftStage = 0, 41 maxAlertLevel = 0,
41 showNumber = true, 42 showNumber = true,
42 numberFontObject = 'WorldPlanFont' 43 numberFontObject = 'WorldPlanFont'
43 }, 44 },
44 zone = { 45 zone = {
45 PinSize = 22, 46 iconWidth = 22,
46 Border = 3, 47 borderWidth = 3,
47 TrackingBorder = 2, 48 highlightWidth = 2,
48 TagSize = 12, 49 TagSize = 12,
49 TimeleftStage = 3, 50 maxAlertLevel = 3,
50 showNumber = true, 51 showNumber = true,
51 numberFontObject = 'WorldPlanNumberFontThin' 52 numberFontObject = 'WorldPlanNumberFontThin'
52 }, 53 },
53 minimized = { 54 minimized = {
54 PinSize = 6, 55 iconWidth = 6,
55 Border = 0, 56 borderWidth = 0,
56 TrackingBorder = 1, 57 highlightWidth = 0,
58 maxAlertLevel = 1,
57 NoIcon = true, 59 NoIcon = true,
58 TimeleftStage = 1, 60 TimeleftStage = 1,
59 showNumber = false, 61 showNumber = false,
60 } 62 }
61 } 63 }
93 end 95 end
94 end 96 end
95 _G.WorldPlan:Refresh() 97 _G.WorldPlan:Refresh()
96 end 98 end
97 99
98 function WorldPlan:print(...) 100 function WorldPlanCore:print(...)
99 local msg 101 local msg
100 for i = 1, select('#', ...) do 102 for i = 1, select('#', ...) do
101 msg = (msg and (msg .. ' ') or '') .. tostring(select(i, ...)) 103 msg = (msg and (msg .. ' ') or '') .. tostring(select(i, ...))
102 end 104 end
103 DEFAULT_CHAT_FRAME:AddMessage("|cFF0088FFWorldPlan|r: " .. msg) 105 DEFAULT_CHAT_FRAME:AddMessage("|cFF0088FFWorldPlan|r: " .. msg)
104 end 106 end
105 107
106 local current_type_owner 108 local current_type_owner
107 function WorldPlan:AddHandler (frame, defaults) 109 function WorldPlanCore:AddHandler (frame, defaults)
108 print('|cFFFFFF00'..self:GetName()..':AddHandler()', frame:GetName()) 110 print('|cFFFFFF00'..self:GetName()..':AddHandler()', frame:GetName())
109 tinsert(self.modules, frame) 111 tinsert(self.modules, frame)
110 self.defaults[frame] = defaults 112 self.defaults[frame] = defaults
111 frame.GetTypeInfo = function(frame, typeID) 113 frame.GetTypeInfo = function(frame, typeID)
112 return self:GetTypeInfo(frame, typeID) 114 return self:GetTypeInfo(frame, typeID)
113 end 115 end
114 end 116 end
115 117
116 function WorldPlan:OnLoad () 118 function WorldPlanCore:OnLoad ()
117 119
118 self.Types = setmetatable({}, { 120 self.Types = setmetatable({}, {
119 __newindex = function(t, k, v) 121 __newindex = function(t, k, v)
120 if type(v) == 'table' then 122 if type(v) == 'table' then
121 print('adding owner', k) 123 print('adding owner', k)
139 141
140 for index, color in pairs(ITEM_QUALITY_COLORS) do 142 for index, color in pairs(ITEM_QUALITY_COLORS) do
141 self:AddTypeInfo(self, index, { r = color.r, g = color.g, b = color.b, hex = color.hex, }) 143 self:AddTypeInfo(self, index, { r = color.r, g = color.g, b = color.b, hex = color.hex, })
142 end 144 end
143 145
144 WorldPlan = self 146
145 147 WorldPlanCore:print('v'..WP_VERSION)
146 WorldPlan:print('v'..WP_VERSION)
147 148
148 self:RegisterEvent("QUESTLINE_UPDATE") 149 self:RegisterEvent("QUESTLINE_UPDATE")
149 self:RegisterEvent("QUEST_LOG_UPDATE") 150 self:RegisterEvent("QUEST_LOG_UPDATE")
150 self:RegisterEvent("WORLD_MAP_UPDATE") 151 self:RegisterEvent("WORLD_MAP_UPDATE")
151 self:RegisterEvent("WORLD_QUEST_COMPLETED_BY_SPELL") 152 self:RegisterEvent("WORLD_QUEST_COMPLETED_BY_SPELL")
154 self:RegisterEvent("ARTIFACT_XP_UPDATE") 155 self:RegisterEvent("ARTIFACT_XP_UPDATE")
155 self:RegisterEvent("ADDON_LOADED") 156 self:RegisterEvent("ADDON_LOADED")
156 self:SetParent(WorldMapFrame) 157 self:SetParent(WorldMapFrame)
157 end 158 end
158 159
159 function WorldPlan:OnShow() 160 function WorldPlanCore:OnShow()
160 print(self:GetName()..':OnShow()') 161 print(self:GetName()..':OnShow()')
161 if self.isStale then 162 if self.isStale then
162 self:Refresh() 163 self:Refresh()
163 end 164 end
164 165
165 hooksecurefunc(self, 'SetScript', function(...) self:print('|cFFFFFF00'..self:GetName()..':SetScript()|r', ...) end) 166 hooksecurefunc(self, 'SetScript', function(...) self:print('|cFFFFFF00'..self:GetName()..':SetScript()|r', ...) end)
166 end 167 end
167 168
168 function WorldPlan:OnEvent (event, ...) 169 function WorldPlanCore:OnEvent (event, ...)
169 print() 170 print()
170 print(event, 'init:', self.initialized) 171 print(event, 'init:', self.initialized)
171 if event == 'ADDON_LOADED' then 172 if event == 'ADDON_LOADED' then
172 local addon = ... 173
173 if addon == "Blizzard_FlightMap" then
174 mprint('sending data provider')
175 local dataProvider = Mixin(MapCanvasDataProviderMixin, WorldPlanDataProvider)
176 WorldPlanDataPinMixin = Mixin(MapCanvasPinMixin, WorldPlanDataPinMixin)
177 for k,v in pairs(dataProvider) do
178 mprint((v == WorldPlanDataProvider[k]) and ('|cFF00FF00'..tostring(k)..'|r') or ('|cFFFF4400'..tostring(k)..'|r'))
179 end
180
181 FlightMapFrame:AddDataProvider(dataProvider)
182 end
183 if IsLoggedIn() and not self.initialized then 174 if IsLoggedIn() and not self.initialized then
184 self:Setup() 175 self:Setup()
185 end 176 end
186 else 177 else
187 if event == 'WORLD_MAP_UPDATE' then 178 if event == 'WORLD_MAP_UPDATE' then
226 end 217 end
227 end 218 end
228 end 219 end
229 end 220 end
230 221
231 function WorldPlan:Setup () 222 function WorldPlanCore:Setup ()
232 if not WorldPlanData then 223 if not WorldPlanData then
233 WorldPlanData = {key = 0 } 224 WorldPlanData = {key = 0 }
234 end 225 end
235 WorldPlanData.key = (WorldPlanData.key or 0) + 1 226 WorldPlanData.key = (WorldPlanData.key or 0) + 1
236 self.db = WorldPlanData 227 self.db = WorldPlanData
270 self:Refresh(true) 261 self:Refresh(true)
271 end 262 end
272 end) 263 end)
273 end 264 end
274 265
275 function WorldPlan:AddTypeInfo(owner, id, info) 266 function WorldPlanCore:AddTypeInfo(owner, id, info)
276 self.Types[owner] = self.Types[owner] or {} 267 self.Types[owner] = self.Types[owner] or {}
277 self.Types[owner][id] = info 268 self.Types[owner][id] = info
278 print('Type('..owner:GetName()..')('..id..') = '.. tostring(info)) 269 print('Type('..owner:GetName()..')('..id..') = '.. tostring(info))
279 end 270 end
280 271
281 function WorldPlan:GetTypeInfo(owner, typeID) 272 function WorldPlanCore:GetTypeInfo(owner, typeID)
282 local info, extraInfo 273 local info, extraInfo
283 if not owner then 274 if not owner then
284 --print('## deferring to default type list') 275 --print('## deferring to default type list')
285 else 276 else
286 --print('## pulling for', owner:GetName(), 'id =', typeID) 277 --print('## pulling for', owner:GetName(), 'id =', typeID)
320 {maxSeconds = 10081, 311 {maxSeconds = 10081,
321 r=0, g=1, b=0, 312 r=0, g=1, b=0,
322 }, -- 7 days + 1 minute 313 }, -- 7 days + 1 minute
323 } 314 }
324 -- Generates a timeleft string 315 -- Generates a timeleft string
325 function WorldPlan:GetTimeInfo(timeLeft, limit) 316 function WorldPlanCore:GetTimeInfo(timeLeft, limit)
326 limit = limit or #timeStates 317 limit = limit or #timeStates
327 for index = 1, limit do 318 for index = 1, limit do
328 local state = timeStates[index] 319 local state = timeStates[index]
329 if timeLeft <= state.maxSeconds then 320 if timeLeft <= state.maxSeconds then
330 local text 321 local text
336 end 327 end
337 return nil, nil 328 return nil, nil
338 end 329 end
339 end 330 end
340 331
341 function WorldPlan:Refresh (forced) 332 function WorldPlanCore:Refresh (forced)
342 print('|cFFFFFF00'..self:GetName()..':Refresh()|r forced:', forced, 'init:', self.initialized) 333 print('|cFFFFFF00'..self:GetName()..':Refresh()|r forced:', forced, 'init:', self.initialized)
343 if not self.initialized then 334 if not self.initialized then
344 return 335 return
345 end 336 end
346 337
351 end 342 end
352 end 343 end
353 end 344 end
354 345
355 -- insert visual options into the tracking button menu 346 -- insert visual options into the tracking button menu
356 WorldPlan.OnDropDownInitialize = function (self, callback, dropType) 347 WorldPlanCore.OnDropDownInitialize = function (self, callback, dropType)
357 if self ~= WorldMapFrameDropDown then 348 if self ~= WorldMapFrameDropDown then
358 return 349 return
359 end 350 end
360 local db = WorldPlan.db 351 local db = WorldPlan.db
361 352
428 419
429 SLASH_WORLDPLAN1 = "/worldplan" 420 SLASH_WORLDPLAN1 = "/worldplan"
430 SLASH_WORLDPLAN2 = "/wp" 421 SLASH_WORLDPLAN2 = "/wp"
431 SlashCmdList.WORLDPLAN = function() 422 SlashCmdList.WORLDPLAN = function()
432 print('command pop') 423 print('command pop')
433 WorldPlan:GetPinsForMap() 424 WorldPlanCore:GetPinsForMap()
434 WorldPlan:RefreshPins() 425 WorldPlanCore:RefreshPins()
435 426
436 SetTimedCallbackForAllPins(0, function(self) self.FadeIn:Play() self.FlashIn:Play() end) 427 SetTimedCallbackForAllPins(0, function(self) self.FadeIn:Play() self.FlashIn:Play() end)
437 SetTimedCallbackForAllPins(5, function(self) self.PendingFade:Play() end) 428 SetTimedCallbackForAllPins(5, function(self) self.PendingFade:Play() end)
438 SetTimedCallbackForAllPins(8, function(self) self.PendingFade:Stop() end) 429 SetTimedCallbackForAllPins(8, function(self) self.PendingFade:Stop() end)
439 end 430 end