annotate WorldPlan.lua @ 56:0749e38081e7

- More fixes for map updates from non-Legion zones.
author Nenue
date Tue, 03 Jan 2017 20:04:16 -0500
parents b289eb3e6a32
children abcdef801db5
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@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
Nenue@33 357 end
Nenue@0 358
Nenue@36 359 function WorldPlanCore:Setup ()
Nenue@40 360 print('|cFFFFFF00'..self:GetName()..':Setup()|r')
Nenue@40 361
Nenue@0 362 if not WorldPlanData then
Nenue@40 363 WorldPlanData = {key = 0}
Nenue@0 364 end
Nenue@0 365 WorldPlanData.key = (WorldPlanData.key or 0) + 1
Nenue@40 366 db.Config = WorldPlanData
Nenue@40 367 for k,v in pairs(db.DefaultConfig) do
Nenue@18 368 --[===[@non-debug@
Nenue@40 369 if not db.Config[k] then
Nenue@40 370 db.Config[k] = v
Nenue@18 371 end
Nenue@18 372
Nenue@18 373 --@end-non-debug@]===]
Nenue@18 374 --@debug@
Nenue@40 375 db.Config[k] = v
Nenue@18 376 --@end-debug@
Nenue@9 377 end
Nenue@9 378
Nenue@0 379
Nenue@40 380 db.currentMapID = GetCurrentMapAreaID()
Nenue@40 381
Nenue@40 382 for i, module in ipairs(db.OrderedModules) do
Nenue@40 383 db.Config[module:GetName()] = db.Config[module:GetName()] or {}
Nenue@0 384 if module.Setup then module:Setup() end
Nenue@0 385 if not module.RegisterEvent then
Nenue@0 386 module.RegisterEvent = self.RegisterEvent
Nenue@0 387 end
Nenue@49 388 if module.OnConfigUpdate then
Nenue@49 389 module:OnConfigUpdate()
Nenue@49 390 end
Nenue@0 391 end
Nenue@40 392
Nenue@40 393
Nenue@0 394 self.initialized = true
Nenue@0 395
Nenue@49 396 hooksecurefunc("UIDropDownMenu_Initialize", DropDown_Initialize)
Nenue@33 397
Nenue@33 398 hooksecurefunc("WorldMapTrackingOptionsDropDown_OnClick", function(button)
Nenue@33 399 print("|cFF0088FFWorldMapTrackingOptionsDropDown_OnClick|r")
Nenue@33 400 local value = button.value
Nenue@33 401 if (value == "worldQuestFilterOrderResources" or value == "worldQuestFilterArtifactPower" or
Nenue@33 402 value == "worldQuestFilterProfessionMaterials" or value == "worldQuestFilterGold" or
Nenue@33 403 value == "worldQuestFilterEquipment") then
Nenue@33 404 self:Refresh(true)
Nenue@33 405 end
Nenue@33 406 end)
Nenue@40 407
Nenue@40 408
Nenue@40 409 hooksecurefunc("WorldMapFrame_Update", function()
Nenue@40 410 print('|cFFFF4400WorldMapFrame_Update|r')
Nenue@41 411 for _,module in ipairs(db.OrderedModules) do
Nenue@41 412 if module.OnWorldMapFrameUpdate then
Nenue@41 413 print(' |cFFFF4400'..module:GetName()..'|r')
Nenue@41 414 module:OnWorldMapFrameUpdate()
Nenue@41 415 end
Nenue@41 416 end
Nenue@40 417 end)
Nenue@40 418
Nenue@40 419 SLASH_WORLDPLAN1 = "/worldplan"
Nenue@40 420 SLASH_WORLDPLAN2 = "/wp"
Nenue@40 421
Nenue@40 422
Nenue@40 423
Nenue@40 424 SlashCmdList.WORLDPLAN = function(args)
Nenue@40 425 local arg1, arg2, extraArgs = args:match("(%S+)%s*(%S*)%s*(.*)")
Nenue@40 426
Nenue@40 427 if arg1 == 'wq' then
Nenue@40 428 if arg2 and WorldPlanQuests[arg2] then
Nenue@40 429 self:print('WorldPlanQuests:'..arg2..'()')
Nenue@40 430 WorldPlanQuests[arg2](WorldPlanQuests)
Nenue@40 431 elseif arg2 == 'flightscale' and extraArgs then
Nenue@40 432 local val1, val2, val3 = extraArgs:match("(%S+)%s*(%S*)%s*(%S*)")
Nenue@40 433 if tonumber(val1) and tonumber(val2) and tonumber(val3) then
Nenue@40 434 db.Config.FlightMapScalingLimits = {tonumber(val1), tonumber(val2), tonumber(val3)}
Nenue@40 435 self:print('FlightMapFrame scaling limits updated:', unpack(db.Config.FlightMapScalingLimits))
Nenue@40 436 else
Nenue@40 437 self:print('FlightMapFrame scaling limits:', unpack(db.Config.FlightMapScalingLimits))
Nenue@40 438 end
Nenue@40 439 elseif arg2 == 'flightalpha' and extraArgs then
Nenue@40 440 local val1, val2, val3 = extraArgs:match("(%S+)%s*(%S*)%s*(%S*)")
Nenue@40 441 if tonumber(val1) and tonumber(val2) and tonumber(val3) then
Nenue@40 442 db.Config.FlightMapAlphaLimits = {tonumber(val1), tonumber(val2), tonumber(val3)}
Nenue@40 443 self:print('FlightMapFrame alpha limits updated:', unpack(db.Config.FlightMapAlphaLimits))
Nenue@40 444 else
Nenue@40 445 self:print('FlightMapFrame alpha limits:', unpack(db.Config.FlightMapAlphaLimits))
Nenue@40 446 end
Nenue@40 447 else
Nenue@40 448
Nenue@40 449 self:print('WorldPlanQuests:Refresh(true)')
Nenue@40 450 WorldPlanQuests:Refresh(true)
Nenue@40 451 end
Nenue@40 452 elseif arg1 == 'filter' then
Nenue@40 453 if arg2 and WorldPlanSummary[arg2] then
Nenue@40 454 self:print('WorldPlanSummary:'..arg2..'()')
Nenue@40 455 WorldPlanSummary[arg2](WorldPlanSummary)
Nenue@40 456 else
Nenue@40 457 self:print('WorldPlanSummary:Refresh(true)')
Nenue@40 458 WorldPlanSummary:Refresh(true)
Nenue@40 459 end
Nenue@40 460 else
Nenue@40 461 self:print('Refreshing data.')
Nenue@40 462 self:Refresh(true)
Nenue@40 463 end
Nenue@40 464
Nenue@40 465 end
Nenue@0 466 end
Nenue@0 467
Nenue@40 468 -- registers a template table
Nenue@36 469 function WorldPlanCore:AddTypeInfo(owner, id, info)
Nenue@30 470 self.Types[owner] = self.Types[owner] or {}
Nenue@30 471 self.Types[owner][id] = info
Nenue@30 472 print('Type('..owner:GetName()..')('..id..') = '.. tostring(info))
Nenue@30 473 end
Nenue@30 474
Nenue@40 475 -- recall a template table, with situational details filled in
Nenue@36 476 function WorldPlanCore:GetTypeInfo(owner, typeID)
Nenue@29 477 local info, extraInfo
Nenue@30 478 if not owner then
Nenue@30 479 --print('## deferring to default type list')
Nenue@30 480 else
Nenue@30 481 --print('## pulling for', owner:GetName(), 'id =', typeID)
Nenue@30 482 end
Nenue@30 483
Nenue@30 484 owner = owner or self
Nenue@30 485 if (not typeID) or (not self.Types[owner][typeID]) then
Nenue@30 486 --print('## sending list default')
Nenue@40 487 info = db.DefaultType
Nenue@29 488 else
Nenue@30 489 --print('## sent list definition', typeID)
Nenue@30 490 info = self.Types[owner][typeID]
Nenue@29 491 end
Nenue@29 492
Nenue@40 493 local subType = 'continent'
Nenue@40 494 if (
Nenue@40 495 FlightMapFrame
Nenue@40 496 and FlightMapFrame:IsVisible()
Nenue@40 497 and FlightMapFrame:IsZoomedIn()
Nenue@40 498 ) or (
Nenue@40 499 not db.isContinentMap
Nenue@40 500 ) or (
Nenue@40 501 db.useContinentType == false
Nenue@40 502 ) then
Nenue@40 503 subType = 'zone'
Nenue@40 504 end
Nenue@29 505
Nenue@40 506 return info, info[subType] or db.DefaultType[subType]
Nenue@29 507 end
Nenue@29 508
Nenue@29 509 do
Nenue@29 510 local timeStates = {
Nenue@29 511 {maxSeconds = 60,
Nenue@29 512 r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end,
Nenue@29 513 },
Nenue@29 514 {maxSeconds = 240,
Nenue@29 515 r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end,
Nenue@29 516 },
Nenue@29 517 {maxSeconds = 1440,
Nenue@29 518 r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end,
Nenue@29 519 },
Nenue@29 520 {maxSeconds = 10081,
Nenue@29 521 r=0, g=1, b=0,
Nenue@29 522 }, -- 7 days + 1 minute
Nenue@29 523 }
Nenue@29 524 -- Generates a timeleft string
Nenue@36 525 function WorldPlanCore:GetTimeInfo(timeLeft, limit)
Nenue@29 526 for index = 1, limit do
Nenue@29 527 local state = timeStates[index]
Nenue@29 528 if timeLeft <= state.maxSeconds then
Nenue@29 529 local text
Nenue@29 530 if state.format then
Nenue@29 531 text = state.format(timeLeft)
Nenue@29 532 end
Nenue@29 533 return text, index
Nenue@29 534 end
Nenue@29 535 end
Nenue@29 536 return nil, nil
Nenue@29 537 end
Nenue@29 538 end
Nenue@29 539
Nenue@36 540 function WorldPlanCore:Refresh (forced)
Nenue@30 541 print('|cFFFFFF00'..self:GetName()..':Refresh()|r forced:', forced, 'init:', self.initialized)
Nenue@9 542 if not self.initialized then
Nenue@9 543 return
Nenue@9 544 end
Nenue@9 545
Nenue@40 546 for i, module in ipairs(db.OrderedModules) do
Nenue@0 547 if module.Refresh then
Nenue@33 548 print('|cFF00FF00external '..module:GetName()..':Refresh()|r')
Nenue@33 549 module:Refresh(forced)
Nenue@0 550 end
Nenue@0 551 end
Nenue@40 552
Nenue@40 553 self.isStale = nil
Nenue@0 554 end
Nenue@0 555
Nenue@0 556
Nenue@30 557 --------------------------------------------------------------------------------------------------------------------
Nenue@35 558 -------------------
Nenue@0 559
Nenue@0 560
Nenue@0 561
Nenue@0 562
Nenue@0 563
Nenue@0 564
Nenue@0 565
Nenue@35 566 --%end-debug%