# HG changeset patch # User Nenue # Date 1477677967 14400 # Node ID 8cb750e799524615fd8691342a7e47c279b31412 # Parent c1612c2c1840aa5a27a57d34cec3df11daf9f09f WorldPlan: - Reworking filters to utilize newly added CVars diff -r c1612c2c1840 -r 8cb750e79952 FilterBar.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FilterBar.lua Fri Oct 28 14:06:07 2016 -0400 @@ -0,0 +1,301 @@ +-- WorldPlan +-- FilterBar.lua +-- Created: 10/27/2016 8:55 PM +-- %file-revision% +-- + +local print = DEVIAN_WORKSPACE and function(...) _G.print('FilterBar', ...) end or nop + +local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD +local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER +local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT +local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES +local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS + + +local LE_QUEST_TAG_TYPE_PVP = LE_QUEST_TAG_TYPE_PVP +local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE +local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON +local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION +local LE_QUEST_TAG_TYPE_NORMAL = LE_QUEST_TAG_TYPE_NORMAL +local DEFAULT_FILTER_LAYOUT = { + PinSize = 22, + Border = 3, + TrackingBorder = 2, + TagSize = 12, + TimeleftStage = 3, + showNumber = true, + numberFontObject = 'WorldPlanNumberFontThin' +} +local DEFAULT_FILTER_LIST = { + { label = 'Filters', texture = "Interface\\WorldMap\\WorldMap-Icon" }, + { filterKey= 'rewardType', cVar = 'worldQuestFilterArtifactPower', filterValue = REWARD_ARTIFACT_POWER, label = 'Artifact Power', texture = "Interface\\ICONS\\inv_7xp_inscription_talenttome01" }, + { filterKey= 'rewardType', cVar = 'worldQuestFilterOrderResources', filterValue = REWARD_CURRENCY,label = 'Order Resources', texture = "Interface\\ICONS\\inv_misc_elvencoins" }, + { filterKey= 'rewardType', cVar = 'worldQuestFilterEquipment', filterValue = REWARD_GEAR, label = 'Equipment', texture = "Interface\\ICONS\\garrison_bluearmorupgrade" }, + { filterKey= 'rewardType', cVar = 'worldQuestFilterProfessionMaterials', filterValue = REWARD_REAGENT, label = 'Materials', texture = 1417744 }, + { filterKey= 'rewardType', cVar = 'worldQuestFilterGold', filterValue = REWARD_CASH, label = 'Gold', texture = "Interface\\Buttons\\UI-GroupLoot-Coin-Up" }, + { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PVP, label = 'PvP', texture = "Interface\\Icons\\Ability_PVP_GladiatorMedallion", spacing = 10 }, + { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PET_BATTLE, label = 'Pet Battle', texture = "Interface\\Icons\\PetJournalPortrait", }, + { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_DUNGEON, label = 'Dungeon', texture = "Interface\\LFGFRAME\\UI-LFR-PORTRAIT", }, + { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PROFESSION, label = 'Profession', texture = "Interface\\ICONS\\70_professions_scroll_02", }, +} +local defaults = {} + +WorldPlanSummaryMixin = { + selectedBountyIndex = {}, + bounties = {}, + filterList = {}, + buttons = {}, +} +WorldPlanFilterPinMixin = {} + +function WorldPlanSummaryMixin:OnLoad() + self:RegisterEvent('QUEST_LOG_UPDATE') + self:RegisterEvent('WORLD_MAP_UPDATE') + + WorldPlan:AddHandler(self, defaults) + + for index, info in ipairs(DEFAULT_FILTER_LIST) do + info.zone = DEFAULT_FILTER_LAYOUT + info.continent = DEFAULT_FILTER_LAYOUT + info.pinMask = "Interface\\Minimap\\UI-Minimap-Background" + + WorldPlan:AddTypeInfo(self,index, info) + end + +end + + +function WorldPlanSummaryMixin:OnEvent(event) +end + +local bountyIndex +local debug_headers = {} + +function WorldPlanSummaryMixin:Setup() + self:GetFilters() +end + + +function WorldPlanSummaryMixin:OnEvent(event,...) + self.isStale = true +end + +function WorldPlanSummaryMixin:OnShow() + self:Refresh() +end + +function WorldPlanSummaryMixin:GetFilters() + + + wipe(self.filterList) + + for index, info in ipairs(DEFAULT_FILTER_LIST) do + tinsert(self.filterList, 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(self.filterList, info) + --{ filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PROFESSION, label = 'Profession', texture = "Interface\\LFGFRAME\\UI-LFR-PORTRAIT", }, + end +end + +function WorldPlanSummaryMixin:Reset() + self.pinLayout = self:GetTypeInfo(255) + self:GetFilters() +end + +function WorldPlanSummaryMixin:Refresh(forced) + self:Update(forced) +end + +local filterFill = "Interface\\BUTTONS\\YELLOWORANGE64" +local filterMask = "Interface\\Minimap\\UI-Minimap-Background" +function WorldPlanSummaryMixin:Update(forced) + local blocks = self.buttons + local relativeFrame = WorldMapFrame.UIElementsFrame.TrackingOptionsButton + local numHeaders = 0 + print('|cFF00FF88'..tostring(self)..':Refresh()|r', 'currentMap=',self.currentMapID) + + + local quests = WorldPlanQuests.QuestsByZone[self.currentMapID] or WorldPlanQuests.QuestsByID + + + for index, info in ipairs(self.filterList) 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') + + button:SetSize(24,24) + button.icon:ClearAllPoints() + button.icon:SetAllPoints(button) + + button.iconBorder:SetPoint('TOPLEFT', button, 'TOPLEFT', -2, 2) + button.iconBorder:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', 2, -2) + button.iconBorder:SetMask(filterMask) + button.iconBorder:SetTexture(filterFill) + button.iconBorder:SetDesaturated(true) + + button.supertrackBorder:Hide() + blocks[numHeaders] = button + end + + button.info = info + button:SetID(index) + button.spacing = ((info.filterKey ~= relativeFrame.filterKey) and 10) or 0 + button.relativeFrame = relativeFrame + button:Refresh((numHeaders == 1), numQuests) + button:Show() + relativeFrame = button + end + + end + + self.numHeaders = numHeaders + for i = numHeaders + 1, #blocks do + if blocks[i] then + blocks[i]:Hide() + end + end +end + +function WorldPlanSummaryMixin:Cleanup() + + -- hide trailing buttons +end + +function WorldPlanFilterPinMixin:OnEnter() + +end +function WorldPlanFilterPinMixin:OnLeave() + +end + + +function WorldPlanFilterPinMixin:Refresh(isFirst, numQuests) + isFirst = isFirst or self.isFirst + numQuests = numQuests or self.numQuests + + local info = self.info + + self.isFirst = isFirst + self.numQuests = numQuests + self.filterKey = info.filterKey + self.filterValue = info.filterValue + self.tagID = info.tagID + + self.icon:SetMask(filterMask) + self.icon:SetTexture(info.texture) + self.count:SetText(numQuests) + self.cVar = info.cVar + + + self.itemTexture = self.texture + + if isFirst then + self:SetPoint('TOP', self.relativeFrame, 'BOTTOM', 0, -5) + else + self:SetPoint('TOPRIGHT', self.relativeFrame, 'BOTTOMRIGHT', 0, -(3 + (self.spacing or 0))) + + end + print('anchor to', self.relativeFrame:GetName(), info.mask) + + 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 + else + if self.cVar and GetCVarBool(self.cVar) then + r, g, b = 0, 1, 0 + end + end + self.iconBorder:SetVertexColor(r, g, b, a) + --self:UpdateSize() +end + +function WorldPlanFilterPinMixin:OnLoad() + self:RegisterForClicks('AnyUp') + self:SetFrameStrata('HIGH') + self:SetFrameLevel(151) + self:SetScript('OnUpdate', nil) +end + +function WorldPlanFilterPinMixin:OnUpdate () +end + +function WorldPlanFilterPinMixin:OnLeave () + if GameTooltip:IsOwned(self) then + GameTooltip:Hide() + end +end + +-- shift-click: reset filter +-- click: rotate through include(1), exclude(-1), ignore(nil) +function WorldPlanFilterPinMixin:OnClick (button) + + 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:Refresh() +end \ No newline at end of file diff -r c1612c2c1840 -r 8cb750e79952 FilterBar.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FilterBar.xml Fri Oct 28 14:06:07 2016 -0400 @@ -0,0 +1,20 @@ + +