Mercurial > wow > worldplan
comparison 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 |
comparison
equal
deleted
inserted
replaced
30:8cb750e79952 | 31:d0114b51cdea |
---|---|
3 -- Created: 10/27/2016 8:55 PM | 3 -- Created: 10/27/2016 8:55 PM |
4 -- %file-revision% | 4 -- %file-revision% |
5 -- | 5 -- |
6 | 6 |
7 local print = DEVIAN_WORKSPACE and function(...) _G.print('FilterBar', ...) end or nop | 7 local print = DEVIAN_WORKSPACE and function(...) _G.print('FilterBar', ...) end or nop |
8 local wipe, ipairs, pairs = table.wipe, ipairs, pairs | |
8 | 9 |
9 local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD | 10 local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD |
10 local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER | 11 local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER |
11 local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT | 12 local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT |
12 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES | 13 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES |
28 numberFontObject = 'WorldPlanNumberFontThin' | 29 numberFontObject = 'WorldPlanNumberFontThin' |
29 } | 30 } |
30 local DEFAULT_FILTER_LIST = { | 31 local DEFAULT_FILTER_LIST = { |
31 { label = 'Filters', texture = "Interface\\WorldMap\\WorldMap-Icon" }, | 32 { label = 'Filters', texture = "Interface\\WorldMap\\WorldMap-Icon" }, |
32 { filterKey= 'rewardType', cVar = 'worldQuestFilterArtifactPower', filterValue = REWARD_ARTIFACT_POWER, label = 'Artifact Power', texture = "Interface\\ICONS\\inv_7xp_inscription_talenttome01" }, | 33 { filterKey= 'rewardType', cVar = 'worldQuestFilterArtifactPower', filterValue = REWARD_ARTIFACT_POWER, label = 'Artifact Power', texture = "Interface\\ICONS\\inv_7xp_inscription_talenttome01" }, |
33 { filterKey= 'rewardType', cVar = 'worldQuestFilterOrderResources', filterValue = REWARD_CURRENCY,label = 'Order Resources', texture = "Interface\\ICONS\\inv_misc_elvencoins" }, | 34 { filterKey= 'rewardType', cVar = 'worldQuestFilterOrderResources', filterValue = REWARD_CURRENCY,label = 'Order Resources', texture = "Interface\\Icons\\inv_orderhall_orderresources" }, |
34 { filterKey= 'rewardType', cVar = 'worldQuestFilterEquipment', filterValue = REWARD_GEAR, label = 'Equipment', texture = "Interface\\ICONS\\garrison_bluearmorupgrade" }, | 35 { filterKey= 'rewardType', cVar = 'worldQuestFilterEquipment', filterValue = REWARD_GEAR, label = 'Equipment', texture = "Interface\\ICONS\\garrison_bluearmorupgrade" }, |
35 { filterKey= 'rewardType', cVar = 'worldQuestFilterProfessionMaterials', filterValue = REWARD_REAGENT, label = 'Materials', texture = 1417744 }, | 36 { filterKey= 'rewardType', cVar = 'worldQuestFilterProfessionMaterials', filterValue = REWARD_REAGENT, label = 'Materials', texture = 1417744 }, |
36 { filterKey= 'rewardType', cVar = 'worldQuestFilterGold', filterValue = REWARD_CASH, label = 'Gold', texture = "Interface\\Buttons\\UI-GroupLoot-Coin-Up" }, | 37 { filterKey= 'rewardType', cVar = 'worldQuestFilterGold', filterValue = REWARD_CASH, label = 'Gold', texture = "Interface\\Buttons\\UI-GroupLoot-Coin-Up" }, |
37 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PVP, label = 'PvP', texture = "Interface\\Icons\\Ability_PVP_GladiatorMedallion", spacing = 10 }, | 38 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PVP, label = 'PvP', texture = "Interface\\Icons\\Ability_PVP_GladiatorMedallion", spacing = 10 }, |
38 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PET_BATTLE, label = 'Pet Battle', texture = "Interface\\Icons\\PetJournalPortrait", }, | 39 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PET_BATTLE, label = 'Pet Battle', texture = "Interface\\Icons\\PetJournalPortrait", }, |
124 self:Update(forced) | 125 self:Update(forced) |
125 end | 126 end |
126 | 127 |
127 local filterFill = "Interface\\BUTTONS\\YELLOWORANGE64" | 128 local filterFill = "Interface\\BUTTONS\\YELLOWORANGE64" |
128 local filterMask = "Interface\\Minimap\\UI-Minimap-Background" | 129 local filterMask = "Interface\\Minimap\\UI-Minimap-Background" |
130 | |
131 local questResults = {{}} | |
129 function WorldPlanSummaryMixin:Update(forced) | 132 function WorldPlanSummaryMixin:Update(forced) |
130 local blocks = self.buttons | 133 local blocks = self.buttons |
131 local relativeFrame = WorldMapFrame.UIElementsFrame.TrackingOptionsButton | 134 local relativeFrame = WorldMapFrame.UIElementsFrame.TrackingOptionsButton |
132 local numHeaders = 0 | 135 local numHeaders = 0 |
133 print('|cFF00FF88'..tostring(self)..':Refresh()|r', 'currentMap=',self.currentMapID) | 136 print('|cFF00FF88'..tostring(self)..':Refresh()|r', 'currentMap=',self.currentMapID) |
134 | 137 |
135 | 138 |
136 local quests = WorldPlanQuests.QuestsByZone[self.currentMapID] or WorldPlanQuests.QuestsByID | 139 local quests = WorldPlanQuests.QuestsByZone[self.currentMapID] or WorldPlanQuests.QuestsByID |
137 | 140 local foundQuests = questResults[1] |
138 | |
139 for index, info in ipairs(self.filterList) do | 141 for index, info in ipairs(self.filterList) do |
140 local numQuests = 0 | 142 local numQuests = 0 |
141 | 143 local resultIndex = numHeaders + 1 |
144 questResults[resultIndex] = questResults[resultIndex] or {} | |
145 wipe(questResults[resultIndex]) | |
142 for questID, pin in pairs(quests) do | 146 for questID, pin in pairs(quests) do |
143 if pin.used then | 147 if pin.used then |
144 if not info.filterKey then | 148 if not info.filterKey then |
145 numQuests = numQuests + 1 | 149 numQuests = numQuests + 1 |
146 elseif pin[info.filterKey] == info.filterValue then | 150 elseif pin[info.filterKey] == info.filterValue then |
147 numQuests = numQuests + 1 | 151 numQuests = numQuests + 1 |
152 tinsert(questResults[resultIndex], pin) | |
148 end | 153 end |
149 end | 154 end |
150 end | 155 end |
151 print(tostring(index).. ' ("'..tostring(info.label)..'" f('.. tostring(info.filterKey).. '='..tostring(info.filterValue) .. '), '..tostring(numQuests)..')') | 156 print(tostring(index).. ' ("'..tostring(info.label)..'" f('.. tostring(info.filterKey).. '='..tostring(info.filterValue) .. '), '..tostring(numQuests)..')') |
152 | 157 |
169 button.supertrackBorder:Hide() | 174 button.supertrackBorder:Hide() |
170 blocks[numHeaders] = button | 175 blocks[numHeaders] = button |
171 end | 176 end |
172 | 177 |
173 button.info = info | 178 button.info = info |
179 button.questList = questResults[resultIndex] | |
174 button:SetID(index) | 180 button:SetID(index) |
175 button.spacing = ((info.filterKey ~= relativeFrame.filterKey) and 10) or 0 | 181 button.spacing = ((info.filterKey ~= relativeFrame.filterKey) and 10) or 0 |
176 button.relativeFrame = relativeFrame | 182 button.relativeFrame = relativeFrame |
177 button:Refresh((numHeaders == 1), numQuests) | 183 button:Refresh((numHeaders == 1), numQuests) |
178 button:Show() | 184 button:Show() |
184 self.numHeaders = numHeaders | 190 self.numHeaders = numHeaders |
185 for i = numHeaders + 1, #blocks do | 191 for i = numHeaders + 1, #blocks do |
186 if blocks[i] then | 192 if blocks[i] then |
187 blocks[i]:Hide() | 193 blocks[i]:Hide() |
188 end | 194 end |
195 if questResults[i] then | |
196 wipe(questResults[i]) | |
197 end | |
189 end | 198 end |
190 end | 199 end |
191 | 200 |
192 function WorldPlanSummaryMixin:Cleanup() | 201 function WorldPlanSummaryMixin:Cleanup() |
193 | |
194 -- hide trailing buttons | 202 -- hide trailing buttons |
195 end | 203 end |
196 | 204 |
205 local rgbWhite = {r = 1, g= 1, b= 1, hex = '|cFFFFFFFF'} | |
197 function WorldPlanFilterPinMixin:OnEnter() | 206 function WorldPlanFilterPinMixin:OnEnter() |
198 | 207 if self.questList and #self.questList >= 1 then |
199 end | 208 GameTooltip:SetOwner(self, 'ANCHOR_LEFT') |
209 GameTooltip_ClearInsertedFrames(GameTooltip) | |
210 GameTooltip:AddLine(self.info.label) | |
211 for index, pin in ipairs(self.questList) do | |
212 local colorInfo = (pin.quality and ITEM_QUALITY_COLORS[pin.quality]) or rgbWhite | |
213 GameTooltip:AddLine(pin.title ..(pin.cheevos and " |cFFFFFF00!|R" or ''), colorInfo.r, colorInfo.g, colorInfo.b) | |
214 GameTooltip:AddTexture(pin.itemTexture) | |
215 local cLine = GameTooltip:NumLines() - 1 | |
216 print(cLine, _G['GameTooltipTexture'..cLine]:GetTexture()) | |
217 if type(pin.itemTexture) == 'number' then | |
218 --- voodoo workaround for IDs getting coerced to string | |
219 _G['GameTooltipTexture'..cLine]:Show() | |
220 _G['GameTooltipTexture'..cLine]:SetTexture(pin.itemTexture) | |
221 end | |
222 GameTooltip:Show() | |
223 end | |
224 end | |
225 end | |
226 | |
200 function WorldPlanFilterPinMixin:OnLeave() | 227 function WorldPlanFilterPinMixin:OnLeave() |
201 | 228 if GameTooltip:IsOwned(self) then |
202 end | 229 GameTooltip:Hide() |
203 | 230 end |
231 end | |
204 | 232 |
205 function WorldPlanFilterPinMixin:Refresh(isFirst, numQuests) | 233 function WorldPlanFilterPinMixin:Refresh(isFirst, numQuests) |
206 isFirst = isFirst or self.isFirst | 234 isFirst = isFirst or self.isFirst |
207 numQuests = numQuests or self.numQuests | 235 numQuests = numQuests or self.numQuests |
208 | 236 |
217 self.icon:SetMask(filterMask) | 245 self.icon:SetMask(filterMask) |
218 self.icon:SetTexture(info.texture) | 246 self.icon:SetTexture(info.texture) |
219 self.count:SetText(numQuests) | 247 self.count:SetText(numQuests) |
220 self.cVar = info.cVar | 248 self.cVar = info.cVar |
221 | 249 |
222 | |
223 self.itemTexture = self.texture | 250 self.itemTexture = self.texture |
224 | 251 |
225 if isFirst then | 252 if isFirst then |
226 self:SetPoint('TOP', self.relativeFrame, 'BOTTOM', 0, -5) | 253 self:SetPoint('TOP', self.relativeFrame, 'BOTTOM', 0, -5) |
227 else | 254 else |
228 self:SetPoint('TOPRIGHT', self.relativeFrame, 'BOTTOMRIGHT', 0, -(3 + (self.spacing or 0))) | 255 self:SetPoint('TOPRIGHT', self.relativeFrame, 'BOTTOMRIGHT', 0, -(3 + (self.spacing or 0))) |
229 | |
230 end | 256 end |
231 print('anchor to', self.relativeFrame:GetName(), info.mask) | 257 print('anchor to', self.relativeFrame:GetName(), info.mask) |
232 | 258 |
233 local r, g, b, a = 1,1,1,1 | 259 local r, g, b, a = 1,1,1,1 |
234 local used = WorldPlan.UsedFilters[self.filterKey] | 260 local desaturated = false |
235 if used and self.filterKey then | 261 if self.cVar then |
236 if used[self.filterValue] == true then | 262 self.iconBorder:SetVertexColor(1, 1, 1, 1) |
237 r, g, b = 0, 1, 0 | 263 if GetCVarBool(self.cVar) == true then |
238 elseif used[self.filterValue] == false then | 264 self.icon:SetVertexColor(1,1,1,1) |
239 r, g, b = 1, 0, 0 | 265 self:SetAlpha(1) |
266 else | |
267 self.icon:SetVertexColor(.5, .5, .5, 1) | |
268 self:SetAlpha(0.5) | |
240 end | 269 end |
241 else | 270 else |
242 if self.cVar and GetCVarBool(self.cVar) then | 271 self:SetAlpha(1) |
243 r, g, b = 0, 1, 0 | 272 if WorldPlan.UsedFilters[self.filterKey] then |
244 end | 273 if WorldPlan.UsedFilters[self.filterKey] == self.filterValue then |
245 end | 274 self.iconBorder:SetVertexColor(0, 1, 0) |
246 self.iconBorder:SetVertexColor(r, g, b, a) | 275 else |
276 self.iconBorder:SetVertexColor(1, 0, 0) | |
277 end | |
278 else | |
279 self.iconBorder:SetVertexColor(1, 1, 1, 1) | |
280 end | |
281 end | |
282 | |
247 --self:UpdateSize() | 283 --self:UpdateSize() |
248 end | 284 end |
249 | 285 |
250 function WorldPlanFilterPinMixin:OnLoad() | 286 function WorldPlanFilterPinMixin:OnLoad() |
251 self:RegisterForClicks('AnyUp') | 287 self:RegisterForClicks('AnyUp') |
265 | 301 |
266 -- shift-click: reset filter | 302 -- shift-click: reset filter |
267 -- click: rotate through include(1), exclude(-1), ignore(nil) | 303 -- click: rotate through include(1), exclude(-1), ignore(nil) |
268 function WorldPlanFilterPinMixin:OnClick (button) | 304 function WorldPlanFilterPinMixin:OnClick (button) |
269 | 305 |
306 print('|cFF00FF88'..self:GetName()..':OnClick()|r', filterKey, filterValue, operation) | |
270 local filterKey = self.filterKey | 307 local filterKey = self.filterKey |
271 local filterValue = self.filterValue | 308 local filterValue = self.filterValue |
272 | 309 |
273 | 310 |
274 local operation = opPrefix | 311 local operation = opPrefix |
275 local setInclude = (button == 'LeftButton') | |
276 | 312 |
277 | 313 |
278 if not filterKey then | 314 if not filterKey then |
279 -- resetting | |
280 wipe(WorldPlan.UsedFilters) | 315 wipe(WorldPlan.UsedFilters) |
281 | 316 elseif self.cVar then |
282 elseif IsShiftKeyDown() then | 317 SetCVar(self.cVar, (GetCVarBool(self.cVar) and 0) or 1) |
283 WorldPlan.UsedFilters[filterKey] = nil | |
284 else | 318 else |
285 WorldPlan.UsedFilters[filterKey] = WorldPlan.UsedFilters[filterKey] or {} | 319 local setInclude = (button == 'LeftButton') |
286 WorldPlan.UsedFilters[filterKey][filterValue] = setInclude | 320 local flushValue |
287 print(filterKey, filterValue, '=', setInclude) | 321 print('') |
288 | 322 if WorldPlan.UsedFilters[filterKey] == filterValue then |
289 for index, info in ipairs(WorldPlan.FilterOptions) do | 323 WorldPlan.UsedFilters[filterKey] = nil |
290 if info.filterKey == filterKey then | 324 else |
291 if (not IsControlKeyDown()) and (filterValue ~= info.filterValue) then | 325 WorldPlan.UsedFilters[filterKey] = filterValue |
292 WorldPlan.UsedFilters[filterKey][info.filterValue] = (not setInclude) | 326 end |
293 print(filterKey, info.filterValue, '=', WorldPlan.UsedFilters[filterKey][info.filterValue]) | 327 end |
294 end | |
295 end | |
296 end | |
297 | |
298 end | |
299 print('|cFF00FF88Filter Update:', filterKey, filterValue, operation) | |
300 WorldPlan:Refresh() | 328 WorldPlan:Refresh() |
301 end | 329 end |