annotate WorldPlan.lua @ 111:e8b6c5433128 v7.3.0-1

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