annotate WorldPlan.lua @ 87:7185905e4894

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