annotate WorldPlan.lua @ 67:96183f981acb

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