Mercurial > wow > worldplan
comparison FilterBar.lua @ 40:589c444d4837
WowAce/Curseforge migration push
| author | Nenue |
|---|---|
| date | Sun, 25 Dec 2016 13:04:57 -0500 |
| parents | 21bcff08b0f4 |
| children | 79e5e96e5f18 |
comparison
equal
deleted
inserted
replaced
| 39:89ddef0594bc | 40:589c444d4837 |
|---|---|
| 1 -- WorldPlan | 1 -- WorldPlan |
| 2 -- FilterBar.lua | 2 -- FilterBar.lua |
| 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 local _, db = ... |
| 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 wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end | 8 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end |
| 9 local wipe, ipairs, pairs = table.wipe, ipairs, pairs | 9 local wipe, ipairs, pairs = table.wipe, ipairs, pairs |
| 10 | 10 |
| 11 local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD | 11 local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD |
| 37 [40337] = {npc = 97709, name = 'Master Tamer Flummox'}, | 37 [40337] = {npc = 97709, name = 'Master Tamer Flummox'}, |
| 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 db.DefaultFilterType = { |
| 43 iconWidth = 24, | 43 iconWidth = 24, |
| 44 iconHeight = 18, | |
| 44 borderWidth = 3, | 45 borderWidth = 3, |
| 45 highlightWidth = 2, | 46 highlightWidth = 2, |
| 46 TagSize = 12, | 47 TagSize = 12, |
| 47 TimeleftStage = 3, | 48 TimeleftStage = 3, |
| 48 showNumber = true, | 49 showNumber = true, |
| 49 numberFontObject = 'WorldPlanNumberFontThin' | 50 numberFontObject = 'WorldPlanNumberFontThin' |
| 50 } | 51 } |
| 51 local DEFAULT_FILTER_LIST = { | 52 db.DefaultFilters = { |
| 52 { label = 'Filters', texture = "Interface\\WorldMap\\WorldMap-Icon" }, | 53 { label = 'Filters', texture = "Interface\\WorldMap\\WorldMap-Icon" }, |
| 53 { filterKey= 'rewardType', cVar = 'worldQuestFilterArtifactPower', filterValue = REWARD_ARTIFACT_POWER, label = 'Artifact Power', texture = "Interface\\ICONS\\inv_7xp_inscription_talenttome01" }, | 54 { filterKey= 'rewardType', cVar = 'worldQuestFilterArtifactPower', filterValue = REWARD_ARTIFACT_POWER, label = 'Artifact Power', texture = "Interface\\ICONS\\inv_7xp_inscription_talenttome01" }, |
| 54 { filterKey= 'rewardType', cVar = 'worldQuestFilterOrderResources', filterValue = REWARD_CURRENCY,label = 'Order Resources', texture = "Interface\\Icons\\inv_orderhall_orderresources" }, | 55 { filterKey= 'rewardType', cVar = 'worldQuestFilterOrderResources', filterValue = REWARD_CURRENCY,label = 'Order Resources', texture = "Interface\\Icons\\inv_orderhall_orderresources" }, |
| 55 { filterKey= 'rewardType', cVar = 'worldQuestFilterEquipment', filterValue = REWARD_GEAR, label = 'Equipment', texture = "Interface\\ICONS\\garrison_bluearmorupgrade" }, | 56 { filterKey= 'rewardType', cVar = 'worldQuestFilterEquipment', filterValue = REWARD_GEAR, label = 'Equipment', texture = "Interface\\ICONS\\garrison_bluearmorupgrade" }, |
| 56 { filterKey= 'rewardType', cVar = 'worldQuestFilterProfessionMaterials', filterValue = REWARD_REAGENT, label = 'Materials', texture = 1417744 }, | 57 { filterKey= 'rewardType', cVar = 'worldQuestFilterProfessionMaterials', filterValue = REWARD_REAGENT, label = 'Materials', texture = 1417744 }, |
| 60 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_DUNGEON, label = 'Dungeon', texture = "Interface\\LFGFRAME\\UI-LFR-PORTRAIT", }, | 61 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_DUNGEON, label = 'Dungeon', texture = "Interface\\LFGFRAME\\UI-LFR-PORTRAIT", }, |
| 61 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PROFESSION, label = 'Profession', texture = "Interface\\ICONS\\70_professions_scroll_02", }, | 62 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PROFESSION, label = 'Profession', texture = "Interface\\ICONS\\70_professions_scroll_02", }, |
| 62 } | 63 } |
| 63 local defaults = {} | 64 local defaults = {} |
| 64 | 65 |
| 65 WorldPlanSummaryMixin = { | 66 WorldPlanSummaryMixin = WorldPlanSummaryMixin or {} |
| 66 selectedBountyIndex = {}, | 67 WorldPlanSummaryMixin.selectedBountyIndex = {} |
| 67 bounties = {}, | 68 WorldPlanSummaryMixin.bounties = {} |
| 68 filterList = {}, | 69 WorldPlanSummaryMixin.filterList = {} |
| 69 buttons = {}, | 70 WorldPlanSummaryMixin.buttons = {} |
| 70 } | 71 WorldPlanSummaryMixin.cvarFiltersDirty = false |
| 71 WorldPlanFilterPinMixin = {} | 72 WorldPlanFilterPinMixin = {} |
| 72 | 73 |
| 73 function WorldPlanSummaryMixin:OnLoad() | 74 function WorldPlanSummaryMixin:OnLoad() |
| 74 WorldPlan:AddHandler(self, defaults) | 75 self:SetParent(WorldMapFrame) |
| 75 for index, info in ipairs(DEFAULT_FILTER_LIST) do | 76 WorldPlan:AddHandler(self) |
| 76 info.zone = DEFAULT_FILTER_LAYOUT | 77 for index, info in ipairs(db.DefaultFilters) do |
| 77 info.continent = DEFAULT_FILTER_LAYOUT | 78 info.zone = db.DefaultFilterType |
| 79 info.continent = db.DefaultFilterType | |
| 78 info.pinMask = "Interface\\Minimap\\UI-Minimap-Background" | 80 info.pinMask = "Interface\\Minimap\\UI-Minimap-Background" |
| 79 | |
| 80 WorldPlan:AddTypeInfo(self,index, info) | 81 WorldPlan:AddTypeInfo(self,index, info) |
| 81 end | 82 end |
| 82 | 83 |
| 83 end | 84 end |
| 84 | 85 |
| 91 local bountyIndex | 92 local bountyIndex |
| 92 local debug_headers = {} | 93 local debug_headers = {} |
| 93 | 94 |
| 94 function WorldPlanSummaryMixin:Setup() | 95 function WorldPlanSummaryMixin:Setup() |
| 95 print('|cFF00FF88'..self:GetName()..':Setup()') | 96 print('|cFF00FF88'..self:GetName()..':Setup()') |
| 96 self:GetFilters() | |
| 97 end | 97 end |
| 98 | 98 |
| 99 | 99 |
| 100 function WorldPlanSummaryMixin:OnUpdate() | 100 function WorldPlanSummaryMixin:OnUpdate() |
| 101 if self.isStale then | 101 if self.isStale then |
| 115 | 115 |
| 116 print('|cFF00FFFF'..self:GetName()..':GetFilters()') | 116 print('|cFF00FFFF'..self:GetName()..':GetFilters()') |
| 117 | 117 |
| 118 wipe(self.filterList) | 118 wipe(self.filterList) |
| 119 | 119 |
| 120 for index, info in ipairs(DEFAULT_FILTER_LIST) do | 120 for index, info in ipairs(db.DefaultFilters) do |
| 121 tinsert(self.filterList, info) | 121 tinsert(self.filterList, info) |
| 122 end | 122 end |
| 123 self.bounties, self.numBounties = GetQuestBountyInfoForMapID(WorldPlan.currentMapID) | 123 self.bounties, self.numBounties = GetQuestBountyInfoForMapID(db.currentMapID) |
| 124 self.BountyFilters = {} | 124 self.BountyFilters = {} |
| 125 for index, data in ipairs(self.bounties) do | 125 for index, data in ipairs(self.bounties) do |
| 126 local info = self.BountyFilters[index] | 126 local info = self.BountyFilters[index] |
| 127 if not info then | 127 if not info then |
| 128 info = {} | 128 info = {} |
| 146 self.pinLayout = self:GetTypeInfo(255) | 146 self.pinLayout = self:GetTypeInfo(255) |
| 147 self:GetFilters() | 147 self:GetFilters() |
| 148 end | 148 end |
| 149 | 149 |
| 150 function WorldPlanSummaryMixin:Refresh() | 150 function WorldPlanSummaryMixin:Refresh() |
| 151 self:GetFilters() | |
| 151 self:Update() | 152 self:Update() |
| 152 end | 153 end |
| 153 | 154 |
| 154 local filterFill = "Interface\\BUTTONS\\YELLOWORANGE64" | 155 local filterFill = "Interface\\BUTTONS\\YELLOWORANGE64" |
| 155 local filterMask = "Interface\\Minimap\\UI-Minimap-Background" | 156 local filterMask = "Interface\\Minimap\\UI-Minimap-Background" |
| 156 | 157 |
| 157 local questResults = {{}} | 158 local questResults = {{}} |
| 158 function WorldPlanSummaryMixin:Update() | 159 function WorldPlanSummaryMixin:Update() |
| 159 local blocks = self.buttons | 160 local blocks = self.buttons |
| 161 | |
| 160 local relativeFrame = WorldMapFrame.UIElementsFrame.TrackingOptionsButton | 162 local relativeFrame = WorldMapFrame.UIElementsFrame.TrackingOptionsButton |
| 161 local numHeaders = 0 | 163 if FlightMapFrame and FlightMapFrame:IsVisible() then |
| 164 relativeFrame = FlightMapFrame | |
| 165 end | |
| 166 self:SetParent(relativeFrame) | |
| 167 | |
| 168 local numHeaders = 0 | |
| 162 print('|cFF00FF88'..self:GetName()..':Update()|r', 'currentMap=',WorldPlan.currentMapID) | 169 print('|cFF00FF88'..self:GetName()..':Update()|r', 'currentMap=',WorldPlan.currentMapID) |
| 163 | 170 |
| 164 local layout = DEFAULT_FILTER_LAYOUT | 171 |
| 172 local layout = db.DefaultFilterType | |
| 165 local borderWidth = layout.iconWidth + (layout.borderWidth * 2) | 173 local borderWidth = layout.iconWidth + (layout.borderWidth * 2) |
| 166 local highlightWidth = borderWidth + (layout.highlightWidth * 2) | 174 local highlightWidth = borderWidth + (layout.highlightWidth * 2) |
| 167 local quests = WorldPlanQuests.QuestsByZone[WorldPlan.currentMapID] or WorldPlanQuests.QuestsByID | 175 local mapQuests = db.QuestsByZone[db.currentMapID] or db.QuestsByID |
| 168 local foundQuests = questResults[1] | 176 local firstCvar, lastCvar |
| 169 for index, info in ipairs(self.filterList) do | 177 for index, info in ipairs(self.filterList) do |
| 170 local numQuests = 0 | 178 local numQuestsHere = 0 |
| 171 local resultIndex = numHeaders + 1 | 179 local numQuestsTotal = 0 |
| 172 questResults[resultIndex] = questResults[resultIndex] or {} | 180 info.questList = info.questList or {} |
| 173 wipe(questResults[resultIndex]) | 181 wipe(info.questList) |
| 174 for questID, pin in pairs(quests) do | 182 |
| 175 if pin.used then | 183 for questID, pin in pairs(db.QuestsByID) do |
| 184 print(pin.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION, (db.Config.ShowAllProfessionQuests or pin.isKnownProfession)) | |
| 185 if (pin.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION) or (db.Config.ShowAllProfessionQuests or pin.isKnownProfession) then | |
| 186 print(pin.title) | |
| 176 if not info.filterKey then | 187 if not info.filterKey then |
| 177 numQuests = numQuests + 1 | 188 if mapQuests[questID] then |
| 189 numQuestsHere = numQuestsHere + 1 | |
| 190 end | |
| 191 numQuestsTotal = numQuestsTotal + 1 | |
| 178 elseif pin[info.filterKey] == info.filterValue then | 192 elseif pin[info.filterKey] == info.filterValue then |
| 179 numQuests = numQuests + 1 | 193 if mapQuests[questID] then |
| 180 tinsert(questResults[resultIndex], pin) | 194 numQuestsHere = numQuestsHere + 1 |
| 181 end | 195 tinsert(info.questList, pin) |
| 182 end | 196 end |
| 183 end | 197 numQuestsTotal = numQuestsTotal + 1 |
| 184 print(tostring(index).. ' ("'..tostring(info.label)..'" f('.. tostring(info.filterKey).. '='..tostring(info.filterValue) .. '), '..tostring(numQuests)..')') | 198 end |
| 185 | 199 end |
| 186 if numQuests >= 1 then | 200 end |
| 201 --print('num here', numQuestsHere, numQuestsTotal) | |
| 202 info.totalQuests = maxQuests | |
| 203 | |
| 204 --print(tostring(index).. ' ("'..tostring(info.label)..'" f('.. tostring(info.filterKey).. '='..tostring(info.filterValue) .. '), '..tostring(numQuests)..')') | |
| 205 | |
| 206 if numQuestsTotal >= 1 then | |
| 187 numHeaders = numHeaders + 1 | 207 numHeaders = numHeaders + 1 |
| 188 local button = blocks[numHeaders] | 208 local button = blocks[numHeaders] |
| 189 if not blocks[numHeaders] then | 209 if not blocks[numHeaders] then |
| 190 button = CreateFrame('Button', 'WorldPlanFilterButton'..numHeaders, WorldMapScrollFrame, 'WorldPlanFilterPin') | 210 button = CreateFrame('Button', 'WorldPlanFilterButton'..numHeaders, self, 'WorldPlanFilterPin') |
| 191 button:SetSize(borderWidth, borderWidth) | 211 button:SetSize(32,20) |
| 192 | 212 button.icon:SetTexCoord(0.1,.9,.1,(1 * (20/32))) |
| 193 button.icon:SetSize(layout.iconWidth, layout.iconWidth) | 213 |
| 194 button.RewardBorder:SetSize(borderWidth, borderWidth) | 214 button.RewardBorder:ClearAllPoints() |
| 195 button.HighlightBorder:SetSize(highlightWidth, highlightWidth) | 215 button.RewardBorder:SetPoint('TOPLEFT', button, 'TOPLEFT') |
| 196 button.RewardBorder:SetMask(filterMask) | 216 button.RewardBorder:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT') |
| 197 button.RewardBorder:SetDesaturated(true) | 217 |
| 198 | 218 |
| 199 button.HighlightBorder:Hide() | |
| 200 blocks[numHeaders] = button | 219 blocks[numHeaders] = button |
| 201 end | 220 end |
| 202 | 221 |
| 203 button.info = info | 222 button.info = info |
| 204 button.questList = questResults[resultIndex] | 223 button.numQuestsTotal = numQuestsTotal |
| 224 button.numQuestsHere = numQuestsHere | |
| 225 button.questList = info.questList | |
| 226 button.isFirst = (numHeaders == 1) | |
| 205 button:SetID(index) | 227 button:SetID(index) |
| 206 button.spacing = ((relativeFrame.cVar and (not info.cVar)) or (relativeFrame.filterKey ~= info.filterKey)) and 5 or 0 | 228 button.spacing = ((relativeFrame.cVar and (not info.cVar)) or (relativeFrame.filterKey ~= info.filterKey)) and 5 or 1 |
| 207 button.relativeFrame = relativeFrame | 229 button.relativeFrame = relativeFrame |
| 208 button:Refresh((numHeaders == 1), numQuests) | 230 button:Refresh() |
| 209 button:Show() | 231 button:Show() |
| 210 relativeFrame = button | 232 relativeFrame = button |
| 211 end | 233 |
| 212 | 234 if info.cVar then |
| 235 firstCvar = firstCvar or button | |
| 236 lastCvar = button | |
| 237 end | |
| 238 | |
| 239 end | |
| 213 end | 240 end |
| 214 | 241 |
| 215 self.numHeaders = numHeaders | 242 self.numHeaders = numHeaders |
| 216 for i = numHeaders + 1, #blocks do | 243 for i = numHeaders + 1, #blocks do |
| 217 if blocks[i] then | 244 if blocks[i] then |
| 219 end | 246 end |
| 220 if questResults[i] then | 247 if questResults[i] then |
| 221 wipe(questResults[i]) | 248 wipe(questResults[i]) |
| 222 end | 249 end |
| 223 end | 250 end |
| 251 | |
| 252 | |
| 253 if firstCvar and lastCvar then | |
| 254 self.CVarsHighlight:ClearAllPoints() | |
| 255 self.CVarsHighlight:SetPoint('TOPLEFT', firstCvar, 'TOPLEFT', -1, 1) | |
| 256 self.CVarsHighlight:SetPoint('BOTTOMRIGHT', lastCvar, 'BOTTOMRIGHT', 1, -1) | |
| 257 end | |
| 258 self.CVarsHighlight:SetShown(self.cvarFiltersDirty or false) | |
| 259 | |
| 260 | |
| 224 self.isStale = nil | 261 self.isStale = nil |
| 225 end | 262 end |
| 226 | 263 |
| 227 function WorldPlanSummaryMixin:Cleanup() | 264 function WorldPlanSummaryMixin:Cleanup() |
| 228 -- hide trailing buttons | 265 -- hide trailing buttons |
| 229 end | 266 end |
| 230 | 267 |
| 231 local rgbWhite = {r = 1, g= 1, b= 1, hex = '|cFFFFFFFF'} | 268 local rgbWhite = {r = 1, g= 1, b= 1, hex = '|cFFFFFFFF'} |
| 232 function WorldPlanFilterPinMixin:OnEnter() | 269 function WorldPlanFilterPinMixin:OnEnter() |
| 233 if self.questList and #self.questList >= 1 then | 270 if #self.questList >= 1 then |
| 234 GameTooltip:SetOwner(self, 'ANCHOR_LEFT') | 271 GameTooltip:SetOwner(self, 'ANCHOR_LEFT') |
| 235 GameTooltip:AddLine(self.info.label) | 272 GameTooltip:AddLine(self.info.label) |
| 236 for index, pin in ipairs(self.questList) do | 273 for index, pin in ipairs(self.questList) do |
| 237 local colorInfo = (pin.quality and ITEM_QUALITY_COLORS[pin.quality]) or rgbWhite | 274 local colorInfo = (pin.quality and ITEM_QUALITY_COLORS[pin.quality]) or rgbWhite |
| 238 GameTooltip:AddLine('|T'.. tostring(pin.itemTexture)..':16:16|t ' .. pin.title ..(pin.cheevos and " |cFFFFFF00!|R" or ''), colorInfo.r, colorInfo.g, colorInfo.b) | 275 GameTooltip:AddLine('|T'.. tostring(pin.itemTexture)..':16:16|t ' .. tostring(pin.title) ..(pin.cheevos and " |cFFFFFF00!|R" or ''), colorInfo.r, colorInfo.g, colorInfo.b) |
| 239 end | 276 end |
| 277 GameTooltip:AddLine(self.numQuestsTotal .. ' total') | |
| 240 GameTooltip:Show() | 278 GameTooltip:Show() |
| 241 end | 279 end |
| 242 end | 280 end |
| 243 | 281 |
| 244 function WorldPlanFilterPinMixin:OnLeave() | 282 function WorldPlanFilterPinMixin:OnLeave() |
| 245 if GameTooltip:IsOwned(self) then | 283 if GameTooltip:IsOwned(self) then |
| 246 GameTooltip:Hide() | 284 GameTooltip:Hide() |
| 247 end | 285 end |
| 248 end | 286 end |
| 249 | 287 |
| 250 function WorldPlanFilterPinMixin:Refresh(isFirst, numQuests) | 288 function WorldPlanFilterPinMixin:Refresh() |
| 251 isFirst = isFirst or self.isFirst | |
| 252 numQuests = numQuests or self.numQuests | |
| 253 | |
| 254 local info = self.info | 289 local info = self.info |
| 255 | |
| 256 self.isFirst = isFirst | |
| 257 self.numQuests = numQuests | |
| 258 self.filterKey = info.filterKey | 290 self.filterKey = info.filterKey |
| 259 self.filterValue = info.filterValue | 291 self.filterValue = info.filterValue |
| 260 self.tagID = info.tagID | 292 self.tagID = info.tagID |
| 261 | 293 |
| 262 self.icon:SetMask(filterMask) | |
| 263 self.icon:SetTexture(info.texture) | 294 self.icon:SetTexture(info.texture) |
| 264 self.count:SetText(numQuests) | 295 self.count:SetText(self.numQuestsHere) |
| 265 self.cVar = info.cVar | 296 self.cVar = info.cVar |
| 266 | 297 |
| 267 self.itemTexture = self.texture | 298 self.itemTexture = self.texture |
| 268 | 299 |
| 269 if isFirst then | 300 if self.isFirst then |
| 270 self:SetPoint('TOP', self.relativeFrame, 'BOTTOM', 0, -5) | 301 if FlightMapFrame and FlightMapFrame:IsVisible() then |
| 302 self:SetPoint('TOPRIGHT', FlightMapFrame, 'TOPRIGHT', -4, -25) | |
| 303 else | |
| 304 self:SetPoint('TOP', self.relativeFrame, 'BOTTOM', 0, -5) | |
| 305 end | |
| 306 | |
| 271 else | 307 else |
| 272 self:SetPoint('TOPRIGHT', self.relativeFrame, 'BOTTOMRIGHT', 0, -(self.spacing or 0)) | 308 self:SetPoint('TOPRIGHT', self.relativeFrame, 'BOTTOMRIGHT', 0, -(self.spacing or 0)) |
| 273 end | 309 end |
| 274 print('anchor to', self.relativeFrame:GetName(), info.mask) | 310 print('anchor to', self.relativeFrame:GetName(), info.mask) |
| 275 | 311 |
| 276 local r, g, b, a = 1,1,1,1 | 312 self.icon:SetDesaturated(self.numQuestsHere == 0) |
| 313 | |
| 314 local r, g, b, a = 0,0,0,1 | |
| 277 local desaturated = false | 315 local desaturated = false |
| 278 if self.cVar then | 316 if (self.numQuestsHere > 0) then |
| 279 self.RewardBorder:SetVertexColor(1, 1, 1, 1) | 317 if self.cVar then |
| 280 if GetCVarBool(self.cVar) then | 318 if GetCVarBool(self.cVar) then |
| 281 self.icon:SetVertexColor(1,1,1,1) | 319 self.count:SetTextColor(1,1,1) |
| 282 self:SetAlpha(1) | 320 r,g,b = 0, 1, 0 |
| 321 else | |
| 322 self:GetParent().cvarFiltersDirty = true | |
| 323 self.count:SetTextColor(1,0,0) | |
| 324 self.icon:SetDesaturated(true) | |
| 325 r,g,b = 1, 0, 0 | |
| 326 end | |
| 283 else | 327 else |
| 284 self.icon:SetVertexColor(.5, .5, .5, 1) | 328 if db.UsedFilters[self.filterKey] then |
| 285 self:SetAlpha(0.5) | 329 if db.UsedFilters[self.filterKey] == self.filterValue then |
| 286 end | 330 self.count:SetTextColor(0,1,0) |
| 287 else | 331 r,g,b = 0, 1, 0 |
| 288 self:SetAlpha(1) | 332 else |
| 289 if WorldPlan.UsedFilters[self.filterKey] then | 333 self.count:SetTextColor(1,0,0) |
| 290 if WorldPlan.UsedFilters[self.filterKey] == self.filterValue then | 334 r, g, b = 1, 0, 0 |
| 291 self.RewardBorder:SetVertexColor(0, 1, 0) | 335 end |
| 292 else | 336 else |
| 293 self.RewardBorder:SetVertexColor(1, 0, 0) | 337 |
| 294 end | 338 self.count:SetTextColor(1,1,1) |
| 295 else | 339 if self.filterKey == 'worldQuestType' then |
| 296 if self.filterKey == 'worldQuestType' then | 340 r, g, b = 0, 0, 1 |
| 297 self.RewardBorder:SetVertexColor(0, 1, 1) | 341 elseif self.filterKey == 'factionID' then |
| 298 elseif self.filterKey == 'factionID' then | 342 r, g, b = 1, 1, 0 |
| 299 self.RewardBorder:SetVertexColor(1, 1, 0) | 343 end |
| 300 else | 344 end |
| 301 | 345 end |
| 302 self.RewardBorder:SetVertexColor(0.5, 0.5, 0.5) | 346 end |
| 303 end | 347 self.RewardBorder:SetColorTexture(r, g, b, a) |
| 304 | |
| 305 end | |
| 306 end | |
| 307 | 348 |
| 308 --self:UpdateSize() | 349 --self:UpdateSize() |
| 309 end | 350 end |
| 310 | 351 |
| 311 function WorldPlanFilterPinMixin:OnLoad() | 352 function WorldPlanFilterPinMixin:OnLoad() |
| 312 self:RegisterForClicks('AnyUp') | 353 self:RegisterForClicks('AnyUp') |
| 313 self:SetFrameStrata('HIGH') | 354 self:SetFrameStrata('HIGH') |
| 314 self:SetFrameLevel(151) | 355 self:SetFrameLevel(151) |
| 315 self:SetScript('OnUpdate', nil) | 356 self:SetScript('OnUpdate', nil) |
| 316 WorldPlanPOIMixin.OnLoad(self) | 357 self.questList = {} |
| 317 end | 358 end |
| 318 | 359 |
| 319 function WorldPlanFilterPinMixin:OnUpdate () | 360 function WorldPlanFilterPinMixin:OnUpdate () |
| 320 end | |
| 321 | |
| 322 | |
| 323 function WorldPlanFilterPinMixin:OnLeave () | |
| 324 if GameTooltip:IsOwned(self) then | |
| 325 GameTooltip:Hide() | |
| 326 end | |
| 327 end | 361 end |
| 328 | 362 |
| 329 -- shift-click: reset filter | 363 -- shift-click: reset filter |
| 330 -- click: rotate through include(1), exclude(-1), ignore(nil) | 364 -- click: rotate through include(1), exclude(-1), ignore(nil) |
| 331 local filtered_report = {} | 365 local filtered_report = {} |
| 366 local RESET_FILTER = "|cFFFFFFFF+%s|r" | |
| 367 local FILTER_EXCLUDE_TYPE = '|cFFFF0000-%s|r' | |
| 368 local FILTER_INCLUDE_TYPE = '|cFF00FF00+%s|r' | |
| 332 function WorldPlanFilterPinMixin:OnClick (button) | 369 function WorldPlanFilterPinMixin:OnClick (button) |
| 333 | 370 |
| 334 print('|cFF00FF88'..self:GetName()..':OnClick()|r', filterKey, filterValue, operation) | |
| 335 local filterKey = self.filterKey | 371 local filterKey = self.filterKey |
| 336 local filterValue = self.filterValue | 372 local filterValue = self.filterValue |
| 337 local cVar = self.cVar | 373 local cVar = self.cVar |
| 338 local parent = self:GetParent() | 374 local parent = self:GetParent() |
| 339 local operation = opPrefix | 375 local setDirty |
| 340 local setDirty = false | 376 |
| 377 print('|cFF00FF88'..self:GetName()..':OnClick()|r', filterKey, filterValue, cVar, parent) | |
| 341 | 378 |
| 342 local resetMode = (button == 'RightButton') | 379 local resetMode = (button == 'RightButton') |
| 343 wipe(filtered_report) | 380 wipe(filtered_report) |
| 344 if not (filterKey or cVar) then | 381 if not (filterKey or cVar) then |
| 345 wipe(WorldPlan.UsedFilters) | 382 for i, info in ipairs(db.DefaultFilters) do |
| 346 for i, info in ipairs(DEFAULT_FILTER_LIST) do | |
| 347 if info.cVar then | 383 if info.cVar then |
| 348 if GetCVar(info.cVar) ~= 1 then | |
| 349 tinsert(filtered_report, '|cFF888888'.. tostring(info.label) ..'|r') | |
| 350 end | |
| 351 SetCVar(info.cVar, 1) | 384 SetCVar(info.cVar, 1) |
| 352 end | 385 elseif info.filterKey then |
| 353 end | 386 if db.UsedFilters[info.filterKey] then |
| 354 | 387 db.UsedFilters[info.filterKey] = nil |
| 388 end | |
| 389 end | |
| 390 end | |
| 391 parent.cvarFiltersDirty = false | |
| 392 | |
| 393 --WorldPlan:print('All filters reset.') | |
| 355 elseif cVar then | 394 elseif cVar then |
| 356 WorldPlan:print('Toggling cvar filter:', cVar) | 395 if resetMode then |
| 357 if (not parent.isDirty) or resetMode then | 396 print('|cFFFF4400cleaning dirty') |
| 358 for i, info in ipairs(DEFAULT_FILTER_LIST) do | 397 for i, info in ipairs(db.DefaultFilters) do |
| 359 if info.cVar then | 398 if info.cVar then |
| 360 local value = GetCVar(info.cVar) | 399 parent.cvarFiltersDirty = false |
| 361 if resetMode then | 400 SetCVar(info.cVar, 1) |
| 362 value = 1 | 401 end |
| 363 parent.isDirty = nil | 402 end |
| 364 else | 403 --WorldPlan:print('Reward filters reset.') |
| 365 | 404 elseif parent.cvarFiltersDirty == true then |
| 366 if (cVar ~= info.cVar) then | 405 if GetCVarBool(cVar) then |
| 367 value = 0 | 406 tinsert(filtered_report, FILTER_EXCLUDE_TYPE:format(tostring(self.info.label))) |
| 368 else | 407 SetCVar(cVar, 0) |
| 369 value = 1 | 408 else |
| 370 end | 409 |
| 371 setDirty = true | 410 tinsert(filtered_report, FILTER_INCLUDE_TYPE:format(tostring(self.info.label))) |
| 372 | 411 SetCVar(cVar, 1) |
| 412 end | |
| 413 | |
| 414 -- check the visible filters and consider it clean if they're all lit | |
| 415 parent.cvarFiltersDirty = false | |
| 416 for i, info in ipairs(parent.filterList) do | |
| 417 if info.cVar and (#info.questList >= 1) then | |
| 418 print(info.cVar, GetCVarBool(info.cVar)) | |
| 419 if GetCVarBool(info.cVar) == false then | |
| 420 parent.cvarFiltersDirty = true | |
| 421 print('|cFFFF4400still dirty') | |
| 422 break | |
| 373 end | 423 end |
| 374 SetCVar(info.cVar, value) | 424 end |
| 375 end | |
| 376 end | |
| 377 if setDirty then | |
| 378 parent.isDirty = true | |
| 379 end | 425 end |
| 380 else | 426 else |
| 381 SetCVar(cVar, (GetCVarBool(cVar) and 0) or 1) | 427 print('|cFFFF4400making dirty') |
| 428 for i, info in ipairs(db.DefaultFilters) do | |
| 429 if info.cVar then | |
| 430 local msgType = (cVar == info.cVar) and FILTER_INCLUDE_TYPE or FILTER_EXCLUDE_TYPE | |
| 431 SetCVar(info.cVar, ((cVar == info.cVar) and 1) or 0) | |
| 432 tinsert(filtered_report, msgType:format(info.label)) | |
| 433 end | |
| 434 end | |
| 435 parent.cvarFiltersDirty = true | |
| 382 end | 436 end |
| 383 else | 437 else |
| 384 local flushValue | 438 if resetMode then |
| 385 print('') | 439 wipe(db.UsedFilters) |
| 386 if WorldPlan.UsedFilters[filterKey] == filterValue then | 440 --WorldPlan:print('Type filters reset.') |
| 387 WorldPlan.UsedFilters[filterKey] = nil | |
| 388 tinsert(filtered_report, '|cFFFF0000'.. tostring(filterKey) ..'|r') | |
| 389 else | 441 else |
| 390 WorldPlan.UsedFilters[filterKey] = filterValue | 442 if (db.UsedFilters[filterKey] == filterValue) or resetMode then |
| 391 tinsert(filtered_report, '|cFF00FF00'.. tostring(filterKey) ..'|r') | 443 db.UsedFilters[filterKey] = nil |
| 392 end | 444 tinsert(filtered_report, FILTER_INCLUDE_TYPE:format(tostring(filterKey))) |
| 393 end | 445 else |
| 394 WorldPlan:print('Changed:', table.concat(filtered_report, ', ')) | 446 db.UsedFilters[filterKey] = filterValue |
| 447 tinsert(filtered_report, FILTER_EXCLUDE_TYPE:format(tostring(filterKey))) | |
| 448 end | |
| 449 end | |
| 450 end | |
| 451 if #filtered_report >= 1 then | |
| 452 --WorldPlan:print('Setting filter(s):', table.concat(filtered_report, ', ')) | |
| 453 end | |
| 395 WorldPlan:Refresh(true) | 454 WorldPlan:Refresh(true) |
| 396 end | 455 end |
