Mercurial > wow > worldplan
diff FilterBar.lua @ 31:d0114b51cdea
WorldPlan:
- Reworking filters to utilize newly added CVars
- Fleshed out POI tooltip for WQ's associated with Family Familiars
- Filter button tooltip includes reward icons
- Respond to tracking menu clicks when they change filter options
author | Nenue |
---|---|
date | Fri, 28 Oct 2016 19:54:00 -0400 |
parents | 8cb750e79952 |
children | e8679ecb48d8 |
line wrap: on
line diff
--- a/FilterBar.lua Fri Oct 28 14:06:07 2016 -0400 +++ b/FilterBar.lua Fri Oct 28 19:54:00 2016 -0400 @@ -5,6 +5,7 @@ -- local print = DEVIAN_WORKSPACE and function(...) _G.print('FilterBar', ...) end or nop +local wipe, ipairs, pairs = table.wipe, ipairs, pairs local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER @@ -30,7 +31,7 @@ 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 = 'worldQuestFilterOrderResources', filterValue = REWARD_CURRENCY,label = 'Order Resources', texture = "Interface\\Icons\\inv_orderhall_orderresources" }, { 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" }, @@ -126,6 +127,8 @@ local filterFill = "Interface\\BUTTONS\\YELLOWORANGE64" local filterMask = "Interface\\Minimap\\UI-Minimap-Background" + +local questResults = {{}} function WorldPlanSummaryMixin:Update(forced) local blocks = self.buttons local relativeFrame = WorldMapFrame.UIElementsFrame.TrackingOptionsButton @@ -134,17 +137,19 @@ local quests = WorldPlanQuests.QuestsByZone[self.currentMapID] or WorldPlanQuests.QuestsByID - - + local foundQuests = questResults[1] for index, info in ipairs(self.filterList) do local numQuests = 0 - + local resultIndex = numHeaders + 1 + questResults[resultIndex] = questResults[resultIndex] or {} + wipe(questResults[resultIndex]) 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 + tinsert(questResults[resultIndex], pin) end end end @@ -171,6 +176,7 @@ end button.info = info + button.questList = questResults[resultIndex] button:SetID(index) button.spacing = ((info.filterKey ~= relativeFrame.filterKey) and 10) or 0 button.relativeFrame = relativeFrame @@ -186,21 +192,43 @@ if blocks[i] then blocks[i]:Hide() end + if questResults[i] then + wipe(questResults[i]) + end end end function WorldPlanSummaryMixin:Cleanup() - -- hide trailing buttons end +local rgbWhite = {r = 1, g= 1, b= 1, hex = '|cFFFFFFFF'} function WorldPlanFilterPinMixin:OnEnter() - -end -function WorldPlanFilterPinMixin:OnLeave() - + if self.questList and #self.questList >= 1 then + GameTooltip:SetOwner(self, 'ANCHOR_LEFT') + GameTooltip_ClearInsertedFrames(GameTooltip) + GameTooltip:AddLine(self.info.label) + for index, pin in ipairs(self.questList) do + local colorInfo = (pin.quality and ITEM_QUALITY_COLORS[pin.quality]) or rgbWhite + GameTooltip:AddLine(pin.title ..(pin.cheevos and " |cFFFFFF00!|R" or ''), colorInfo.r, colorInfo.g, colorInfo.b) + GameTooltip:AddTexture(pin.itemTexture) + local cLine = GameTooltip:NumLines() - 1 + print(cLine, _G['GameTooltipTexture'..cLine]:GetTexture()) + if type(pin.itemTexture) == 'number' then + --- voodoo workaround for IDs getting coerced to string + _G['GameTooltipTexture'..cLine]:Show() + _G['GameTooltipTexture'..cLine]:SetTexture(pin.itemTexture) + end + GameTooltip:Show() + end + end end +function WorldPlanFilterPinMixin:OnLeave() + if GameTooltip:IsOwned(self) then + GameTooltip:Hide() + end +end function WorldPlanFilterPinMixin:Refresh(isFirst, numQuests) isFirst = isFirst or self.isFirst @@ -219,31 +247,39 @@ 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 + local desaturated = false + if self.cVar then + self.iconBorder:SetVertexColor(1, 1, 1, 1) + if GetCVarBool(self.cVar) == true then + self.icon:SetVertexColor(1,1,1,1) + self:SetAlpha(1) + else + self.icon:SetVertexColor(.5, .5, .5, 1) + self:SetAlpha(0.5) end else - if self.cVar and GetCVarBool(self.cVar) then - r, g, b = 0, 1, 0 + self:SetAlpha(1) + if WorldPlan.UsedFilters[self.filterKey] then + if WorldPlan.UsedFilters[self.filterKey] == self.filterValue then + self.iconBorder:SetVertexColor(0, 1, 0) + else + self.iconBorder:SetVertexColor(1, 0, 0) + end + else + self.iconBorder:SetVertexColor(1, 1, 1, 1) end end - self.iconBorder:SetVertexColor(r, g, b, a) + --self:UpdateSize() end @@ -267,35 +303,27 @@ -- click: rotate through include(1), exclude(-1), ignore(nil) function WorldPlanFilterPinMixin:OnClick (button) + print('|cFF00FF88'..self:GetName()..':OnClick()|r', filterKey, filterValue, operation) 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 + elseif self.cVar then + SetCVar(self.cVar, (GetCVarBool(self.cVar) and 0) or 1) 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 + local setInclude = (button == 'LeftButton') + local flushValue + print('') + if WorldPlan.UsedFilters[filterKey] == filterValue then + WorldPlan.UsedFilters[filterKey] = nil + else + WorldPlan.UsedFilters[filterKey] = filterValue end - end - print('|cFF00FF88Filter Update:', filterKey, filterValue, operation) WorldPlan:Refresh() end \ No newline at end of file