annotate WorldPlan.lua @ 96:8591401ec278

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