annotate WorldPlan.lua @ 54:b289eb3e6a32

- Fix stray pin text arising from pins that are never shown.
author Nenue
date Sat, 31 Dec 2016 17:31:39 -0500
parents dbd81d49af02
children 0749e38081e7
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@41 290 local isBrokenIsle = BROKEN_ISLE_MAPS[mapAreaID]
Nenue@41 291
Nenue@54 292 local isContinent = (mapAreaID == BROKEN_ISLES_ID)
Nenue@41 293 db.currentMapID = mapAreaID
Nenue@54 294 db.isContinentMap = isContinent
Nenue@40 295 db.useContinentType = (WorldMapDetailFrame:GetScale() < 1)
Nenue@40 296
Nenue@41 297 for _, module in ipairs(db.OrderedModules) do
Nenue@41 298 if module.OnMapInfo then
Nenue@41 299 print(' |cFF00FFFF'..module:GetName() .. ':OnMapInfo()|r')
Nenue@54 300 module:OnMapInfo(isBrokenIsle, isContinent, mapAreaID)
Nenue@41 301 end
Nenue@41 302 end
Nenue@40 303 end
Nenue@40 304
Nenue@40 305
Nenue@36 306 function WorldPlanCore:OnEvent (event, ...)
Nenue@40 307
Nenue@40 308 print('|cFF00FF88'..self:GetName().. ':OnEvent()|r', event, GetTime(), 'init:', self.initialized)
Nenue@0 309 if event == 'ADDON_LOADED' then
Nenue@0 310
Nenue@0 311 if IsLoggedIn() and not self.initialized then
Nenue@0 312 self:Setup()
Nenue@0 313 end
Nenue@27 314 else
Nenue@41 315 if (event == 'WORLD_MAP_UPDATE') or (event == 'PLAYER_ENTERING_WORLD') or (event == 'PLAYER_LOGIN') then
Nenue@40 316 print('|cFFFF4400currentMapID =', db.currentMapID, ...)
Nenue@41 317 self:SetCurrentMap()
Nenue@0 318 end
Nenue@0 319 end
Nenue@0 320 end
Nenue@0 321
Nenue@33 322 function WorldPlanCore:OnNext(func)
Nenue@34 323
Nenue@34 324
Nenue@33 325 tinsert(self.TaskQueue, func)
Nenue@35 326 --self:print('|cFF00FF00adding scheduled task #', #self.TaskQueue)
Nenue@33 327 end
Nenue@33 328
Nenue@33 329 function WorldPlanCore:OnUpdate()
Nenue@33 330 if #self.TaskQueue >= 1 then
Nenue@34 331 local func = tremove(self.TaskQueue, 1)
Nenue@34 332 --self:print('|cFF00FF00running scheduled task #', #self.TaskQueue)
Nenue@33 333 func()
Nenue@33 334 end
Nenue@33 335
Nenue@33 336 if self.isStale then
Nenue@40 337 -- these need to happen in load order
Nenue@40 338 for i, module in ipairs(db.OrderedModules) do
Nenue@40 339 if module:IsVisible() and module.isStale then
Nenue@33 340 print('|cFF00FF00internal '..module:GetName()..':Refresh()|r')
Nenue@33 341 module:Refresh()
Nenue@33 342 end
Nenue@33 343 end
Nenue@40 344 self.isStale = nil
Nenue@33 345 end
Nenue@40 346
Nenue@40 347 if #db.ReportChunks >= 1 then
Nenue@40 348
Nenue@40 349 DEFAULT_CHAT_FRAME:AddMessage("|cFF0088FF"..addonFileName.."|r: " .. table.concat(db.ReportChunks, ', '))
Nenue@40 350 wipe(db.ReportChunks)
Nenue@40 351 end
Nenue@40 352
Nenue@33 353 end
Nenue@0 354
Nenue@36 355 function WorldPlanCore:Setup ()
Nenue@40 356 print('|cFFFFFF00'..self:GetName()..':Setup()|r')
Nenue@40 357
Nenue@0 358 if not WorldPlanData then
Nenue@40 359 WorldPlanData = {key = 0}
Nenue@0 360 end
Nenue@0 361 WorldPlanData.key = (WorldPlanData.key or 0) + 1
Nenue@40 362 db.Config = WorldPlanData
Nenue@40 363 for k,v in pairs(db.DefaultConfig) do
Nenue@18 364 --[===[@non-debug@
Nenue@40 365 if not db.Config[k] then
Nenue@40 366 db.Config[k] = v
Nenue@18 367 end
Nenue@18 368
Nenue@18 369 --@end-non-debug@]===]
Nenue@18 370 --@debug@
Nenue@40 371 db.Config[k] = v
Nenue@18 372 --@end-debug@
Nenue@9 373 end
Nenue@9 374
Nenue@0 375
Nenue@40 376 db.currentMapID = GetCurrentMapAreaID()
Nenue@40 377
Nenue@40 378 for i, module in ipairs(db.OrderedModules) do
Nenue@40 379 db.Config[module:GetName()] = db.Config[module:GetName()] or {}
Nenue@0 380 if module.Setup then module:Setup() end
Nenue@0 381 if not module.RegisterEvent then
Nenue@0 382 module.RegisterEvent = self.RegisterEvent
Nenue@0 383 end
Nenue@49 384 if module.OnConfigUpdate then
Nenue@49 385 module:OnConfigUpdate()
Nenue@49 386 end
Nenue@0 387 end
Nenue@40 388
Nenue@40 389
Nenue@0 390 self.initialized = true
Nenue@0 391
Nenue@49 392 hooksecurefunc("UIDropDownMenu_Initialize", DropDown_Initialize)
Nenue@33 393
Nenue@33 394 hooksecurefunc("WorldMapTrackingOptionsDropDown_OnClick", function(button)
Nenue@33 395 print("|cFF0088FFWorldMapTrackingOptionsDropDown_OnClick|r")
Nenue@33 396 local value = button.value
Nenue@33 397 if (value == "worldQuestFilterOrderResources" or value == "worldQuestFilterArtifactPower" or
Nenue@33 398 value == "worldQuestFilterProfessionMaterials" or value == "worldQuestFilterGold" or
Nenue@33 399 value == "worldQuestFilterEquipment") then
Nenue@33 400 self:Refresh(true)
Nenue@33 401 end
Nenue@33 402 end)
Nenue@40 403
Nenue@40 404
Nenue@40 405 hooksecurefunc("WorldMapFrame_Update", function()
Nenue@40 406 print('|cFFFF4400WorldMapFrame_Update|r')
Nenue@41 407 for _,module in ipairs(db.OrderedModules) do
Nenue@41 408 if module.OnWorldMapFrameUpdate then
Nenue@41 409 print(' |cFFFF4400'..module:GetName()..'|r')
Nenue@41 410 module:OnWorldMapFrameUpdate()
Nenue@41 411 end
Nenue@41 412 end
Nenue@40 413 end)
Nenue@40 414
Nenue@40 415 SLASH_WORLDPLAN1 = "/worldplan"
Nenue@40 416 SLASH_WORLDPLAN2 = "/wp"
Nenue@40 417
Nenue@40 418
Nenue@40 419
Nenue@40 420 SlashCmdList.WORLDPLAN = function(args)
Nenue@40 421 local arg1, arg2, extraArgs = args:match("(%S+)%s*(%S*)%s*(.*)")
Nenue@40 422
Nenue@40 423 if arg1 == 'wq' then
Nenue@40 424 if arg2 and WorldPlanQuests[arg2] then
Nenue@40 425 self:print('WorldPlanQuests:'..arg2..'()')
Nenue@40 426 WorldPlanQuests[arg2](WorldPlanQuests)
Nenue@40 427 elseif arg2 == 'flightscale' 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.FlightMapScalingLimits = {tonumber(val1), tonumber(val2), tonumber(val3)}
Nenue@40 431 self:print('FlightMapFrame scaling limits updated:', unpack(db.Config.FlightMapScalingLimits))
Nenue@40 432 else
Nenue@40 433 self:print('FlightMapFrame scaling limits:', unpack(db.Config.FlightMapScalingLimits))
Nenue@40 434 end
Nenue@40 435 elseif arg2 == 'flightalpha' 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.FlightMapAlphaLimits = {tonumber(val1), tonumber(val2), tonumber(val3)}
Nenue@40 439 self:print('FlightMapFrame alpha limits updated:', unpack(db.Config.FlightMapAlphaLimits))
Nenue@40 440 else
Nenue@40 441 self:print('FlightMapFrame alpha limits:', unpack(db.Config.FlightMapAlphaLimits))
Nenue@40 442 end
Nenue@40 443 else
Nenue@40 444
Nenue@40 445 self:print('WorldPlanQuests:Refresh(true)')
Nenue@40 446 WorldPlanQuests:Refresh(true)
Nenue@40 447 end
Nenue@40 448 elseif arg1 == 'filter' then
Nenue@40 449 if arg2 and WorldPlanSummary[arg2] then
Nenue@40 450 self:print('WorldPlanSummary:'..arg2..'()')
Nenue@40 451 WorldPlanSummary[arg2](WorldPlanSummary)
Nenue@40 452 else
Nenue@40 453 self:print('WorldPlanSummary:Refresh(true)')
Nenue@40 454 WorldPlanSummary:Refresh(true)
Nenue@40 455 end
Nenue@40 456 else
Nenue@40 457 self:print('Refreshing data.')
Nenue@40 458 self:Refresh(true)
Nenue@40 459 end
Nenue@40 460
Nenue@40 461 end
Nenue@0 462 end
Nenue@0 463
Nenue@40 464 -- registers a template table
Nenue@36 465 function WorldPlanCore:AddTypeInfo(owner, id, info)
Nenue@30 466 self.Types[owner] = self.Types[owner] or {}
Nenue@30 467 self.Types[owner][id] = info
Nenue@30 468 print('Type('..owner:GetName()..')('..id..') = '.. tostring(info))
Nenue@30 469 end
Nenue@30 470
Nenue@40 471 -- recall a template table, with situational details filled in
Nenue@36 472 function WorldPlanCore:GetTypeInfo(owner, typeID)
Nenue@29 473 local info, extraInfo
Nenue@30 474 if not owner then
Nenue@30 475 --print('## deferring to default type list')
Nenue@30 476 else
Nenue@30 477 --print('## pulling for', owner:GetName(), 'id =', typeID)
Nenue@30 478 end
Nenue@30 479
Nenue@30 480 owner = owner or self
Nenue@30 481 if (not typeID) or (not self.Types[owner][typeID]) then
Nenue@30 482 --print('## sending list default')
Nenue@40 483 info = db.DefaultType
Nenue@29 484 else
Nenue@30 485 --print('## sent list definition', typeID)
Nenue@30 486 info = self.Types[owner][typeID]
Nenue@29 487 end
Nenue@29 488
Nenue@40 489 local subType = 'continent'
Nenue@40 490 if (
Nenue@40 491 FlightMapFrame
Nenue@40 492 and FlightMapFrame:IsVisible()
Nenue@40 493 and FlightMapFrame:IsZoomedIn()
Nenue@40 494 ) or (
Nenue@40 495 not db.isContinentMap
Nenue@40 496 ) or (
Nenue@40 497 db.useContinentType == false
Nenue@40 498 ) then
Nenue@40 499 subType = 'zone'
Nenue@40 500 end
Nenue@29 501
Nenue@40 502 return info, info[subType] or db.DefaultType[subType]
Nenue@29 503 end
Nenue@29 504
Nenue@29 505 do
Nenue@29 506 local timeStates = {
Nenue@29 507 {maxSeconds = 60,
Nenue@29 508 r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end,
Nenue@29 509 },
Nenue@29 510 {maxSeconds = 240,
Nenue@29 511 r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end,
Nenue@29 512 },
Nenue@29 513 {maxSeconds = 1440,
Nenue@29 514 r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end,
Nenue@29 515 },
Nenue@29 516 {maxSeconds = 10081,
Nenue@29 517 r=0, g=1, b=0,
Nenue@29 518 }, -- 7 days + 1 minute
Nenue@29 519 }
Nenue@29 520 -- Generates a timeleft string
Nenue@36 521 function WorldPlanCore:GetTimeInfo(timeLeft, limit)
Nenue@29 522 for index = 1, limit do
Nenue@29 523 local state = timeStates[index]
Nenue@29 524 if timeLeft <= state.maxSeconds then
Nenue@29 525 local text
Nenue@29 526 if state.format then
Nenue@29 527 text = state.format(timeLeft)
Nenue@29 528 end
Nenue@29 529 return text, index
Nenue@29 530 end
Nenue@29 531 end
Nenue@29 532 return nil, nil
Nenue@29 533 end
Nenue@29 534 end
Nenue@29 535
Nenue@36 536 function WorldPlanCore:Refresh (forced)
Nenue@30 537 print('|cFFFFFF00'..self:GetName()..':Refresh()|r forced:', forced, 'init:', self.initialized)
Nenue@9 538 if not self.initialized then
Nenue@9 539 return
Nenue@9 540 end
Nenue@9 541
Nenue@40 542 for i, module in ipairs(db.OrderedModules) do
Nenue@0 543 if module.Refresh then
Nenue@33 544 print('|cFF00FF00external '..module:GetName()..':Refresh()|r')
Nenue@33 545 module:Refresh(forced)
Nenue@0 546 end
Nenue@0 547 end
Nenue@40 548
Nenue@40 549 self.isStale = nil
Nenue@0 550 end
Nenue@0 551
Nenue@0 552
Nenue@30 553 --------------------------------------------------------------------------------------------------------------------
Nenue@35 554 -------------------
Nenue@0 555
Nenue@0 556
Nenue@0 557
Nenue@0 558
Nenue@0 559
Nenue@0 560
Nenue@0 561
Nenue@35 562 --%end-debug%