annotate WorldPlan.lua @ 121:1fcc4fe645dc tip

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