Mercurial > wow > worldplan
comparison FilterBar.lua @ 93:98b5e08b75ed v1.4.9
- Fixed quest completion checking and handling
- Changed animation method to hopefully stop weird flickering.
- Pins are now visible before full reward data is loaded
- Filter bar redesigned:
- aligned horizontally along the top of the map display
- filter buttons display a '+' when there are matches in both current and other zones, and '*' when there only matches in other zones
- button tooltips separate local and global quests
- button categories are highlighted and labeled when the cursor is over them
- Fixed invalid POI targets appearing when the spell targeting cursor is active
author | Nenue |
---|---|
date | Sat, 15 Apr 2017 11:04:54 -0400 |
parents | a12f782571c5 |
children | b29b35cb8539 |
comparison
equal
deleted
inserted
replaced
92:df725cba1a6a | 93:98b5e08b75ed |
---|---|
13 local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT | 13 local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT |
14 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES | 14 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES |
15 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS | 15 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS |
16 | 16 |
17 | 17 |
18 local filtersUsed | |
19 local filterFill = "Interface\\BUTTONS\\YELLOWORANGE64" | |
20 local filterMask = "Interface\\Minimap\\UI-Minimap-Background" | |
21 | |
22 local HEADERS_SPACING = 3 | |
23 local BUTTONS_SPACING = 1 | |
24 local BUTTONS_HEIGHT = 20 | |
25 local TOGGLE_SIZE = 20 | |
26 local HEADERS_HEIGHT = 40 | |
27 | |
18 local LE_QUEST_TAG_TYPE_PVP = LE_QUEST_TAG_TYPE_PVP | 28 local LE_QUEST_TAG_TYPE_PVP = LE_QUEST_TAG_TYPE_PVP |
19 local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE | 29 local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE |
20 local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON | 30 local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON |
21 local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION | 31 local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION |
32 | |
33 local barMouseOver | |
34 local filtersDirty = true | |
35 local layoutDirty = true | |
36 local matchesDirty -- don't flag until first filter loadout | |
22 | 37 |
23 local familiars = { | 38 local familiars = { |
24 [42159] = {npc = 106552, name = 'Nightwatcher Merayl'}, | 39 [42159] = {npc = 106552, name = 'Nightwatcher Merayl'}, |
25 [40277] = {npc = 97804, name = 'Tiffany Nelson'}, | 40 [40277] = {npc = 97804, name = 'Tiffany Nelson'}, |
26 [40298] = {npc = 99182, name = 'Sir Galveston'}, | 41 [40298] = {npc = 99182, name = 'Sir Galveston'}, |
47 TagSize = 12, | 62 TagSize = 12, |
48 TimeleftStage = 3, | 63 TimeleftStage = 3, |
49 showNumber = true, | 64 showNumber = true, |
50 numberFontObject = 'WorldPlanNumberFontThin' | 65 numberFontObject = 'WorldPlanNumberFontThin' |
51 } | 66 } |
67 | |
68 local headerNames = { | |
69 ['rewardType'] = 'Reward Type', | |
70 ['worldQuestType'] = 'Quest Type', | |
71 ['isElite'] = 'Elite', | |
72 ['factionID'] = 'Bounties' | |
73 } | |
74 | |
52 db.DefaultFilters = { | 75 db.DefaultFilters = { |
53 { label = 'Filters', texture = "Interface\\WorldMap\\WorldMap-Icon" }, | |
54 { filterKey= 'rewardType', cVar = 'worldQuestFilterArtifactPower', filterValue = REWARD_ARTIFACT_POWER, label = 'Artifact Power', texture = "Interface\\ICONS\\inv_7xp_inscription_talenttome01" }, | 76 { filterKey= 'rewardType', cVar = 'worldQuestFilterArtifactPower', filterValue = REWARD_ARTIFACT_POWER, label = 'Artifact Power', texture = "Interface\\ICONS\\inv_7xp_inscription_talenttome01" }, |
55 { filterKey= 'rewardType', cVar = 'worldQuestFilterOrderResources', filterValue = REWARD_CURRENCY,label = 'Order Resources', texture = "Interface\\Icons\\inv_orderhall_orderresources" }, | 77 { filterKey= 'rewardType', cVar = 'worldQuestFilterOrderResources', filterValue = REWARD_CURRENCY,label = 'Order Resources', texture = "Interface\\Icons\\inv_orderhall_orderresources" }, |
56 { filterKey= 'rewardType', cVar = 'worldQuestFilterEquipment', filterValue = REWARD_GEAR, label = 'Equipment', texture = "Interface\\ICONS\\garrison_bluearmorupgrade" }, | 78 { filterKey= 'rewardType', cVar = 'worldQuestFilterEquipment', filterValue = REWARD_GEAR, label = 'Equipment', texture = "Interface\\ICONS\\garrison_bluearmorupgrade" }, |
57 { filterKey= 'rewardType', cVar = 'worldQuestFilterProfessionMaterials', filterValue = REWARD_REAGENT, label = 'Materials', texture = 1417744 }, | 79 { filterKey= 'rewardType', cVar = 'worldQuestFilterProfessionMaterials', filterValue = REWARD_REAGENT, label = 'Materials', texture = 1417744 }, |
58 { filterKey= 'rewardType', cVar = 'worldQuestFilterGold', filterValue = REWARD_CASH, label = 'Gold', texture = "Interface\\Buttons\\UI-GroupLoot-Coin-Up" }, | 80 { filterKey= 'rewardType', cVar = 'worldQuestFilterGold', filterValue = REWARD_CASH, label = 'Gold', texture = "Interface\\Buttons\\UI-GroupLoot-Coin-Up" }, |
59 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PVP, label = 'PvP', texture = "Interface\\Icons\\Ability_PVP_GladiatorMedallion", spacing = 10 }, | 81 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PVP, label = 'PvP', texture = "Interface\\Icons\\Ability_PVP_GladiatorMedallion", spacing = 10 }, |
60 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PET_BATTLE, label = 'Pet Battle', texture = "Interface\\Icons\\PetJournalPortrait", }, | 82 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PET_BATTLE, label = 'Pet Battle', texture = "Interface\\Icons\\PetJournalPortrait", }, |
61 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_DUNGEON, label = 'Dungeon', texture = "Interface\\LFGFRAME\\UI-LFR-PORTRAIT", }, | 83 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_DUNGEON, label = 'Dungeon', texture = "Interface\\LFGFRAME\\BattlenetWorking0", }, |
62 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PROFESSION, label = 'Profession', texture = "Interface\\ICONS\\70_professions_scroll_02", }, | 84 { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PROFESSION, label = 'Profession', texture = "Interface\\ICONS\\70_professions_scroll_02", }, |
85 --{ filterKey = 'isElite', filterValue = true, label = 'Elite', texture = "", desaturated = false}, | |
86 --{ filterKey = 'isElite', filterValue = false, label = 'Not-Elite', texture = "", desaturated = false}, | |
63 } | 87 } |
64 local defaults = {} | 88 local defaults = {} |
65 | 89 |
66 WorldPlanSummaryMixin = WorldPlanSummaryMixin or {} | 90 WorldPlanSummaryMixin = WorldPlanSummaryMixin or {} |
67 local Module = WorldPlanSummaryMixin | 91 local Module = WorldPlanSummaryMixin |
68 Module.selectedBountyIndex = {} | 92 Module.selectedBountyIndex = {} |
69 Module.bounties = {} | 93 Module.bounties = {} |
70 Module.filterList = {} | 94 Module.filterList = {} |
71 Module.buttons = {} | 95 Module.Buttons = {} |
96 Module.Headers = {} | |
72 Module.cvarFiltersDirty = false | 97 Module.cvarFiltersDirty = false |
73 WorldPlanFilterPinMixin = {} | 98 WorldPlanFilterButtonMixin = {} |
74 local Pin = WorldPlanFilterPinMixin | 99 local Pin = WorldPlanFilterButtonMixin |
75 | 100 |
76 function Module:OnLoad() | 101 function Module:OnLoad() |
77 self:SetParent(WorldMapFrame.UIElementsFrame) | 102 --self:SetParent(WorldMapFrame.UIElementsFrame) |
78 self:ClearAllPoints() | |
79 self:SetPoint('TOPRIGHT') | |
80 WorldPlan:AddHandler(self) | 103 WorldPlan:AddHandler(self) |
81 --[[for index, info in ipairs(db.DefaultFilters) do | 104 --[[for index, info in ipairs(db.DefaultFilters) do |
82 info.zone = db.DefaultFilterType | 105 info.zone = db.DefaultFilterType |
83 info.continent = db.DefaultFilterType | 106 info.continent = db.DefaultFilterType |
84 info.pinMask = "Interface\\Minimap\\UI-Minimap-Background" | 107 info.pinMask = "Interface\\Minimap\\UI-Minimap-Background" |
85 WorldPlan:AddTypeInfo(self,index, info) | 108 WorldPlan:AddTypeInfo(self,index, info) |
86 end | 109 end |
87 --]] | 110 --]] |
111 | |
112 | |
88 end | 113 end |
89 | 114 |
90 | 115 |
91 function Module:OnEvent(event, arg) | 116 function Module:OnEvent(event, arg) |
92 print('|cFF00FF88'..self:GetName()..':OnEvent()', event) | 117 print('|cFF00FF88'..self:GetName()..':OnEvent()', event) |
93 if (event == 'QUEST_LOG_UPDATE') and arg then | 118 if (event == 'QUEST_LOG_UPDATE') and arg then |
94 if db.QuestsByID[arg] then | 119 filtersDirty = true |
95 if db.QuestsByID[arg].factionID then | 120 self:Refresh() |
96 | 121 end |
97 end | |
98 end | |
99 end | |
100 | |
101 self.isStale = true | |
102 end | 122 end |
103 | 123 |
104 local bountyIndex | 124 local bountyIndex |
105 local debug_headers = {} | 125 local debug_headers = {} |
106 | 126 local ToggleButton = {} |
107 function Module:Setup() | 127 function Module:Setup() |
108 print('|cFF00FF88'..self:GetName()..':Setup()') | 128 print('|cFF00FF88'..self:GetName()..':Setup()') |
109 self.isStale = true | 129 self.isStale = true |
110 self:SetShown(true) | 130 self:SetParent(WorldMapFrame.UIElementsFrame) |
111 end | 131 --self:SetPoint('BOTTOMLEFT') |
112 | 132 for k,v in pairs( ToggleButton) do |
113 | 133 self.Toggle:SetScript(k,v) |
114 function Module:OnUpdate() | 134 end |
135 self.Toggle:SetSize(TOGGLE_SIZE, TOGGLE_SIZE) | |
136 | |
137 end | |
138 | |
139 | |
140 function Module:OnUpdate(sinceLast) | |
115 if self.isStale then | 141 if self.isStale then |
116 wprint('|cFF00FF00pushing update') | 142 print('|cFF00FF00pushing update') |
117 self:Refresh() | 143 self:Refresh() |
118 end | 144 end |
145 | |
146 barMouseOver = self:IsMouseOver() | |
147 if barMouseOver or filtersUsed then | |
148 | |
149 self.toAlpha = 1 | |
150 self.Backdrop:Show() | |
151 else | |
152 self.toAlpha = 0.25 | |
153 self.Backdrop:Hide() | |
154 end | |
155 local cAlpha = self:GetAlpha() | |
156 if cAlpha ~= self.toAlpha then | |
157 if cAlpha > self.toAlpha then | |
158 cAlpha = cAlpha - sinceLast*4 | |
159 if cAlpha <= self.toAlpha then | |
160 cAlpha = self.toAlpha | |
161 end | |
162 else | |
163 cAlpha = cAlpha + sinceLast*4 | |
164 if cAlpha >= self.toAlpha then | |
165 cAlpha = self.toAlpha | |
166 end | |
167 end | |
168 end | |
169 self:SetAlpha(cAlpha) | |
119 end | 170 end |
120 | 171 |
121 function Module:OnMapInfo(isBrokenIsle, isZoomedOut, mapAreaID, isNewMap, isMapOpen) | 172 function Module:OnMapInfo(isBrokenIsle, isZoomedOut, mapAreaID, isNewMap, isMapOpen) |
122 print('|cFFFFFF00OnMapInfo()', isBrokenIsle, isZoomedOut, mapAreaID, isNewMap, isMapOpen) | 173 print('|cFFFFFF00OnMapInfo()', isBrokenIsle, isZoomedOut, mapAreaID, isNewMap, isMapOpen) |
123 if not isBrokenIsle then | 174 if not isBrokenIsle then |
124 self:SetShown(false) | 175 self:SetShown(false) |
125 else | 176 else |
126 if self:IsShown() then | 177 self:SetShown(true) |
178 if isMapOpen then | |
127 self:Refresh() | 179 self:Refresh() |
128 end | 180 else |
129 self:SetShown(true) | 181 matchesDirty = true |
182 layoutDirty = true | |
183 end | |
130 end | 184 end |
131 end | 185 end |
132 | 186 |
133 function Module:OnShow() | 187 function Module:OnShow() |
134 print('|cFF00FF88'..self:GetName()..':OnShow()') | 188 print('|cFF00FF88'..self:GetName()..':OnShow()') |
135 if self.isStale then | 189 self:Refresh() |
136 self:Refresh() | 190 end |
137 end | 191 |
192 local IsBountyCriteria = function(poiFrame, questID) | |
193 return IsQuestCriteriaForBounty(poiFrame.questID, questID) | |
138 end | 194 end |
139 | 195 |
140 local tinsert, GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID = tinsert, GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID | 196 local tinsert, GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID = tinsert, GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID |
141 function Module:GetFilters() | 197 |
142 | 198 function Module:OnConfigUpdate() |
143 print('|cFF00FFFF'..self:GetName()..':GetFilters()') | 199 |
144 | 200 ToggleButton.OnShow(self.Toggle) |
145 wipe(self.filterList) | 201 end |
202 | |
203 function Module:Reset() | |
204 self:UpdateFilters('SUMMARY_RESET') | |
205 self:UpdateMatches('SUMMARY_RESET') | |
206 self:UpdateLayout('SUMMARY_RESET') | |
207 end | |
208 | |
209 function Module:Refresh() | |
210 self:UpdateFilters('SUMMARY_REFRESH') | |
211 self:UpdateMatches('SUMMARY_REFRESH') | |
212 self:UpdateLayout('SUMMARY_REFRESH') | |
213 end | |
214 | |
215 local questResults = {{} } | |
216 db.FilterList = {} | |
217 | |
218 function Module:UpdateFilters(event) | |
219 | |
220 print('|cFF00FFFF'..self:GetName()..':GetFilters()', event) | |
221 | |
222 wipe(db.FilterList) | |
146 | 223 |
147 for index, info in ipairs(db.DefaultFilters) do | 224 for index, info in ipairs(db.DefaultFilters) do |
148 tinsert(self.filterList, info) | 225 tinsert(db.FilterList, info) |
149 end | 226 end |
150 self.bounties, self.numBounties = GetQuestBountyInfoForMapID(db.currentMapID) | 227 self.bounties = db.Bounties |
151 self.BountyFilters = {} | 228 self.BountyFilters = {} |
152 for index, data in ipairs(self.bounties) do | 229 for index, data in ipairs(self.bounties) do |
153 local info = self.BountyFilters[index] | 230 if not IsQuestComplete(data.questID) then |
154 if not info then | 231 |
155 info = {} | 232 local info = self.BountyFilters[index] |
156 self.BountyFilters[index] = info | 233 if not info then |
157 end | 234 info = {} |
158 | 235 self.BountyFilters[index] = info |
159 local questTitle = GetQuestLogTitle(GetQuestLogIndexByID(data.questID)) | 236 layoutDirty = true |
160 | 237 else |
161 info.filterKey = 'factionID' | 238 if info.questID ~= data.questID then |
162 info.filterValue = data.factionID | 239 layoutDirty = true |
163 info.label = questTitle | 240 end |
164 info.texture = data.icon | 241 end |
165 print('loading emissary', questTitle) | 242 |
166 | 243 local questTitle = GetQuestLogTitle(GetQuestLogIndexByID(data.questID)) |
167 tinsert(self.filterList, info) | 244 info.filterKey = 'factionID' |
168 --{ filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PROFESSION, label = 'Profession', texture = "Interface\\LFGFRAME\\UI-LFR-PORTRAIT", }, | 245 info.filterFunc = IsBountyCriteria |
169 end | 246 info.filterValue = data.questID |
170 end | 247 info.label = questTitle |
171 | 248 info.texture = data.icon |
172 function Module:Reset() | 249 print('loading emissary', questTitle) |
173 self:GetFilters() | 250 |
174 end | 251 tinsert(db.FilterList, info) |
175 | 252 --{ filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_PROFESSION, label = 'Profession', texture = "Interface\\LFGFRAME\\UI-LFR-PORTRAIT", }, |
176 function Module:Refresh() | 253 end |
177 self:GetFilters() | 254 |
178 self:Update() | 255 end |
179 end | 256 end |
180 | 257 |
181 local filterFill = "Interface\\BUTTONS\\YELLOWORANGE64" | 258 function Module:UpdateMatches(event) |
182 local filterMask = "Interface\\Minimap\\UI-Minimap-Background" | 259 print('|cFF00FF00UpdateMatches()', event) |
183 | 260 local quests = db.QuestsByID |
184 local questResults = {{}} | 261 local questsForMap = db.QuestsByZone[db.currentMapID] or quests |
185 function Module:Update() | 262 |
186 local blocks = self.buttons | 263 for index, info in ipairs(db.FilterList) do |
187 | 264 info.GlobalMatches = info.GlobalMatches or {} |
265 info.LocalMatches = info.LocalMatches or {} | |
266 wipe(info.GlobalMatches) | |
267 wipe(info.LocalMatches) | |
268 print(info.filterKey, info.filterValue, info.filterFunc and 'func test' or 'compare') | |
269 for questID, pin in pairs(quests) do | |
270 print('', questID, pin.dataLoaded, (not IsQuestComplete(questID))) | |
271 if pin.dataLoaded and not IsQuestComplete(questID) then | |
272 | |
273 local keyName, keyValue = info.filterKey, info.filterValue | |
274 local isMatch | |
275 if info.filterFunc then | |
276 | |
277 isMatch = info.filterFunc(pin, keyValue) | |
278 print(' running special function, result =', isMatch) | |
279 | |
280 elseif pin[keyName] and (pin[keyName] == keyValue) then | |
281 isMatch = true | |
282 print(' rote match') | |
283 end | |
284 if isMatch then | |
285 tinsert(info.GlobalMatches, pin) | |
286 if questsForMap[questID] then | |
287 print(' local map') | |
288 tinsert(info.LocalMatches, pin) | |
289 end | |
290 | |
291 end | |
292 end | |
293 | |
294 end | |
295 print('global', #info.GlobalMatches, 'local', #info.LocalMatches) | |
296 end | |
297 end | |
298 | |
299 function Module:UpdateLayout(event) | |
300 print('|cFF00FF88UpdateLayout()|r', event, 'currentMap=',db.currentMapID) | |
301 | |
302 self.filtersSelected = nil | |
303 | |
304 local currentHeader | |
188 local relativeFrame = self | 305 local relativeFrame = self |
189 | 306 local lastKey |
190 local numHeaders = 0 | 307 |
191 print('|cFF00FF88'..self:GetName()..':Update()|r', 'currentMap=',db.currentMapID) | 308 local numHeaders = 0 |
309 local numButtons = 0 | |
310 | |
311 local layoutWidth = TOGGLE_SIZE + HEADERS_SPACING * 2 | |
312 local headerWidth = HEADERS_SPACING | |
192 | 313 |
193 | 314 |
194 local layout = db.DefaultFilterType | 315 local layout = db.DefaultFilterType |
195 local borderWidth = layout.iconWidth + (layout.borderWidth * 2) | 316 local borderWidth = layout.iconWidth + (layout.borderWidth * 2) |
196 local highlightWidth = borderWidth + (layout.highlightWidth * 2) | 317 local highlightWidth = borderWidth + (layout.highlightWidth * 2) |
199 for _ in pairs(mapQuests) do | 320 for _ in pairs(mapQuests) do |
200 n = n + 1 | 321 n = n + 1 |
201 end | 322 end |
202 print(n, 'pins to work with') | 323 print(n, 'pins to work with') |
203 | 324 |
325 | |
326 filtersUsed = nil | |
204 local firstCvar, lastCvar | 327 local firstCvar, lastCvar |
205 for index, info in ipairs(self.filterList) do | 328 local isFirst = true |
206 local numQuestsHere = 0 | 329 for index, info in ipairs(db.FilterList) do |
207 local numQuestsTotal = 0 | |
208 info.questList = info.questList or {} | |
209 wipe(info.questList) | |
210 print(info.filterKey, info.filterValue) | |
211 | |
212 for questID, pin in pairs(db.QuestsByID) do | |
213 --print(pin.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION, (db.Config.ShowAllProfessionQuests or pin.isKnownProfession)) | |
214 if pin.used then | |
215 | |
216 print(pin.title, mapQuests[questID]) | |
217 if (pin.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION) or (db.Config.ShowAllProfessionQuests or pin.isKnownProfession) then | |
218 | |
219 if not info.filterKey then | |
220 if mapQuests[questID] then | |
221 numQuestsHere = numQuestsHere + 1 | |
222 end | |
223 numQuestsTotal = numQuestsTotal + 1 | |
224 elseif pin[info.filterKey] == info.filterValue then | |
225 if mapQuests[questID] then | |
226 numQuestsHere = numQuestsHere + 1 | |
227 tinsert(info.questList, pin) | |
228 end | |
229 numQuestsTotal = numQuestsTotal + 1 | |
230 end | |
231 end | |
232 end | |
233 | |
234 end | |
235 --print('num here', numQuestsHere, numQuestsTotal) | 330 --print('num here', numQuestsHere, numQuestsTotal) |
236 info.totalQuests = numQuestsTotal | 331 |
237 | 332 |
238 --print(tostring(index).. ' ("'..tostring(info.label)..'" f('.. tostring(info.filterKey).. '='..tostring(info.filterValue) .. '), '..tostring(numQuests)..')') | 333 --print(tostring(index).. ' ("'..tostring(info.label)..'" f('.. tostring(info.filterKey).. '='..tostring(info.filterValue) .. '), '..tostring(numQuests)..')') |
239 | 334 |
240 if numQuestsTotal >= 1 then | 335 if #info.GlobalMatches >= 1 then |
241 numHeaders = numHeaders + 1 | 336 if info.filterKey ~= lastKey then |
242 local button = blocks[numHeaders] | 337 |
243 if not blocks[numHeaders] then | 338 numHeaders = numHeaders + 1 |
244 button = CreateFrame('Button', 'WorldPlanFilterButton'..numHeaders, self, 'WorldPlanFilterPin') | 339 local nextHeader = self.Headers[numHeaders] or CreateFrame('Frame', 'FilterHeader' .. numHeaders, self, 'WorldPlanFilterHeader') |
245 button:SetSize(32,20) | 340 if currentHeader then |
246 button.icon:SetTexCoord(0.1,.9,.1,(1 * (20/32))) | 341 nextHeader:SetPoint('TOPLEFT', currentHeader, 'TOPRIGHT', 0, 0) |
342 | |
343 currentHeader:SetSize(headerWidth - BUTTONS_SPACING + HEADERS_SPACING, HEADERS_HEIGHT) | |
344 layoutWidth = layoutWidth + headerWidth | |
345 headerWidth = HEADERS_SPACING | |
346 else | |
347 nextHeader:SetPoint('TOPLEFT', TOGGLE_SIZE + HEADERS_SPACING * 2, 0) | |
348 | |
349 end | |
350 | |
351 print(' begin header '..numHeaders, 'layout width =', floor(layoutWidth+.5)) | |
352 isFirst = true | |
353 currentHeader = nextHeader | |
354 currentHeader.Backdrop:SetHeight(BUTTONS_HEIGHT *2) | |
355 currentHeader.Label:SetText(headerNames[info.filterKey]) | |
356 relativeFrame = currentHeader | |
357 end | |
358 | |
359 numButtons = numButtons + 1 | |
360 local button = self.Buttons[numButtons] | |
361 if not button then | |
362 button = CreateFrame('Button', 'FilterButton'..numButtons, self, 'WorldPlanFilterButton') | |
363 button:SetSize(32,BUTTONS_HEIGHT) | |
364 button.icon:SetTexCoord(0.1,.9,.1,(1 * (BUTTONS_HEIGHT/32))) | |
247 | 365 |
248 button.RewardBorder:ClearAllPoints() | 366 button.RewardBorder:ClearAllPoints() |
249 button.RewardBorder:SetPoint('TOPLEFT', button, 'TOPLEFT') | 367 button.RewardBorder:SetPoint('TOPLEFT', button, 'TOPLEFT') |
250 button.RewardBorder:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT') | 368 button.RewardBorder:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT') |
251 | |
252 | |
253 blocks[numHeaders] = button | |
254 end | 369 end |
255 | 370 |
256 button.info = info | 371 button.info = info |
257 button.numQuestsTotal = numQuestsTotal | 372 button.numQuestsTotal = #info.GlobalMatches |
258 button.numQuestsHere = numQuestsHere | 373 button.numQuestsHere = #info.LocalMatches |
259 button.questList = info.questList | 374 button.GlobalMatches = info.GlobalMatches |
260 button.isFirst = (numHeaders == 1) | 375 button.LocalMatches = info.LocalMatches |
376 button.isFirst = isFirst | |
261 button:SetID(index) | 377 button:SetID(index) |
262 button.spacing = ((relativeFrame.cVar and (not info.cVar)) or (relativeFrame.filterKey ~= info.filterKey)) and 5 or 1 | 378 button:SetParent(currentHeader) |
263 button.relativeFrame = relativeFrame | 379 button.relativeFrame = relativeFrame |
264 button:Refresh() | 380 button:Refresh() |
265 button:Show() | 381 button:Show() |
266 relativeFrame = button | 382 relativeFrame = button |
267 | 383 headerWidth = headerWidth + button:GetWidth() + BUTTONS_SPACING |
384 | |
385 isFirst = false | |
268 if info.cVar then | 386 if info.cVar then |
269 firstCvar = firstCvar or button | 387 firstCvar = firstCvar or button |
270 lastCvar = button | 388 lastCvar = button |
271 end | 389 end |
272 | 390 lastKey = info.filterKey |
273 end | 391 end |
274 end | 392 end |
275 | 393 |
276 self.numHeaders = numHeaders | 394 self.numHeaders = numHeaders |
277 for i = numHeaders + 1, #blocks do | 395 for i = numButtons + 1, #self.Buttons do |
278 if blocks[i] then | 396 if self.Buttons[i] then |
279 blocks[i]:Hide() | 397 self.Buttons[i]:Hide() |
280 wipe(blocks[i].questList) | 398 wipe(self.Buttons[i].LocalMatches) |
281 end | 399 wipe(self.Buttons[i].GlobalMatches) |
282 end | 400 end |
283 | 401 end |
284 | 402 for i = numHeaders + 1, #self.Headers do |
285 | 403 if self.Headers[i] then |
404 self.Headers[i]:Hide() | |
405 end | |
406 end | |
407 | |
408 | |
409 if currentHeader then | |
410 currentHeader:SetSize(headerWidth - BUTTONS_SPACING + HEADERS_SPACING, HEADERS_HEIGHT) | |
411 layoutWidth = layoutWidth + headerWidth + HEADERS_SPACING | |
412 end | |
413 | |
414 self:SetSize(layoutWidth, BUTTONS_HEIGHT + BUTTONS_SPACING * 2) | |
415 self:ClearAllPoints() | |
416 self:SetPoint('TOP') | |
286 self.isStale = nil | 417 self.isStale = nil |
418 layoutDirty = nil | |
287 end | 419 end |
288 | 420 |
289 function Module:Cleanup() | 421 function Module:Cleanup() |
290 -- hide trailing buttons | 422 -- hide trailing buttons |
291 end | 423 end |
292 | 424 |
293 local rgbWhite = {r = 1, g= 1, b= 1, hex = '|cFFFFFFFF'} | 425 local rgbWhite = {r = 1, g= 1, b= 1, hex = '|cFFFFFFFF' } |
426 local found = {} | |
294 function Pin:OnEnter() | 427 function Pin:OnEnter() |
295 if #self.questList >= 1 then | 428 if #self.GlobalMatches >= 1 then |
296 GameTooltip:SetOwner(self, 'ANCHOR_LEFT') | 429 GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMRIGHT') |
297 GameTooltip:AddLine(self.info.label) | 430 GameTooltip:AddLine(self.info.label) |
298 for index, pin in ipairs(self.questList) do | 431 wipe(found) |
299 local colorInfo = (pin.quality and ITEM_QUALITY_COLORS[pin.quality]) or rgbWhite | 432 |
300 GameTooltip:AddLine('|T'.. tostring(pin.itemTexture)..':16:16|t ' .. tostring(pin.title) ..(pin.cheevos and " |cFFFFFF00!|R" or ''), colorInfo.r, colorInfo.g, colorInfo.b) | 433 if self.numQuestsHere >= 1 then |
301 end | 434 if self.numQuestsHere < self.numQuestsTotal then |
435 GameTooltip:AddLine('This Zone', 1, 1, 0) | |
436 end | |
437 for index, pin in ipairs(self.LocalMatches) do | |
438 local colorInfo = (pin.quality and ITEM_QUALITY_COLORS[pin.quality]) or rgbWhite | |
439 found[pin] = pin | |
440 GameTooltip:AddLine('|T'.. tostring(pin.itemTexture)..':16:16|t ' .. tostring(pin.title) ..(pin.cheevos and " |cFFFFFF00!|R" or ''), 0, 1, 0) | |
441 end | |
442 end | |
443 | |
444 if self.numQuestsHere < self.numQuestsTotal then | |
445 if self.numQuestsHere >= 1 then | |
446 GameTooltip:AddLine(' ') | |
447 end | |
448 GameTooltip:AddLine('Other Maps', 1, 1, 0) | |
449 for index, pin in ipairs(self.GlobalMatches) do | |
450 if not found[pin] then | |
451 local colorInfo = (pin.quality and ITEM_QUALITY_COLORS[pin.quality]) or rgbWhite | |
452 found[pin] = pin | |
453 GameTooltip:AddLine('|T'.. tostring(pin.itemTexture)..':16:16|t ' .. tostring(pin.title) ..(pin.cheevos and " |cFFFFFF00!|R" or ''), 1, 1, 1) | |
454 end | |
455 end | |
456 end | |
457 | |
458 | |
302 GameTooltip:AddLine(self.numQuestsTotal .. ' total') | 459 GameTooltip:AddLine(self.numQuestsTotal .. ' total') |
303 GameTooltip:Show() | 460 GameTooltip:Show() |
304 end | 461 end |
305 end | 462 end |
306 | 463 |
315 self.filterKey = info.filterKey | 472 self.filterKey = info.filterKey |
316 self.filterValue = info.filterValue | 473 self.filterValue = info.filterValue |
317 self.tagID = info.tagID | 474 self.tagID = info.tagID |
318 | 475 |
319 self.icon:SetTexture(info.texture) | 476 self.icon:SetTexture(info.texture) |
320 self.count:SetText(self.numQuestsHere) | 477 |
478 if (self.numQuestsHere == 0) and (self.numQuestsTotal >= 1) then | |
479 self.count:SetText('*'..self.numQuestsTotal) | |
480 self.count:SetTextColor(0,1,1) | |
481 elseif self.numQuestsHere < self.numQuestsTotal then | |
482 self.count:SetText(self.numQuestsHere..'+') | |
483 self.count:SetTextColor(1,1,0) | |
484 else | |
485 self.count:SetText(self.numQuestsHere) | |
486 self.count:SetTextColor(1,1,1) | |
487 end | |
488 | |
321 self.cVar = info.cVar | 489 self.cVar = info.cVar |
322 | |
323 self.itemTexture = self.texture | 490 self.itemTexture = self.texture |
324 | 491 |
325 self:ClearAllPoints() | 492 self:ClearAllPoints() |
326 if self.isFirst then | 493 if self.isFirst then |
327 self:SetPoint('TOPRIGHT', self.relativeFrame, 'TOPRIGHT', -5, -42) | 494 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPLEFT', HEADERS_SPACING, -HEADERS_SPACING) |
328 else | 495 else |
329 self:SetPoint('TOPLEFT', self.relativeFrame, 'BOTTOMLEFT', 0, -(self.spacing or 0)) | 496 self:SetPoint('LEFT', self.relativeFrame, 'RIGHT', BUTTONS_SPACING, 0) |
330 end | 497 end |
331 print('anchor', self.relativeFrame:IsShown(), self:GetPoint(1)) | 498 --print('anchor', self.relativeFrame:IsShown(), self:GetPoint(1)) |
332 | 499 |
333 self.icon:SetDesaturated(self.numQuestsHere == 0) | 500 self.icon:SetDesaturated(self.numQuestsHere == 0) |
334 | 501 |
335 local r, g, b, a = 0,0,0,1 | 502 local r, g, b, a = 0,0,0,1 |
336 local desaturated = false | 503 local desaturated = false |
337 if (self.numQuestsHere > 0) then | 504 if (self.numQuestsHere > 0) or db.UsedFilters[self.filterKey] then |
505 | |
338 if self.cVar then | 506 if self.cVar then |
339 if GetCVarBool(self.cVar) then | 507 if GetCVarBool(self.cVar) then |
340 self.count:SetTextColor(1,1,1) | 508 --self.count:SetTextColor(1,1,1) |
341 r,g,b,a = 0, 0, 0, 1 | 509 r,g,b,a = 0, 0, 0, 1 |
342 else | 510 else |
343 self:GetParent().cvarFiltersDirty = true | 511 filtersUsed = true |
344 self.count:SetTextColor(1,0,0) | 512 --self.count:SetTextColor(1,0,0) |
345 self.icon:SetDesaturated(true) | 513 self.icon:SetDesaturated(true) |
346 r,g,b,a = 1, 0, 0, 0.5 | 514 r,g,b,a = 1, 0, 0, 0.5 |
347 end | 515 end |
348 else | 516 else |
349 if db.UsedFilters[self.filterKey] then | 517 if db.UsedFilters[self.filterKey] then |
518 filtersUsed = true | |
350 if db.UsedFilters[self.filterKey] == self.filterValue then | 519 if db.UsedFilters[self.filterKey] == self.filterValue then |
351 self.count:SetTextColor(0,1,0) | 520 --self.count:SetTextColor(0,1,0) |
352 r, g, b = 0, 1, 0 | 521 r, g, b = 0, 1, 0 |
353 else | 522 else |
354 self.count:SetTextColor(1,0,0) | 523 --self.count:SetTextColor(1,0,0) |
355 r, g, b = 1, 0, 0 | 524 r, g, b = 1, 0, 0 |
356 end | 525 end |
357 else | 526 else |
358 | 527 |
359 self.count:SetTextColor(1,1,1) | 528 --self.count:SetTextColor(1,1,1) |
360 if self.filterKey == 'worldQuestType' then | 529 if self.filterKey == 'worldQuestType' then |
361 r, g, b = 0, 0, 1 | 530 r, g, b = 0, 0, 1 |
362 elseif self.filterKey == 'factionID' then | 531 elseif self.filterKey == 'factionID' then |
363 r, g, b = 1, 1, 0 | 532 r, g, b = 1, 1, 0 |
364 end | 533 end |
373 | 542 |
374 function Pin:OnLoad() | 543 function Pin:OnLoad() |
375 self:RegisterForClicks('AnyUp') | 544 self:RegisterForClicks('AnyUp') |
376 self:SetFrameStrata('HIGH') | 545 self:SetFrameStrata('HIGH') |
377 self:SetFrameLevel(151) | 546 self:SetFrameLevel(151) |
378 self:SetScript('OnUpdate', nil) | |
379 self.questList = {} | 547 self.questList = {} |
380 -- WORLD_MAP_UPDATE and PLAYER_ENTERING_WORLD are passed down from a higher level | 548 -- WORLD_MAP_UPDATE and PLAYER_ENTERING_WORLD are passed down from a higher level |
381 end | 549 end |
382 | 550 |
383 function Pin:OnUpdate () | 551 function Pin:OnUpdate () |
552 local group = self:GetParent() | |
553 if group:IsMouseOver() and barMouseOver then | |
554 group.Backdrop:Show() | |
555 group.Label:Show() | |
556 else | |
557 group.Backdrop:Hide() | |
558 group.Label:Hide() | |
559 end | |
384 end | 560 end |
385 | 561 |
386 -- shift-click: reset filter | 562 -- shift-click: reset filter |
387 -- click: rotate through include(1), exclude(-1), ignore(nil) | 563 -- click: rotate through include(1), exclude(-1), ignore(nil) |
388 local filtered_report = {} | 564 local filtered_report = {} |
434 SetCVar(cVar, 1) | 610 SetCVar(cVar, 1) |
435 end | 611 end |
436 | 612 |
437 -- check the visible filters and consider it clean if they're all lit | 613 -- check the visible filters and consider it clean if they're all lit |
438 parent.cvarFiltersDirty = false | 614 parent.cvarFiltersDirty = false |
439 for i, info in ipairs(parent.filterList) do | 615 for i, info in ipairs(db.FilterList) do |
440 if info.cVar and (#info.questList >= 1) then | 616 if info.cVar and (#info.GlobalMatches >= 1) then |
441 print(info.cVar, GetCVarBool(info.cVar)) | 617 print(info.cVar, GetCVarBool(info.cVar)) |
442 if GetCVarBool(info.cVar) == false then | 618 if GetCVarBool(info.cVar) == false then |
443 parent.cvarFiltersDirty = true | 619 parent.cvarFiltersDirty = true |
444 print('|cFFFF4400still dirty') | 620 print('|cFFFF4400still dirty') |
445 break | 621 break |
474 if #filtered_report >= 1 then | 650 if #filtered_report >= 1 then |
475 --WorldPlan:print('Setting filter(s):', table.concat(filtered_report, ', ')) | 651 --WorldPlan:print('Setting filter(s):', table.concat(filtered_report, ', ')) |
476 end | 652 end |
477 WorldPlan:Refresh(true) | 653 WorldPlan:Refresh(true) |
478 end | 654 end |
655 function ToggleButton:OnEnter() | |
656 | |
657 GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMRIGHT') | |
658 GameTooltip:AddLine('Toggle Pins') | |
659 GameTooltip:Show() | |
660 end | |
661 function ToggleButton:OnLeave() | |
662 | |
663 if GameTooltip:IsOwned(self) then | |
664 GameTooltip:Hide() | |
665 end | |
666 end | |
667 function ToggleButton:OnShow() | |
668 self:SetChecked(db.Config.EnablePins and true or false) | |
669 end | |
670 function ToggleButton:OnHide() | |
671 if GameTooltip:IsOwned(self) then | |
672 GameTooltip:Hide() | |
673 end | |
674 | |
675 end | |
676 function ToggleButton:OnClick() | |
677 --print(self:GetChecked()) | |
678 db.Config.EnablePins = self:GetChecked() | |
679 _G.WorldPlan:OnConfigUpdate() | |
680 end |