Mercurial > wow > worldplan
diff WorldPlan.lua @ 30:8cb750e79952
WorldPlan:
- Reworking filters to utilize newly added CVars
author | Nenue |
---|---|
date | Fri, 28 Oct 2016 14:06:07 -0400 |
parents | c1612c2c1840 |
children | d0114b51cdea |
line wrap: on
line diff
--- a/WorldPlan.lua Thu Oct 27 13:50:56 2016 -0400 +++ b/WorldPlan.lua Fri Oct 28 14:06:07 2016 -0400 @@ -1,14 +1,8 @@ --- Veneer -- WorldPlan.lua -- Created: 8/16/2016 8:19 AM -- %file-revision% ---[[ - Summary: - Adds reward icons to the world quest POI markers, and adds said markers to the continent map. - Issues: - Dalaran quests aren't visible until that map has been specifically viewed by the player. ---]] +local addonName, db = ... local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark" local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up" @@ -22,13 +16,18 @@ WorldPlanCore = { defaults = {}, - + modules = {}, +} +WorldPlanQuestsMixin = { + QuestsByZone = {}, + QuestsByID = {}, + freePins = {}, } WorldPlanPOIMixin = {} -WorldPlanFilterPinMixin = {} +WorldPlanFilterPinMixin = setmetatable({ QuestsByID = {}, freePins = {} }, {__tostring = function() return 'QuestHandler' end}) local WorldPlanFlightMapMixin = setmetatable({}, {__tostring = function() return 'FlightMapHandler' end}) -local WorldQuests = setmetatable({ QuestsByID = {}, freePins = {} }, {__tostring = function() return 'QuestHandler' end}) -local FilterBar = setmetatable({ SummaryHeaders = {} }, {__tostring = function() return 'FilterBar' end}) +local WorldQuests = WorldPlanQuestsMixin + local WorldPlan = WorldPlanCore local QuestPOI = WorldPlanPOIMixin @@ -62,13 +61,6 @@ local MC_GetNumZones, MC_GetZoneInfo = C_MapCanvas.GetNumZones, C_MapCanvas.GetZoneInfo -local PinBaseIndex = 1600 -local BROKEN_ISLES_ID, DALARAN_ID, AZSUNA_ID, VALSHARAH_ID, HIGHMOUNTAIN_ID, STORMHEIM_ID, SURAMAR_ID, EOA_ID = 1007, 1014, 1015,1018, 1024, 1017, 1033, 1096 - --- maps where we do our own anchors -local CONTINENT_MAPS = { [BROKEN_ISLES_ID] = BROKEN_ISLES_ID, } -local WORLD_QUEST_MAPS = { [DALARAN_ID] = 'Dalaran70', [AZSUNA_ID] = 'Azsuna', [VALSHARAH_ID] = "Val'sharah", - [HIGHMOUNTAIN_ID] = 'Highmountain', [STORMHEIM_ID] = 'Stormheim', [SURAMAR_ID] = 'Suramar', [EOA_ID] = 'EyeOfAszhara', } -- default color templates local ARTIFACT_COLOR = ITEM_QUALITY_COLORS[LE_ITEM_QUALITY_ARTIFACT] local MONEY_COLOR = {hex ='|cFFFFFF00', r=1, g=1, b=0} @@ -82,12 +74,13 @@ rewardMask = POI_BORDER_MASK, texture = POI_BORDER_FILL, continent = { - PinSize = 18, - Border = 3, - TrackingBorder = 2, + PinSize = 14, + Border = 2, + TrackingBorder = 1, TagSize = 6, - TimeleftStage = 3, + TimeleftStage = 0, showNumber = true, + numberFontObject = 'WorldPlanFont' }, zone = { PinSize = 22, @@ -96,11 +89,12 @@ TagSize = 12, TimeleftStage = 3, showNumber = true, + numberFontObject = 'WorldPlanNumberFontThin' }, minimized = { PinSize = 4, - Border = 1, - TrackingBorder = 2, + Border = 0, + TrackingBorder = 1, NoIcon = true, TimeleftStage = 1, showNumber = false, @@ -165,12 +159,6 @@ local hasNewQuestPins local isContinentMap local numPins = 0 -local QuestsByZone = {} -local QuestsByFaction = {} -local QuestsByReward = {} -local QuestsByTag = {} -local QuestsByID = {} -local QuestPositions = {} local FilterInclusions = {rewardType = {}, worldQuestType = {}, factionID = {}} local NotificationTypes = {} local ZoneInfo = {} @@ -183,8 +171,6 @@ local notifyPlayed local scanner, wmtt, WorldMapPOIFrame -WorldPlanCore.QuestsByID = QuestsByID -WorldPlanCore.QuestsByZone = QuestsByZone local tasksQueue = {} local function OnNext (func) @@ -203,17 +189,6 @@ tinsert(tasksQueue, func) end --- combines templates -local function DoMixins(frame,...) - for i = 1, select('#', ...) do - for k,v in pairs(select(i,...)) do - frame[k] = v - end - end - return frame -end - - -- update a masked texture without messing up its blending mask local SetMaskedTexture = function(region, file, mask) mask = mask or POI_BORDER_MASK @@ -243,30 +218,42 @@ DEFAULT_CHAT_FRAME:AddMessage("|cFF0088FFWorldPlan|r: " .. msg) end +local current_type_owner +function WorldPlan:AddHandler (frame, defaults) + print('|cFFFFFF00'..self:GetName()..':AddHandler()', frame:GetName()) + tinsert(self.modules, frame) + self.defaults[frame] = defaults + frame.GetTypeInfo = function(frame, typeID) + return self:GetTypeInfo(frame, typeID) + end +end + function WorldPlan:OnLoad () self.Types = setmetatable({}, { __newindex = function(t, k, v) - print('adding type', k) if type(v) == 'table' then - v = setmetatable(v, {__index = function(t,k) - print('##deferring to default key', k) - return DEFAULT_TYPE[k] + print('adding owner', k) + v = setmetatable(v, { + __newindex = function(t2,k2,v2) + if type(v2) == 'table' then + print('adding type', k2) + v2 = setmetatable(v2, {__index = function(t3,k3) + --print('##deferring to default key', k3) + return DEFAULT_TYPE[k3] + end}) + end + rawset(t2,k2,v2) end}) end rawset(t,k,v) end }) - local rgbWhite = {1, 1, 1} - self.Types[REWARD_REAGENT] = { r = 0, g = 1, b = 1 } - self.Types[REWARD_ARTIFACT_POWER] = { r = 1, g = .25, b = .5, hasNumeric = true, numberRGB = rgbWhite } - self.Types[REWARD_GEAR] = { r = .1, g = .2, b = 1 } - self.Types[REWARD_CURRENCY] = { r = 1, g = 1, b = 0, hasNumeric = true, numberRGB = rgbWhite, } - self.Types[REWARD_CASH] = { r = 0, g = 0, b = 0, } + self.Types[self] = {} for index, color in pairs(ITEM_QUALITY_COLORS) do - self.Types[(index+127)] = { r = color.r, g = color.g, b = color.b, hex = color.hex, } + self:AddTypeInfo(self, index, { r = color.r, g = color.g, b = color.b, hex = color.hex, }) end WorldPlan = self @@ -285,16 +272,12 @@ self:RegisterEvent("ARTIFACT_XP_UPDATE") self:RegisterEvent("ADDON_LOADED") self:SetParent(WorldMapFrame) - - WorldPlan.modules = { - WorldQuests, FilterBar, WorldPlanFlightMapMixin, - } end function WorldPlan:OnShow() print(self:GetName()..':OnShow()') if self.isStale then - self:RefreshAll() + self:Refresh() end end @@ -314,7 +297,8 @@ end elseif event == 'WORLD_MAP_UPDATE' then self.currentMapID = GetCurrentMapAreaID() - self:RefreshAll() + print('|cFFFF4400currentMapID =', self.currentMapID) + self:Refresh() else for i, module in ipairs(self.modules) do if module.OnEvent then @@ -360,23 +344,36 @@ hooksecurefunc("UIDropDownMenu_Initialize", self.OnDropDownInitialize) end -function WorldPlan:GetTypeInfo(typeID) +function WorldPlan:AddTypeInfo(owner, id, info) + self.Types[owner] = self.Types[owner] or {} + self.Types[owner][id] = info + print('Type('..owner:GetName()..')('..id..') = '.. tostring(info)) +end + +function WorldPlan:GetTypeInfo(owner, typeID) local info, extraInfo - if (not typeID) or (not self.Types[typeID]) then - qprint('## sent default type') + if not owner then + --print('## deferring to default type list') + else + --print('## pulling for', owner:GetName(), 'id =', typeID) + end + + owner = owner or self + if (not typeID) or (not self.Types[owner][typeID]) then + --print('## sending list default') info = DEFAULT_TYPE else - qprint('## sent defined type', typeID) - info = self.Types[typeID] + --print('## sent list definition', typeID) + info = self.Types[owner][typeID] end if isContinentMap then extraInfo = info.continent - qprint('### continent subtype', extraInfo) + --print('### continent subtype', extraInfo) else extraInfo = info.zone - qprint('### zone subtype', extraInfo) + --print('### zone subtype', extraInfo) end return info, extraInfo end @@ -413,7 +410,8 @@ end end -function WorldPlan:RefreshAll (forced) +function WorldPlan:Refresh (forced) + print('|cFFFFFF00'..self:GetName()..':Refresh()|r forced:', forced, 'init:', self.initialized) if not self.initialized then return end @@ -517,11 +515,22 @@ UIDropDownMenu_AddButton(info) end +-------------------------------------------------------------------------------------------------------------------- +-------------------------------------------------------------------------------------------------------------------- + +local PinBaseIndex = 1600 +local BROKEN_ISLES_ID, DALARAN_ID, AZSUNA_ID, VALSHARAH_ID, HIGHMOUNTAIN_ID, STORMHEIM_ID, SURAMAR_ID, EOA_ID = 1007, 1014, 1015,1018, 1024, 1017, 1033, 1096 + +-- maps where we do our own anchors +local CONTINENT_MAPS = { [BROKEN_ISLES_ID] = BROKEN_ISLES_ID, } +local WORLD_QUEST_MAPS = { [DALARAN_ID] = 'Dalaran70', [AZSUNA_ID] = 'Azsuna', [VALSHARAH_ID] = "Val'sharah", + [HIGHMOUNTAIN_ID] = 'Highmountain', [STORMHEIM_ID] = 'Stormheim', [SURAMAR_ID] = 'Suramar', [EOA_ID] = 'EyeOfAszhara', } + function WorldQuests:Setup() for mapID, mapName in pairs(WORLD_QUEST_MAPS) do - QuestsByZone[mapID] = {} + self.QuestsByZone[mapID] = {} end @@ -542,8 +551,33 @@ end +local defaults = {} +function WorldQuests:OnLoad() + print('|cFF00FF88'..self:GetName()..':OnLoad') + + WorldPlan:AddHandler(self, defaults) + + local rgbWhite = {1, 1, 1} + WorldPlan:AddTypeInfo(self, REWARD_REAGENT, { r = 0, g = 1, b = 1 }) + WorldPlan:AddTypeInfo(self, REWARD_ARTIFACT_POWER, { r = 1, g = .25, b = .5, hasNumeric = true, numberRGB = rgbWhite }) + WorldPlan:AddTypeInfo(self, REWARD_GEAR, { r = .1, g = .2, b = 1 }) + WorldPlan:AddTypeInfo(self, REWARD_CURRENCY, { r = 1, g = 1, b = 0, hasNumeric = true, numberRGB = {1,1,0}, }) + WorldPlan:AddTypeInfo(self, REWARD_CASH, { r = 0, g = 0, b = 0, }) + + for areaID, fileName in pairs(WORLD_QUEST_MAPS) do + self.QuestsByZone[areaID] = {} + end + + self:RegisterEvent('QUEST_LOG_UPDATE') + self:RegisterEvent('WORLD_QUEST_COMPLETED_BY_SPELL') + self:RegisterEvent('SKILL_LINES_CHANGED') + + +end + function WorldQuests:OnEvent (event, ...) - print('|cFFFFFF00'..tostring(self)..':OnEvent()'..event..'|r', GetTime(), ...) + local print = wqprint + print('|cFFFFFF00'..self:GetName()..':OnEvent()'..event..'|r', GetTime(), ...) if event == 'QUEST_LOG_UPDATE' then local questID, added = ... if questID and added then @@ -552,23 +586,27 @@ else self:RefreshData() end - print('WorldMapFrame', WorldMapFrame:IsVisible(), 'doRefresh:', hasNewQuestPins) - if WorldMapFrame:IsVisible() and hasNewQuestPins then - self:Refresh(true) - end - + print('WorldMapFrame', WorldMapFrame:IsVisible(), 'hasUpdates:', self.hasUpdate) elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then local questID = ... - if questID and QuestsByID[questID] then - self:ReleasePin(QuestsByID[questID]) + if questID and self.QuestsByID[questID] then + self:ReleasePin(self.QuestsByID[questID]) end elseif event == 'SKILL_LINES_CHANGED' then + self.hasUpdate = true + end +end + +function WorldQuests:OnUpdate() + if self.hasUpdate then + wqprint('|cFF00FF00pushing update') self:Refresh(true) end end + local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation function WorldQuests:AcquirePin (questID, mapID) - local pin = QuestsByID[questID] + local pin = self.QuestsByID[questID] local isNew = false if not pin then isNew = true @@ -582,6 +620,9 @@ pin = CreateFrame('Frame', name, WorldMapPOIFrame, 'WorldPlanQuestPin') pin:SetFrameStrata('HIGH') + pin.GetTypeInfo = function(frame, typeID) + return self:GetTypeInfo(typeID) + end NumPinFrames = NumPinFrames + 1 --pin.iconBorder:SetVertexColor(0,0,0,1) end @@ -593,12 +634,12 @@ pin.questID = questID pin.worldQuest = true - QuestsByID[questID] = pin + self.QuestsByID[questID] = pin else --print('|cFF00FF00Using', pin:GetName()) end mapID = mapID or TQ_GetQuestZoneID(questID) - QuestsByZone[mapID][questID] = pin + self.QuestsByZone[mapID][questID] = pin return pin, isNew end @@ -608,15 +649,12 @@ local id = pin.questId if id then - QuestsByID[id] = nil - for i, zone in pairs(QuestsByZone) do + self.QuestsByID[id] = nil + for i, zone in pairs(self.QuestsByZone) do print('-', i, zone[i]) zone[id] = nil end end - if pin.factionID then - QuestsByFaction[pin.factionID][id] = nil - end pin:Hide() pin:ClearAllPoints() tinsert(self.freePins, pin) @@ -632,48 +670,49 @@ -- info not available yet return end + + print('|cFF00FF88'..self:GetName()..':RefreshData()|r', 'map:', mapID, 'realMap:', GetCurrentMapAreaID()) + if mapID == BROKEN_ISLES_ID then self.hasUpdate = false - print('|cFF00FFFFRefreshQuestsForMap|r', mapID, GetMapNameByID(mapID), superTrackedID) + print('|cFF00FFFFContinent:|r', mapID, GetMapNameByID(mapID), superTrackedID) self.fullSearch = true for i = 1, MC_GetNumZones(mapID) do local submapID, name, depth = MC_GetZoneInfo(mapID, i) self:RefreshData(submapID) end self.fullSearch = nil - elseif QuestsByZone[mapID] then + elseif self.QuestsByZone[mapID] then local taskInfo = TQ_GetQuestsForPlayerByMapID(mapID) - local quest = QuestsByZone[mapID] local numQuests = 0 if taskInfo and #taskInfo >= 1 then - print('|cFF00FFFFRefreshQuestsForMap|r', mapID, GetMapNameByID(mapID), #taskInfo) - wipe(QuestsByZone[mapID]) + print('|cFF00FFFF Zone:|r', mapID, GetMapNameByID(mapID), #taskInfo) + wipe(self.QuestsByZone[mapID]) ZoneInfo[mapID] = taskInfo + qprint('|cFFFF4400START of', GetMapNameByID(mapID)) for taskID, info in pairs(taskInfo) do - print('-', taskID) local questID = info.questId info.mapID = mapID local questPOI = self:AcquirePin(questID, mapID) - local hasUpdate, isPending = questPOI:RefreshData(taskInfo) + local hasUpdate, isPending = questPOI:RefreshData(info) self.hasUpdate = (self.hasUpdate or hasUpdate) self.isPending = (self.isPending or isPending) numQuests = numQuests + 1 end + qprint('|cFFFF4400END of', GetMapNameByID(mapID)) end end - print(' hasUpdate:', self.hasUpdate, 'isPending:', self.isPending, 'timer:', self.OnNext) - if self.hasUpdate then - self.OnNext = self.OnNext or C_Timer.NewTimer(0.25, function() - self:Refresh(true) - self.OnNext = nil - end) + if not self.fullSearch then + print(' hasUpdate:', self.hasUpdate, 'isPending:', self.isPending, 'timer:', (self.OnNext and 'waiting' or '')) + end + end function WorldQuests:Refresh(forced) local print = wqprint - print('|cFF00FF88'..tostring(self)..':Refresh()|r') + print('|cFF00FF88'..self:GetName()..':Refresh()|r') if not WorldMapPOIFrame:IsVisible() then return end @@ -690,11 +729,8 @@ -- prepares elements for a map update function WorldQuests:Reset () local print = wqprint - print('|cFF00FF88'..tostring(self)..':Reset()|r') - wipe(QuestPositions) - wipe(QuestsByReward) - wipe(QuestsByTag) - for questID, pin in pairs(QuestsByID) do + print('|cFF00FF88'..self:GetName()..':Reset()|r') + for questID, pin in pairs(self.QuestsByID) do pin.used = nil end end @@ -715,7 +751,7 @@ print('not updating map for reasons') return end - print('|cFF88FF00'..tostring(self)..':UpdateAnchors|r', submapID, GetMapNameByID(submapID), 'pin count:', numPins) + print('|cFF88FF00'..self:GetName()..':UpdateAnchors|r', submapID, GetMapNameByID(submapID), 'pin count:', numPins) local numZones = MC_GetNumZones(submapID) if numZones then for i = 1, numZones do @@ -723,12 +759,13 @@ self:UpdateAnchors(subMapID) end end - local pins = QuestsByZone[submapID] + local pins = self.QuestsByZone[submapID] if pins then local hostFrame = WorldMapPOIFrame local mapWidth, mapHeight = hostFrame:GetSize() for questID, pin in pairs(pins) do + pin.hasUpdate = true pin:IsShowable() if pin.used then pin:SetFrameLevel(PinBaseIndex+ (pin.whiteListed and 200 or 0) +numPins) @@ -758,10 +795,11 @@ local fadeGrouped = (db.FadeWhileGrouped and IsInGroup()) numPins = 0 - for questID, pin in pairs(QuestsByID) do + for questID, pin in pairs(self.QuestsByID) do -- can we show it? if showQuestPOI and (pin.used) then + pin.hasUpdate = true if fadeGrouped then pin:SetAlpha(0.25) else @@ -790,9 +828,8 @@ -- trap new but animating pins here else -- hard show existing pin - print('refresh #', questID, 'filtered:', pin.filtered) - pin.hasUpdate = true - pin:Show(true) + print('refresh #', questID, 'filtered:', pin.filtered, 'hasUpdate', pin.hasUpdate) + pin:Show() tinsert(debug_show,questID) end else @@ -809,6 +846,7 @@ print(' hiding:', table.concat(debug_hide, ',' )) hasNewQuestPins = nil notifyPlayed = nil + self.hasUpdate = nil end -- data provider manipulations for the taxi map @@ -833,7 +871,7 @@ for pin in self:EnumerateAllPins() do if pin.worldQuest then --print('got pin #', pin.questID) - local wp = QuestsByID[pin.questID] + local wp = self.QuestsByID[pin.questID] if wp then wp:ClearAllPoints() wp:SetParent(FlightMapFrame.ScrollContainer) @@ -873,24 +911,12 @@ print(' |cFFFF4400IsShowable()|r', self.title) - local isIncluded - for filterKey, filterValues in pairs(WorldPlan.UsedFilters) do - local controlValue = self[filterKey] - if controlValue then - local filterType = filterValues[controlValue] - if filterType == true then - isIncluded = true - print(' include? ', filterKey, controlValue, filterType) - end - end - self.filtered = (not isIncluded) + if not self.passesBlizzFilters then + self.filtered = true end - - if not TQ_IsActive(self.questID) then self.used = nil - end - if qType == LE_QUEST_TAG_TYPE_PROFESSION then + elseif qType == LE_QUEST_TAG_TYPE_PROFESSION then if not (db.ShowAllProfessionQuests or (self.tradeskillLineIndex and GetProfessionInfo(self.tradeskillLineIndex))) then self.used = nil end @@ -904,11 +930,10 @@ --- Fixes icons upon size update function QuestPOI:UpdateSize (style, subStyle) - self.style = self.style or POI_DEFAULT_TYPE style = style or self.style subStyle = subStyle or self.subStyle - qprint('|cFF00FF88'..self:GetName()..'|r:UpdateSize()', style, subStyle) + --qprint('|cFF00FF88'..self:GetName()..'|r:UpdateSize()', style, subStyle) self.currentWidth = subStyle.PinSize self.borderSize = subStyle.Border @@ -966,242 +991,11 @@ end -function FilterBar:OnEvent(event) - if event == 'QUEST_LOG_UPDATE' then - self:Refresh() - end -end - -function FilterBar:PassesFilterSet(filterKey, pin) - local passesFilter = true - for filterKey, filters in pairs(QuestFilters) do - for rewardType, value in pairs(QuestFilters[filterKey]) do - if value == 1 and rewardType == pin[filterKey] then - passesFilter = true - elseif value == -1 and rewardType == pin[filterKey] then - passesFilter = false - end - end - end - return passesFilter -end - - -local bountyIndex -local debug_headers = {} - -function FilterBar:Setup() - self:GetFilters() -end - -function FilterBar:OnEvent(event,...) - if event == 'QUEST_LOG_UPDATE' then - self:Reset() - self:Refresh() - end -end - -function FilterBar:GetFilters() - - local print = fbprint - wipe(WorldPlan.FilterOptions) - - for index, info in ipairs(POI_FILTER_OPTIONS) do - tinsert(WorldPlan.FilterOptions, info) - end - self.bounties, self.numBounties = GetQuestBountyInfoForMapID(WorldPlan.currentMapID) - self.BountyFilters = {} - for index, data in ipairs(self.bounties) do - local info = self.BountyFilters[index] - if not info then - info = {} - self.BountyFilters[index] = info - end - - local questTitle = GetQuestLogTitle(GetQuestLogIndexByID(data.questID)) - - info.filterKey = 'factionID' - info.filterValue = data.factionID - info.label = questTitle - info.texture = data.icon - print('loading emissary', questTitle) - tinsert(WorldPlan.FilterOptions, info) - --{ filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PROFESSION, label = 'Profession', texture = "Interface\\LFGFRAME\\UI-LFR-PORTRAIT", }, - end -end - -function FilterBar:Reset() - self:GetFilters() -end - -function FilterBar:Refresh(forced) - local print = fbprint - local blocks = self.SummaryHeaders - local relativeFrame = WorldMapFrame.UIElementsFrame.TrackingOptionsButton - local numHeaders = 0 - print('|cFF00FF88'..tostring(self)..':Refresh()|r', 'currentMap=',WorldPlan.currentMapID) - - - local quests = QuestsByZone[WorldPlan.currentMapID] or QuestsByID - - - for index, info in ipairs(WorldPlan.FilterOptions) do - local numQuests = 0 - - for questID, pin in pairs(quests) do - if pin.used then - if not info.filterKey then - numQuests = numQuests + 1 - elseif pin[info.filterKey] == info.filterValue then - numQuests = numQuests + 1 - end - end - end - print(tostring(index).. ' ("'..tostring(info.label)..'" f('.. tostring(info.filterKey).. '='..tostring(info.filterValue) .. '), '..tostring(numQuests)..')') - - if numQuests >= 1 then - numHeaders = numHeaders + 1 - local button = blocks[numHeaders] - if not blocks[numHeaders] then - button = CreateFrame('Button', 'WorldPlanFilterButton'..numHeaders, WorldMapScrollFrame, 'WorldPlanFilterPin') - for k,v in pairs(info)do print(k,v) end - button.iconBorder:SetTexture(info.fill or POI_BORDER_FILL) - button.iconBorder:SetMask(info.mask or POI_BORDER_MASK) - button.iconBorder:SetDesaturated(info.desaturated) - button.supertrackBorder:SetTexture(info.fill or POI_BORDER_FILL) - button.supertrackBorder:SetMask(info.mask or POI_BORDER_MASK) - button.supertrackBorder:SetDesaturated(true) - blocks[numHeaders] = button - end - - button:SetID(index) - button.spacing = ((info.filterKey ~= relativeFrame.filterKey) and 10) or 0 - button.relativeFrame = relativeFrame - button:Refresh(info, (numHeaders == 1), numQuests) - button:Show() - relativeFrame = button - end - - end - - self.numHeaders = numHeaders - for i = numHeaders + 1, #WorldPlan.FilterOptions do - if self.SummaryHeaders[i] then - self.SummaryHeaders[i]:Hide() - end - end -end - -function FilterBar:Cleanup() - - -- hide trailing buttons -end - - -function FilterPin:Refresh(info, isFirst, numQuests) - local print = fbprint - isFirst = isFirst or self.isFirst - numQuests = numQuests or self.numQuests - - if info then - self.isFirst = isFirst - self.numQuests = numQuests - self.filterKey = info.filterKey - self.filterValue = info.filterValue - self.tagID = info.tagID - - self.icon:ClearAllPoints() - self.icon:SetTexture(info.texture) - self.icon:SetAllPoints(self) - self.supertrackBorder:Hide() - self.count:SetText(numQuests) - self:Show() - end - - - self.itemTexture = self.texture - - if isFirst then - self:SetPoint('TOP', self.relativeFrame, 'BOTTOM', 0, -5) - else - self:SetPoint('TOPRIGHT', self.relativeFrame, 'BOTTOMRIGHT', 0, -(3*2 + 1 + (self.spacing or 0))) - - end - print('anchor to', self.relativeFrame:GetName()) - - local r, g, b, a = 1,1,1,1 - local used = WorldPlan.UsedFilters[self.filterKey] - if used and self.filterKey then - if used[self.filterValue] == true then - r, g, b = 0, 1, 0 - elseif used[self.filterValue] == false then - r, g, b = 1, 0, 0 - end - end - self.iconBorder:SetVertexColor(r, g, b, a) - self:UpdateSize() -end - -function FilterPin:OnLoad() - self:RegisterForClicks('AnyUp') - self:SetFrameStrata('HIGH') - self:SetFrameLevel(151) - self:SetScript('OnUpdate', nil) - self.style = db.filterStyle - self.subStyle = db.defaultPinStyle.continent -end - -function FilterPin:OnUpdate () - -end - -function FilterPin:OnLeave () - if GameTooltip:IsOwned(self) then - GameTooltip:Hide() - end -end - --- shift-click: reset filter --- click: rotate through include(1), exclude(-1), ignore(nil) -function FilterPin:OnClick (button) - local print = fbprint - local filterKey = self.filterKey - local filterValue = self.filterValue - - - local operation = opPrefix - local setInclude = (button == 'LeftButton') - - - if not filterKey then - -- resetting - wipe(WorldPlan.UsedFilters) - - elseif IsShiftKeyDown() then - WorldPlan.UsedFilters[filterKey] = nil - else - WorldPlan.UsedFilters[filterKey] = WorldPlan.UsedFilters[filterKey] or {} - WorldPlan.UsedFilters[filterKey][filterValue] = setInclude - print(filterKey, filterValue, '=', setInclude) - - for index, info in ipairs(WorldPlan.FilterOptions) do - if info.filterKey == filterKey then - if (not IsControlKeyDown()) and (filterValue ~= info.filterValue) then - WorldPlan.UsedFilters[filterKey][info.filterValue] = (not setInclude) - print(filterKey, info.filterValue, '=', WorldPlan.UsedFilters[filterKey][info.filterValue]) - end - end - end - - end - print('|cFF00FF88Filter Update:', filterKey, filterValue, operation) - WorldPlan:RefreshAll() -end --%debug% local SetTimedCallbackForAllPins = function(seconds, callback) C_Timer.After(seconds, function() - for id, pin in pairs(QuestsByID) do + for id, pin in pairs(WorldPlanQuests.QuestsByID) do callback(pin) end end)