annotate WorldPlan.lua @ 108:b67ba1078824

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