annotate WorldPlan.lua @ 109:caa482329919

POI optimization
author Nenue
date Mon, 10 Jul 2017 18:34:11 -0400
parents b67ba1078824
children f6ef9a9f5476
rev   line source
Nenue@0 1 -- WorldPlan.lua
Nenue@0 2 -- Created: 8/16/2016 8:19 AM
Nenue@0 3 -- %file-revision%
Nenue@40 4 local addonFileName, db = ...
Nenue@40 5 local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
Nenue@67 6 local WP_VERSION = "1.4"
Nenue@40 7 local tinsert, pairs, floor = tinsert, pairs, floor
Nenue@40 8 local tremove, ipairs, wipe, unpack = tremove, ipairs, wipe, unpack
Nenue@40 9 local select, type, tostring, tonumber = select, type, tostring, tonumber
Nenue@40 10 local ITEM_QUALITY_COLORS = ITEM_QUALITY_COLORS
Nenue@40 11 local BROKEN_ISLES_ID = 1007
Nenue@40 12 local GetCurrentMapAreaID = GetCurrentMapAreaID
Nenue@40 13 local GetTime, IsLoggedIn = GetTime, IsLoggedIn
Nenue@69 14 local DEBUG_HISTORY = {}
Nenue@0 15
Nenue@40 16 -- Define tables here so the pointers match up
Nenue@40 17 WorldPlanCore = { defaults = {}, modules = {}, TaskQueue = {}, }
Nenue@35 18 WorldPlanPOIMixin = {}
Nenue@40 19 WorldPlanSummaryMixin = {}
Nenue@40 20 db.filtersDirty = true
Nenue@40 21 db.questsDirty = true
Nenue@40 22 db.OrderedModules = {}
Nenue@40 23 db.LoadedModules = {}
Nenue@40 24 db.UsedFilters = {}
Nenue@40 25 db.QuestsByZone = {}
Nenue@40 26 db.QuestsByID = {}
Nenue@40 27 db.TasksByID = {}
Nenue@40 28 db.FreePins = {}
Nenue@40 29 db.UsedPins = {}
Nenue@67 30 db.UpdatedPins = {}
Nenue@40 31 db.ReportChunks = {}
Nenue@75 32 db.Bounties = {}
Nenue@75 33 db.BountiesByQuestID = {}
Nenue@72 34 db.BountiesByFactionID = {}
Nenue@100 35 db.IgnoreTimers = {}
Nenue@108 36 db.CLTriggers = {
Nenue@108 37 wq = function(arg2, extraArgs)
Nenue@108 38 if arg2 and WorldPlanQuests[arg2] then
Nenue@108 39 self:print('WorldPlanQuests:'..arg2..'()')
Nenue@108 40 WorldPlanQuests[arg2](WorldPlanQuests)
Nenue@108 41 else
Nenue@108 42 self:print('WorldPlanQuests:Refresh(true)')
Nenue@108 43 WorldPlanQuests:Refresh(true)
Nenue@108 44 end
Nenue@108 45 end,
Nenue@108 46 flightmap = function(arg2, extraArgs)
Nenue@108 47 if not extraArgs then
Nenue@108 48 return
Nenue@108 49 end
Nenue@108 50
Nenue@108 51 local val1, val2, val3 = extraArgs:match("(%S+)%s*(%S*)%s*(%S*)")
Nenue@108 52 if arg2 == 'scale' then
Nenue@108 53 if tonumber(val1) and tonumber(val2) and tonumber(val3) then
Nenue@108 54 db.Config.FlightMapScalingLimits = {tonumber(val1), tonumber(val2), tonumber(val3)}
Nenue@108 55 self:print('FlightMapFrame scaling limits updated:', unpack(db.Config.FlightMapScalingLimits))
Nenue@108 56 else
Nenue@108 57 self:print('FlightMapFrame scaling limits:', unpack(db.Config.FlightMapScalingLimits))
Nenue@108 58 end
Nenue@108 59 elseif arg2 == 'alpha' then
Nenue@108 60
Nenue@108 61 if tonumber(val1) and tonumber(val2) and tonumber(val3) then
Nenue@108 62 db.Config.FlightMapAlphaLimits = {tonumber(val1), tonumber(val2), tonumber(val3)}
Nenue@108 63 self:print('FlightMapFrame alpha limits updated:', unpack(db.Config.FlightMapAlphaLimits))
Nenue@108 64 else
Nenue@108 65 self:print('FlightMapFrame alpha limits:', unpack(db.Config.FlightMapAlphaLimits))
Nenue@108 66 end
Nenue@108 67 end
Nenue@108 68
Nenue@108 69 end,
Nenue@108 70 filter = function(arg2)
Nenue@108 71 if arg2 and WorldPlanSummary[arg2] then
Nenue@108 72 self:print('WorldPlanSummary:'..arg2..'()')
Nenue@108 73 WorldPlanSummary[arg2](WorldPlanSummary)
Nenue@108 74 else
Nenue@108 75 self:print('WorldPlanSummary:Refresh(true)')
Nenue@108 76 WorldPlanSummary:Refresh(true)
Nenue@108 77 end
Nenue@108 78 end,
Nenue@108 79 log = function()
Nenue@108 80 if WorldPlanDebug:IsShown() then
Nenue@108 81 WorldPlanDebug:SetShown(false)
Nenue@108 82 else
Nenue@108 83 WorldPlanDebug:SetShown(true)
Nenue@108 84 end
Nenue@108 85
Nenue@108 86 end,
Nenue@108 87 debug = function()
Nenue@108 88
Nenue@108 89 if WorldPlanData then
Nenue@108 90 WorldPlanData.DebugEnabled = (not WorldPlanData.DebugEnabled)
Nenue@108 91 self:print(WorldPlanData.DebugEnabled and "Debugger on." or "Debugger off.")
Nenue@108 92 end
Nenue@108 93 end
Nenue@108 94 }
Nenue@108 95
Nenue@0 96
Nenue@100 97 -- default color templates
Nenue@40 98 db.DefaultType = {
Nenue@0 99 a = 1,
Nenue@0 100 r = 1, g = 1, b = 1,
Nenue@0 101 x = 0, y = 0,
Nenue@0 102 desaturated = true,
Nenue@33 103 pinMask = "Interface\\Minimap\\UI-Minimap-Background",
Nenue@33 104 rewardMask = "Interface\\Minimap\\UI-Minimap-Background",
Nenue@33 105 texture = "Interface\\BUTTONS\\YELLOWORANGE64",
Nenue@0 106 continent = {
Nenue@40 107 iconWidth = 14,
Nenue@40 108 borderWidth = 2,
Nenue@36 109 highlightWidth = 1,
Nenue@40 110 TagSize = 8,
Nenue@36 111 maxAlertLevel = 0,
Nenue@27 112 showNumber = true,
Nenue@30 113 numberFontObject = 'WorldPlanFont'
Nenue@0 114 },
Nenue@0 115 zone = {
Nick@62 116 iconWidth = 18,
Nenue@47 117 borderWidth = 2,
Nenue@36 118 highlightWidth = 2,
Nenue@0 119 TagSize = 12,
Nenue@36 120 maxAlertLevel = 3,
Nenue@27 121 showNumber = true,
Nenue@30 122 numberFontObject = 'WorldPlanNumberFontThin'
Nenue@0 123 },
Nenue@0 124 minimized = {
Nenue@40 125 r = 0, g = 0, b = 0, a = 0.1,
Nenue@40 126 iconWidth = 8,
Nenue@49 127 borderWidth = 0,
Nenue@40 128 alpha = 0.5,
Nenue@36 129 highlightWidth = 0,
Nenue@40 130 maxAlertLevel = 0,
Nenue@0 131 NoIcon = true,
Nenue@40 132
Nenue@40 133 TagSize = 8,
Nenue@0 134 TimeleftStage = 1,
Nenue@27 135 showNumber = false,
Nenue@40 136 alpha = 0.1,
Nenue@0 137 }
Nenue@0 138 }
Nenue@29 139
Nenue@54 140
Nenue@40 141 db.DefaultConfig = {
Nenue@27 142 ShowAllProfessionQuests = false,
Nenue@9 143 DisplayContinentSummary = true,
Nenue@9 144 DisplayContinentPins = true,
Nenue@9 145 NotifyWhenNewQuests = true,
Nenue@9 146 EnablePins = true,
Nenue@34 147 FadeWhileGrouped = false,
Nenue@67 148 FlightMapAlphaLimits = {1, .7, 1},
Nenue@40 149 FlightMapScalingLimits = {1, 3, 1.5},
Nenue@54 150 --UntrackedColor = {},
Nenue@54 151 --TrackedColor = {},
Nenue@54 152 --CriteriaColor = {},
Nenue@54 153 --RewardColorGold = {},
Nenue@54 154 --RewardColorReagent = {},
Nenue@54 155 --RewardColorArtifactPower = {},
Nenue@54 156 --RewardColorCurrency = {},
Nenue@100 157 IgnoreTimers = {},
Nenue@9 158 }
Nenue@9 159
Nenue@0 160
Nenue@0 161
Nenue@0 162 -- tracking menu toggler
Nenue@0 163 local DropDown_OnClick = function(self)
Nenue@0 164 local key = self.value
Nenue@0 165 if key then
Nenue@0 166 if WorldPlanData[key] then
Nenue@0 167 WorldPlanData[key] = nil
Nenue@0 168 else
Nenue@0 169 WorldPlanData[key] = true
Nenue@0 170 end
Nenue@0 171 end
Nenue@67 172 _G.WorldPlan:OnConfigUpdate()
Nenue@0 173 end
Nenue@0 174
Nenue@49 175 -- insert visual options into the tracking button menu
Nenue@49 176 local DropDown_Initialize = function (self, callback, dropType)
Nenue@49 177 if self ~= WorldMapFrameDropDown then
Nenue@49 178 return
Nenue@49 179 end
Nenue@49 180 local config = WorldPlanData
Nenue@49 181 local info = UIDropDownMenu_CreateInfo()
Nenue@49 182 info.text = ""
Nenue@49 183 info.isTitle = true
Nenue@49 184 UIDropDownMenu_AddButton(info)
Nenue@49 185 info.text = "|cFF00AAFFWorldPlan|r"
Nenue@49 186 info.isTitle = true
Nenue@49 187 UIDropDownMenu_AddButton(info)
Nenue@49 188 info.isTitle = nil
Nenue@49 189 info.disabled = nil
Nenue@49 190 info.keepShownOnClick = true
Nenue@49 191 info.tooltipOnButton = 1
Nenue@49 192
Nenue@49 193 info.text = "Enable"
Nenue@49 194 info.isNotRadio = true
Nenue@49 195 info.value = "EnablePins"
Nenue@49 196 info.checked = config.EnablePins
Nenue@49 197 info.tooltipTitle = "Enable World Quest Overlays"
Nenue@49 198 info.tooltipText = "Toggle the detail layers here."
Nenue@49 199 info.func = DropDown_OnClick
Nenue@49 200 UIDropDownMenu_AddButton(info)
Nenue@49 201
Nenue@49 202 info.text = "Display All Profession Quests"
Nenue@49 203 info.isNotRadio = true
Nenue@49 204 info.value = "ShowAllProfessionQuests"
Nenue@49 205 info.checked = config.ShowAllProfessionQuests
Nenue@49 206 info.tooltipTitle = "Hidden Quests"
Nenue@49 207 info.tooltipText = "Display work order and profession-related quests that are skipped by the default UI."
Nenue@49 208 info.func = DropDown_OnClick
Nenue@49 209 UIDropDownMenu_AddButton(info)
Nenue@49 210
Nenue@49 211 info.text = "Show Continent Pins"
Nenue@49 212 info.isNotRadio = true
Nenue@49 213 info.value = "DisplayContinentPins"
Nenue@49 214 info.checked = config.DisplayContinentPins
Nenue@49 215 info.tooltipTitle = "Continent Pins"
Nenue@49 216 info.tooltipText = "Display quest pins on the continent map (may get cramped)."
Nenue@49 217 info.func = DropDown_OnClick
Nenue@49 218 UIDropDownMenu_AddButton(info)
Nenue@49 219
Nenue@49 220 info.text = "Show Summary"
Nenue@49 221 info.isNotRadio = true
Nenue@49 222 info.value = "DisplayContinentSummary"
Nenue@49 223 info.tooltipTitle = "Summary Bar"
Nenue@49 224 info.tooltipText = "Display a summary of active world quests. Note: requires directly viewing Broken Isle and Dalaran maps to gain complete info."
Nenue@49 225 info.checked = config.DisplayContinentSummary
Nenue@49 226 info.func = DropDown_OnClick
Nenue@49 227 UIDropDownMenu_AddButton(info)
Nenue@49 228 --[[
Nenue@49 229
Nenue@49 230 info.text = "Nudge Pins"
Nenue@49 231 info.isNotRadio = true
Nenue@49 232 info.value = "NudgePins"
Nenue@49 233 info.tooltipTitle = "Pin Nudging"
Nenue@49 234 info.tooltipText = "Adjust the position of quest pins that overlap."
Nenue@49 235 info.checked = config.NudgePins
Nenue@49 236 info.func = DropDown_OnClick
Nenue@49 237 UIDropDownMenu_AddButton(info)
Nenue@49 238
Nenue@49 239 info.text = "Fade Whiled Grouped"
Nenue@49 240 info.isNotRadio = true
Nenue@49 241 info.value = "FadeWhileGrouped"
Nenue@49 242 info.tooltipTitle = "Group Fade"
Nenue@49 243 info.tooltipText = "Reduce pin alpha when grouped, so player dots are easier to see."
Nenue@49 244 info.checked = config.FadeWhileGrouped
Nenue@49 245 info.func = DropDown_OnClick
Nenue@49 246 UIDropDownMenu_AddButton(info)
Nenue@49 247 --]]
Nenue@49 248 end
Nenue@49 249
Nenue@108 250 local function Handler_UpdateFader(self, sinceLast, isActive)
Nenue@108 251
Nenue@108 252 if isActive then
Nenue@108 253 self.toAlpha = 1
Nenue@108 254 self.Backdrop:Show()
Nenue@108 255 else
Nenue@108 256 self.toAlpha = self.fadeOpacity
Nenue@108 257 self.Backdrop:Hide()
Nenue@108 258 end
Nenue@108 259 local cAlpha = self:GetAlpha()
Nenue@108 260 if cAlpha ~= self.toAlpha then
Nenue@108 261 if cAlpha > self.toAlpha then
Nenue@108 262 cAlpha = cAlpha - sinceLast*4
Nenue@108 263 if cAlpha <= self.toAlpha then
Nenue@108 264 cAlpha = self.toAlpha
Nenue@108 265 end
Nenue@108 266 else
Nenue@108 267 cAlpha = cAlpha + sinceLast*4
Nenue@108 268 if cAlpha >= self.toAlpha then
Nenue@108 269 cAlpha = self.toAlpha
Nenue@108 270 end
Nenue@108 271 end
Nenue@108 272 end
Nenue@108 273 self:SetAlpha(cAlpha)
Nenue@108 274 end
Nenue@49 275
Nenue@40 276 function db.print(...)
Nenue@0 277 for i = 1, select('#', ...) do
Nenue@40 278 tinsert(db.ReportChunks, tostring(select(i, ...)))
Nenue@0 279 end
Nenue@0 280 end
Nenue@0 281
Nenue@69 282 function db.log(msg)
Nenue@69 283 WorldPlanData.Debug = WorldPlanData.Debug or {}
Nenue@69 284 tinsert(WorldPlanData.Debug, msg)
Nenue@69 285 tinsert(DEBUG_HISTORY, msg)
Nenue@69 286 if WorldPlanDebug:IsShown() then
Nenue@69 287 WorldPlanDebug:Update()
Nenue@69 288 end
Nenue@69 289 end
Nenue@69 290
Nenue@69 291 WorldPlanDebugMixin = {
Nenue@69 292 OnLoad = function(self)
Nenue@69 293 self:SetFont("Interface\\Addons\\Devian\\font\\SourceCodePro-Regular.ttf", 13, 'NORMAL')
Nenue@69 294 self:SetJustifyH('LEFT')
Nenue@69 295 self:SetFading(false)
Nenue@69 296 self:SetMaxLines(2048)
Nenue@69 297 self.loadedMessages = 0
Nenue@69 298 end,
Nenue@69 299 OnShow = function(self)
Nenue@69 300 if self.loadedMessages < #DEBUG_HISTORY then
Nenue@69 301 self:Update()
Nenue@69 302 end
Nenue@69 303 end,
Nenue@69 304 Update = function(self)
Nenue@69 305 for i = self.loadedMessages, #DEBUG_HISTORY do
Nenue@69 306 self:AddMessage(DEBUG_HISTORY[i])
Nenue@69 307 self.loadedMessages = i
Nenue@69 308 end
Nenue@69 309 end ,
Nenue@69 310 OnMouseWheel = function(self, delta)
Nenue@69 311
Nenue@69 312 local up = delta > 0
Nenue@69 313 if IsControlKeyDown() then
Nenue@69 314 if up then self:ScrollToTop()
Nenue@69 315 else self:ScrollToBottom() end
Nenue@69 316 elseif IsShiftKeyDown() then
Nenue@69 317 if up then self:PageUp()
Nenue@69 318 else self:PageDown() end
Nenue@69 319 else
Nenue@69 320 if up then self:ScrollUp()
Nenue@69 321 else self:ScrollDown() end
Nenue@69 322 end
Nenue@69 323 end
Nenue@69 324 }
Nenue@69 325
Nenue@108 326
Nenue@67 327 function WorldPlanCore:OnConfigUpdate()
Nenue@67 328 for _, module in ipairs(db.OrderedModules) do
Nenue@67 329 if module.OnConfigUpdate then
Nenue@67 330 module:OnConfigUpdate()
Nenue@67 331 end
Nenue@67 332 end
Nenue@67 333 db.currentMapID = nil
Nenue@67 334 db.BountyUpdate = true
Nenue@67 335 self:SetCurrentMap('CONFIG_UPDATE')
Nenue@67 336 self:Refresh()
Nenue@67 337 end
Nenue@67 338
Nenue@40 339 function WorldPlanCore:print(...) db.print(...) end
Nenue@40 340
Nenue@40 341 function WorldPlanCore:AddHandler (frame)
Nenue@40 342 if not db.LoadedModules[frame] then
Nenue@40 343 print('|cFFFFFF00'..self:GetName()..':AddHandler()', frame:GetName(), self.initialized)
Nenue@40 344 db.LoadedModules[frame] = true
Nenue@40 345 tinsert(db.OrderedModules, frame)
Nenue@40 346
Nenue@40 347 if frame.defaults then
Nenue@40 348 db.DefaultConfig[frame:GetName()] = frame.defaults
Nenue@40 349 end
Nenue@108 350 frame.UpdateAlpha = Handler_UpdateFader
Nenue@40 351 frame.owningFrame = self
Nenue@40 352 else
Nenue@40 353
Nenue@40 354 print('|cFFFF4400'..self:GetName()..':AddHandler()', frame:GetName())
Nenue@30 355 end
Nenue@30 356 end
Nenue@30 357
Nenue@36 358 function WorldPlanCore:OnLoad ()
Nenue@29 359
Nenue@29 360 self.Types = setmetatable({}, {
Nenue@29 361 __newindex = function(t, k, v)
Nenue@29 362 if type(v) == 'table' then
Nenue@30 363 print('adding owner', k)
Nenue@30 364 v = setmetatable(v, {
Nenue@30 365 __newindex = function(t2,k2,v2)
Nenue@30 366 if type(v2) == 'table' then
Nenue@40 367 --print('adding type', k2)
Nenue@30 368 v2 = setmetatable(v2, {__index = function(t3,k3)
Nenue@30 369 --print('##deferring to default key', k3)
Nenue@40 370 return db.DefaultType[k3]
Nenue@30 371 end})
Nenue@30 372 end
Nenue@30 373 rawset(t2,k2,v2)
Nenue@29 374 end})
Nenue@29 375 end
Nenue@29 376 rawset(t,k,v)
Nenue@29 377 end
Nenue@29 378 })
Nenue@29 379
Nenue@30 380 self.Types[self] = {}
Nenue@29 381
Nenue@29 382 for index, color in pairs(ITEM_QUALITY_COLORS) do
Nenue@30 383 self:AddTypeInfo(self, index, { r = color.r, g = color.g, b = color.b, hex = color.hex, })
Nenue@29 384 end
Nenue@29 385
Nenue@0 386
Nenue@40 387 db.print('v'..WP_VERSION)
Nenue@40 388
Nenue@0 389
Nenue@0 390 self:RegisterEvent("QUESTLINE_UPDATE")
Nenue@0 391 self:RegisterEvent("QUEST_LOG_UPDATE")
Nenue@0 392 self:RegisterEvent("WORLD_MAP_UPDATE")
Nenue@40 393 self:RegisterEvent("SPELLS_CHANGED")
Nenue@40 394 self:RegisterEvent('PLAYER_ENTERING_WORLD')
Nenue@0 395 self:RegisterEvent("WORLD_QUEST_COMPLETED_BY_SPELL")
Nenue@0 396 self:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED")
Nenue@0 397 self:RegisterEvent("SKILL_LINES_CHANGED")
Nenue@0 398 self:RegisterEvent("ARTIFACT_XP_UPDATE")
Nenue@0 399 self:RegisterEvent("ADDON_LOADED")
Nenue@40 400 self:RegisterEvent("PLAYER_LOGIN")
Nenue@40 401 --self:SetParent(WorldMapFrame)
Nenue@0 402 end
Nenue@0 403
Nenue@36 404 function WorldPlanCore:OnShow()
Nenue@40 405 --print(self:GetName()..':OnShow()')
Nenue@40 406 --hooksecurefunc(self, 'SetScript', function(...) self:print('|cFFFFFF00'..self:GetName()..':SetScript()|r', ...) end)
Nenue@27 407 end
Nenue@27 408
Nenue@41 409 local BROKEN_ISLE_MAPS = {
Nenue@41 410 [1007] = true, -- Broken Isle
Nenue@41 411 [1014] = true, -- Dalaran
Nenue@41 412 [1021] = true, -- Broken Shoree
Nenue@41 413 [1024] = true, -- Highmountain
Nenue@43 414 [1015] = true, -- Azsuna
Nenue@41 415 [1017] = true, -- Azsuna
Nenue@41 416 [1018] = true, -- Val'Sharah
Nenue@41 417 [1033] = true, -- Suramar
Nenue@41 418 [1077] = true, -- Dreamgrove
Nenue@41 419 [1096] = true, -- Eye of Azshara
Nenue@41 420 [1080] = true, -- Thunder Totem
Nenue@41 421 [1072] = true, -- True Shot Lodge,
Nenue@40 422
Nenue@41 423 }
Nenue@41 424
Nenue@67 425 function WorldPlanCore:SetCurrentMap(event)
Nenue@68 426 local mapAreaID, isContinent = GetCurrentMapAreaID()
Nenue@56 427 if not mapAreaID then
Nenue@56 428 return
Nenue@56 429 end
Nenue@67 430 print('SetCurrentMap()', event, mapAreaID)
Nenue@41 431 local isBrokenIsle = BROKEN_ISLE_MAPS[mapAreaID]
Nenue@68 432
Nenue@68 433 local mapFileName, textureHeight, textureWidth, isMicroDungeon, microDungeonMapName = GetMapInfo()
Nenue@41 434
Nenue@67 435 local isMapOpen = WorldMapFrame:IsShown()
Nenue@93 436 local isNewMap = (mapAreaID ~= db.currentMapID) or (isMapOpen ~= db.isMapOpen) or (db.isMicroDungeon ~= isMicroDungeon) or (db.isContinentMap ~= isContinent)
Nenue@68 437
Nenue@68 438 db.isMicroDungeon = isMicroDungeon
Nenue@68 439 db.isMapOpen = isMapOpen
Nenue@41 440 db.currentMapID = mapAreaID
Nenue@54 441 db.isContinentMap = isContinent
Nenue@67 442 db.isBrokenIsle = isBrokenIsle
Nenue@40 443
Nenue@41 444 for _, module in ipairs(db.OrderedModules) do
Nenue@41 445 if module.OnMapInfo then
Nenue@75 446 if module.Debug then
Nenue@75 447 module:Debug(event)
Nenue@75 448 end
Nenue@41 449 print(' |cFF00FFFF'..module:GetName() .. ':OnMapInfo()|r')
Nenue@67 450 module:OnMapInfo(isBrokenIsle, isContinent, mapAreaID, isNewMap, isMapOpen)
Nenue@41 451 end
Nenue@41 452 end
Nenue@40 453 end
Nenue@40 454
Nenue@36 455 function WorldPlanCore:OnEvent (event, ...)
Nenue@40 456
Nenue@40 457 print('|cFF00FF88'..self:GetName().. ':OnEvent()|r', event, GetTime(), 'init:', self.initialized)
Nenue@0 458 if event == 'ADDON_LOADED' then
Nenue@0 459
Nenue@0 460 if IsLoggedIn() and not self.initialized then
Nenue@0 461 self:Setup()
Nenue@0 462 end
Nenue@27 463 else
Nenue@41 464 if (event == 'WORLD_MAP_UPDATE') or (event == 'PLAYER_ENTERING_WORLD') or (event == 'PLAYER_LOGIN') then
Nenue@40 465 print('|cFFFF4400currentMapID =', db.currentMapID, ...)
Nenue@93 466 if event == 'PLAYER_ENTERING_WORLD' then
Nenue@93 467 -- start from scratch
Nenue@93 468 db.isMicroDungeon = nil
Nenue@93 469 db.isMapOpen = nil
Nenue@93 470 db.currentMapID = nil
Nenue@93 471 db.isContinentMap = nil
Nenue@93 472 db.isBrokenIsle = nil
Nenue@93 473 end
Nenue@67 474
Nenue@67 475
Nenue@75 476 self:SetCurrentMap(event .. ' ' .. GetTime())
Nenue@0 477 end
Nenue@0 478 end
Nenue@0 479 end
Nenue@0 480
Nenue@33 481 function WorldPlanCore:OnNext(func)
Nenue@34 482
Nenue@34 483
Nenue@33 484 tinsert(self.TaskQueue, func)
Nenue@35 485 --self:print('|cFF00FF00adding scheduled task #', #self.TaskQueue)
Nenue@33 486 end
Nenue@33 487
Nenue@33 488 function WorldPlanCore:OnUpdate()
Nenue@33 489 if #self.TaskQueue >= 1 then
Nenue@34 490 local func = tremove(self.TaskQueue, 1)
Nenue@34 491 --self:print('|cFF00FF00running scheduled task #', #self.TaskQueue)
Nenue@33 492 func()
Nenue@33 493 end
Nenue@33 494
Nenue@33 495 if self.isStale then
Nenue@40 496 -- these need to happen in load order
Nenue@40 497 for i, module in ipairs(db.OrderedModules) do
Nenue@40 498 if module:IsVisible() and module.isStale then
Nenue@33 499 print('|cFF00FF00internal '..module:GetName()..':Refresh()|r')
Nenue@33 500 module:Refresh()
Nenue@33 501 end
Nenue@33 502 end
Nenue@40 503 self.isStale = nil
Nenue@33 504 end
Nenue@40 505
Nenue@40 506 if #db.ReportChunks >= 1 then
Nenue@40 507
Nenue@40 508 DEFAULT_CHAT_FRAME:AddMessage("|cFF0088FF"..addonFileName.."|r: " .. table.concat(db.ReportChunks, ', '))
Nenue@40 509 wipe(db.ReportChunks)
Nenue@40 510 end
Nenue@40 511
Nick@63 512 if self.dataFlush then
Nick@63 513 self:FireCallbacks()
Nick@63 514 end
Nick@63 515
Nenue@33 516 end
Nenue@0 517
Nenue@36 518 function WorldPlanCore:Setup ()
Nenue@40 519 print('|cFFFFFF00'..self:GetName()..':Setup()|r')
Nenue@40 520
Nenue@0 521 if not WorldPlanData then
Nenue@40 522 WorldPlanData = {key = 0}
Nenue@0 523 end
Nenue@69 524
Nenue@69 525 -- debug info
Nenue@0 526 WorldPlanData.key = (WorldPlanData.key or 0) + 1
Nenue@69 527 WorldPlanData.Debug = WorldPlanData.Debug or {}
Nenue@100 528 local guid = UnitGUID('player')
Nenue@100 529 WorldPlanData.IgnoreTimers = WorldPlanData.IgnoreTimers or {}
Nenue@100 530 WorldPlanData.IgnoreTimers[guid] = WorldPlanData.IgnoreTimers[guid] or {}
Nenue@100 531
Nenue@69 532 for _, msg in ipairs(WorldPlanData.Debug) do
Nenue@69 533 tinsert(DEBUG_HISTORY, msg)
Nenue@69 534 end
Nenue@69 535 tinsert(DEBUG_HISTORY, '--SESSION BREAK--')
Nenue@69 536 wipe(WorldPlanData.Debug)
Nenue@69 537
Nenue@100 538 db.IgnoreTimers = WorldPlanData.IgnoreTimers
Nenue@40 539 db.Config = WorldPlanData
Nenue@40 540 for k,v in pairs(db.DefaultConfig) do
Nenue@18 541 --[===[@non-debug@
Nenue@40 542 if not db.Config[k] then
Nenue@40 543 db.Config[k] = v
Nenue@18 544 end
Nenue@18 545
Nenue@18 546 --@end-non-debug@]===]
Nenue@18 547 --@debug@
Nenue@40 548 db.Config[k] = v
Nenue@18 549 --@end-debug@
Nenue@9 550 end
Nenue@9 551
Nenue@0 552
Nenue@40 553 db.currentMapID = GetCurrentMapAreaID()
Nenue@40 554
Nenue@40 555 for i, module in ipairs(db.OrderedModules) do
Nenue@40 556 db.Config[module:GetName()] = db.Config[module:GetName()] or {}
Nenue@0 557 if module.Setup then module:Setup() end
Nenue@0 558 if not module.RegisterEvent then
Nenue@0 559 module.RegisterEvent = self.RegisterEvent
Nenue@0 560 end
Nenue@49 561 if module.OnConfigUpdate then
Nenue@49 562 module:OnConfigUpdate()
Nenue@49 563 end
Nenue@0 564 end
Nenue@40 565
Nenue@40 566
Nenue@0 567 self.initialized = true
Nenue@0 568
Nenue@49 569 hooksecurefunc("UIDropDownMenu_Initialize", DropDown_Initialize)
Nenue@33 570
Nenue@33 571 hooksecurefunc("WorldMapTrackingOptionsDropDown_OnClick", function(button)
Nenue@33 572 print("|cFF0088FFWorldMapTrackingOptionsDropDown_OnClick|r")
Nenue@33 573 local value = button.value
Nenue@33 574 if (value == "worldQuestFilterOrderResources" or value == "worldQuestFilterArtifactPower" or
Nenue@33 575 value == "worldQuestFilterProfessionMaterials" or value == "worldQuestFilterGold" or
Nenue@33 576 value == "worldQuestFilterEquipment") then
Nenue@33 577 self:Refresh(true)
Nenue@33 578 end
Nenue@33 579 end)
Nenue@40 580
Nenue@40 581
Nenue@40 582 hooksecurefunc("WorldMapFrame_Update", function()
Nenue@40 583 print('|cFFFF4400WorldMapFrame_Update|r')
Nenue@41 584 for _,module in ipairs(db.OrderedModules) do
Nenue@41 585 if module.OnWorldMapFrameUpdate then
Nenue@41 586 print(' |cFFFF4400'..module:GetName()..'|r')
Nenue@41 587 module:OnWorldMapFrameUpdate()
Nenue@41 588 end
Nenue@41 589 end
Nenue@40 590 end)
Nenue@40 591
Nenue@40 592 SLASH_WORLDPLAN1 = "/worldplan"
Nenue@40 593 SLASH_WORLDPLAN2 = "/wp"
Nenue@40 594
Nenue@40 595
Nenue@40 596
Nenue@108 597
Nenue@40 598 SlashCmdList.WORLDPLAN = function(args)
Nenue@40 599 local arg1, arg2, extraArgs = args:match("(%S+)%s*(%S*)%s*(.*)")
Nenue@40 600
Nenue@108 601 if db.CLTriggers[arg1] then
Nenue@108 602 db.CLTriggers[arg1](arg2, extraArgs)
Nenue@40 603 else
Nenue@40 604 self:print('Refreshing data.')
Nenue@40 605 self:Refresh(true)
Nenue@40 606 end
Nenue@40 607
Nenue@40 608 end
Nenue@0 609 end
Nenue@0 610
Nenue@40 611 -- registers a template table
Nenue@36 612 function WorldPlanCore:AddTypeInfo(owner, id, info)
Nenue@30 613 self.Types[owner] = self.Types[owner] or {}
Nenue@30 614 self.Types[owner][id] = info
Nenue@30 615 print('Type('..owner:GetName()..')('..id..') = '.. tostring(info))
Nenue@30 616 end
Nenue@30 617
Nenue@40 618 -- recall a template table, with situational details filled in
Nenue@36 619 function WorldPlanCore:GetTypeInfo(owner, typeID)
Nenue@29 620 local info, extraInfo
Nenue@30 621 if not owner then
Nenue@30 622 --print('## deferring to default type list')
Nenue@30 623 else
Nenue@30 624 --print('## pulling for', owner:GetName(), 'id =', typeID)
Nenue@30 625 end
Nenue@30 626
Nenue@30 627 owner = owner or self
Nenue@30 628 if (not typeID) or (not self.Types[owner][typeID]) then
Nenue@30 629 --print('## sending list default')
Nenue@40 630 info = db.DefaultType
Nenue@29 631 else
Nenue@30 632 --print('## sent list definition', typeID)
Nenue@30 633 info = self.Types[owner][typeID]
Nenue@29 634 end
Nenue@29 635
Nenue@40 636 local subType = 'continent'
Nenue@40 637 if (
Nenue@40 638 FlightMapFrame
Nenue@40 639 and FlightMapFrame:IsVisible()
Nenue@40 640 and FlightMapFrame:IsZoomedIn()
Nenue@40 641 ) or (
Nenue@40 642 not db.isContinentMap
Nenue@40 643 ) or (
Nenue@40 644 db.useContinentType == false
Nenue@40 645 ) then
Nenue@40 646 subType = 'zone'
Nenue@40 647 end
Nenue@29 648
Nenue@40 649 return info, info[subType] or db.DefaultType[subType]
Nenue@29 650 end
Nenue@29 651
Nenue@29 652
Nenue@36 653 function WorldPlanCore:Refresh (forced)
Nenue@30 654 print('|cFFFFFF00'..self:GetName()..':Refresh()|r forced:', forced, 'init:', self.initialized)
Nenue@9 655 if not self.initialized then
Nenue@9 656 return
Nenue@9 657 end
Nenue@9 658
Nenue@40 659 for i, module in ipairs(db.OrderedModules) do
Nenue@0 660 if module.Refresh then
Nenue@33 661 print('|cFF00FF00external '..module:GetName()..':Refresh()|r')
Nenue@75 662 module:Refresh('WORLDPLAN_REFRESH')
Nenue@0 663 end
Nenue@0 664 end
Nenue@40 665
Nenue@40 666 self.isStale = nil
Nenue@0 667 end
Nenue@0 668
Nenue@0 669
Nenue@30 670 --------------------------------------------------------------------------------------------------------------------
Nenue@35 671 -------------------
Nick@63 672 function WorldPlanCore:GetQuestPins(zoneID)
Nick@63 673 return db.UsedPins
Nick@63 674 end
Nick@63 675 function WorldPlanCore:RegisterDataCallback(func)
Nick@63 676 self.callbacks = self.callbacks or {}
Nick@63 677 self.callbacks[func] = func
Nick@63 678 end
Nick@63 679 function WorldPlanCore:FireCallbacks()
Nick@64 680 self.callbacks = self.callbacks or {}
Nick@63 681 for func in pairs(self.callbacks) do
Nick@63 682 func()
Nick@63 683 end
Nick@63 684 self.dataFlush = nil
Nick@63 685 end
Nenue@0 686
Nenue@102 687 function WorldPlanCore:SetHook(base, arg1, arg2)
Nenue@102 688 if type(base) == 'table' then
Nenue@102 689 end
Nenue@102 690
Nenue@102 691 end
Nenue@0 692
Nenue@0 693
Nenue@0 694
Nenue@0 695
Nenue@35 696 --%end-debug%