annotate WorldPlan.lua @ 49:dbd81d49af02

- Solve more frame data flagging issues - Unify method for resolving filter and visibility states - Flight Map modifications respect filter settings - Solve initial draw issues with tag icon, filter state handling - Solve issues with text layer synchronization during map changes
author Nenue
date Thu, 29 Dec 2016 13:31:20 -0500
parents c0b88bd1e40b
children b289eb3e6a32
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@40 6 local WP_VERSION = "1.0"
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 = {
Nenue@36 53 iconWidth = 22,
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@40 77 db.DefaultConfig = {
Nenue@27 78 ShowAllProfessionQuests = false,
Nenue@9 79 DisplayContinentSummary = true,
Nenue@9 80 DisplayContinentPins = true,
Nenue@9 81 NotifyWhenNewQuests = true,
Nenue@9 82 EnablePins = true,
Nenue@34 83 FadeWhileGrouped = false,
Nenue@40 84 FlightMapAlphaLimits = {1, 1, 1},
Nenue@40 85 FlightMapScalingLimits = {1, 3, 1.5},
Nenue@9 86 }
Nenue@9 87
Nenue@0 88
Nenue@0 89
Nenue@0 90 -- tracking menu toggler
Nenue@0 91 local DropDown_OnClick = function(self)
Nenue@0 92 local key = self.value
Nenue@0 93 if key then
Nenue@0 94 if WorldPlanData[key] then
Nenue@0 95 WorldPlanData[key] = nil
Nenue@0 96 else
Nenue@0 97 WorldPlanData[key] = true
Nenue@0 98 end
Nenue@0 99 end
Nenue@49 100 for _, module in ipairs(db.OrderedModules) do
Nenue@49 101 if module.OnConfigUpdate then
Nenue@49 102 module:OnConfigUpdate()
Nenue@49 103 end
Nenue@49 104 end
Nenue@33 105 _G.WorldPlan:Refresh()
Nenue@0 106 end
Nenue@0 107
Nenue@49 108 -- insert visual options into the tracking button menu
Nenue@49 109 local DropDown_Initialize = function (self, callback, dropType)
Nenue@49 110 if self ~= WorldMapFrameDropDown then
Nenue@49 111 return
Nenue@49 112 end
Nenue@49 113 local config = WorldPlanData
Nenue@49 114 local info = UIDropDownMenu_CreateInfo()
Nenue@49 115 info.text = ""
Nenue@49 116 info.isTitle = true
Nenue@49 117 UIDropDownMenu_AddButton(info)
Nenue@49 118 info.text = "|cFF00AAFFWorldPlan|r"
Nenue@49 119 info.isTitle = true
Nenue@49 120 UIDropDownMenu_AddButton(info)
Nenue@49 121 info.isTitle = nil
Nenue@49 122 info.disabled = nil
Nenue@49 123 info.keepShownOnClick = true
Nenue@49 124 info.tooltipOnButton = 1
Nenue@49 125
Nenue@49 126 info.text = "Enable"
Nenue@49 127 info.isNotRadio = true
Nenue@49 128 info.value = "EnablePins"
Nenue@49 129 info.checked = config.EnablePins
Nenue@49 130 info.tooltipTitle = "Enable World Quest Overlays"
Nenue@49 131 info.tooltipText = "Toggle the detail layers here."
Nenue@49 132 info.func = DropDown_OnClick
Nenue@49 133 UIDropDownMenu_AddButton(info)
Nenue@49 134
Nenue@49 135 info.text = "Display All Profession Quests"
Nenue@49 136 info.isNotRadio = true
Nenue@49 137 info.value = "ShowAllProfessionQuests"
Nenue@49 138 info.checked = config.ShowAllProfessionQuests
Nenue@49 139 info.tooltipTitle = "Hidden Quests"
Nenue@49 140 info.tooltipText = "Display work order and profession-related quests that are skipped by the default UI."
Nenue@49 141 info.func = DropDown_OnClick
Nenue@49 142 UIDropDownMenu_AddButton(info)
Nenue@49 143
Nenue@49 144 info.text = "Show Continent Pins"
Nenue@49 145 info.isNotRadio = true
Nenue@49 146 info.value = "DisplayContinentPins"
Nenue@49 147 info.checked = config.DisplayContinentPins
Nenue@49 148 info.tooltipTitle = "Continent Pins"
Nenue@49 149 info.tooltipText = "Display quest pins on the continent map (may get cramped)."
Nenue@49 150 info.func = DropDown_OnClick
Nenue@49 151 UIDropDownMenu_AddButton(info)
Nenue@49 152
Nenue@49 153 info.text = "Show Summary"
Nenue@49 154 info.isNotRadio = true
Nenue@49 155 info.value = "DisplayContinentSummary"
Nenue@49 156 info.tooltipTitle = "Summary Bar"
Nenue@49 157 info.tooltipText = "Display a summary of active world quests. Note: requires directly viewing Broken Isle and Dalaran maps to gain complete info."
Nenue@49 158 info.checked = config.DisplayContinentSummary
Nenue@49 159 info.func = DropDown_OnClick
Nenue@49 160 UIDropDownMenu_AddButton(info)
Nenue@49 161 --[[
Nenue@49 162
Nenue@49 163 info.text = "Nudge Pins"
Nenue@49 164 info.isNotRadio = true
Nenue@49 165 info.value = "NudgePins"
Nenue@49 166 info.tooltipTitle = "Pin Nudging"
Nenue@49 167 info.tooltipText = "Adjust the position of quest pins that overlap."
Nenue@49 168 info.checked = config.NudgePins
Nenue@49 169 info.func = DropDown_OnClick
Nenue@49 170 UIDropDownMenu_AddButton(info)
Nenue@49 171
Nenue@49 172 info.text = "Fade Whiled Grouped"
Nenue@49 173 info.isNotRadio = true
Nenue@49 174 info.value = "FadeWhileGrouped"
Nenue@49 175 info.tooltipTitle = "Group Fade"
Nenue@49 176 info.tooltipText = "Reduce pin alpha when grouped, so player dots are easier to see."
Nenue@49 177 info.checked = config.FadeWhileGrouped
Nenue@49 178 info.func = DropDown_OnClick
Nenue@49 179 UIDropDownMenu_AddButton(info)
Nenue@49 180 --]]
Nenue@49 181 end
Nenue@49 182
Nenue@49 183
Nenue@40 184 function db.print(...)
Nenue@0 185 for i = 1, select('#', ...) do
Nenue@40 186 tinsert(db.ReportChunks, tostring(select(i, ...)))
Nenue@0 187 end
Nenue@0 188 end
Nenue@0 189
Nenue@40 190 function WorldPlanCore:print(...) db.print(...) end
Nenue@40 191
Nenue@40 192 function WorldPlanCore:AddHandler (frame)
Nenue@40 193 if not db.LoadedModules[frame] then
Nenue@40 194 print('|cFFFFFF00'..self:GetName()..':AddHandler()', frame:GetName(), self.initialized)
Nenue@40 195 db.LoadedModules[frame] = true
Nenue@40 196 tinsert(db.OrderedModules, frame)
Nenue@40 197
Nenue@40 198 if frame.defaults then
Nenue@40 199 db.DefaultConfig[frame:GetName()] = frame.defaults
Nenue@40 200 end
Nenue@40 201
Nenue@40 202 frame.GetTypeInfo = function(frame, typeID)
Nenue@40 203 return self:GetTypeInfo(frame, typeID)
Nenue@40 204 end
Nenue@40 205
Nenue@40 206 frame.owningFrame = self
Nenue@40 207 else
Nenue@40 208
Nenue@40 209 print('|cFFFF4400'..self:GetName()..':AddHandler()', frame:GetName())
Nenue@30 210 end
Nenue@30 211 end
Nenue@30 212
Nenue@36 213 function WorldPlanCore:OnLoad ()
Nenue@29 214
Nenue@29 215 self.Types = setmetatable({}, {
Nenue@29 216 __newindex = function(t, k, v)
Nenue@29 217 if type(v) == 'table' then
Nenue@30 218 print('adding owner', k)
Nenue@30 219 v = setmetatable(v, {
Nenue@30 220 __newindex = function(t2,k2,v2)
Nenue@30 221 if type(v2) == 'table' then
Nenue@40 222 --print('adding type', k2)
Nenue@30 223 v2 = setmetatable(v2, {__index = function(t3,k3)
Nenue@30 224 --print('##deferring to default key', k3)
Nenue@40 225 return db.DefaultType[k3]
Nenue@30 226 end})
Nenue@30 227 end
Nenue@30 228 rawset(t2,k2,v2)
Nenue@29 229 end})
Nenue@29 230 end
Nenue@29 231 rawset(t,k,v)
Nenue@29 232 end
Nenue@29 233 })
Nenue@29 234
Nenue@30 235 self.Types[self] = {}
Nenue@29 236
Nenue@29 237 for index, color in pairs(ITEM_QUALITY_COLORS) do
Nenue@30 238 self:AddTypeInfo(self, index, { r = color.r, g = color.g, b = color.b, hex = color.hex, })
Nenue@29 239 end
Nenue@29 240
Nenue@0 241
Nenue@40 242 db.print('v'..WP_VERSION)
Nenue@40 243
Nenue@0 244
Nenue@0 245 self:RegisterEvent("QUESTLINE_UPDATE")
Nenue@0 246 self:RegisterEvent("QUEST_LOG_UPDATE")
Nenue@0 247 self:RegisterEvent("WORLD_MAP_UPDATE")
Nenue@40 248 self:RegisterEvent("SPELLS_CHANGED")
Nenue@40 249 self:RegisterEvent('PLAYER_ENTERING_WORLD')
Nenue@0 250 self:RegisterEvent("WORLD_QUEST_COMPLETED_BY_SPELL")
Nenue@0 251 self:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED")
Nenue@0 252 self:RegisterEvent("SKILL_LINES_CHANGED")
Nenue@0 253 self:RegisterEvent("ARTIFACT_XP_UPDATE")
Nenue@0 254 self:RegisterEvent("ADDON_LOADED")
Nenue@40 255 self:RegisterEvent("PLAYER_LOGIN")
Nenue@40 256 --self:SetParent(WorldMapFrame)
Nenue@0 257 end
Nenue@0 258
Nenue@36 259 function WorldPlanCore:OnShow()
Nenue@40 260 --print(self:GetName()..':OnShow()')
Nenue@40 261 --hooksecurefunc(self, 'SetScript', function(...) self:print('|cFFFFFF00'..self:GetName()..':SetScript()|r', ...) end)
Nenue@27 262 end
Nenue@27 263
Nenue@41 264 local BROKEN_ISLE_MAPS = {
Nenue@41 265 [1007] = true, -- Broken Isle
Nenue@41 266 [1014] = true, -- Dalaran
Nenue@41 267 [1021] = true, -- Broken Shoree
Nenue@41 268 [1024] = true, -- Highmountain
Nenue@43 269 [1015] = true, -- Azsuna
Nenue@41 270 [1017] = true, -- Azsuna
Nenue@41 271 [1018] = true, -- Val'Sharah
Nenue@41 272 [1033] = true, -- Suramar
Nenue@41 273 [1077] = true, -- Dreamgrove
Nenue@41 274 [1096] = true, -- Eye of Azshara
Nenue@41 275 [1080] = true, -- Thunder Totem
Nenue@41 276 [1072] = true, -- True Shot Lodge,
Nenue@40 277
Nenue@41 278 }
Nenue@41 279
Nenue@41 280 function WorldPlanCore:SetCurrentMap()
Nenue@41 281 local mapAreaID = GetCurrentMapAreaID()
Nenue@41 282 local isBrokenIsle = BROKEN_ISLE_MAPS[mapAreaID]
Nenue@41 283
Nenue@41 284
Nenue@41 285 db.currentMapID = mapAreaID
Nenue@41 286 db.isContinentMap = (mapAreaID == BROKEN_ISLES_ID)
Nenue@40 287 db.useContinentType = (WorldMapDetailFrame:GetScale() < 1)
Nenue@40 288
Nenue@41 289 for _, module in ipairs(db.OrderedModules) do
Nenue@41 290 if module.OnMapInfo then
Nenue@41 291 print(' |cFF00FFFF'..module:GetName() .. ':OnMapInfo()|r')
Nenue@41 292 module:OnMapInfo(isBrokenIsle, mapAreaID)
Nenue@41 293 end
Nenue@41 294 end
Nenue@40 295 end
Nenue@40 296
Nenue@40 297
Nenue@36 298 function WorldPlanCore:OnEvent (event, ...)
Nenue@40 299
Nenue@40 300 print('|cFF00FF88'..self:GetName().. ':OnEvent()|r', event, GetTime(), 'init:', self.initialized)
Nenue@0 301 if event == 'ADDON_LOADED' then
Nenue@0 302
Nenue@0 303 if IsLoggedIn() and not self.initialized then
Nenue@0 304 self:Setup()
Nenue@0 305 end
Nenue@27 306 else
Nenue@41 307 if (event == 'WORLD_MAP_UPDATE') or (event == 'PLAYER_ENTERING_WORLD') or (event == 'PLAYER_LOGIN') then
Nenue@40 308 print('|cFFFF4400currentMapID =', db.currentMapID, ...)
Nenue@41 309 self:SetCurrentMap()
Nenue@0 310 end
Nenue@0 311 end
Nenue@0 312 end
Nenue@0 313
Nenue@33 314 function WorldPlanCore:OnNext(func)
Nenue@34 315
Nenue@34 316
Nenue@33 317 tinsert(self.TaskQueue, func)
Nenue@35 318 --self:print('|cFF00FF00adding scheduled task #', #self.TaskQueue)
Nenue@33 319 end
Nenue@33 320
Nenue@33 321 function WorldPlanCore:OnUpdate()
Nenue@33 322 if #self.TaskQueue >= 1 then
Nenue@34 323 local func = tremove(self.TaskQueue, 1)
Nenue@34 324 --self:print('|cFF00FF00running scheduled task #', #self.TaskQueue)
Nenue@33 325 func()
Nenue@33 326 end
Nenue@33 327
Nenue@33 328 if self.isStale then
Nenue@40 329 -- these need to happen in load order
Nenue@40 330 for i, module in ipairs(db.OrderedModules) do
Nenue@40 331 if module:IsVisible() and module.isStale then
Nenue@33 332 print('|cFF00FF00internal '..module:GetName()..':Refresh()|r')
Nenue@33 333 module:Refresh()
Nenue@33 334 end
Nenue@33 335 end
Nenue@40 336 self.isStale = nil
Nenue@33 337 end
Nenue@40 338
Nenue@40 339 if #db.ReportChunks >= 1 then
Nenue@40 340
Nenue@40 341 DEFAULT_CHAT_FRAME:AddMessage("|cFF0088FF"..addonFileName.."|r: " .. table.concat(db.ReportChunks, ', '))
Nenue@40 342 wipe(db.ReportChunks)
Nenue@40 343 end
Nenue@40 344
Nenue@33 345 end
Nenue@0 346
Nenue@36 347 function WorldPlanCore:Setup ()
Nenue@40 348 print('|cFFFFFF00'..self:GetName()..':Setup()|r')
Nenue@40 349
Nenue@0 350 if not WorldPlanData then
Nenue@40 351 WorldPlanData = {key = 0}
Nenue@0 352 end
Nenue@0 353 WorldPlanData.key = (WorldPlanData.key or 0) + 1
Nenue@40 354 db.Config = WorldPlanData
Nenue@40 355 for k,v in pairs(db.DefaultConfig) do
Nenue@18 356 --[===[@non-debug@
Nenue@40 357 if not db.Config[k] then
Nenue@40 358 db.Config[k] = v
Nenue@18 359 end
Nenue@18 360
Nenue@18 361 --@end-non-debug@]===]
Nenue@18 362 --@debug@
Nenue@40 363 db.Config[k] = v
Nenue@18 364 --@end-debug@
Nenue@9 365 end
Nenue@9 366
Nenue@0 367
Nenue@40 368 db.currentMapID = GetCurrentMapAreaID()
Nenue@40 369
Nenue@40 370 for i, module in ipairs(db.OrderedModules) do
Nenue@40 371 db.Config[module:GetName()] = db.Config[module:GetName()] or {}
Nenue@0 372 if module.Setup then module:Setup() end
Nenue@0 373 if not module.RegisterEvent then
Nenue@0 374 module.RegisterEvent = self.RegisterEvent
Nenue@0 375 end
Nenue@49 376 if module.OnConfigUpdate then
Nenue@49 377 module:OnConfigUpdate()
Nenue@49 378 end
Nenue@0 379 end
Nenue@40 380
Nenue@40 381
Nenue@0 382 self.initialized = true
Nenue@0 383
Nenue@49 384 hooksecurefunc("UIDropDownMenu_Initialize", DropDown_Initialize)
Nenue@33 385
Nenue@33 386 hooksecurefunc("WorldMapTrackingOptionsDropDown_OnClick", function(button)
Nenue@33 387 print("|cFF0088FFWorldMapTrackingOptionsDropDown_OnClick|r")
Nenue@33 388 local value = button.value
Nenue@33 389 if (value == "worldQuestFilterOrderResources" or value == "worldQuestFilterArtifactPower" or
Nenue@33 390 value == "worldQuestFilterProfessionMaterials" or value == "worldQuestFilterGold" or
Nenue@33 391 value == "worldQuestFilterEquipment") then
Nenue@33 392 self:Refresh(true)
Nenue@33 393 end
Nenue@33 394 end)
Nenue@40 395
Nenue@40 396
Nenue@40 397 hooksecurefunc("WorldMapFrame_Update", function()
Nenue@40 398 print('|cFFFF4400WorldMapFrame_Update|r')
Nenue@41 399 for _,module in ipairs(db.OrderedModules) do
Nenue@41 400 if module.OnWorldMapFrameUpdate then
Nenue@41 401 print(' |cFFFF4400'..module:GetName()..'|r')
Nenue@41 402 module:OnWorldMapFrameUpdate()
Nenue@41 403 end
Nenue@41 404 end
Nenue@40 405 end)
Nenue@40 406
Nenue@40 407 SLASH_WORLDPLAN1 = "/worldplan"
Nenue@40 408 SLASH_WORLDPLAN2 = "/wp"
Nenue@40 409
Nenue@40 410
Nenue@40 411
Nenue@40 412 SlashCmdList.WORLDPLAN = function(args)
Nenue@40 413 local arg1, arg2, extraArgs = args:match("(%S+)%s*(%S*)%s*(.*)")
Nenue@40 414
Nenue@40 415 if arg1 == 'wq' then
Nenue@40 416 if arg2 and WorldPlanQuests[arg2] then
Nenue@40 417 self:print('WorldPlanQuests:'..arg2..'()')
Nenue@40 418 WorldPlanQuests[arg2](WorldPlanQuests)
Nenue@40 419 elseif arg2 == 'flightscale' and extraArgs then
Nenue@40 420 local val1, val2, val3 = extraArgs:match("(%S+)%s*(%S*)%s*(%S*)")
Nenue@40 421 if tonumber(val1) and tonumber(val2) and tonumber(val3) then
Nenue@40 422 db.Config.FlightMapScalingLimits = {tonumber(val1), tonumber(val2), tonumber(val3)}
Nenue@40 423 self:print('FlightMapFrame scaling limits updated:', unpack(db.Config.FlightMapScalingLimits))
Nenue@40 424 else
Nenue@40 425 self:print('FlightMapFrame scaling limits:', unpack(db.Config.FlightMapScalingLimits))
Nenue@40 426 end
Nenue@40 427 elseif arg2 == 'flightalpha' and extraArgs then
Nenue@40 428 local val1, val2, val3 = extraArgs:match("(%S+)%s*(%S*)%s*(%S*)")
Nenue@40 429 if tonumber(val1) and tonumber(val2) and tonumber(val3) then
Nenue@40 430 db.Config.FlightMapAlphaLimits = {tonumber(val1), tonumber(val2), tonumber(val3)}
Nenue@40 431 self:print('FlightMapFrame alpha limits updated:', unpack(db.Config.FlightMapAlphaLimits))
Nenue@40 432 else
Nenue@40 433 self:print('FlightMapFrame alpha limits:', unpack(db.Config.FlightMapAlphaLimits))
Nenue@40 434 end
Nenue@40 435 else
Nenue@40 436
Nenue@40 437 self:print('WorldPlanQuests:Refresh(true)')
Nenue@40 438 WorldPlanQuests:Refresh(true)
Nenue@40 439 end
Nenue@40 440 elseif arg1 == 'filter' then
Nenue@40 441 if arg2 and WorldPlanSummary[arg2] then
Nenue@40 442 self:print('WorldPlanSummary:'..arg2..'()')
Nenue@40 443 WorldPlanSummary[arg2](WorldPlanSummary)
Nenue@40 444 else
Nenue@40 445 self:print('WorldPlanSummary:Refresh(true)')
Nenue@40 446 WorldPlanSummary:Refresh(true)
Nenue@40 447 end
Nenue@40 448 else
Nenue@40 449 self:print('Refreshing data.')
Nenue@40 450 self:Refresh(true)
Nenue@40 451 end
Nenue@40 452
Nenue@40 453 end
Nenue@0 454 end
Nenue@0 455
Nenue@40 456 -- registers a template table
Nenue@36 457 function WorldPlanCore:AddTypeInfo(owner, id, info)
Nenue@30 458 self.Types[owner] = self.Types[owner] or {}
Nenue@30 459 self.Types[owner][id] = info
Nenue@30 460 print('Type('..owner:GetName()..')('..id..') = '.. tostring(info))
Nenue@30 461 end
Nenue@30 462
Nenue@40 463 -- recall a template table, with situational details filled in
Nenue@36 464 function WorldPlanCore:GetTypeInfo(owner, typeID)
Nenue@29 465 local info, extraInfo
Nenue@30 466 if not owner then
Nenue@30 467 --print('## deferring to default type list')
Nenue@30 468 else
Nenue@30 469 --print('## pulling for', owner:GetName(), 'id =', typeID)
Nenue@30 470 end
Nenue@30 471
Nenue@30 472 owner = owner or self
Nenue@30 473 if (not typeID) or (not self.Types[owner][typeID]) then
Nenue@30 474 --print('## sending list default')
Nenue@40 475 info = db.DefaultType
Nenue@29 476 else
Nenue@30 477 --print('## sent list definition', typeID)
Nenue@30 478 info = self.Types[owner][typeID]
Nenue@29 479 end
Nenue@29 480
Nenue@40 481 local subType = 'continent'
Nenue@40 482 if (
Nenue@40 483 FlightMapFrame
Nenue@40 484 and FlightMapFrame:IsVisible()
Nenue@40 485 and FlightMapFrame:IsZoomedIn()
Nenue@40 486 ) or (
Nenue@40 487 not db.isContinentMap
Nenue@40 488 ) or (
Nenue@40 489 db.useContinentType == false
Nenue@40 490 ) then
Nenue@40 491 subType = 'zone'
Nenue@40 492 end
Nenue@29 493
Nenue@40 494 return info, info[subType] or db.DefaultType[subType]
Nenue@29 495 end
Nenue@29 496
Nenue@29 497 do
Nenue@29 498 local timeStates = {
Nenue@29 499 {maxSeconds = 60,
Nenue@29 500 r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end,
Nenue@29 501 },
Nenue@29 502 {maxSeconds = 240,
Nenue@29 503 r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end,
Nenue@29 504 },
Nenue@29 505 {maxSeconds = 1440,
Nenue@29 506 r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end,
Nenue@29 507 },
Nenue@29 508 {maxSeconds = 10081,
Nenue@29 509 r=0, g=1, b=0,
Nenue@29 510 }, -- 7 days + 1 minute
Nenue@29 511 }
Nenue@29 512 -- Generates a timeleft string
Nenue@36 513 function WorldPlanCore:GetTimeInfo(timeLeft, limit)
Nenue@29 514 for index = 1, limit do
Nenue@29 515 local state = timeStates[index]
Nenue@29 516 if timeLeft <= state.maxSeconds then
Nenue@29 517 local text
Nenue@29 518 if state.format then
Nenue@29 519 text = state.format(timeLeft)
Nenue@29 520 end
Nenue@29 521 return text, index
Nenue@29 522 end
Nenue@29 523 end
Nenue@29 524 return nil, nil
Nenue@29 525 end
Nenue@29 526 end
Nenue@29 527
Nenue@36 528 function WorldPlanCore:Refresh (forced)
Nenue@30 529 print('|cFFFFFF00'..self:GetName()..':Refresh()|r forced:', forced, 'init:', self.initialized)
Nenue@9 530 if not self.initialized then
Nenue@9 531 return
Nenue@9 532 end
Nenue@9 533
Nenue@40 534 for i, module in ipairs(db.OrderedModules) do
Nenue@0 535 if module.Refresh then
Nenue@33 536 print('|cFF00FF00external '..module:GetName()..':Refresh()|r')
Nenue@33 537 module:Refresh(forced)
Nenue@0 538 end
Nenue@0 539 end
Nenue@40 540
Nenue@40 541 self.isStale = nil
Nenue@0 542 end
Nenue@0 543
Nenue@0 544
Nenue@30 545 --------------------------------------------------------------------------------------------------------------------
Nenue@35 546 -------------------
Nenue@0 547
Nenue@0 548
Nenue@0 549
Nenue@0 550
Nenue@0 551
Nenue@0 552
Nenue@0 553
Nenue@35 554 --%end-debug%