comparison FilterBar.lua @ 36:21bcff08b0f4

WorldPlan: - Quest pins are now placed on the flight map. Their visibility rules will mirror the filter options from the world map. - Filter controls polish: - First click negates other reward type filters. Subsequent clicks will then toggle individual reward types until the filters are reset via Right-click. - Adheres to the Blizzard CVars added in patch 7.1 - Numerous optimizations to how data and visual updates are handled; should see an even better load time, and snappier world map interaction. ClassPlan: - The 'Available Missions' list is now recorded. It can be reviewed by clicking on the mission list heading. - Information filtering by character and realm.
author Nenue
date Fri, 04 Nov 2016 01:40:39 -0400
parents be4db60219ca
children 589c444d4837
comparison
equal deleted inserted replaced
35:26dfa661daa7 36:21bcff08b0f4
38 [40279] = {npc = 99035, name = 'Durian Strongfruit'} 38 [40279] = {npc = 99035, name = 'Durian Strongfruit'}
39 } 39 }
40 local familiars_id = 9696 40 local familiars_id = 9696
41 41
42 local DEFAULT_FILTER_LAYOUT = { 42 local DEFAULT_FILTER_LAYOUT = {
43 PinSize = 22, 43 iconWidth = 24,
44 Border = 3, 44 borderWidth = 3,
45 TrackingBorder = 2, 45 highlightWidth = 2,
46 TagSize = 12, 46 TagSize = 12,
47 TimeleftStage = 3, 47 TimeleftStage = 3,
48 showNumber = true, 48 showNumber = true,
49 numberFontObject = 'WorldPlanNumberFontThin' 49 numberFontObject = 'WorldPlanNumberFontThin'
50 } 50 }
159 local blocks = self.buttons 159 local blocks = self.buttons
160 local relativeFrame = WorldMapFrame.UIElementsFrame.TrackingOptionsButton 160 local relativeFrame = WorldMapFrame.UIElementsFrame.TrackingOptionsButton
161 local numHeaders = 0 161 local numHeaders = 0
162 print('|cFF00FF88'..self:GetName()..':Update()|r', 'currentMap=',WorldPlan.currentMapID) 162 print('|cFF00FF88'..self:GetName()..':Update()|r', 'currentMap=',WorldPlan.currentMapID)
163 163
164 164 local layout = DEFAULT_FILTER_LAYOUT
165 local borderWidth = layout.iconWidth + (layout.borderWidth * 2)
166 local highlightWidth = borderWidth + (layout.highlightWidth * 2)
165 local quests = WorldPlanQuests.QuestsByZone[WorldPlan.currentMapID] or WorldPlanQuests.QuestsByID 167 local quests = WorldPlanQuests.QuestsByZone[WorldPlan.currentMapID] or WorldPlanQuests.QuestsByID
166 local foundQuests = questResults[1] 168 local foundQuests = questResults[1]
167 for index, info in ipairs(self.filterList) do 169 for index, info in ipairs(self.filterList) do
168 local numQuests = 0 170 local numQuests = 0
169 local resultIndex = numHeaders + 1 171 local resultIndex = numHeaders + 1
184 if numQuests >= 1 then 186 if numQuests >= 1 then
185 numHeaders = numHeaders + 1 187 numHeaders = numHeaders + 1
186 local button = blocks[numHeaders] 188 local button = blocks[numHeaders]
187 if not blocks[numHeaders] then 189 if not blocks[numHeaders] then
188 button = CreateFrame('Button', 'WorldPlanFilterButton'..numHeaders, WorldMapScrollFrame, 'WorldPlanFilterPin') 190 button = CreateFrame('Button', 'WorldPlanFilterButton'..numHeaders, WorldMapScrollFrame, 'WorldPlanFilterPin')
189 191 button:SetSize(borderWidth, borderWidth)
190 button:SetSize(24,24) 192
191 button.icon:ClearAllPoints() 193 button.icon:SetSize(layout.iconWidth, layout.iconWidth)
192 button.icon:SetAllPoints(button) 194 button.RewardBorder:SetSize(borderWidth, borderWidth)
193 195 button.HighlightBorder:SetSize(highlightWidth, highlightWidth)
194 button.iconBorder:SetPoint('TOPLEFT', button, 'TOPLEFT', -2, 2) 196 button.RewardBorder:SetMask(filterMask)
195 button.iconBorder:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', 2, -2) 197 button.RewardBorder:SetDesaturated(true)
196 button.iconBorder:SetMask(filterMask) 198
197 button.iconBorder:SetTexture(filterFill) 199 button.HighlightBorder:Hide()
198 button.iconBorder:SetDesaturated(true)
199
200 button.supertrackBorder:Hide()
201 blocks[numHeaders] = button 200 blocks[numHeaders] = button
202 end 201 end
203 202
204 button.info = info 203 button.info = info
205 button.questList = questResults[resultIndex] 204 button.questList = questResults[resultIndex]
206 button:SetID(index) 205 button:SetID(index)
207 button.spacing = ((info.filterKey ~= relativeFrame.filterKey) and 10) or 0 206 button.spacing = ((relativeFrame.cVar and (not info.cVar)) or (relativeFrame.filterKey ~= info.filterKey)) and 5 or 0
208 button.relativeFrame = relativeFrame 207 button.relativeFrame = relativeFrame
209 button:Refresh((numHeaders == 1), numQuests) 208 button:Refresh((numHeaders == 1), numQuests)
210 button:Show() 209 button:Show()
211 relativeFrame = button 210 relativeFrame = button
212 end 211 end
231 230
232 local rgbWhite = {r = 1, g= 1, b= 1, hex = '|cFFFFFFFF'} 231 local rgbWhite = {r = 1, g= 1, b= 1, hex = '|cFFFFFFFF'}
233 function WorldPlanFilterPinMixin:OnEnter() 232 function WorldPlanFilterPinMixin:OnEnter()
234 if self.questList and #self.questList >= 1 then 233 if self.questList and #self.questList >= 1 then
235 GameTooltip:SetOwner(self, 'ANCHOR_LEFT') 234 GameTooltip:SetOwner(self, 'ANCHOR_LEFT')
236 GameTooltip_ClearInsertedFrames(GameTooltip)
237 GameTooltip:AddLine(self.info.label) 235 GameTooltip:AddLine(self.info.label)
238 for index, pin in ipairs(self.questList) do 236 for index, pin in ipairs(self.questList) do
239 local colorInfo = (pin.quality and ITEM_QUALITY_COLORS[pin.quality]) or rgbWhite 237 local colorInfo = (pin.quality and ITEM_QUALITY_COLORS[pin.quality]) or rgbWhite
240 GameTooltip:AddLine(pin.title ..(pin.cheevos and " |cFFFFFF00!|R" or ''), colorInfo.r, colorInfo.g, colorInfo.b) 238 GameTooltip:AddLine('|T'.. tostring(pin.itemTexture)..':16:16|t ' .. pin.title ..(pin.cheevos and " |cFFFFFF00!|R" or ''), colorInfo.r, colorInfo.g, colorInfo.b)
241 GameTooltip:AddTexture(pin.itemTexture) 239 end
242 local cLine = GameTooltip:NumLines() - 1 240 GameTooltip:Show()
243 --print(cLine, _G['GameTooltipTexture'..cLine]:GetTexture())
244 if type(pin.itemTexture) == 'number' then
245 --- voodoo workaround for IDs getting coerced to string
246 _G['GameTooltipTexture'..cLine]:Show()
247 _G['GameTooltipTexture'..cLine]:SetTexture(pin.itemTexture)
248 end
249 GameTooltip:Show()
250 end
251 end 241 end
252 end 242 end
253 243
254 function WorldPlanFilterPinMixin:OnLeave() 244 function WorldPlanFilterPinMixin:OnLeave()
255 if GameTooltip:IsOwned(self) then 245 if GameTooltip:IsOwned(self) then
277 self.itemTexture = self.texture 267 self.itemTexture = self.texture
278 268
279 if isFirst then 269 if isFirst then
280 self:SetPoint('TOP', self.relativeFrame, 'BOTTOM', 0, -5) 270 self:SetPoint('TOP', self.relativeFrame, 'BOTTOM', 0, -5)
281 else 271 else
282 self:SetPoint('TOPRIGHT', self.relativeFrame, 'BOTTOMRIGHT', 0, -(3 + (self.spacing or 0))) 272 self:SetPoint('TOPRIGHT', self.relativeFrame, 'BOTTOMRIGHT', 0, -(self.spacing or 0))
283 end 273 end
284 print('anchor to', self.relativeFrame:GetName(), info.mask) 274 print('anchor to', self.relativeFrame:GetName(), info.mask)
285 275
286 local r, g, b, a = 1,1,1,1 276 local r, g, b, a = 1,1,1,1
287 local desaturated = false 277 local desaturated = false
288 if self.cVar then 278 if self.cVar then
289 self.iconBorder:SetVertexColor(1, 1, 1, 1) 279 self.RewardBorder:SetVertexColor(1, 1, 1, 1)
290 if GetCVarBool(self.cVar) then 280 if GetCVarBool(self.cVar) then
291 self.icon:SetVertexColor(1,1,1,1) 281 self.icon:SetVertexColor(1,1,1,1)
292 self:SetAlpha(1) 282 self:SetAlpha(1)
293 else 283 else
294 self.icon:SetVertexColor(.5, .5, .5, 1) 284 self.icon:SetVertexColor(.5, .5, .5, 1)
296 end 286 end
297 else 287 else
298 self:SetAlpha(1) 288 self:SetAlpha(1)
299 if WorldPlan.UsedFilters[self.filterKey] then 289 if WorldPlan.UsedFilters[self.filterKey] then
300 if WorldPlan.UsedFilters[self.filterKey] == self.filterValue then 290 if WorldPlan.UsedFilters[self.filterKey] == self.filterValue then
301 self.iconBorder:SetVertexColor(0, 1, 0) 291 self.RewardBorder:SetVertexColor(0, 1, 0)
302 else 292 else
303 self.iconBorder:SetVertexColor(1, 0, 0) 293 self.RewardBorder:SetVertexColor(1, 0, 0)
304 end 294 end
305 else 295 else
306 self.iconBorder:SetVertexColor(1, 1, 1, 1) 296 if self.filterKey == 'worldQuestType' then
297 self.RewardBorder:SetVertexColor(0, 1, 1)
298 elseif self.filterKey == 'factionID' then
299 self.RewardBorder:SetVertexColor(1, 1, 0)
300 else
301
302 self.RewardBorder:SetVertexColor(0.5, 0.5, 0.5)
303 end
304
307 end 305 end
308 end 306 end
309 307
310 --self:UpdateSize() 308 --self:UpdateSize()
311 end 309 end
313 function WorldPlanFilterPinMixin:OnLoad() 311 function WorldPlanFilterPinMixin:OnLoad()
314 self:RegisterForClicks('AnyUp') 312 self:RegisterForClicks('AnyUp')
315 self:SetFrameStrata('HIGH') 313 self:SetFrameStrata('HIGH')
316 self:SetFrameLevel(151) 314 self:SetFrameLevel(151)
317 self:SetScript('OnUpdate', nil) 315 self:SetScript('OnUpdate', nil)
316 WorldPlanPOIMixin.OnLoad(self)
318 end 317 end
319 318
320 function WorldPlanFilterPinMixin:OnUpdate () 319 function WorldPlanFilterPinMixin:OnUpdate ()
321 end 320 end
322 321
327 end 326 end
328 end 327 end
329 328
330 -- shift-click: reset filter 329 -- shift-click: reset filter
331 -- click: rotate through include(1), exclude(-1), ignore(nil) 330 -- click: rotate through include(1), exclude(-1), ignore(nil)
331 local filtered_report = {}
332 function WorldPlanFilterPinMixin:OnClick (button) 332 function WorldPlanFilterPinMixin:OnClick (button)
333 333
334 print('|cFF00FF88'..self:GetName()..':OnClick()|r', filterKey, filterValue, operation) 334 print('|cFF00FF88'..self:GetName()..':OnClick()|r', filterKey, filterValue, operation)
335 local filterKey = self.filterKey 335 local filterKey = self.filterKey
336 local filterValue = self.filterValue 336 local filterValue = self.filterValue
337 337 local cVar = self.cVar
338 338 local parent = self:GetParent()
339 local operation = opPrefix 339 local operation = opPrefix
340 340 local setDirty = false
341 341
342 if not filterKey then 342 local resetMode = (button == 'RightButton')
343 wipe(filtered_report)
344 if not (filterKey or cVar) then
343 wipe(WorldPlan.UsedFilters) 345 wipe(WorldPlan.UsedFilters)
344 for i, info in ipairs(DEFAULT_FILTER_LIST) do 346 for i, info in ipairs(DEFAULT_FILTER_LIST) do
345 if info.cVar then 347 if info.cVar then
348 if GetCVar(info.cVar) ~= 1 then
349 tinsert(filtered_report, '|cFF888888'.. tostring(info.label) ..'|r')
350 end
346 SetCVar(info.cVar, 1) 351 SetCVar(info.cVar, 1)
347 end 352 end
348 end 353 end
349 354
350 elseif self.cVar then 355 elseif cVar then
356 WorldPlan:print('Toggling cvar filter:', cVar)
357 if (not parent.isDirty) or resetMode then
351 for i, info in ipairs(DEFAULT_FILTER_LIST) do 358 for i, info in ipairs(DEFAULT_FILTER_LIST) do
352 if info.cVar then 359 if info.cVar then
353 if (info.cVar ~= self.cVar) and (button == 'LeftButton') then 360 local value = GetCVar(info.cVar)
354 SetCVar(info.cVar, 0) 361 if resetMode then
362 value = 1
363 parent.isDirty = nil
355 else 364 else
356 SetCVar(info.cVar, 1) 365
366 if (cVar ~= info.cVar) then
367 value = 0
368 else
369 value = 1
370 end
371 setDirty = true
372
357 end 373 end
374 SetCVar(info.cVar, value)
358 end 375 end
359 end 376 end
377 if setDirty then
378 parent.isDirty = true
379 end
380 else
381 SetCVar(cVar, (GetCVarBool(cVar) and 0) or 1)
382 end
360 else 383 else
361 local setInclude = (button == 'LeftButton')
362 local flushValue 384 local flushValue
363 print('') 385 print('')
364 if WorldPlan.UsedFilters[filterKey] == filterValue then 386 if WorldPlan.UsedFilters[filterKey] == filterValue then
365 WorldPlan.UsedFilters[filterKey] = nil 387 WorldPlan.UsedFilters[filterKey] = nil
388 tinsert(filtered_report, '|cFFFF0000'.. tostring(filterKey) ..'|r')
366 else 389 else
367 WorldPlan.UsedFilters[filterKey] = filterValue 390 WorldPlan.UsedFilters[filterKey] = filterValue
368 end 391 tinsert(filtered_report, '|cFF00FF00'.. tostring(filterKey) ..'|r')
369 end 392 end
393 end
394 WorldPlan:print('Changed:', table.concat(filtered_report, ', '))
370 WorldPlan:Refresh(true) 395 WorldPlan:Refresh(true)
371 end 396 end