annotate WorldPlan.lua @ 70:bb2baedae81f

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