Mercurial > wow > buffalo2
comparison ObjectiveFrame.lua @ 21:d5ee940de273
use hardcoded aesthetic manipulations over loadstring cramming
author | Nenue |
---|---|
date | Fri, 08 Apr 2016 06:12:05 -0400 |
parents | 605e8f0e46db |
children | 9b3fa734abff |
comparison
equal
deleted
inserted
replaced
20:6bd2102d340b | 21:d5ee940de273 |
---|---|
6 local B = select(2,...).frame | 6 local B = select(2,...).frame |
7 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') | 7 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') |
8 local ipairs, max, min, unpack, floor, pairs, tostring, type, band = ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band | 8 local ipairs, max, min, unpack, floor, pairs, tostring, type, band = ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band |
9 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion | 9 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion |
10 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent | 10 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent |
11 local DefaultTracker, Quest, Bonus, Cheevs = mod.DefaultTracker, mod.Quest, mod.Bonus, mod.Cheevs | 11 local Default, AutoQuest, Quest, Bonus, Cheevs = mod.DefaultHandler, mod.AutoQuest, mod.Quest, mod.Bonus, mod.Cheevs |
12 local CreateFrame = CreateFrame | 12 local CreateFrame = CreateFrame |
13 local print = B.print('ObjWrapper') | 13 local print = B.print('Tracker') |
14 local unitLevel = 1 | 14 local unitLevel = 1 |
15 local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_REASON | 15 local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_REASON |
16 local debug = false | |
16 -------------------------------------------------------------------- | 17 -------------------------------------------------------------------- |
17 --- Global frame layout | 18 --- Global frame layout |
18 -------------------------------------------------------------------- | 19 -------------------------------------------------------------------- |
19 | 20 |
20 --- Upvalues | 21 --- Upvalues |
30 local previousBlock | 31 local previousBlock |
31 local currentBlock | 32 local currentBlock |
32 --- todo: source these from config | 33 --- todo: source these from config |
33 local itemButtonSize, itemButtonSpacing = 36, 1 | 34 local itemButtonSize, itemButtonSpacing = 36, 1 |
34 local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]] | 35 local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]] |
35 local titleSize, textSize = 15, 15 | 36 local titleSize, textSize = 16, 16 |
37 local titlebg, textbg = {'HORIZONTAL', 1, 0, .7, .25, 1, 0, .7, .125}, {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0} | |
36 local titleOutline, textOutline = "OUTLINE", "OUTLINE" | 38 local titleOutline, textOutline = "OUTLINE", "OUTLINE" |
37 local titleSpacing, textSpacing = 4, 3 | 39 local titleSpacing, textSpacing = 3, 3 |
38 local textIndent = 5 | 40 local titleIndent, textIndent = 2, 5 |
41 local blockSpacing = 1 | |
39 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed | 42 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed |
40 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' | 43 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' |
41 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 | 44 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 |
42 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 | 45 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 |
43 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0} | 46 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0} |
47 local oprint = B.print('Objectives') | |
48 local bprint = B.print('Block') | |
49 local tprint = B.print('Tracker') | |
50 local lprint = B.print('Line') | |
44 | 51 |
45 local band = bit.band | 52 local band = bit.band |
46 local currentPosition, anchorFrame, anchorPoint | 53 local currentPosition, anchorFrame, anchorPoint |
47 function mod:Update (reason, dataID) | 54 |
48 local updateWrapper = 0 | 55 Default.GetLine = function(handler, blockIndex, lineIndex) |
49 local hasStuff | 56 local print = lprint |
50 local insertingStuff | 57 if not handler.lines[blockIndex] then |
51 reason = reason or OBJECTIVE_TRACKER_UPDATE_REASON | 58 handler.lines[blockIndex] = {} |
52 currentPosition = 0 | 59 end |
53 anchorPoint = 'TOPLEFT' | 60 local lines = handler.lines[blockIndex] |
54 anchorFrame = Scroll | 61 if not lines[lineIndex] then |
55 | 62 print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex) |
56 local wrapperHeight = 0 | 63 lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, handler:GetBlock(blockIndex), 'VeneerTrackerObjective') |
57 for id, handler in pairs(mod.orderedHandlers) do | 64 local line = lines[lineIndex] |
58 local frame = handler.frame | 65 line.index = lineIndex |
59 | 66 line.height = 0 |
60 print(format('|cFF00FFFFbitcheck (%04X vs %04x+%04x):|r', reason, handler.updateReasonModule, handler.updateReasonEvents), band(reason, handler.updateReasonModule + handler.updateReasonEvents)) | 67 line.status:SetSpacing(textSpacing) |
61 if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then | 68 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0) |
62 handler:Update(reason, dataID) | 69 B.SetConfigLayers(line) |
63 print('|cFF00FF00'..id..'|r', handler.displayName, 'count:', handler.numWatched) | 70 |
64 insertingStuff = true | 71 if lines[lineIndex+1] then |
65 else | 72 lines[lineIndex+1]:ClearAllPoints() |
66 print('|cFFFF0088'..id..'|r', 'no reason') | 73 end |
67 end | 74 |
68 | 75 if debug then |
69 if handler.numWatched >= 1 then | 76 for _, region in ipairs(lines[lineIndex].debug) do |
70 hasStuff = true | 77 region:Show() |
71 currentPosition = currentPosition + 1 | 78 end |
72 frame:SetParent(Scroll) | 79 end |
73 frame:SetPoint('TOPLEFT', anchorFrame, anchorPoint, 0, 0) | 80 |
74 print(' |cFF00BBFFpinning to', anchorFrame:GetName(), anchorPoint) | 81 end |
75 anchorFrame = handler.frame | 82 return lines[lineIndex] |
76 anchorPoint = 'BOTTOMLEFT' | 83 end |
77 | 84 |
78 print('current frame height:', frame.height) | 85 Default.GetBlock = function(handler, blockIndex) |
79 wrapperHeight = wrapperHeight + frame.height | 86 local print = bprint |
80 print('|cFFFF0088total height:', wrapperHeight) | |
81 else | |
82 handler.frame:Hide() | |
83 end | |
84 end | |
85 | |
86 | |
87 if hasStuff or insertingStuff then | |
88 | |
89 print('updating height to', wrapperHeight) | |
90 Wrapper:SetHeight(wrapperHeight) | |
91 Scroller:SetHeight(wrapperHeight) | |
92 Scroll:SetHeight(wrapperHeight) | |
93 print('|cFFFF8800Wrapper:', Wrapper:GetSize()) | |
94 for i = 1, Wrapper:GetNumPoints() do | |
95 print(' ', Wrapper:GetPoint(i)) | |
96 end | |
97 print(' |cFF00FFFFScroller:', Scroller:GetSize()) | |
98 for i = 1, Scroller:GetNumPoints() do | |
99 print(' ', Scroller:GetPoint(i)) | |
100 end | |
101 print(' |cFF00FFFFScroll:', Scroll:GetSize()) | |
102 for i = 1, Scroll:GetNumPoints() do | |
103 print(' ', Scroll:GetPoint(i)) | |
104 end | |
105 | |
106 Wrapper:Show() | |
107 Scroller:Show() | |
108 Scroll:Show() | |
109 end | |
110 | |
111 end | |
112 | |
113 DefaultTracker.GetBlock = function(handler, blockIndex) | |
114 local block = handler.usedBlocks[blockIndex] | 87 local block = handler.usedBlocks[blockIndex] |
88 | |
115 if not handler.usedBlocks[blockIndex] then | 89 if not handler.usedBlocks[blockIndex] then |
116 if #handler.freeBlocks >= 1 then | 90 if #handler.freeBlocks >= 1 then |
117 block = handler.freeBlocks[#handler.freeBlocks] | 91 block = handler.freeBlocks[#handler.freeBlocks] |
118 handler.freeBlocks[#handler.freeBlocks] = nil | 92 handler.freeBlocks[#handler.freeBlocks] = nil |
119 else | 93 else |
120 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, Scroll, 'VeneerTrackerBlock') | 94 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, Scroll, 'VeneerTrackerBlock') |
95 block.GetLine = function(block, lineIndex, data) return handler:GetLine(blockIndex, lineIndex, data) end | |
96 block.UpdateLine = function(block, lineIndex, data) return handler:UpdateLine(block, lineIndex, data) end | |
97 block.UpdateObjectives = function(block) return handler:UpdateObjectives(block) end | |
98 block.SetTag = function(block, ...) return handler.SetTag(block, ...) end | |
99 | |
100 local c = mod.Conf.Wrapper | |
101 block.blockIndex = blockIndex | |
121 block.SetStyle = mod.SetBlockStyle | 102 block.SetStyle = mod.SetBlockStyle |
103 block:SetWidth(c.Width) | |
104 | |
105 block.title:SetSpacing(c.TitleSpacing) | |
106 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing) | |
107 | |
108 block.titlebg:SetTexture(1,1,1,1) | |
109 block.titlebg:SetGradientAlpha(unpack(titlebg)) | |
110 block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0) | |
111 block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing) | |
112 | |
113 block.status:SetSpacing(c.TextSpacing) | |
114 block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing) | |
115 block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0) | |
116 | |
117 block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0) | |
118 block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0) | |
119 block.statusbg:SetTexture(1,1,1,1) | |
120 block.statusbg:SetGradientAlpha(unpack(textbg)) | |
121 | |
122 block.SelectionOverlay:SetPoint('TOPLEFT') | |
123 block.SelectionOverlay:SetPoint('BOTTOMRIGHT') | |
124 | |
125 | |
126 | |
127 --- methods for event handlers | |
128 | |
122 block.Select = handler.Select | 129 block.Select = handler.Select |
123 block.Open = handler.Open | 130 block.Open = handler.Open |
124 block.Remove = handler.Remove | 131 block.Remove = handler.Remove |
125 block.Link = handler.Link | 132 block.Link = handler.Link |
126 block:SetScript('OnMouseUp', handler.OnMouseUp) | 133 block:SetScript('OnMouseUp', handler.OnMouseUp) |
127 block:SetScript('OnMouseDown', handler.OnMouseDown) | 134 block:SetScript('OnMouseDown', handler.OnMouseDown) |
128 block.attachmentHeight = 0 | 135 block.attachmentHeight = 0 |
129 block:ClearAllPoints() | 136 block:ClearAllPoints() |
130 end | 137 |
131 | 138 B.SetConfigLayers(block) |
139 | |
140 if debug then | |
141 for _, region in ipairs(block.debug) do | |
142 region:Show() | |
143 end | |
144 end | |
145 end | |
132 handler.usedBlocks[blockIndex] = block | 146 handler.usedBlocks[blockIndex] = block |
133 end | 147 end |
134 return handler.usedBlocks[blockIndex] | 148 return handler.usedBlocks[blockIndex] |
135 end | 149 end |
136 | 150 |
137 DefaultTracker.Update = function (self, reason, dataID) | 151 Default.SetTag = function (block, tagName, tagPoint, tagAnchor, tagRelative) |
138 local tracker = self.frame | 152 local print = bprint |
139 print('|cFFFF4400'..tracker:GetName().. '|r:Update()') | 153 local tag = block[tagName] |
140 local blockIndex = 0 | 154 if block.info[tagName] and tag then |
141 local trackerHeight = 0 | 155 tag:SetTexCoord(unpack(block.info[tagName])) |
142 | 156 tag:Show() |
143 | 157 tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) |
144 self.currentAnchor = tracker.titlebg | 158 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT' |
145 local numWatched = self:GetNumWatched() | 159 else |
146 local numBlocks = self.numBlocks | 160 block[tagName]:Hide() |
147 local actualBlocks = 0 | 161 end |
148 for watchIndex = 1, 25 do | 162 return tagPoint, tagAnchor, tagRelative |
149 blockIndex = blockIndex + 1 | 163 end |
150 if watchIndex <= numWatched then | 164 |
151 local info = self:GetInfo(watchIndex) | 165 Default.UpdateObjectives = function(handler, block) |
152 if info then | 166 local print = lprint |
153 local currentBlock = self:UpdateBlock(blockIndex, info) | 167 local info = block.info |
154 self.currentAnchor = currentBlock | 168 |
155 print(' |cFFFFFF00'..watchIndex..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height) | 169 print(' |cFF00FF00doing objectives', block:GetName()) |
156 print(currentBlock:IsVisible()) | 170 |
157 print(currentBlock:GetPoint(1)) | 171 -- set the starting positions |
158 trackerHeight = trackerHeight + currentBlock.height | 172 block.endPoint = block.status |
159 numBlocks = max(numBlocks, watchIndex) | 173 local completionScore, completionMax = 0, 0 |
160 actualBlocks = actualBlocks + 1 | 174 local displayObjectiveHeader = false |
161 else | 175 |
162 print(' |cFFFF0000Failed to draw info for index #'..watchIndex) | 176 if info.description and #info.description >= 1 then |
177 print(' |cFF00FFFF header line:|r', info.description) | |
178 block.status:SetText(info.description) | |
179 displayObjectiveHeader = true | |
180 end | |
181 | |
182 local attachmentHeight = 0 | |
183 if info.objectives then | |
184 for i, data in ipairs(info.objectives) do | |
185 print(' |cFF88FF00#', i, data.type, data.text) | |
186 displayObjectiveHeader = true | |
187 local line = block:GetLine(i) | |
188 line.height = 0 | |
189 block:UpdateLine(line, data) | |
190 | |
191 line:ClearAllPoints() | |
192 if line.displayText then | |
193 line.status:SetText(line.displayText) | |
194 line.height = floor(line.status:GetStringHeight()+.5) | |
163 end | 195 end |
164 | 196 |
165 elseif watchIndex <= numBlocks then | 197 if line.widget then |
166 local used = self.usedBlocks | 198 line.widget:SetPoint('TOP', line, 'TOP', 0, 0) |
167 local free = self.freeBlocks | 199 line.widget:Show() |
168 print('clean up dead quest block') | |
169 if used[blockIndex] then | |
170 used[blockIndex]:Hide() | |
171 used[blockIndex]:ClearAllPoints() | |
172 free[#free+1]= used[blockIndex] | |
173 used[blockIndex] = nil | |
174 end | 200 end |
175 else | 201 |
176 print(' |cFFFF9900END|r @', blockIndex) | 202 |
177 break -- done with quest stuff | 203 line:Show() |
178 end | 204 |
179 end | 205 line:SetPoint('LEFT', block, 'LEFT', 0, 0) |
180 self.numWatched = numWatched | 206 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, 0) |
181 self.numBlocks = numBlocks | 207 line:SetPoint('RIGHT', block, 'RIGHT', 0, 0) |
182 self.actualBlocks = actualBlocks | 208 line:SetHeight(line.height) |
183 self:Report() | 209 |
184 | 210 attachmentHeight = attachmentHeight + line.height |
185 tracker.previousHeight = tracker.height | 211 print(' sz', line:GetSize()) |
186 if numBlocks >= 1 then | 212 print(' pt', line:GetPoint(1)) |
187 previousBlock = nil | 213 print(' |cFF44BBFF#', i, 'anchoring line, size:', line.height, 'current endpoint:', line.statusbg) |
188 | 214 |
189 tracker.height = trackerHeight + tracker.titlebg:GetHeight() | 215 block.endPoint = line |
190 tracker:SetHeight(tracker.height) | 216 end |
191 tracker:Show() | 217 |
192 | 218 if attachmentHeight > 0 then |
193 print(tracker.height) | 219 block.attachmentHeight = attachmentHeight + textSpacing * 2 |
194 | 220 print(' |cFF00FF00attachment:', block.attachmentHeight) |
195 else | 221 end |
196 tracker.height = 0 | 222 |
197 tracker:Hide() | 223 local lines = handler.lines[block.blockIndex] |
198 end | 224 local numObjectives = info.numObjectives |
199 | 225 local numLines = #lines |
200 return tracker.numWatched, tracker.numAll | 226 if numLines > numObjectives then |
201 end | 227 print(' has extra lines, need to clean up;', numLines, numObjectives) |
202 | 228 for i = numObjectives+1, numLines do |
203 --- Updates the selected block frame to display the given info batch | 229 print(' hide', i, lines[i]:GetName()) |
204 -- If `previousBlock` is set, it will attempt to anchor to that | 230 lines[i]:Hide() |
205 -- @param blockNum the ordered block to be updated, not a watchIndex value | |
206 -- @param info the reference returned by the GetXInfo functions | |
207 -- REMEMBER: t.info and questData[questID] are the same table | |
208 DefaultTracker.UpdateBlock = function (self, blockIndex, info) | |
209 local print = B.print('BlockParse') | |
210 print(' Read list item |cFF00FFFF'..blockIndex..'|r') | |
211 if not blockIndex or not info then | |
212 return | |
213 end | |
214 local frame = self.frame | |
215 local t = self:GetBlock(blockIndex) | |
216 t.handler = self | |
217 t.info = info | |
218 t.mainStyle = info.mainStyle or 'Normal' | |
219 t.subStyle = info.subStyle | |
220 | |
221 info.blockIndex = blockIndex | |
222 if info.questID then self.QuestBlock[info.questID] = t end | |
223 if info.questLogIndex then self.LogBlock[info.questLogIndex] = t end | |
224 if info.watchIndex then self.WatchBlock[info.watchIndex] = t end | |
225 self.BlockInfo[blockIndex] = info | |
226 | |
227 t.attachmentHeight = 0 | |
228 if info.isComplete then | |
229 if mod.AutoQuest.Info[info.questID] then | |
230 t.status:SetText('(Click to Complete)') | |
231 t.status:Show() | |
232 else | |
233 t.status:SetText('Ready to turn in') | |
234 t.status:Show() | |
235 end | |
236 elseif info.completed then | |
237 t.status:SetText(nil) | |
238 t.status:Hide() | |
239 elseif info.numObjectives >= 1 then | |
240 t.attachmentHeight = 0 | |
241 t.status:Show() | |
242 print(' lines to parse:', info.numObjectives) | |
243 local text = '' | |
244 | |
245 mod.UpdateObjectives(t, info, text) | |
246 print(' |cFF00FF00attachment', t.attachmentHeight) | |
247 elseif info.description then | |
248 t.status:SetText(info.description) | |
249 t.status:Show() | |
250 else | |
251 t.status:SetText(nil) | |
252 t.status:Show() | |
253 end | |
254 t.title:SetText(info.title) | |
255 | |
256 | |
257 if info.specialItem and not info.itemButton then | |
258 print(' - |cFF00FFFFgenerating item button for info set') | |
259 info.itemButton = mod.SetItemButton(t, info) | |
260 else | |
261 --info.itemButton = nil | |
262 end | |
263 | |
264 if self.currentAnchor then | |
265 t:SetPoint('TOPLEFT', self.currentAnchor, 'BOTTOMLEFT', 0, 0) | |
266 t:SetPoint('RIGHT', frame,'RIGHT', 0, 0) | |
267 print(' anchor to|cFF0088FF', self.currentAnchor:GetName()) | |
268 end | |
269 | |
270 | |
271 --- metrics are calculated in SetStyle | |
272 t:SetStyle('TrackerBlock', self.name, t.mainStyle, t.subStyle) | |
273 print(' |cFFFFFF00height|r', t.height) | |
274 t:Show() | |
275 | |
276 print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) | |
277 | |
278 local tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t, 'TOPRIGHT' | |
279 if info.rewardInfo then | |
280 print('has immediate reward') | |
281 if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then | |
282 t.icon:Show() | |
283 t.iconLabel:SetText(info.rewardInfo[1].count) | |
284 t.icon:SetSize(t.height, t.height) | |
285 t.icon:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) | |
286 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.icon, 'TOPLEFT' | |
287 t.icon:SetTexture(info.rewardInfo[1].texture) | |
288 end | |
289 else | |
290 t.icon:Hide() | |
291 end | |
292 | |
293 if info.selected then | |
294 t.SelectionOverlay:Show() | |
295 else | |
296 t.SelectionOverlay:Hide() | |
297 end | |
298 | |
299 if info.frequencyTag then | |
300 t.FrequencyTag:SetTexCoord(unpack(info.frequencyTag)) | |
301 t.FrequencyTag:Show() | |
302 t.FrequencyTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) | |
303 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.FrequencyTag, 'TOPLEFT' | |
304 else | |
305 t.FrequencyTag:Hide() | |
306 end | |
307 if info.typeTag then | |
308 t.TypeTag:SetTexCoord(unpack(info.typeTag)) | |
309 t.TypeTag:Show() | |
310 t.TypeTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) | |
311 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.TypeTag, 'TOPLEFT' | |
312 else | |
313 t.TypeTag:Hide() | |
314 end | |
315 if info.completionTag then | |
316 t.CompletionTag:SetTexCoord(unpack(info.completionTag)) | |
317 t.CompletionTag:Show() | |
318 t.CompletionTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) | |
319 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.CompletionTag, 'TOPLEFT' | |
320 else | |
321 t.CompletionTag:Hide() | |
322 end | |
323 | |
324 --[[if Devian and Devian.InWorkspace() then | |
325 t.debugText:Show() | |
326 t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName()) .. "\n" .. (tostring(t.mainStyle) .. '/' .. tostring(t.subStyle))) | |
327 end]] | |
328 return t | |
329 end | |
330 | |
331 | |
332 | |
333 mod.UpdateObjectives = function(block, info, text) | |
334 local print = B.print('BlockLine') | |
335 print(' |cFF00FF00objective updates for', block:GetName()) | |
336 | |
337 local attachmentHeight = block.attachmentHeight | |
338 print(attachmentHeight) | |
339 if info.description and not(info.earnedBy or info.isComplete) then | |
340 print(' -- has description text:', select('#', info.description), info.description) | |
341 text = info.description | |
342 end | |
343 local completionScore, completionMax = 0, 0 | |
344 | |
345 for i, line in ipairs(info.objectives) do | |
346 print(attachmentHeight) | |
347 print(' |cFF88FF00objective', i) | |
348 block.handler.ParseObjective(line, info) | |
349 | |
350 if line.title then | |
351 info.title = line.title | |
352 line.title = nil | |
353 end | |
354 | |
355 if line.widget then | |
356 if attachmentHeight == 0 then | |
357 attachmentHeight = (block.status.spacing or block.status:GetSpacing()) * 2 | |
358 --print(attachmentHeight) | |
359 end | 231 end |
360 line.widget:Show() | 232 end |
361 line.widget:SetParent(block) | 233 end |
362 line.widget:SetPoint('TOPLEFT', block.status, 'BOTTOMLEFT', 0, -attachmentHeight ) | 234 |
363 print(' has a widget, height is', line.widget.height) | 235 |
364 attachmentHeight = attachmentHeight + line.widget.height | 236 |
365 completionScore = completionScore + line.progress | 237 print(' displayHeader:', displayObjectiveHeader) |
366 completionMax = completionMax + 2 | 238 |
367 end | 239 if debug then |
368 | 240 for i, region in ipairs(block.debug) do |
369 if line.displayText then | 241 for j = 1, region:GetNumPoints() do |
370 print(' has text') | 242 local _, target = region:GetPoint(j) |
371 text = text .. ((text == '') and "" or "\n") .. '|cFF'..line.displayColor.. line.displayText .. '|r' | 243 if target:IsVisible() then |
372 end | 244 region:Hide() |
373 end | 245 else |
374 | 246 region:Show() |
375 | 247 end |
248 end | |
249 end | |
250 end | |
376 | 251 |
377 block.completionScore = completionScore / completionMax | 252 block.completionScore = completionScore / completionMax |
378 block.attachmentHeight = attachmentHeight | 253 end |
379 | 254 |
380 if #text >= 1 then | 255 Bonus.UpdateObjectives = function(handler, block) |
381 block.status:SetText(text) | 256 Default.UpdateObjectives(handler, block) |
382 block.status:SetWordWrap(true) | 257 end |
383 else | 258 |
384 block.status:SetText(nil) | 259 local CLICK_TO_COMPLETE = 'Click to Complete' |
385 block.status:Hide() | 260 local CLICK_TO_ACCEPT = 'Click to Accept' |
386 end | 261 |
387 | 262 AutoQuest.UpdateObjectives = function(handler, block) |
388 end | 263 local print = lprint |
389 | 264 if block.info.type == 'OFFER' then |
390 --- Objective parsers | 265 block.status:SetText(CLICK_TO_ACCEPT) |
391 -- defines the following variables | 266 end |
267 | |
268 end | |
269 | |
270 Quest.UpdateObjectives = function(handler, block) | |
271 local print = lprint | |
272 print('|cFF00FFFFUpdateObjectives()') | |
273 Default.UpdateObjectives(handler, block) | |
274 local info = block.info | |
275 local completionText | |
276 if info.isAutoComplete then | |
277 local questID, popupType = GetAutoQuestPopUp(info.questLogIndex) | |
278 if popupType == 'COMPLETE' then | |
279 completionText = CLICK_TO_COMPLETE | |
280 end | |
281 end | |
282 if not completionText then | |
283 completionText = GetQuestLogCompletionText(info.questLogIndex) | |
284 end | |
285 | |
286 block.status:SetText() | |
287 end | |
288 | |
289 --- Module-specific display variables | |
392 -- * height - height of whatever display widget is involved in conveying the task | 290 -- * height - height of whatever display widget is involved in conveying the task |
393 -- * lines - number of non-wrapped text lines to account for line space; may be discarded depending on things | |
394 -- * money - boolean that determines listening for money events or not | 291 -- * money - boolean that determines listening for money events or not |
395 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively | 292 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively |
396 DefaultTracker.ParseObjective = function(line, info) | 293 |
397 | 294 Quest.UpdateLine = function(handler, block, line, data) |
398 if line.finished then | 295 local print = lprint |
296 print(' |cFFFF0088', block:GetName(), line.index, data.type) | |
297 local objectiveType = data.type | |
298 local r, g, b, a = 0, 1, 1, 1 | |
299 line.progress = 0 | |
300 if data.finished then | |
399 line.progress = 2 | 301 line.progress = 2 |
400 elseif line.quantity > 0 then | 302 r, g, b, a = 0, 1, 0, 1 |
401 line.progress = 1 | 303 elseif objectiveType == 'monster' then |
402 else | 304 r, g, b, a = 1, 0, .45, 1 |
403 line.progress = 0 | 305 elseif objectiveType == 'item' then |
404 end | 306 r, g, b, a = .8, .8, .8, 1 |
405 | 307 elseif objectiveType == 'object' then |
406 end | 308 r, g, b, a = 1, 1, 1, 1 |
407 | 309 elseif objectiveType == 'player' then |
408 Bonus.ParseObjective = function(line, info) | 310 r, g, b, a = 0, 0.8, 1, 1 |
409 local print = B.print('BonusLine') | 311 end |
312 | |
313 line.displayColor = {r, g, b, a} | |
314 line.status:SetTextColor(r, g, b, a) | |
315 line.displayText = data.text | |
316 return line | |
317 end | |
318 | |
319 Bonus.UpdateLine = function(handler, block, line, data) | |
320 local info = block.info | |
321 local print = lprint | |
410 | 322 |
411 | 323 |
412 line.displayColor = 'FFFFFF' | 324 line.displayColor = 'FFFFFF' |
413 if line.text and not info.title then | 325 if data.text and not info.title then |
414 line.title = line.text | 326 print('using first text item as title') |
415 else | 327 info.title = data.text |
416 line.displayText = line.text | 328 else |
329 line.displayText = data.text | |
417 end | 330 end |
418 | 331 |
419 line.progress = 0 | 332 line.progress = 0 |
420 print(' ', line.index,'|cFFFF0088-|r', line.objectiveType, line.text) | 333 print(' ', data.objectiveIndex,'|cFFFF0088-|r', data.objectiveType, data.text) |
421 if line.objectiveType == 'progressbar' then | 334 if data.objectiveType == 'progressbar' then |
422 line.widgetType = 'ProgressBar' | 335 line.widgetType = 'ProgressBar' |
423 print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID))) | 336 print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID))) |
424 line.value = GetQuestProgressBarPercent(info.questID) or 0 | 337 data.value = GetQuestProgressBarPercent(info.questID) or 0 |
425 line.maxValue = 100 | 338 data.maxValue = 100 |
426 if line.value >= line.maxValue then | 339 if data.value >= data.maxValue then |
427 line.progress = 1 | 340 line.progress = 1 |
428 elseif line.value > 0 then | 341 elseif data.value > 0 then |
429 line.progress = 2 | 342 line.progress = 2 |
430 end | 343 end |
431 line.format = PERCENTAGE_STRING | 344 line.format = PERCENTAGE_STRING |
432 line.widget = mod.SetWidget(line, info, 'ProgressBar', info.questID..'-'..line.index) | 345 local widget = mod.SetWidget(line, data, 'ProgressBar', info.questID..'-'..data.objectiveIndex) |
433 print(' ** text:', line.text, 'value:', line.value, 'max:', line.maxValue) | 346 print(' |cFFFF0022** text:|r', data.text, '|cFFFF0022value:|r', data.value, '|cFFFF0022max:|r', data.maxValue) |
434 else | 347 widget:SetPoint('CENTER', line, 'CENTER', 0, 0) |
348 | |
349 line.widget = widget | |
350 line.height = widget.height | |
351 else | |
352 line.displayText = data.text | |
435 line.widget = nil | 353 line.widget = nil |
436 end | 354 end |
437 end | 355 return line |
438 | 356 end |
439 Cheevs.ParseObjective = function(line, info) | 357 |
358 Cheevs.UpdateLine = function(handler, block, line, data) | |
440 local print = B.print('CheevsLine') | 359 local print = B.print('CheevsLine') |
441 line.progress = 0 | 360 line.progress = 0 |
442 if line.flags then | 361 print(' ', data.objectiveIndex,'|cFF0088FF-|r', data.objectiveType, data.text) |
443 if band(line.flags, 0x00000001) > 0 then | 362 if data.flags then |
363 if band(data.flags, 0x00000001) > 0 then | |
444 line.format = "%d/%d" | 364 line.format = "%d/%d" |
445 line.widget = mod.SetWidget(line, info, 'ProgressBar', line.criteriaID) | 365 line.widget = mod.SetWidget(line, data, 'ProgressBar', data.criteriaID) |
446 elseif band(line.flags, 0x00000002) then | 366 line.height = line.widget.height |
367 elseif band(data.flags, 0x00000002) then | |
447 line.widget = nil | 368 line.widget = nil |
448 else | 369 else |
449 line.widget = nil | 370 line.widget = nil |
450 line.displayColor = 'FFFFFF' | 371 line.displayColor = 'FFFFFF' |
451 line.displayText = line.text | 372 line.displayText = line.text |
452 | 373 |
453 end | 374 end |
454 end | 375 else |
455 print('line.type =', line.type) | 376 |
456 print(' ** qtyStr:', line.quantityString, 'qty:', line.quantity, 'assetID:', line.assetID) | 377 line.displayText = data.text |
457 end | 378 end |
458 | 379 print('line.type =', data.type) |
459 Quest.ParseObjective = function(line) | 380 print(' ** qtyStr:', data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID) |
460 local print = B.print('QuestLine') | 381 end |
461 print(' |cFFFF0088', line.type) | 382 Default.UpdateLine = function(block, line) |
462 local color = '00FFFF' | |
463 line.progress = 0 | |
464 if line.finished then | 383 if line.finished then |
465 line.progress = 2 | 384 line.progress = 2 |
466 color = 'FFFFFF' | 385 elseif line.quantity > 0 then |
467 elseif line.type == 'monster' then | 386 line.progress = 1 |
468 color = 'FFFF00' | 387 else |
469 elseif line.type == 'item' then | 388 line.progress = 0 |
470 color = '44DDFF' | 389 end |
471 elseif line.type == 'object' then | 390 return line |
472 color = 'FF44DD' | |
473 end | |
474 line.displayColor = color | |
475 line.displayText = line.text | |
476 end | 391 end |
477 | 392 |
478 | 393 |
479 mod.Quest.numButtons = 0 | 394 mod.Quest.numButtons = 0 |
480 local usedButtons = mod.Quest.itemButtons | 395 local usedButtons = mod.Quest.itemButtons |
558 --]] | 473 --]] |
559 mod.UpdateActionButtons() | 474 mod.UpdateActionButtons() |
560 | 475 |
561 end | 476 end |
562 --]=] | 477 --]=] |
478 | |
479 | |
480 Default.Update = function (self, reason, ...) | |
481 local print = tprint | |
482 local tracker = self.frame | |
483 print('|cFFFF4400'..tracker:GetName().. '|r:Update()', reason, ...) | |
484 local blockIndex = 0 | |
485 local trackerHeight = floor(tracker.titlebg:GetHeight()+.5) | |
486 | |
487 self.currentAnchor = tracker.titlebg | |
488 local numWatched = self:GetNumWatched() | |
489 local numBlocks = self.numBlocks | |
490 local actualBlocks = 0 | |
491 for watchIndex = 1, 25 do | |
492 blockIndex = blockIndex + 1 | |
493 if watchIndex <= numWatched then | |
494 local info = self:GetInfo(watchIndex) | |
495 if info then | |
496 local currentBlock = self:UpdateBlock(blockIndex, info) | |
497 currentBlock:SetPoint('TOPLEFT', self.currentAnchor, 'BOTTOMLEFT', 0, -1) | |
498 currentBlock:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) | |
499 self.currentAnchor = currentBlock | |
500 print(' |cFFFFFF00'..watchIndex..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height) | |
501 trackerHeight = trackerHeight + currentBlock.height | |
502 numBlocks = max(numBlocks, watchIndex) | |
503 actualBlocks = actualBlocks + 1 | |
504 else | |
505 print(' |cFFFF0000bad GetInfo data for #'..watchIndex) | |
506 end | |
507 | |
508 elseif watchIndex <= numBlocks then | |
509 local used = self.usedBlocks | |
510 local free = self.freeBlocks | |
511 print('clean up dead quest block') | |
512 if used[blockIndex] then | |
513 used[blockIndex]:Hide() | |
514 used[blockIndex]:ClearAllPoints() | |
515 free[#free+1]= used[blockIndex] | |
516 used[blockIndex] = nil | |
517 end | |
518 else | |
519 print(' |cFFFF9900END|r @', blockIndex) | |
520 break -- done with quest stuff | |
521 end | |
522 end | |
523 self.numWatched = numWatched | |
524 self.numBlocks = numBlocks | |
525 self.actualBlocks = actualBlocks | |
526 | |
527 tracker.previousHeight = tracker.height | |
528 if numBlocks >= 1 then | |
529 previousBlock = nil | |
530 | |
531 tracker.height = trackerHeight + tracker.titlebg:GetHeight() | |
532 tracker:SetHeight(tracker.height) | |
533 tracker:Show() | |
534 | |
535 | |
536 else | |
537 tracker.height = 0 | |
538 tracker:Hide() | |
539 end | |
540 | |
541 return tracker.numWatched, tracker.numAll | |
542 end | |
543 | |
544 --- Updates the selected block frame to display the given info batch | |
545 -- If `previousBlock` is set, it will attempt to anchor to that | |
546 -- @param blockNum the ordered block to be updated, not a watchIndex value | |
547 -- @param info the reference returned by the GetXInfo functions | |
548 -- REMEMBER: t.info and questData[questID] are the same table | |
549 Default.UpdateBlock = function (self, blockIndex, info) | |
550 local print = bprint | |
551 print(' Read list item |cFF00FFFF'..blockIndex..'|r') | |
552 if not blockIndex or not info then | |
553 return | |
554 end | |
555 local frame = self.frame | |
556 local block = self:GetBlock(blockIndex) | |
557 block.handler = self | |
558 block.info = info | |
559 block.mainStyle = info.mainStyle or 'Normal' | |
560 block.subStyle = info.subStyle | |
561 | |
562 info.blockIndex = blockIndex | |
563 if info.questID then self.QuestBlock[info.questID] = block end | |
564 if info.questLogIndex then self.LogBlock[info.questLogIndex] = block end | |
565 if info.watchIndex then self.WatchBlock[info.watchIndex] = block end | |
566 self.BlockInfo[blockIndex] = info | |
567 | |
568 block.endPoint = block.titlebg | |
569 block.attachmentHeight = 0 | |
570 block:UpdateObjectives() | |
571 | |
572 block.title:SetText(info.title) | |
573 local titleHeight = floor(block.title:GetHeight()+.5) | |
574 local statusHeight = floor(block.status:GetHeight()+.5) | |
575 local attachmentHeight =floor(block.attachmentHeight + .5) | |
576 local titlebgHeight = titleHeight + titleSpacing*2 | |
577 local statusbgHeight = statusHeight + textSpacing*2 | |
578 | |
579 block.titlebg:SetHeight(titlebgHeight) | |
580 | |
581 | |
582 print(' |cFF0088FFanchor to', self.currentAnchor:GetName()) | |
583 | |
584 print(' |cFF00FF00total sizes:') | |
585 print(' attachment:', attachmentHeight) | |
586 print(' title:', titlebgHeight, '('.. titleHeight..')') | |
587 --block.titlebg:SetHeight(block.title:GetHeight() + mod.Conf.Wrapper.TitleSpacing) | |
588 block.height = titlebgHeight + attachmentHeight | |
589 if statusHeight > 1 then | |
590 block.height = block.height + statusbgHeight | |
591 print(' status:', statusbgHeight, '('.. statusHeight..')') | |
592 else | |
593 print(' |cFFFF0088 skipped') | |
594 end | |
595 block:SetHeight(block.height) | |
596 | |
597 print(' |cFFFFFF00height|r:', block.height) | |
598 print(' |cFF00FFFF)|r -> ', block, block:GetHeight()) | |
599 | |
600 block:Show() | |
601 | |
602 | |
603 if info.specialItem and not info.itemButton then | |
604 print(' - |cFF00FFFFgenerating item button for info set') | |
605 info.itemButton = mod.SetItemButton(block, info) | |
606 else | |
607 --info.itemButton = nil | |
608 end | |
609 | |
610 local tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block, 'TOPRIGHT' | |
611 if info.rewardInfo then | |
612 print('has immediate reward') | |
613 if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then | |
614 block.icon:Show() | |
615 block.iconLabel:SetText(info.rewardInfo[1].count) | |
616 block.icon:SetSize(block.height, block.height) | |
617 block.icon:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) | |
618 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block.icon, 'TOPLEFT' | |
619 block.icon:SetTexture(info.rewardInfo[1].texture) | |
620 end | |
621 else | |
622 block.icon:Hide() | |
623 end | |
624 | |
625 if info.selected then | |
626 block.SelectionOverlay:Show() | |
627 else | |
628 block.SelectionOverlay:Hide() | |
629 end | |
630 | |
631 -- workaround for scrollchild issue where layers fall out of sync: in this case, it's by 1 vertical pixel | |
632 block.highlight:SetPoint('TOPLEFT', block, 'TOPLEFT', 0, 1) | |
633 block.lowlight:SetPoint('BOTTOMLEFT', block, 'BOTTOMLEFT', 0, 1) | |
634 | |
635 tagPoint, tagAnchor, tagRelative = block:SetTag('frequencyTag', tagPoint, tagAnchor, tagRelative) | |
636 tagPoint, tagAnchor, tagRelative = block:SetTag('typeTag', tagPoint, tagAnchor, tagRelative) | |
637 tagPoint, tagAnchor, tagRelative = block:SetTag('completionTag', tagPoint, tagAnchor, tagRelative) | |
638 | |
639 return block | |
640 end | |
641 ---------- | |
642 --- Top level methods | |
643 | |
644 local tick = 0 | |
645 function mod:Update (reason, ...) | |
646 tick = tick + 1 | |
647 local print = tprint | |
648 reason = reason or OBJECTIVE_TRACKER_UPDATE_REASON | |
649 local updateWrapper = 0 | |
650 local hasStuff | |
651 local insertingStuff | |
652 | |
653 print(format('%d |cFFFF%04X Update()', tick, bit.lshift(reason, 4)), reason, ...) | |
654 currentPosition = 0 | |
655 anchorPoint = 'TOP' | |
656 anchorFrame = Scroll | |
657 | |
658 local wrapperHeight = 0 | |
659 for id, handler in pairs(mod.orderedHandlers) do | |
660 local frame = handler.frame | |
661 | |
662 print(format(' |cFF00FFFFbitcheck (%04X vs %04x+%04x):|r', reason, handler.updateReasonModule, handler.updateReasonEvents), band(reason, handler.updateReasonModule + handler.updateReasonEvents)) | |
663 if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then | |
664 handler:Update(reason, ...) | |
665 print(' |cFF00FF00'..id..'|r', handler.displayName, 'count:', handler.numWatched) | |
666 insertingStuff = true | |
667 else | |
668 print(' |cFFFF0088'..id..'|r', 'no reason to update') | |
669 end | |
670 | |
671 if handler.numWatched >= 1 then | |
672 hasStuff = true | |
673 currentPosition = currentPosition + 1 | |
674 frame:SetParent(Scroll) | |
675 frame:SetPoint('TOP', anchorFrame, anchorPoint, 0, 0) | |
676 print(' |cFF00BBFFpinning to', anchorFrame:GetName(), anchorPoint) | |
677 anchorFrame = handler.frame | |
678 anchorPoint = 'BOTTOM' | |
679 | |
680 print('current frame height:', frame.height) | |
681 wrapperHeight = wrapperHeight + frame.height | |
682 print('|cFFFF0088total height:', wrapperHeight) | |
683 else | |
684 handler.frame:Hide() | |
685 end | |
686 end | |
687 | |
688 | |
689 if hasStuff or insertingStuff then | |
690 print('updating height to', wrapperHeight) | |
691 Wrapper:SetHeight(wrapperHeight) | |
692 Scroller:SetHeight(wrapperHeight) | |
693 Scroll:SetHeight(wrapperHeight) | |
694 Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0) | |
695 print('|cFFFF8800Wrapper:', Wrapper:GetSize()) | |
696 for i = 1, Wrapper:GetNumPoints() do | |
697 print(' ', Wrapper:GetPoint(i)) | |
698 end | |
699 print(' |cFF00FFFFScroller:', Scroller:GetSize()) | |
700 for i = 1, Scroller:GetNumPoints() do | |
701 print(' ', Scroller:GetPoint(i)) | |
702 end | |
703 print(' |cFF00FFFFScroll:', Scroll:GetSize()) | |
704 for i = 1, Scroll:GetNumPoints() do | |
705 print(' ', Scroll:GetPoint(i)) | |
706 end | |
707 | |
708 Wrapper:Show() | |
709 Scroller:Show() | |
710 Scroll:Show() | |
711 end | |
712 | |
713 end | |
563 | 714 |
564 --- Queue any active item buttons for update for that frame | 715 --- Queue any active item buttons for update for that frame |
565 mod.UpdateActionButtons = function(updateReason) | 716 mod.UpdateActionButtons = function(updateReason) |
566 Scroller.snap_upper = 0 | 717 Scroller.snap_upper = 0 |
567 Scroller.snap_lower = 0 | 718 Scroller.snap_lower = 0 |