annotate WorldPlan.lua @ 64:876c3f0bfd0e

- script upvalues cleanup - add quest active status to pin metadata
author Nick@Zahhak
date Thu, 23 Mar 2017 05:26:51 -0400
parents 8e130c92698f
children e43e10c5576b
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
Nick@64 6 local WP_VERSION = "1.2"
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@40 32 db.ReportChunks = {}
Nenue@0 33
Nenue@0 34 -- default color templates
Nenue@40 35 db.DefaultType = {
Nenue@0 36 a = 1,
Nenue@0 37 r = 1, g = 1, b = 1,
Nenue@0 38 x = 0, y = 0,
Nenue@0 39 desaturated = true,
Nenue@33 40 pinMask = "Interface\\Minimap\\UI-Minimap-Background",
Nenue@33 41 rewardMask = "Interface\\Minimap\\UI-Minimap-Background",
Nenue@33 42 texture = "Interface\\BUTTONS\\YELLOWORANGE64",
Nenue@0 43 continent = {
Nenue@40 44 iconWidth = 14,
Nenue@40 45 borderWidth = 2,
Nenue@36 46 highlightWidth = 1,
Nenue@40 47 TagSize = 8,
Nenue@36 48 maxAlertLevel = 0,
Nenue@27 49 showNumber = true,
Nenue@30 50 numberFontObject = 'WorldPlanFont'
Nenue@0 51 },
Nenue@0 52 zone = {
Nick@62 53 iconWidth = 18,
Nenue@47 54 borderWidth = 2,
Nenue@36 55 highlightWidth = 2,
Nenue@0 56 TagSize = 12,
Nenue@36 57 maxAlertLevel = 3,
Nenue@27 58 showNumber = true,
Nenue@30 59 numberFontObject = 'WorldPlanNumberFontThin'
Nenue@0 60 },
Nenue@0 61 minimized = {
Nenue@40 62 r = 0, g = 0, b = 0, a = 0.1,
Nenue@40 63 iconWidth = 8,
Nenue@49 64 borderWidth = 0,
Nenue@40 65 alpha = 0.5,
Nenue@36 66 highlightWidth = 0,
Nenue@40 67 maxAlertLevel = 0,
Nenue@0 68 NoIcon = true,
Nenue@40 69
Nenue@40 70 TagSize = 8,
Nenue@0 71 TimeleftStage = 1,
Nenue@27 72 showNumber = false,
Nenue@40 73 alpha = 0.1,
Nenue@0 74 }
Nenue@0 75 }
Nenue@29 76
Nenue@54 77
Nenue@40 78 db.DefaultConfig = {
Nenue@27 79 ShowAllProfessionQuests = false,
Nenue@9 80 DisplayContinentSummary = true,
Nenue@9 81 DisplayContinentPins = true,
Nenue@9 82 NotifyWhenNewQuests = true,
Nenue@9 83 EnablePins = true,
Nenue@34 84 FadeWhileGrouped = false,
Nenue@40 85 FlightMapAlphaLimits = {1, 1, 1},
Nenue@40 86 FlightMapScalingLimits = {1, 3, 1.5},
Nenue@54 87 --UntrackedColor = {},
Nenue@54 88 --TrackedColor = {},
Nenue@54 89 --CriteriaColor = {},
Nenue@54 90 --RewardColorGold = {},
Nenue@54 91 --RewardColorReagent = {},
Nenue@54 92 --RewardColorArtifactPower = {},
Nenue@54 93 --RewardColorCurrency = {},
Nenue@9 94 }
Nenue@9 95
Nenue@0 96
Nenue@0 97
Nenue@0 98 -- tracking menu toggler
Nenue@0 99 local DropDown_OnClick = function(self)
Nenue@0 100 local key = self.value
Nenue@0 101 if key then
Nenue@0 102 if WorldPlanData[key] then
Nenue@0 103 WorldPlanData[key] = nil
Nenue@0 104 else
Nenue@0 105 WorldPlanData[key] = true
Nenue@0 106 end
Nenue@0 107 end
Nenue@49 108 for _, module in ipairs(db.OrderedModules) do
Nenue@49 109 if module.OnConfigUpdate then
Nenue@49 110 module:OnConfigUpdate()
Nenue@49 111 end
Nenue@49 112 end
Nenue@33 113 _G.WorldPlan:Refresh()
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@40 198 function WorldPlanCore:print(...) db.print(...) end
Nenue@40 199
Nenue@40 200 function WorldPlanCore:AddHandler (frame)
Nenue@40 201 if not db.LoadedModules[frame] then
Nenue@40 202 print('|cFFFFFF00'..self:GetName()..':AddHandler()', frame:GetName(), self.initialized)
Nenue@40 203 db.LoadedModules[frame] = true
Nenue@40 204 tinsert(db.OrderedModules, frame)
Nenue@40 205
Nenue@40 206 if frame.defaults then
Nenue@40 207 db.DefaultConfig[frame:GetName()] = frame.defaults
Nenue@40 208 end
Nenue@40 209
Nenue@40 210 frame.GetTypeInfo = function(frame, typeID)
Nenue@40 211 return self:GetTypeInfo(frame, typeID)
Nenue@40 212 end
Nenue@40 213
Nenue@40 214 frame.owningFrame = self
Nenue@40 215 else
Nenue@40 216
Nenue@40 217 print('|cFFFF4400'..self:GetName()..':AddHandler()', frame:GetName())
Nenue@30 218 end
Nenue@30 219 end
Nenue@30 220
Nenue@36 221 function WorldPlanCore:OnLoad ()
Nenue@29 222
Nenue@29 223 self.Types = setmetatable({}, {
Nenue@29 224 __newindex = function(t, k, v)
Nenue@29 225 if type(v) == 'table' then
Nenue@30 226 print('adding owner', k)
Nenue@30 227 v = setmetatable(v, {
Nenue@30 228 __newindex = function(t2,k2,v2)
Nenue@30 229 if type(v2) == 'table' then
Nenue@40 230 --print('adding type', k2)
Nenue@30 231 v2 = setmetatable(v2, {__index = function(t3,k3)
Nenue@30 232 --print('##deferring to default key', k3)
Nenue@40 233 return db.DefaultType[k3]
Nenue@30 234 end})
Nenue@30 235 end
Nenue@30 236 rawset(t2,k2,v2)
Nenue@29 237 end})
Nenue@29 238 end
Nenue@29 239 rawset(t,k,v)
Nenue@29 240 end
Nenue@29 241 })
Nenue@29 242
Nenue@30 243 self.Types[self] = {}
Nenue@29 244
Nenue@29 245 for index, color in pairs(ITEM_QUALITY_COLORS) do
Nenue@30 246 self:AddTypeInfo(self, index, { r = color.r, g = color.g, b = color.b, hex = color.hex, })
Nenue@29 247 end
Nenue@29 248
Nenue@0 249
Nenue@40 250 db.print('v'..WP_VERSION)
Nenue@40 251
Nenue@0 252
Nenue@0 253 self:RegisterEvent("QUESTLINE_UPDATE")
Nenue@0 254 self:RegisterEvent("QUEST_LOG_UPDATE")
Nenue@0 255 self:RegisterEvent("WORLD_MAP_UPDATE")
Nenue@40 256 self:RegisterEvent("SPELLS_CHANGED")
Nenue@40 257 self:RegisterEvent('PLAYER_ENTERING_WORLD')
Nenue@0 258 self:RegisterEvent("WORLD_QUEST_COMPLETED_BY_SPELL")
Nenue@0 259 self:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED")
Nenue@0 260 self:RegisterEvent("SKILL_LINES_CHANGED")
Nenue@0 261 self:RegisterEvent("ARTIFACT_XP_UPDATE")
Nenue@0 262 self:RegisterEvent("ADDON_LOADED")
Nenue@40 263 self:RegisterEvent("PLAYER_LOGIN")
Nenue@40 264 --self:SetParent(WorldMapFrame)
Nenue@0 265 end
Nenue@0 266
Nenue@36 267 function WorldPlanCore:OnShow()
Nenue@40 268 --print(self:GetName()..':OnShow()')
Nenue@40 269 --hooksecurefunc(self, 'SetScript', function(...) self:print('|cFFFFFF00'..self:GetName()..':SetScript()|r', ...) end)
Nenue@27 270 end
Nenue@27 271
Nenue@41 272 local BROKEN_ISLE_MAPS = {
Nenue@41 273 [1007] = true, -- Broken Isle
Nenue@41 274 [1014] = true, -- Dalaran
Nenue@41 275 [1021] = true, -- Broken Shoree
Nenue@41 276 [1024] = true, -- Highmountain
Nenue@43 277 [1015] = true, -- Azsuna
Nenue@41 278 [1017] = true, -- Azsuna
Nenue@41 279 [1018] = true, -- Val'Sharah
Nenue@41 280 [1033] = true, -- Suramar
Nenue@41 281 [1077] = true, -- Dreamgrove
Nenue@41 282 [1096] = true, -- Eye of Azshara
Nenue@41 283 [1080] = true, -- Thunder Totem
Nenue@41 284 [1072] = true, -- True Shot Lodge,
Nenue@40 285
Nenue@41 286 }
Nenue@41 287
Nenue@41 288 function WorldPlanCore:SetCurrentMap()
Nenue@41 289 local mapAreaID = GetCurrentMapAreaID()
Nenue@56 290 if not mapAreaID then
Nenue@56 291 return
Nenue@56 292 end
Nenue@56 293 print(mapAreaID)
Nenue@41 294 local isBrokenIsle = BROKEN_ISLE_MAPS[mapAreaID]
Nenue@56 295 local isContinent = (mapAreaID == BROKEN_ISLES_ID)
Nenue@41 296
Nenue@41 297 db.currentMapID = mapAreaID
Nenue@54 298 db.isContinentMap = isContinent
Nenue@40 299 db.useContinentType = (WorldMapDetailFrame:GetScale() < 1)
Nenue@40 300
Nenue@41 301 for _, module in ipairs(db.OrderedModules) do
Nenue@41 302 if module.OnMapInfo then
Nenue@41 303 print(' |cFF00FFFF'..module:GetName() .. ':OnMapInfo()|r')
Nenue@54 304 module:OnMapInfo(isBrokenIsle, isContinent, mapAreaID)
Nenue@41 305 end
Nenue@41 306 end
Nenue@40 307 end
Nenue@40 308
Nenue@40 309
Nenue@36 310 function WorldPlanCore:OnEvent (event, ...)
Nenue@40 311
Nenue@40 312 print('|cFF00FF88'..self:GetName().. ':OnEvent()|r', event, GetTime(), 'init:', self.initialized)
Nenue@0 313 if event == 'ADDON_LOADED' then
Nenue@0 314
Nenue@0 315 if IsLoggedIn() and not self.initialized then
Nenue@0 316 self:Setup()
Nenue@0 317 end
Nenue@27 318 else
Nenue@41 319 if (event == 'WORLD_MAP_UPDATE') or (event == 'PLAYER_ENTERING_WORLD') or (event == 'PLAYER_LOGIN') then
Nenue@40 320 print('|cFFFF4400currentMapID =', db.currentMapID, ...)
Nenue@41 321 self:SetCurrentMap()
Nenue@0 322 end
Nenue@0 323 end
Nenue@0 324 end
Nenue@0 325
Nenue@33 326 function WorldPlanCore:OnNext(func)
Nenue@34 327
Nenue@34 328
Nenue@33 329 tinsert(self.TaskQueue, func)
Nenue@35 330 --self:print('|cFF00FF00adding scheduled task #', #self.TaskQueue)
Nenue@33 331 end
Nenue@33 332
Nenue@33 333 function WorldPlanCore:OnUpdate()
Nenue@33 334 if #self.TaskQueue >= 1 then
Nenue@34 335 local func = tremove(self.TaskQueue, 1)
Nenue@34 336 --self:print('|cFF00FF00running scheduled task #', #self.TaskQueue)
Nenue@33 337 func()
Nenue@33 338 end
Nenue@33 339
Nenue@33 340 if self.isStale then
Nenue@40 341 -- these need to happen in load order
Nenue@40 342 for i, module in ipairs(db.OrderedModules) do
Nenue@40 343 if module:IsVisible() and module.isStale then
Nenue@33 344 print('|cFF00FF00internal '..module:GetName()..':Refresh()|r')
Nenue@33 345 module:Refresh()
Nenue@33 346 end
Nenue@33 347 end
Nenue@40 348 self.isStale = nil
Nenue@33 349 end
Nenue@40 350
Nenue@40 351 if #db.ReportChunks >= 1 then
Nenue@40 352
Nenue@40 353 DEFAULT_CHAT_FRAME:AddMessage("|cFF0088FF"..addonFileName.."|r: " .. table.concat(db.ReportChunks, ', '))
Nenue@40 354 wipe(db.ReportChunks)
Nenue@40 355 end
Nenue@40 356
Nick@63 357 if self.dataFlush then
Nick@63 358 self:FireCallbacks()
Nick@63 359 end
Nick@63 360
Nenue@33 361 end
Nenue@0 362
Nenue@36 363 function WorldPlanCore:Setup ()
Nenue@40 364 print('|cFFFFFF00'..self:GetName()..':Setup()|r')
Nenue@40 365
Nenue@0 366 if not WorldPlanData then
Nenue@40 367 WorldPlanData = {key = 0}
Nenue@0 368 end
Nenue@0 369 WorldPlanData.key = (WorldPlanData.key or 0) + 1
Nenue@40 370 db.Config = WorldPlanData
Nenue@40 371 for k,v in pairs(db.DefaultConfig) do
Nenue@18 372 --[===[@non-debug@
Nenue@40 373 if not db.Config[k] then
Nenue@40 374 db.Config[k] = v
Nenue@18 375 end
Nenue@18 376
Nenue@18 377 --@end-non-debug@]===]
Nenue@18 378 --@debug@
Nenue@40 379 db.Config[k] = v
Nenue@18 380 --@end-debug@
Nenue@9 381 end
Nenue@9 382
Nenue@0 383
Nenue@40 384 db.currentMapID = GetCurrentMapAreaID()
Nenue@40 385
Nenue@40 386 for i, module in ipairs(db.OrderedModules) do
Nenue@40 387 db.Config[module:GetName()] = db.Config[module:GetName()] or {}
Nenue@0 388 if module.Setup then module:Setup() end
Nenue@0 389 if not module.RegisterEvent then
Nenue@0 390 module.RegisterEvent = self.RegisterEvent
Nenue@0 391 end
Nenue@49 392 if module.OnConfigUpdate then
Nenue@49 393 module:OnConfigUpdate()
Nenue@49 394 end
Nenue@0 395 end
Nenue@40 396
Nenue@40 397
Nenue@0 398 self.initialized = true
Nenue@0 399
Nenue@49 400 hooksecurefunc("UIDropDownMenu_Initialize", DropDown_Initialize)
Nenue@33 401
Nenue@33 402 hooksecurefunc("WorldMapTrackingOptionsDropDown_OnClick", function(button)
Nenue@33 403 print("|cFF0088FFWorldMapTrackingOptionsDropDown_OnClick|r")
Nenue@33 404 local value = button.value
Nenue@33 405 if (value == "worldQuestFilterOrderResources" or value == "worldQuestFilterArtifactPower" or
Nenue@33 406 value == "worldQuestFilterProfessionMaterials" or value == "worldQuestFilterGold" or
Nenue@33 407 value == "worldQuestFilterEquipment") then
Nenue@33 408 self:Refresh(true)
Nenue@33 409 end
Nenue@33 410 end)
Nenue@40 411
Nenue@40 412
Nenue@40 413 hooksecurefunc("WorldMapFrame_Update", function()
Nenue@40 414 print('|cFFFF4400WorldMapFrame_Update|r')
Nenue@41 415 for _,module in ipairs(db.OrderedModules) do
Nenue@41 416 if module.OnWorldMapFrameUpdate then
Nenue@41 417 print(' |cFFFF4400'..module:GetName()..'|r')
Nenue@41 418 module:OnWorldMapFrameUpdate()
Nenue@41 419 end
Nenue@41 420 end
Nenue@40 421 end)
Nenue@40 422
Nenue@40 423 SLASH_WORLDPLAN1 = "/worldplan"
Nenue@40 424 SLASH_WORLDPLAN2 = "/wp"
Nenue@40 425
Nenue@40 426
Nenue@40 427
Nenue@40 428 SlashCmdList.WORLDPLAN = function(args)
Nenue@40 429 local arg1, arg2, extraArgs = args:match("(%S+)%s*(%S*)%s*(.*)")
Nenue@40 430
Nenue@40 431 if arg1 == 'wq' then
Nenue@40 432 if arg2 and WorldPlanQuests[arg2] then
Nenue@40 433 self:print('WorldPlanQuests:'..arg2..'()')
Nenue@40 434 WorldPlanQuests[arg2](WorldPlanQuests)
Nenue@40 435 elseif arg2 == 'flightscale' and extraArgs then
Nenue@40 436 local val1, val2, val3 = extraArgs:match("(%S+)%s*(%S*)%s*(%S*)")
Nenue@40 437 if tonumber(val1) and tonumber(val2) and tonumber(val3) then
Nenue@40 438 db.Config.FlightMapScalingLimits = {tonumber(val1), tonumber(val2), tonumber(val3)}
Nenue@40 439 self:print('FlightMapFrame scaling limits updated:', unpack(db.Config.FlightMapScalingLimits))
Nenue@40 440 else
Nenue@40 441 self:print('FlightMapFrame scaling limits:', unpack(db.Config.FlightMapScalingLimits))
Nenue@40 442 end
Nenue@40 443 elseif arg2 == 'flightalpha' and extraArgs then
Nenue@40 444 local val1, val2, val3 = extraArgs:match("(%S+)%s*(%S*)%s*(%S*)")
Nenue@40 445 if tonumber(val1) and tonumber(val2) and tonumber(val3) then
Nenue@40 446 db.Config.FlightMapAlphaLimits = {tonumber(val1), tonumber(val2), tonumber(val3)}
Nenue@40 447 self:print('FlightMapFrame alpha limits updated:', unpack(db.Config.FlightMapAlphaLimits))
Nenue@40 448 else
Nenue@40 449 self:print('FlightMapFrame alpha limits:', unpack(db.Config.FlightMapAlphaLimits))
Nenue@40 450 end
Nenue@40 451 else
Nenue@40 452
Nenue@40 453 self:print('WorldPlanQuests:Refresh(true)')
Nenue@40 454 WorldPlanQuests:Refresh(true)
Nenue@40 455 end
Nenue@40 456 elseif arg1 == 'filter' then
Nenue@40 457 if arg2 and WorldPlanSummary[arg2] then
Nenue@40 458 self:print('WorldPlanSummary:'..arg2..'()')
Nenue@40 459 WorldPlanSummary[arg2](WorldPlanSummary)
Nenue@40 460 else
Nenue@40 461 self:print('WorldPlanSummary:Refresh(true)')
Nenue@40 462 WorldPlanSummary:Refresh(true)
Nenue@40 463 end
Nenue@40 464 else
Nenue@40 465 self:print('Refreshing data.')
Nenue@40 466 self:Refresh(true)
Nenue@40 467 end
Nenue@40 468
Nenue@40 469 end
Nenue@0 470 end
Nenue@0 471
Nenue@40 472 -- registers a template table
Nenue@36 473 function WorldPlanCore:AddTypeInfo(owner, id, info)
Nenue@30 474 self.Types[owner] = self.Types[owner] or {}
Nenue@30 475 self.Types[owner][id] = info
Nenue@30 476 print('Type('..owner:GetName()..')('..id..') = '.. tostring(info))
Nenue@30 477 end
Nenue@30 478
Nenue@40 479 -- recall a template table, with situational details filled in
Nenue@36 480 function WorldPlanCore:GetTypeInfo(owner, typeID)
Nenue@29 481 local info, extraInfo
Nenue@30 482 if not owner then
Nenue@30 483 --print('## deferring to default type list')
Nenue@30 484 else
Nenue@30 485 --print('## pulling for', owner:GetName(), 'id =', typeID)
Nenue@30 486 end
Nenue@30 487
Nenue@30 488 owner = owner or self
Nenue@30 489 if (not typeID) or (not self.Types[owner][typeID]) then
Nenue@30 490 --print('## sending list default')
Nenue@40 491 info = db.DefaultType
Nenue@29 492 else
Nenue@30 493 --print('## sent list definition', typeID)
Nenue@30 494 info = self.Types[owner][typeID]
Nenue@29 495 end
Nenue@29 496
Nenue@40 497 local subType = 'continent'
Nenue@40 498 if (
Nenue@40 499 FlightMapFrame
Nenue@40 500 and FlightMapFrame:IsVisible()
Nenue@40 501 and FlightMapFrame:IsZoomedIn()
Nenue@40 502 ) or (
Nenue@40 503 not db.isContinentMap
Nenue@40 504 ) or (
Nenue@40 505 db.useContinentType == false
Nenue@40 506 ) then
Nenue@40 507 subType = 'zone'
Nenue@40 508 end
Nenue@29 509
Nenue@40 510 return info, info[subType] or db.DefaultType[subType]
Nenue@29 511 end
Nenue@29 512
Nenue@29 513 do
Nenue@29 514 local timeStates = {
Nenue@29 515 {maxSeconds = 60,
Nenue@29 516 r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end,
Nenue@29 517 },
Nenue@29 518 {maxSeconds = 240,
Nenue@29 519 r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end,
Nenue@29 520 },
Nenue@29 521 {maxSeconds = 1440,
Nenue@29 522 r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end,
Nenue@29 523 },
Nenue@29 524 {maxSeconds = 10081,
Nenue@29 525 r=0, g=1, b=0,
Nenue@29 526 }, -- 7 days + 1 minute
Nenue@29 527 }
Nenue@29 528 -- Generates a timeleft string
Nenue@36 529 function WorldPlanCore:GetTimeInfo(timeLeft, limit)
Nenue@29 530 for index = 1, limit do
Nenue@29 531 local state = timeStates[index]
Nenue@29 532 if timeLeft <= state.maxSeconds then
Nenue@29 533 local text
Nenue@29 534 if state.format then
Nenue@29 535 text = state.format(timeLeft)
Nenue@29 536 end
Nenue@29 537 return text, index
Nenue@29 538 end
Nenue@29 539 end
Nenue@29 540 return nil, nil
Nenue@29 541 end
Nenue@29 542 end
Nenue@29 543
Nenue@36 544 function WorldPlanCore:Refresh (forced)
Nenue@30 545 print('|cFFFFFF00'..self:GetName()..':Refresh()|r forced:', forced, 'init:', self.initialized)
Nenue@9 546 if not self.initialized then
Nenue@9 547 return
Nenue@9 548 end
Nenue@9 549
Nenue@40 550 for i, module in ipairs(db.OrderedModules) do
Nenue@0 551 if module.Refresh then
Nenue@33 552 print('|cFF00FF00external '..module:GetName()..':Refresh()|r')
Nenue@33 553 module:Refresh(forced)
Nenue@0 554 end
Nenue@0 555 end
Nenue@40 556
Nenue@40 557 self.isStale = nil
Nenue@0 558 end
Nenue@0 559
Nenue@0 560
Nenue@30 561 --------------------------------------------------------------------------------------------------------------------
Nenue@35 562 -------------------
Nick@63 563 function WorldPlanCore:GetQuestPins(zoneID)
Nick@63 564 return db.UsedPins
Nick@63 565 end
Nick@63 566 function WorldPlanCore:RegisterDataCallback(func)
Nick@63 567 self.callbacks = self.callbacks or {}
Nick@63 568 self.callbacks[func] = func
Nick@63 569 end
Nick@63 570 function WorldPlanCore:FireCallbacks()
Nick@64 571 self.callbacks = self.callbacks or {}
Nick@63 572 for func in pairs(self.callbacks) do
Nick@63 573 func()
Nick@63 574 end
Nick@63 575 self.dataFlush = nil
Nick@63 576 end
Nenue@0 577
Nenue@0 578
Nenue@0 579
Nenue@0 580
Nenue@0 581
Nenue@35 582 --%end-debug%