annotate WorldPlan.lua @ 68:cce68795f955

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