Nenue@0: -- WorldPlan.lua Nenue@0: -- Created: 8/16/2016 8:19 AM Nenue@0: -- %file-revision% Nenue@40: local addonFileName, db = ... Nenue@40: local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end Nenue@67: local WP_VERSION = "1.4" Nenue@40: local tinsert, pairs, floor = tinsert, pairs, floor Nenue@40: local tremove, ipairs, wipe, unpack = tremove, ipairs, wipe, unpack Nenue@40: local select, type, tostring, tonumber = select, type, tostring, tonumber Nenue@40: local ITEM_QUALITY_COLORS = ITEM_QUALITY_COLORS Nenue@40: local BROKEN_ISLES_ID = 1007 Nenue@40: local GetCurrentMapAreaID = GetCurrentMapAreaID Nenue@40: local GetTime, IsLoggedIn = GetTime, IsLoggedIn Nenue@69: local DEBUG_HISTORY = {} Nenue@110: local ofunc = {} Nenue@0: Nenue@40: -- Define tables here so the pointers match up Nenue@40: WorldPlanCore = { defaults = {}, modules = {}, TaskQueue = {}, } Nenue@35: WorldPlanPOIMixin = {} Nenue@40: WorldPlanSummaryMixin = {} Nenue@40: db.filtersDirty = true Nenue@40: db.questsDirty = true Nenue@40: db.OrderedModules = {} Nenue@40: db.LoadedModules = {} Nenue@40: db.UsedFilters = {} Nenue@40: db.QuestsByZone = {} Nenue@40: db.QuestsByID = {} Nenue@40: db.TasksByID = {} Nenue@40: db.FreePins = {} Nenue@40: db.UsedPins = {} Nenue@67: db.UpdatedPins = {} Nenue@40: db.ReportChunks = {} Nenue@75: db.Bounties = {} Nenue@75: db.BountiesByQuestID = {} Nenue@72: db.BountiesByFactionID = {} Nenue@100: db.IgnoreTimers = {} Nenue@108: db.CLTriggers = { Nenue@108: wq = function(arg2, extraArgs) Nenue@108: if arg2 and WorldPlanQuests[arg2] then Nenue@108: self:print('WorldPlanQuests:'..arg2..'()') Nenue@108: WorldPlanQuests[arg2](WorldPlanQuests) Nenue@108: else Nenue@108: self:print('WorldPlanQuests:Refresh(true)') Nenue@108: WorldPlanQuests:Refresh(true) Nenue@108: end Nenue@108: end, Nenue@108: flightmap = function(arg2, extraArgs) Nenue@108: if not extraArgs then Nenue@108: return Nenue@108: end Nenue@108: Nenue@108: local val1, val2, val3 = extraArgs:match("(%S+)%s*(%S*)%s*(%S*)") Nenue@108: if arg2 == 'scale' then Nenue@108: if tonumber(val1) and tonumber(val2) and tonumber(val3) then Nenue@108: db.Config.FlightMapScalingLimits = {tonumber(val1), tonumber(val2), tonumber(val3)} Nenue@108: self:print('FlightMapFrame scaling limits updated:', unpack(db.Config.FlightMapScalingLimits)) Nenue@108: else Nenue@108: self:print('FlightMapFrame scaling limits:', unpack(db.Config.FlightMapScalingLimits)) Nenue@108: end Nenue@108: elseif arg2 == 'alpha' then Nenue@108: Nenue@108: if tonumber(val1) and tonumber(val2) and tonumber(val3) then Nenue@108: db.Config.FlightMapAlphaLimits = {tonumber(val1), tonumber(val2), tonumber(val3)} Nenue@108: self:print('FlightMapFrame alpha limits updated:', unpack(db.Config.FlightMapAlphaLimits)) Nenue@108: else Nenue@108: self:print('FlightMapFrame alpha limits:', unpack(db.Config.FlightMapAlphaLimits)) Nenue@108: end Nenue@108: end Nenue@108: Nenue@108: end, Nenue@108: filter = function(arg2) Nenue@108: if arg2 and WorldPlanSummary[arg2] then Nenue@108: self:print('WorldPlanSummary:'..arg2..'()') Nenue@108: WorldPlanSummary[arg2](WorldPlanSummary) Nenue@108: else Nenue@108: self:print('WorldPlanSummary:Refresh(true)') Nenue@108: WorldPlanSummary:Refresh(true) Nenue@108: end Nenue@108: end, Nenue@108: log = function() Nenue@108: if WorldPlanDebug:IsShown() then Nenue@108: WorldPlanDebug:SetShown(false) Nenue@108: else Nenue@108: WorldPlanDebug:SetShown(true) Nenue@108: end Nenue@108: Nenue@108: end, Nenue@108: debug = function() Nenue@108: Nenue@108: if WorldPlanData then Nenue@108: WorldPlanData.DebugEnabled = (not WorldPlanData.DebugEnabled) Nenue@108: self:print(WorldPlanData.DebugEnabled and "Debugger on." or "Debugger off.") Nenue@108: end Nenue@108: end Nenue@108: } Nenue@108: Nenue@0: Nenue@100: -- default color templates Nenue@40: db.DefaultType = { Nenue@0: a = 1, Nenue@0: r = 1, g = 1, b = 1, Nenue@0: x = 0, y = 0, Nenue@0: desaturated = true, Nenue@33: pinMask = "Interface\\Minimap\\UI-Minimap-Background", Nenue@33: rewardMask = "Interface\\Minimap\\UI-Minimap-Background", Nenue@33: texture = "Interface\\BUTTONS\\YELLOWORANGE64", Nenue@0: continent = { Nenue@40: iconWidth = 14, Nenue@40: borderWidth = 2, Nenue@36: highlightWidth = 1, Nenue@40: TagSize = 8, Nenue@36: maxAlertLevel = 0, Nenue@27: showNumber = true, Nenue@30: numberFontObject = 'WorldPlanFont' Nenue@0: }, Nenue@0: zone = { Nick@62: iconWidth = 18, Nenue@47: borderWidth = 2, Nenue@36: highlightWidth = 2, Nenue@0: TagSize = 12, Nenue@36: maxAlertLevel = 3, Nenue@27: showNumber = true, Nenue@30: numberFontObject = 'WorldPlanNumberFontThin' Nenue@0: }, Nenue@0: minimized = { Nenue@40: r = 0, g = 0, b = 0, a = 0.1, Nenue@40: iconWidth = 8, Nenue@49: borderWidth = 0, Nenue@40: alpha = 0.5, Nenue@36: highlightWidth = 0, Nenue@40: maxAlertLevel = 0, Nenue@0: NoIcon = true, Nenue@40: Nenue@40: TagSize = 8, Nenue@0: TimeleftStage = 1, Nenue@27: showNumber = false, Nenue@40: alpha = 0.1, Nenue@0: } Nenue@0: } Nenue@29: Nenue@54: Nenue@40: db.DefaultConfig = { Nenue@27: ShowAllProfessionQuests = false, Nenue@9: DisplayContinentSummary = true, Nenue@9: DisplayContinentPins = true, Nenue@9: NotifyWhenNewQuests = true, Nenue@9: EnablePins = true, Nenue@34: FadeWhileGrouped = false, Nenue@67: FlightMapAlphaLimits = {1, .7, 1}, Nenue@111: FlightMapScalingLimits = {1, 1, 1.5}, Nenue@54: --UntrackedColor = {}, Nenue@54: --TrackedColor = {}, Nenue@54: --CriteriaColor = {}, Nenue@54: --RewardColorGold = {}, Nenue@54: --RewardColorReagent = {}, Nenue@54: --RewardColorArtifactPower = {}, Nenue@54: --RewardColorCurrency = {}, Nenue@100: IgnoreTimers = {}, Nenue@9: } Nenue@9: Nenue@0: Nenue@0: Nenue@0: -- tracking menu toggler Nenue@0: local DropDown_OnClick = function(self) Nenue@0: local key = self.value Nenue@0: if key then Nenue@0: if WorldPlanData[key] then Nenue@0: WorldPlanData[key] = nil Nenue@0: else Nenue@0: WorldPlanData[key] = true Nenue@0: end Nenue@0: end Nenue@67: _G.WorldPlan:OnConfigUpdate() Nenue@0: end Nenue@0: Nenue@49: -- insert visual options into the tracking button menu Nenue@49: local DropDown_Initialize = function (self, callback, dropType) Nenue@49: if self ~= WorldMapFrameDropDown then Nenue@49: return Nenue@49: end Nenue@49: local config = WorldPlanData Nenue@49: local info = UIDropDownMenu_CreateInfo() Nenue@49: info.text = "" Nenue@49: info.isTitle = true Nenue@49: UIDropDownMenu_AddButton(info) Nenue@49: info.text = "|cFF00AAFFWorldPlan|r" Nenue@49: info.isTitle = true Nenue@49: UIDropDownMenu_AddButton(info) Nenue@49: info.isTitle = nil Nenue@49: info.disabled = nil Nenue@49: info.keepShownOnClick = true Nenue@49: info.tooltipOnButton = 1 Nenue@49: Nenue@49: info.text = "Enable" Nenue@49: info.isNotRadio = true Nenue@49: info.value = "EnablePins" Nenue@49: info.checked = config.EnablePins Nenue@49: info.tooltipTitle = "Enable World Quest Overlays" Nenue@49: info.tooltipText = "Toggle the detail layers here." Nenue@49: info.func = DropDown_OnClick Nenue@49: UIDropDownMenu_AddButton(info) Nenue@49: Nenue@49: info.text = "Display All Profession Quests" Nenue@49: info.isNotRadio = true Nenue@49: info.value = "ShowAllProfessionQuests" Nenue@49: info.checked = config.ShowAllProfessionQuests Nenue@49: info.tooltipTitle = "Hidden Quests" Nenue@49: info.tooltipText = "Display work order and profession-related quests that are skipped by the default UI." Nenue@49: info.func = DropDown_OnClick Nenue@49: UIDropDownMenu_AddButton(info) Nenue@49: Nenue@49: info.text = "Show Continent Pins" Nenue@49: info.isNotRadio = true Nenue@49: info.value = "DisplayContinentPins" Nenue@49: info.checked = config.DisplayContinentPins Nenue@49: info.tooltipTitle = "Continent Pins" Nenue@49: info.tooltipText = "Display quest pins on the continent map (may get cramped)." Nenue@49: info.func = DropDown_OnClick Nenue@49: UIDropDownMenu_AddButton(info) Nenue@49: Nenue@49: info.text = "Show Summary" Nenue@49: info.isNotRadio = true Nenue@49: info.value = "DisplayContinentSummary" Nenue@49: info.tooltipTitle = "Summary Bar" Nenue@49: info.tooltipText = "Display a summary of active world quests. Note: requires directly viewing Broken Isle and Dalaran maps to gain complete info." Nenue@49: info.checked = config.DisplayContinentSummary Nenue@49: info.func = DropDown_OnClick Nenue@49: UIDropDownMenu_AddButton(info) Nenue@49: --[[ Nenue@49: Nenue@49: info.text = "Nudge Pins" Nenue@49: info.isNotRadio = true Nenue@49: info.value = "NudgePins" Nenue@49: info.tooltipTitle = "Pin Nudging" Nenue@49: info.tooltipText = "Adjust the position of quest pins that overlap." Nenue@49: info.checked = config.NudgePins Nenue@49: info.func = DropDown_OnClick Nenue@49: UIDropDownMenu_AddButton(info) Nenue@49: Nenue@49: info.text = "Fade Whiled Grouped" Nenue@49: info.isNotRadio = true Nenue@49: info.value = "FadeWhileGrouped" Nenue@49: info.tooltipTitle = "Group Fade" Nenue@49: info.tooltipText = "Reduce pin alpha when grouped, so player dots are easier to see." Nenue@49: info.checked = config.FadeWhileGrouped Nenue@49: info.func = DropDown_OnClick Nenue@49: UIDropDownMenu_AddButton(info) Nenue@49: --]] Nenue@49: end Nenue@49: Nenue@108: local function Handler_UpdateFader(self, sinceLast, isActive) Nenue@108: Nenue@108: if isActive then Nenue@108: self.toAlpha = 1 Nenue@108: self.Backdrop:Show() Nenue@108: else Nenue@108: self.toAlpha = self.fadeOpacity Nenue@108: self.Backdrop:Hide() Nenue@108: end Nenue@108: local cAlpha = self:GetAlpha() Nenue@108: if cAlpha ~= self.toAlpha then Nenue@108: if cAlpha > self.toAlpha then Nenue@108: cAlpha = cAlpha - sinceLast*4 Nenue@108: if cAlpha <= self.toAlpha then Nenue@108: cAlpha = self.toAlpha Nenue@108: end Nenue@108: else Nenue@108: cAlpha = cAlpha + sinceLast*4 Nenue@108: if cAlpha >= self.toAlpha then Nenue@108: cAlpha = self.toAlpha Nenue@108: end Nenue@108: end Nenue@108: end Nenue@108: self:SetAlpha(cAlpha) Nenue@108: end Nenue@49: Nenue@40: function db.print(...) Nenue@0: for i = 1, select('#', ...) do Nenue@40: tinsert(db.ReportChunks, tostring(select(i, ...))) Nenue@0: end Nenue@0: end Nenue@0: Nenue@69: function db.log(msg) Nenue@69: WorldPlanData.Debug = WorldPlanData.Debug or {} Nenue@69: tinsert(WorldPlanData.Debug, msg) Nenue@69: tinsert(DEBUG_HISTORY, msg) Nenue@69: if WorldPlanDebug:IsShown() then Nenue@69: WorldPlanDebug:Update() Nenue@69: end Nenue@69: end Nenue@69: Nenue@69: WorldPlanDebugMixin = { Nenue@69: OnLoad = function(self) Nenue@69: self:SetFont("Interface\\Addons\\Devian\\font\\SourceCodePro-Regular.ttf", 13, 'NORMAL') Nenue@69: self:SetJustifyH('LEFT') Nenue@69: self:SetFading(false) Nenue@69: self:SetMaxLines(2048) Nenue@69: self.loadedMessages = 0 Nenue@69: end, Nenue@69: OnShow = function(self) Nenue@69: if self.loadedMessages < #DEBUG_HISTORY then Nenue@69: self:Update() Nenue@69: end Nenue@69: end, Nenue@69: Update = function(self) Nenue@69: for i = self.loadedMessages, #DEBUG_HISTORY do Nenue@69: self:AddMessage(DEBUG_HISTORY[i]) Nenue@69: self.loadedMessages = i Nenue@69: end Nenue@69: end , Nenue@69: OnMouseWheel = function(self, delta) Nenue@69: Nenue@69: local up = delta > 0 Nenue@69: if IsControlKeyDown() then Nenue@69: if up then self:ScrollToTop() Nenue@69: else self:ScrollToBottom() end Nenue@69: elseif IsShiftKeyDown() then Nenue@69: if up then self:PageUp() Nenue@69: else self:PageDown() end Nenue@69: else Nenue@69: if up then self:ScrollUp() Nenue@69: else self:ScrollDown() end Nenue@69: end Nenue@69: end Nenue@69: } Nenue@69: Nenue@108: Nenue@67: function WorldPlanCore:OnConfigUpdate() Nenue@67: for _, module in ipairs(db.OrderedModules) do Nenue@67: if module.OnConfigUpdate then Nenue@67: module:OnConfigUpdate() Nenue@67: end Nenue@67: end Nenue@67: db.currentMapID = nil Nenue@67: db.BountyUpdate = true Nenue@67: self:SetCurrentMap('CONFIG_UPDATE') Nenue@67: self:Refresh() Nenue@67: end Nenue@67: Nenue@40: function WorldPlanCore:print(...) db.print(...) end Nenue@40: Nenue@40: function WorldPlanCore:AddHandler (frame) Nenue@40: if not db.LoadedModules[frame] then Nenue@40: print('|cFFFFFF00'..self:GetName()..':AddHandler()', frame:GetName(), self.initialized) Nenue@40: db.LoadedModules[frame] = true Nenue@40: tinsert(db.OrderedModules, frame) Nenue@40: Nenue@40: if frame.defaults then Nenue@40: db.DefaultConfig[frame:GetName()] = frame.defaults Nenue@40: end Nenue@108: frame.UpdateAlpha = Handler_UpdateFader Nenue@40: frame.owningFrame = self Nenue@40: else Nenue@40: Nenue@40: print('|cFFFF4400'..self:GetName()..':AddHandler()', frame:GetName()) Nenue@30: end Nenue@30: end Nenue@30: Nenue@36: function WorldPlanCore:OnLoad () Nenue@29: Nenue@29: self.Types = setmetatable({}, { Nenue@29: __newindex = function(t, k, v) Nenue@29: if type(v) == 'table' then Nenue@30: print('adding owner', k) Nenue@30: v = setmetatable(v, { Nenue@30: __newindex = function(t2,k2,v2) Nenue@30: if type(v2) == 'table' then Nenue@40: --print('adding type', k2) Nenue@30: v2 = setmetatable(v2, {__index = function(t3,k3) Nenue@30: --print('##deferring to default key', k3) Nenue@40: return db.DefaultType[k3] Nenue@30: end}) Nenue@30: end Nenue@30: rawset(t2,k2,v2) Nenue@29: end}) Nenue@29: end Nenue@29: rawset(t,k,v) Nenue@29: end Nenue@29: }) Nenue@29: Nenue@30: self.Types[self] = {} Nenue@29: Nenue@29: for index, color in pairs(ITEM_QUALITY_COLORS) do Nenue@30: self:AddTypeInfo(self, index, { r = color.r, g = color.g, b = color.b, hex = color.hex, }) Nenue@29: end Nenue@29: Nenue@0: Nenue@40: db.print('v'..WP_VERSION) Nenue@40: Nenue@0: Nenue@0: self:RegisterEvent("QUESTLINE_UPDATE") Nenue@0: self:RegisterEvent("QUEST_LOG_UPDATE") Nenue@0: self:RegisterEvent("WORLD_MAP_UPDATE") Nenue@40: self:RegisterEvent("SPELLS_CHANGED") Nenue@40: self:RegisterEvent('PLAYER_ENTERING_WORLD') Nenue@0: self:RegisterEvent("WORLD_QUEST_COMPLETED_BY_SPELL") Nenue@0: self:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED") Nenue@0: self:RegisterEvent("SKILL_LINES_CHANGED") Nenue@0: self:RegisterEvent("ARTIFACT_XP_UPDATE") Nenue@0: self:RegisterEvent("ADDON_LOADED") Nenue@40: self:RegisterEvent("PLAYER_LOGIN") Nenue@40: --self:SetParent(WorldMapFrame) Nenue@110: Nenue@110: Nenue@111: --ofunc[WorldMap_SetupWorldQuestButton] = WorldMap_SetupWorldQuestButton Nenue@111: --WorldMap_SetupWorldQuestButton = nop Nenue@0: end Nenue@0: Nenue@36: function WorldPlanCore:OnShow() Nenue@40: --print(self:GetName()..':OnShow()') Nenue@40: --hooksecurefunc(self, 'SetScript', function(...) self:print('|cFFFFFF00'..self:GetName()..':SetScript()|r', ...) end) Nenue@27: end Nenue@27: Nenue@41: local BROKEN_ISLE_MAPS = { Nenue@41: [1007] = true, -- Broken Isle Nenue@41: [1014] = true, -- Dalaran Nenue@41: [1021] = true, -- Broken Shoree Nenue@41: [1024] = true, -- Highmountain Nenue@43: [1015] = true, -- Azsuna Nenue@41: [1017] = true, -- Azsuna Nenue@41: [1018] = true, -- Val'Sharah Nenue@41: [1033] = true, -- Suramar Nenue@41: [1077] = true, -- Dreamgrove Nenue@41: [1096] = true, -- Eye of Azshara Nenue@41: [1080] = true, -- Thunder Totem Nenue@41: [1072] = true, -- True Shot Lodge, Nenue@40: Nenue@41: } Nenue@41: Nenue@67: function WorldPlanCore:SetCurrentMap(event) Nenue@68: local mapAreaID, isContinent = GetCurrentMapAreaID() Nenue@56: if not mapAreaID then Nenue@56: return Nenue@56: end Nenue@67: print('SetCurrentMap()', event, mapAreaID) Nenue@41: local isBrokenIsle = BROKEN_ISLE_MAPS[mapAreaID] Nenue@68: Nenue@68: local mapFileName, textureHeight, textureWidth, isMicroDungeon, microDungeonMapName = GetMapInfo() Nenue@41: Nenue@67: local isMapOpen = WorldMapFrame:IsShown() Nenue@93: local isNewMap = (mapAreaID ~= db.currentMapID) or (isMapOpen ~= db.isMapOpen) or (db.isMicroDungeon ~= isMicroDungeon) or (db.isContinentMap ~= isContinent) Nenue@68: Nenue@68: db.isMicroDungeon = isMicroDungeon Nenue@68: db.isMapOpen = isMapOpen Nenue@41: db.currentMapID = mapAreaID Nenue@54: db.isContinentMap = isContinent Nenue@67: db.isBrokenIsle = isBrokenIsle Nenue@40: Nenue@41: for _, module in ipairs(db.OrderedModules) do Nenue@41: if module.OnMapInfo then Nenue@75: if module.Debug then Nenue@75: module:Debug(event) Nenue@75: end Nenue@41: print(' |cFF00FFFF'..module:GetName() .. ':OnMapInfo()|r') Nenue@67: module:OnMapInfo(isBrokenIsle, isContinent, mapAreaID, isNewMap, isMapOpen) Nenue@41: end Nenue@41: end Nenue@40: end Nenue@40: Nenue@36: function WorldPlanCore:OnEvent (event, ...) Nenue@40: Nenue@40: print('|cFF00FF88'..self:GetName().. ':OnEvent()|r', event, GetTime(), 'init:', self.initialized) Nenue@0: if event == 'ADDON_LOADED' then Nenue@0: Nenue@0: if IsLoggedIn() and not self.initialized then Nenue@0: self:Setup() Nenue@0: end Nenue@27: else Nenue@41: if (event == 'WORLD_MAP_UPDATE') or (event == 'PLAYER_ENTERING_WORLD') or (event == 'PLAYER_LOGIN') then Nenue@40: print('|cFFFF4400currentMapID =', db.currentMapID, ...) Nenue@93: if event == 'PLAYER_ENTERING_WORLD' then Nenue@93: -- start from scratch Nenue@93: db.isMicroDungeon = nil Nenue@93: db.isMapOpen = nil Nenue@93: db.currentMapID = nil Nenue@93: db.isContinentMap = nil Nenue@93: db.isBrokenIsle = nil Nenue@93: end Nenue@67: Nenue@67: Nenue@75: self:SetCurrentMap(event .. ' ' .. GetTime()) Nenue@0: end Nenue@0: end Nenue@0: end Nenue@0: Nenue@33: function WorldPlanCore:OnNext(func) Nenue@34: Nenue@34: Nenue@33: tinsert(self.TaskQueue, func) Nenue@35: --self:print('|cFF00FF00adding scheduled task #', #self.TaskQueue) Nenue@33: end Nenue@33: Nenue@33: function WorldPlanCore:OnUpdate() Nenue@33: if #self.TaskQueue >= 1 then Nenue@34: local func = tremove(self.TaskQueue, 1) Nenue@34: --self:print('|cFF00FF00running scheduled task #', #self.TaskQueue) Nenue@33: func() Nenue@33: end Nenue@33: Nenue@33: if self.isStale then Nenue@40: -- these need to happen in load order Nenue@40: for i, module in ipairs(db.OrderedModules) do Nenue@40: if module:IsVisible() and module.isStale then Nenue@33: print('|cFF00FF00internal '..module:GetName()..':Refresh()|r') Nenue@33: module:Refresh() Nenue@33: end Nenue@33: end Nenue@40: self.isStale = nil Nenue@33: end Nenue@40: Nenue@40: if #db.ReportChunks >= 1 then Nenue@40: Nenue@40: DEFAULT_CHAT_FRAME:AddMessage("|cFF0088FF"..addonFileName.."|r: " .. table.concat(db.ReportChunks, ', ')) Nenue@40: wipe(db.ReportChunks) Nenue@40: end Nenue@40: Nick@63: if self.dataFlush then Nick@63: self:FireCallbacks() Nick@63: end Nick@63: Nenue@33: end Nenue@0: Nenue@36: function WorldPlanCore:Setup () Nenue@40: print('|cFFFFFF00'..self:GetName()..':Setup()|r') Nenue@40: Nenue@0: if not WorldPlanData then Nenue@40: WorldPlanData = {key = 0} Nenue@0: end Nenue@69: Nenue@69: -- debug info Nenue@0: WorldPlanData.key = (WorldPlanData.key or 0) + 1 Nenue@69: WorldPlanData.Debug = WorldPlanData.Debug or {} Nenue@100: local guid = UnitGUID('player') Nenue@100: WorldPlanData.IgnoreTimers = WorldPlanData.IgnoreTimers or {} Nenue@100: WorldPlanData.IgnoreTimers[guid] = WorldPlanData.IgnoreTimers[guid] or {} Nenue@100: Nenue@69: for _, msg in ipairs(WorldPlanData.Debug) do Nenue@69: tinsert(DEBUG_HISTORY, msg) Nenue@69: end Nenue@69: tinsert(DEBUG_HISTORY, '--SESSION BREAK--') Nenue@69: wipe(WorldPlanData.Debug) Nenue@69: Nenue@100: db.IgnoreTimers = WorldPlanData.IgnoreTimers Nenue@40: db.Config = WorldPlanData Nenue@40: for k,v in pairs(db.DefaultConfig) do Nenue@18: --[===[@non-debug@ Nenue@40: if not db.Config[k] then Nenue@40: db.Config[k] = v Nenue@18: end Nenue@18: Nenue@18: --@end-non-debug@]===] Nenue@18: --@debug@ Nenue@40: db.Config[k] = v Nenue@18: --@end-debug@ Nenue@9: end Nenue@9: Nenue@0: Nenue@40: db.currentMapID = GetCurrentMapAreaID() Nenue@40: Nenue@40: for i, module in ipairs(db.OrderedModules) do Nenue@40: db.Config[module:GetName()] = db.Config[module:GetName()] or {} Nenue@0: if module.Setup then module:Setup() end Nenue@0: if not module.RegisterEvent then Nenue@0: module.RegisterEvent = self.RegisterEvent Nenue@0: end Nenue@49: if module.OnConfigUpdate then Nenue@49: module:OnConfigUpdate() Nenue@49: end Nenue@0: end Nenue@40: Nenue@40: Nenue@0: self.initialized = true Nenue@0: Nenue@49: hooksecurefunc("UIDropDownMenu_Initialize", DropDown_Initialize) Nenue@33: Nenue@33: hooksecurefunc("WorldMapTrackingOptionsDropDown_OnClick", function(button) Nenue@33: print("|cFF0088FFWorldMapTrackingOptionsDropDown_OnClick|r") Nenue@33: local value = button.value Nenue@33: if (value == "worldQuestFilterOrderResources" or value == "worldQuestFilterArtifactPower" or Nenue@33: value == "worldQuestFilterProfessionMaterials" or value == "worldQuestFilterGold" or Nenue@33: value == "worldQuestFilterEquipment") then Nenue@33: self:Refresh(true) Nenue@33: end Nenue@33: end) Nenue@40: Nenue@40: Nenue@40: hooksecurefunc("WorldMapFrame_Update", function() Nenue@40: print('|cFFFF4400WorldMapFrame_Update|r') Nenue@41: for _,module in ipairs(db.OrderedModules) do Nenue@41: if module.OnWorldMapFrameUpdate then Nenue@41: print(' |cFFFF4400'..module:GetName()..'|r') Nenue@41: module:OnWorldMapFrameUpdate() Nenue@41: end Nenue@41: end Nenue@40: end) Nenue@40: Nenue@40: SLASH_WORLDPLAN1 = "/worldplan" Nenue@40: SLASH_WORLDPLAN2 = "/wp" Nenue@40: Nenue@40: Nenue@40: Nenue@108: Nenue@40: SlashCmdList.WORLDPLAN = function(args) Nenue@40: local arg1, arg2, extraArgs = args:match("(%S+)%s*(%S*)%s*(.*)") Nenue@40: Nenue@108: if db.CLTriggers[arg1] then Nenue@108: db.CLTriggers[arg1](arg2, extraArgs) Nenue@40: else Nenue@40: self:print('Refreshing data.') Nenue@40: self:Refresh(true) Nenue@40: end Nenue@40: Nenue@40: end Nenue@0: end Nenue@0: Nenue@40: -- registers a template table Nenue@36: function WorldPlanCore:AddTypeInfo(owner, id, info) Nenue@30: self.Types[owner] = self.Types[owner] or {} Nenue@30: self.Types[owner][id] = info Nenue@30: print('Type('..owner:GetName()..')('..id..') = '.. tostring(info)) Nenue@30: end Nenue@30: Nenue@40: -- recall a template table, with situational details filled in Nenue@36: function WorldPlanCore:GetTypeInfo(owner, typeID) Nenue@29: local info, extraInfo Nenue@30: if not owner then Nenue@30: --print('## deferring to default type list') Nenue@30: else Nenue@30: --print('## pulling for', owner:GetName(), 'id =', typeID) Nenue@30: end Nenue@30: Nenue@30: owner = owner or self Nenue@30: if (not typeID) or (not self.Types[owner][typeID]) then Nenue@30: --print('## sending list default') Nenue@40: info = db.DefaultType Nenue@29: else Nenue@30: --print('## sent list definition', typeID) Nenue@30: info = self.Types[owner][typeID] Nenue@29: end Nenue@29: Nenue@40: local subType = 'continent' Nenue@40: if ( Nenue@40: FlightMapFrame Nenue@40: and FlightMapFrame:IsVisible() Nenue@40: and FlightMapFrame:IsZoomedIn() Nenue@40: ) or ( Nenue@40: not db.isContinentMap Nenue@40: ) or ( Nenue@40: db.useContinentType == false Nenue@40: ) then Nenue@40: subType = 'zone' Nenue@40: end Nenue@29: Nenue@40: return info, info[subType] or db.DefaultType[subType] Nenue@29: end Nenue@29: Nenue@29: Nenue@36: function WorldPlanCore:Refresh (forced) Nenue@30: print('|cFFFFFF00'..self:GetName()..':Refresh()|r forced:', forced, 'init:', self.initialized) Nenue@9: if not self.initialized then Nenue@9: return Nenue@9: end Nenue@9: Nenue@40: for i, module in ipairs(db.OrderedModules) do Nenue@0: if module.Refresh then Nenue@33: print('|cFF00FF00external '..module:GetName()..':Refresh()|r') Nenue@75: module:Refresh('WORLDPLAN_REFRESH') Nenue@0: end Nenue@0: end Nenue@40: Nenue@40: self.isStale = nil Nenue@0: end Nenue@0: Nenue@0: Nenue@30: -------------------------------------------------------------------------------------------------------------------- Nenue@35: ------------------- Nick@63: function WorldPlanCore:GetQuestPins(zoneID) Nick@63: return db.UsedPins Nick@63: end Nick@63: function WorldPlanCore:RegisterDataCallback(func) Nick@63: self.callbacks = self.callbacks or {} Nick@63: self.callbacks[func] = func Nick@63: end Nick@63: function WorldPlanCore:FireCallbacks() Nick@64: self.callbacks = self.callbacks or {} Nick@63: for func in pairs(self.callbacks) do Nick@63: func() Nick@63: end Nick@63: self.dataFlush = nil Nick@63: end Nenue@0: Nenue@102: function WorldPlanCore:SetHook(base, arg1, arg2) Nenue@102: if type(base) == 'table' then Nenue@102: end Nenue@102: Nenue@102: end Nenue@0: Nenue@0: Nenue@0: Nenue@0: Nenue@35: --%end-debug%