annotate WorldPlan.lua @ 100:fbd4ead2a19f v1.4.11

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