Nenue@28
|
1 --- ${PACKAGE_NAME}
|
Nenue@28
|
2 -- @file-author@
|
Nenue@28
|
3 -- @project-revision@ @project-hash@
|
Nenue@28
|
4 -- @file-revision@ @file-hash@
|
Nenue@28
|
5 -- Created: 3/30/2016 12:49 AM
|
Nenue@28
|
6 local B = select(2,...).frame
|
Nenue@30
|
7 local Module = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
|
Nenue@28
|
8 local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band
|
Nenue@34
|
9 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion, tinsert, tremove = IsResting, UnitXP, UnitXPMax, GetXPExhaustion, table.insert, table.remove
|
Nenue@28
|
10 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent
|
Nenue@28
|
11 local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText
|
Nenue@28
|
12 local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent
|
Nenue@30
|
13 local Default, AutoQuest, Quest, Bonus, Cheevs = Module.DefaultHandler, Module.AutoQuest, Module.Quest, Module.Bonus, Module.Cheevs
|
Nenue@28
|
14 local InCombatLockdown, format, lshift, CreateFrame = InCombatLockdown, format, bit.lshift, CreateFrame
|
Nenue@29
|
15 local IsModifiedClick, ChatEdit_GetActiveWindow = IsModifiedClick, ChatEdit_GetActiveWindow
|
Nenue@28
|
16 local print = B.print('Tracker')
|
Nenue@34
|
17 local oprint = B.print('Objectives')
|
Nenue@34
|
18 local bprint = B.print('Block')
|
Nenue@34
|
19 local tprint = B.print('Tracker')
|
Nenue@34
|
20 local lprint = B.print('Line')
|
Nenue@28
|
21 local unitLevel = 1
|
Nenue@28
|
22 local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_REASON
|
Nenue@28
|
23 local debug = false
|
Nenue@28
|
24
|
Nenue@34
|
25 --- FRAMES
|
Nenue@28
|
26 local Wrapper = _G.VeneerObjectiveWrapper
|
Nenue@28
|
27 local Scroller = Wrapper.scrollArea
|
Nenue@28
|
28 local Scroll = _G.VeneerObjectiveScroll
|
Nenue@30
|
29 local orderedHandlers = Module.orderedHandlers
|
Nenue@30
|
30 local orderedNames = Module.orderedNames
|
Nenue@28
|
31
|
Nenue@34
|
32 --- FRAME TEMP VARIABLES
|
Nenue@28
|
33 local wrapperWidth, wrapperHeight
|
Nenue@28
|
34 local scrollWidth, scrollHeight
|
Nenue@34
|
35
|
Nenue@34
|
36 --- SCHEMA VARIABLES
|
Nenue@34
|
37 local schemaName, lastSchema = {
|
Nenue@34
|
38 tracker = '',
|
Nenue@34
|
39 block = '',
|
Nenue@34
|
40 line = ''
|
Nenue@34
|
41 }, {}
|
Nenue@34
|
42 local trackerSchema, blockSchema, lineSchema
|
Nenue@34
|
43
|
Nenue@28
|
44 local itemButtonSize, itemButtonSpacing = 36, 1
|
Nenue@34
|
45 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed
|
Nenue@34
|
46 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
|
Nenue@34
|
47 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 }
|
Nenue@34
|
48 local rewardSize = 24
|
Nenue@28
|
49
|
Nenue@30
|
50 local headerHeight, headerColor, headerSpacing = 16, {1,.75,0,1}, 2
|
Nenue@28
|
51 local headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0}
|
Nenue@28
|
52 local headerFont, headerSize, headerOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE'
|
Nenue@28
|
53
|
Nenue@31
|
54 local titlebg = {'HORIZONTAL', 1, 0, .7, 0, 1, 0, .7, .2}
|
Nenue@28
|
55 local titleFont, titleSize, titleOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE'
|
Nenue@34
|
56 local titleColor = {0,.7,1,1}
|
Nenue@28
|
57
|
Nenue@28
|
58 local textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 }
|
Nenue@28
|
59 local textFont, textSize, textOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]], 16, 'OUTLINE'
|
Nenue@34
|
60 local textColor = {1,1,1,1}
|
Nenue@28
|
61
|
Nenue@28
|
62 local selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225}
|
Nenue@28
|
63 local titleSpacing, textSpacing, blockSpacing = 3, 3, 1
|
Nenue@28
|
64 local titleIndent, textIndent,selectionIndent = 2, 5, 50
|
Nenue@34
|
65 --- END SCHEMA
|
Nenue@34
|
66 --- schema swapper
|
Nenue@34
|
67 Module.UpdateSchema = function(layer, newSchema)
|
Nenue@34
|
68 if not (Module.Conf.Schema[layer] and Module.Conf.Schema[layer][newSchema]) then
|
Nenue@34
|
69 return
|
Nenue@34
|
70 elseif schemaName[layer] == newSchema then
|
Nenue@34
|
71 return
|
Nenue@34
|
72 end
|
Nenue@34
|
73 lastSchema[layer] = schemaName[layer]
|
Nenue@34
|
74 schemaName[layer] = newSchema
|
Nenue@34
|
75 local c = Module.Conf.Schema[layer][newSchema]
|
Nenue@28
|
76
|
Nenue@34
|
77 if layer == 'tracker' then
|
Nenue@34
|
78 headerHeight, headerSpacing = c.headerHeight, c.headerSpacing
|
Nenue@34
|
79 headerColor = c.headerColor
|
Nenue@34
|
80 headerbg = c.headerbg
|
Nenue@34
|
81 headerFont, headerSize, headerOutline = c.headerFont, c.headerSize, c.headerOutline
|
Nenue@34
|
82 trackerSchema = newSchema
|
Nenue@34
|
83 elseif layer == 'block' then
|
Nenue@34
|
84 titlebg = c.titlebg
|
Nenue@34
|
85 titleFont, titleSize, titleOutline = c.titleFont, c.titleSize, c.titleOutline
|
Nenue@34
|
86 selectionbg = c.selectionbg
|
Nenue@34
|
87 titleSpacing, textSpacing, blockSpacing = c.titleSpacing, c.textSpacing, c.blockSpacing
|
Nenue@34
|
88 titleIndent, textIndent,selectionIndent = 2, 5, 50
|
Nenue@34
|
89 titleColor = c.titleColor
|
Nenue@34
|
90 rewardSize = 24
|
Nenue@34
|
91 blockSchema = newSchema
|
Nenue@34
|
92 textFont, textSize, textOutline = c.textFont, c.textSize, c.textOutline
|
Nenue@34
|
93 textbg = c.textbg
|
Nenue@34
|
94 textIndent = c.textIndent
|
Nenue@34
|
95 rewardSize = c.rewardSize
|
Nenue@34
|
96 elseif layer == 'line' then
|
Nenue@34
|
97 textColor = c.textColor
|
Nenue@34
|
98 lineSchema = newSchema
|
Nenue@34
|
99 end
|
Nenue@34
|
100 print('|cFFFF0088UpdateSchema:|r', layer, lastSchema[layer], '->', newSchema)
|
Nenue@34
|
101 end
|
Nenue@28
|
102
|
Nenue@30
|
103 Default.AddBlock = function(self, block, blockIndex)
|
Nenue@30
|
104 local blockIndex = blockIndex or (self.currentBlock + 1)
|
Nenue@28
|
105 local print = bprint
|
Nenue@28
|
106 local tracker = self.frame
|
Nenue@28
|
107 local info = block.info
|
Nenue@30
|
108
|
Nenue@34
|
109 if blockSchema ~= block.schema then
|
Nenue@34
|
110 print('new schema detected, applicating...')
|
Nenue@34
|
111 block.schema = blockSchema
|
Nenue@34
|
112 block:SetWidth(Module.Conf.Wrapper.Width)
|
Nenue@34
|
113 block.title:SetSpacing(titleSpacing)
|
Nenue@34
|
114 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing)
|
Nenue@34
|
115 block.title:SetPoint('LEFT', block, 'LEFT', titleIndent, 0)
|
Nenue@34
|
116 block.titlebg:SetTexture(1,1,1,1)
|
Nenue@34
|
117 block.titlebg:SetGradientAlpha(unpack(titlebg))
|
Nenue@34
|
118 block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0)
|
Nenue@34
|
119 block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing)
|
Nenue@34
|
120 block.status:SetSpacing(textSpacing)
|
Nenue@34
|
121 block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing)
|
Nenue@34
|
122 block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0)
|
Nenue@34
|
123 block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0)
|
Nenue@34
|
124 block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0)
|
Nenue@34
|
125 block.statusbg:SetTexture(1,1,1,1)
|
Nenue@34
|
126 block.statusbg:SetGradientAlpha(unpack(textbg))
|
Nenue@34
|
127 block.SelectionOverlay:SetGradientAlpha(unpack(selectionbg))
|
Nenue@34
|
128 block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
|
Nenue@34
|
129 block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
|
Nenue@34
|
130
|
Nenue@34
|
131 local anchor, target, point, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
|
Nenue@34
|
132 for i, tile in ipairs(block.rewardTile) do
|
Nenue@34
|
133 print(rewardSize)
|
Nenue@34
|
134 tile:SetSize(rewardSize, rewardSize)
|
Nenue@34
|
135 tile:ClearAllPoints()
|
Nenue@34
|
136 tile:SetPoint(anchor, target, point, x, y)
|
Nenue@34
|
137 block.rewardLabel[i]:SetPoint('TOP', tile, 'TOP', 0, 0)
|
Nenue@34
|
138 anchor, target, point, x, y = 'TOPRIGHT', tile, 'TOPLEFT', -2, 0
|
Nenue@34
|
139 end
|
Nenue@34
|
140 end
|
Nenue@34
|
141
|
Nenue@34
|
142 if block.debug then
|
Nenue@34
|
143 local func = (B.Conf.GuidesMode == true) and 'Show' or 'Hide'
|
Nenue@34
|
144 for _, region in ipairs(block.debug) do
|
Nenue@34
|
145 region[func]()
|
Nenue@34
|
146 end
|
Nenue@34
|
147 end
|
Nenue@34
|
148
|
Nenue@34
|
149 -- positioned by offset since they tend to swap contents
|
Nenue@30
|
150 block.index = blockIndex
|
Nenue@30
|
151 block:SetPoint('TOPLEFT', self.frame, 'TOPLEFT', 0, block.offset)
|
Nenue@29
|
152 block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
|
Nenue@30
|
153 self.currentBlock = blockIndex
|
Nenue@29
|
154 self.currentAnchor = block
|
Nenue@29
|
155 print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height)
|
Nenue@29
|
156 tracker.height = tracker.height + block.height
|
Nenue@29
|
157 self.actualBlocks = self.actualBlocks + 1
|
Nenue@28
|
158 end
|
Nenue@28
|
159
|
Nenue@28
|
160 --- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons)
|
Nenue@30
|
161 Default.AddTag = function (handler, block, tagInfo, tagPoint, tagAnchor, tagRelative)
|
Nenue@28
|
162 local print = bprint
|
Nenue@30
|
163
|
Nenue@30
|
164 for order, tagName in ipairs(block.info.tagInfo) do
|
Nenue@30
|
165 local tag = block[tagName]
|
Nenue@30
|
166 if block.tagCoords[tagName] and tag then
|
Nenue@30
|
167 tag:SetTexCoord(unpack(block.tagCoords[tagName]))
|
Nenue@30
|
168 tag:Show()
|
Nenue@30
|
169 tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
|
Nenue@30
|
170 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT'
|
Nenue@30
|
171 else
|
Nenue@30
|
172 block[tagName]:Hide()
|
Nenue@30
|
173 end
|
Nenue@28
|
174 end
|
Nenue@30
|
175
|
Nenue@28
|
176 return tagPoint, tagAnchor, tagRelative
|
Nenue@28
|
177 end
|
Nenue@28
|
178
|
Nenue@28
|
179 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call.
|
Nenue@30
|
180 Default.AddLine = function(handler, block, text, attachment, template)
|
Nenue@28
|
181 local print = lprint
|
Nenue@30
|
182 local lineIndex = block.currentLine + 1
|
Nenue@34
|
183 local line = handler:GetLine(block, lineIndex)
|
Nenue@31
|
184 line.index = lineIndex
|
Nenue@34
|
185 if line.schema ~= template then
|
Nenue@34
|
186 print(' |cFF00FF00change schema', template)
|
Nenue@34
|
187 Module.UpdateSchema('line', template)
|
Nenue@34
|
188 line.status:SetSpacing(textSpacing)
|
Nenue@34
|
189 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
|
Nenue@34
|
190 line.status:SetPoint('RIGHT', line, 'RIGHT', -textIndent, 0)
|
Nenue@34
|
191 line.status:SetTextColor(unpack(textColor))
|
Nenue@34
|
192 line.schema = template
|
Nenue@34
|
193 else
|
Nenue@34
|
194 print(' |cFFFFFF00keep schema', template)
|
Nenue@34
|
195 end
|
Nenue@34
|
196 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing)
|
Nenue@28
|
197 line:Show()
|
Nenue@28
|
198
|
Nenue@34
|
199
|
Nenue@34
|
200 print(' |cFF0088FFAddLine >>|r', block, '::', block.endPoint:GetName(),'"'.. text .. '"', attachment, template)
|
Nenue@34
|
201
|
Nenue@34
|
202
|
Nenue@34
|
203 -- fill in the text, then derive pixel-rounded height
|
Nenue@30
|
204 line.status:SetText(text)
|
Nenue@34
|
205 line.height = floor(line.status:GetStringHeight()+.5)
|
Nenue@30
|
206
|
Nenue@30
|
207 -- For progressbar and timer lines, status text may be used as the title heading
|
Nenue@30
|
208 if attachment then
|
Nenue@34
|
209 print(' |cFFFF0088doing things with a widget', attachment:GetSize())
|
Nenue@34
|
210 line.height = attachment:GetHeight()
|
Nenue@34
|
211 if text then
|
Nenue@34
|
212 line.height = max(line.height, line.status:GetStringHeight())
|
Nenue@31
|
213 end
|
Nenue@34
|
214 if attachment.status:GetText() then
|
Nenue@34
|
215 line.height = max(line.height, attachment.status:GetStringHeight())
|
Nenue@34
|
216 end
|
Nenue@30
|
217 attachment:Show()
|
Nenue@30
|
218 end
|
Nenue@30
|
219
|
Nenue@34
|
220 line:SetHeight(line.height)
|
Nenue@34
|
221 block.attachmentHeight = block.attachmentHeight + line.height + textSpacing
|
Nenue@34
|
222 print(' |cFF0088FFsetting line #'..lineIndex..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height,
|
Nenue@28
|
223 "|cFF0088FFpoint:|r", line:GetPoint(1), "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N'))
|
Nenue@30
|
224 block.currentLine = lineIndex
|
Nenue@31
|
225 block.endPoint = line.statusbg -- edge used for the next block
|
Nenue@31
|
226
|
Nenue@31
|
227 return lineIndex
|
Nenue@28
|
228 end
|
Nenue@28
|
229
|
Nenue@28
|
230 --- Creates or retrieves a complete line data object
|
Nenue@30
|
231 Default.GetLine = function(handler, block, lineIndex)
|
Nenue@28
|
232 local print = lprint
|
Nenue@28
|
233 local blockIndex = block.index
|
Nenue@30
|
234 local lines = block.lines
|
Nenue@30
|
235 if not lineIndex then
|
Nenue@30
|
236 lineIndex = block.currentLine + 1
|
Nenue@34
|
237 print(' |cFFFFFF00generating a frame')
|
Nenue@28
|
238 end
|
Nenue@30
|
239
|
Nenue@30
|
240 block.numLines = max(block.numLines, lineIndex)
|
Nenue@30
|
241
|
Nenue@28
|
242 if not lines[lineIndex] then
|
Nenue@28
|
243 print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex)
|
Nenue@28
|
244 lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, block, 'VeneerTrackerObjective')
|
Nenue@28
|
245 local line = lines[lineIndex]
|
Nenue@28
|
246 line.index = lineIndex
|
Nenue@28
|
247 line.height = 0
|
Nenue@28
|
248 B.SetConfigLayers(line)
|
Nenue@28
|
249
|
Nenue@28
|
250 if debug then
|
Nenue@28
|
251 for _, region in ipairs(lines[lineIndex].debug) do
|
Nenue@28
|
252 region:Show()
|
Nenue@28
|
253 end
|
Nenue@28
|
254 end
|
Nenue@28
|
255
|
Nenue@28
|
256 end
|
Nenue@28
|
257 return lines[lineIndex]
|
Nenue@28
|
258 end
|
Nenue@28
|
259
|
Nenue@29
|
260
|
Nenue@29
|
261
|
Nenue@28
|
262 --- Creates or retrieves a complete block frame object
|
Nenue@34
|
263 --- todo: make it use data index to avoid re-coloring every block
|
Nenue@34
|
264 Default.GetBlock = function(handler, logIndex)
|
Nenue@28
|
265 local print = bprint
|
Nenue@34
|
266 print('|cFFFFFF00getting a block for logID', logIndex ..',', #handler.usedBlocks,'used', #handler.freeBlocks, 'free')
|
Nenue@34
|
267 local block = handler.LogBlock[logIndex]
|
Nenue@28
|
268
|
Nenue@34
|
269 if not block then
|
Nenue@28
|
270 if #handler.freeBlocks >= 1 then
|
Nenue@34
|
271 block = tremove(handler.freeBlocks)
|
Nenue@34
|
272 print(' assigning from free heap|cFF00FFFF', block:GetName())
|
Nenue@28
|
273 else
|
Nenue@34
|
274
|
Nenue@34
|
275 local blockIndex = handler.numBlocks + 1
|
Nenue@30
|
276 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, handler.frame, 'VeneerTrackerBlock')
|
Nenue@30
|
277 block.lines = {}
|
Nenue@30
|
278 block.numLines = 0
|
Nenue@30
|
279 block.currentLine = 0
|
Nenue@34
|
280 block.attachmentHeight = 0
|
Nenue@34
|
281 B.SetConfigLayers(block)
|
Nenue@28
|
282 --- methods for event handlers
|
Nenue@28
|
283
|
Nenue@28
|
284 block.Select = handler.Select
|
Nenue@28
|
285 block.Open = handler.Open
|
Nenue@28
|
286 block.Remove = handler.Remove
|
Nenue@28
|
287 block.Link = handler.Link
|
Nenue@28
|
288 block.clickZone:SetScript('OnMouseUp', function(self, ...) handler.OnMouseUp(block, ...) end)
|
Nenue@28
|
289 block.clickZone:SetScript('OnMouseDown', function(self, ...) handler.OnMouseDown(block, ...) end)
|
Nenue@28
|
290 block:ClearAllPoints()
|
Nenue@34
|
291 block.index = blockIndex
|
Nenue@34
|
292 handler.numBlocks = max(handler.numBlocks, blockIndex)
|
Nenue@28
|
293
|
Nenue@34
|
294 print(' |cFFFFFF00creating new|r', block:GetName())
|
Nenue@28
|
295 end
|
Nenue@34
|
296 handler.LogBlock[logIndex] = block
|
Nenue@34
|
297 tinsert(handler.usedBlocks, block)
|
Nenue@34
|
298 else
|
Nenue@34
|
299 print(' |cFFFFFF00use existing block|r', block:GetName())
|
Nenue@28
|
300 end
|
Nenue@34
|
301 return block
|
Nenue@28
|
302 end
|
Nenue@28
|
303
|
Nenue@30
|
304 local currentPosition, anchorFrame, anchorPoint
|
Nenue@30
|
305 --- Positioning and stuff
|
Nenue@30
|
306 local tick = 0
|
Nenue@34
|
307 local firstUpdate = true
|
Nenue@30
|
308 function Module:Update (reason, ...)
|
Nenue@34
|
309 if not B.Conf.VeneerObjectiveWrapper.enabled then
|
Nenue@34
|
310 return
|
Nenue@34
|
311 end
|
Nenue@34
|
312
|
Nenue@30
|
313 tick = tick + 1
|
Nenue@34
|
314 if firstUpdate or not reason then
|
Nenue@34
|
315 reason = _G.OBJECTIVE_TRACKER_UPDATE_ALL
|
Nenue@30
|
316 end
|
Nenue@30
|
317
|
Nenue@30
|
318 local print = tprint
|
Nenue@30
|
319 local updateWrapper = 0
|
Nenue@30
|
320 local hasStuff
|
Nenue@30
|
321 local insertingStuff
|
Nenue@30
|
322
|
Nenue@34
|
323 print(format('|cFFBB0066Update:|r |cFFFF%04X%d|r ', tick, lshift(reason, 4)), reason, ...)
|
Nenue@30
|
324 currentPosition = 0
|
Nenue@30
|
325 anchorPoint = 'TOP'
|
Nenue@30
|
326 anchorFrame = Scroll
|
Nenue@30
|
327
|
Nenue@30
|
328 local wrapperHeight = 0
|
Nenue@30
|
329 for id, handler in pairs(Module.orderedHandlers) do
|
Nenue@30
|
330 local frame = handler.frame
|
Nenue@30
|
331
|
Nenue@34
|
332
|
Nenue@30
|
333 if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then
|
Nenue@30
|
334 handler:UpdateTracker(reason, ...)
|
Nenue@30
|
335 insertingStuff = true
|
Nenue@30
|
336 else
|
Nenue@30
|
337 print(' |cFFFF0088'..id..'|r', 'no reason to update')
|
Nenue@30
|
338 end
|
Nenue@30
|
339
|
Nenue@30
|
340 if handler.numWatched >= 1 then
|
Nenue@34
|
341
|
Nenue@34
|
342 print(format('|cFF88FFBB%s and(%04X, %04x+%04x) = %04X|r', handler.name, reason, handler.updateReasonModule, handler.updateReasonEvents, band(reason, handler.updateReasonModule + handler.updateReasonEvents)))
|
Nenue@30
|
343 hasStuff = true
|
Nenue@30
|
344 currentPosition = currentPosition + 1
|
Nenue@30
|
345 frame.destinationOffset = -wrapperHeight
|
Nenue@34
|
346 if (not firstUpdate) and frame.previousOffset ~= wrapperHeight and frame:IsVisible() then
|
Nenue@30
|
347 print(frame.SlideIn.translation)
|
Nenue@30
|
348 local postFrame, postPoint = anchorFrame, anchorPoint
|
Nenue@30
|
349 local delta = frame.destinationOffset - frame.previousOffset
|
Nenue@30
|
350 local _, _, _, _, offset = frame:GetPoint(1)
|
Nenue@30
|
351 print(' |cFF00BBFFstart slide for', delta, 'pixels, from', frame.previousOffset, '(', offset, ')')
|
Nenue@30
|
352 frame.SlideIn.translation:SetTarget(frame)
|
Nenue@30
|
353 frame.SlideIn.translation:SetOffset(0, delta)
|
Nenue@30
|
354 frame.SlideIn:Play()
|
Nenue@30
|
355 for i, b in ipairs(handler.usedBlocks) do
|
Nenue@30
|
356 b.SlideIn.translation:SetOffset(0, delta)
|
Nenue@30
|
357 b.SlideIn:Play()
|
Nenue@30
|
358 end
|
Nenue@34
|
359 local start = GetTime()
|
Nenue@30
|
360 frame.SlideIn:SetScript('OnFinished', function()
|
Nenue@34
|
361 print(' |cFF00BBFFsliding finished:', delta, 'pixels covered; duration:', GetTime()-start)
|
Nenue@30
|
362 frame:SetParent(Scroll)
|
Nenue@30
|
363 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
|
Nenue@30
|
364 frame.previousOffset = frame.destinationOffset
|
Nenue@30
|
365 frame.SlideIn:SetScript('OnFinished', nil)
|
Nenue@30
|
366 if Wrapper.destinationHeight then
|
Nenue@30
|
367 Wrapper:SetHeight(Wrapper.destinationHeight)
|
Nenue@30
|
368 Scroller:SetHeight(Wrapper.destinationHeight)
|
Nenue@30
|
369 Scroll:SetHeight(Wrapper.destinationHeight)
|
Nenue@30
|
370 Wrapper.previousHeight = Wrapper.destinationHeight
|
Nenue@30
|
371 Wrapper.destinationHeight = nil
|
Nenue@30
|
372 end
|
Nenue@30
|
373
|
Nenue@30
|
374 end)
|
Nenue@30
|
375 else
|
Nenue@34
|
376 print(' |cFF00BBFFpinning to', anchorFrame:GetName(), anchorPoint, '|rcurrent frame height:', frame.height)
|
Nenue@34
|
377 print(' |cFFFF0088total height:', wrapperHeight)
|
Nenue@30
|
378 frame:SetParent(Scroll)
|
Nenue@30
|
379 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
|
Nenue@30
|
380 end
|
Nenue@30
|
381
|
Nenue@30
|
382 frame:Show()
|
Nenue@30
|
383 anchorFrame = handler.frame
|
Nenue@30
|
384 anchorPoint = 'BOTTOM'
|
Nenue@30
|
385
|
Nenue@30
|
386 wrapperHeight = wrapperHeight + frame.height
|
Nenue@30
|
387 else
|
Nenue@34
|
388
|
Nenue@34
|
389 print(' |cFFFF4400GetNumWatched:|r',handler.name, '0')
|
Nenue@30
|
390 frame:SetPoint('TOP', Scroll, 'TOP', 0, 0)
|
Nenue@30
|
391 frame.destinationOffset = 0
|
Nenue@30
|
392 frame.previousOffset = 0
|
Nenue@30
|
393 handler.frame:Hide()
|
Nenue@30
|
394 end
|
Nenue@30
|
395 end
|
Nenue@30
|
396
|
Nenue@30
|
397
|
Nenue@30
|
398 if hasStuff or insertingStuff then
|
Nenue@30
|
399 print('updating height to', wrapperHeight)
|
Nenue@30
|
400 if wrapperHeight > Wrapper.previousHeight then
|
Nenue@30
|
401 Wrapper:SetHeight(wrapperHeight)
|
Nenue@30
|
402 Scroller:SetHeight(wrapperHeight)
|
Nenue@30
|
403 Scroll:SetHeight(wrapperHeight)
|
Nenue@30
|
404 Wrapper.previousHeight = wrapperHeight
|
Nenue@30
|
405 Wrapper.destinationHeight = wrapperHeight
|
Nenue@30
|
406 end
|
Nenue@30
|
407 Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0)
|
Nenue@30
|
408 print('|cFFFF8800Wrapper:', Wrapper:GetSize())
|
Nenue@30
|
409 for i = 1, Wrapper:GetNumPoints() do
|
Nenue@30
|
410 print(' ', Wrapper:GetPoint(i))
|
Nenue@30
|
411 end
|
Nenue@30
|
412 print(' |cFF00FFFFScroller:', Scroller:GetSize())
|
Nenue@30
|
413 for i = 1, Scroller:GetNumPoints() do
|
Nenue@30
|
414 print(' ', Scroller:GetPoint(i))
|
Nenue@30
|
415 end
|
Nenue@30
|
416 print(' |cFF00FFFFScroll:', Scroll:GetSize())
|
Nenue@30
|
417 for i = 1, Scroll:GetNumPoints() do
|
Nenue@30
|
418 print(' ', Scroll:GetPoint(i))
|
Nenue@30
|
419 end
|
Nenue@30
|
420
|
Nenue@30
|
421 Wrapper:Show()
|
Nenue@30
|
422 Scroller:Show()
|
Nenue@30
|
423 Scroll:Show()
|
Nenue@30
|
424 end
|
Nenue@30
|
425 Quest.GetClosest()
|
Nenue@30
|
426 --Module.UpdateActionButtons(reason)
|
Nenue@34
|
427 if firstUpdate then
|
Nenue@34
|
428 firstUpdate = nil
|
Nenue@34
|
429 end
|
Nenue@30
|
430 end
|
Nenue@30
|
431
|
Nenue@28
|
432 --- Content generator base
|
Nenue@30
|
433 Default.UpdateTracker = function (handler, reason, id, isNew)
|
Nenue@28
|
434 local print = tprint
|
Nenue@30
|
435 local tracker = handler.frame
|
Nenue@28
|
436 local blockIndex = 0
|
Nenue@28
|
437 tracker.previousHeight = tracker.height
|
Nenue@28
|
438 tracker.height = 0
|
Nenue@28
|
439
|
Nenue@28
|
440 tracker.title:SetFont(headerFont, headerSize, headerOutline)
|
Nenue@28
|
441 tracker.titlebg:SetHeight(headerHeight)
|
Nenue@28
|
442 tracker.title:SetTextColor(unpack(headerColor))
|
Nenue@28
|
443
|
Nenue@30
|
444 handler.updateReason = reason
|
Nenue@30
|
445 handler.numWatched = handler:GetNumWatched()
|
Nenue@34
|
446 if handler.numWatched >= 1 then
|
Nenue@34
|
447
|
Nenue@34
|
448 print(' |cFF00FF88GetNumWatched:|r',handler.name, handler.numWatched, 'of', handler.numAll)
|
Nenue@34
|
449 end
|
Nenue@34
|
450
|
Nenue@30
|
451 handler.currentBlock = 0
|
Nenue@30
|
452 handler.currentAnchor = tracker.titlebg
|
Nenue@30
|
453 local blockPosition = -headerHeight
|
Nenue@30
|
454 for blockIndex = 1, handler.numWatched do
|
Nenue@30
|
455 local currentBlock = handler:UpdateBlock(blockIndex, id, isNew)
|
Nenue@30
|
456 if currentBlock then
|
Nenue@30
|
457 currentBlock.offset = blockPosition
|
Nenue@30
|
458 handler:AddBlock(currentBlock)
|
Nenue@30
|
459 blockPosition = blockPosition - currentBlock.height
|
Nenue@28
|
460 else
|
Nenue@28
|
461 print(' |cFFFF9900END|r @', blockIndex)
|
Nenue@28
|
462 break -- done with quest stuff
|
Nenue@28
|
463 end
|
Nenue@28
|
464 end
|
Nenue@28
|
465
|
Nenue@34
|
466
|
Nenue@34
|
467 local numBlocks = handler.numBlocks
|
Nenue@34
|
468 local used = handler.usedBlocks
|
Nenue@34
|
469 if numBlocks < #used then
|
Nenue@34
|
470 print(' |cFF0088FFcull the dead: showing|r', numBlocks, '|cFF0088FF out of|r', #used)
|
Nenue@30
|
471 local free = handler.freeBlocks
|
Nenue@34
|
472 local remaining = #used
|
Nenue@34
|
473 for i = #used, 1, -1 do
|
Nenue@34
|
474 print(' -', 'i='.. i, 'watchIndex='..used[i].info.watchIndex)
|
Nenue@34
|
475 if used[i].info.watchIndex > numBlocks then
|
Nenue@34
|
476 print(' clean up dead quest block')
|
Nenue@34
|
477 local released = tremove(used, i)
|
Nenue@34
|
478 released:Hide()
|
Nenue@34
|
479 released:ClearAllPoints()
|
Nenue@34
|
480 tinsert(free, used[blockIndex])
|
Nenue@34
|
481 end
|
Nenue@30
|
482 end
|
Nenue@30
|
483 end
|
Nenue@28
|
484
|
Nenue@30
|
485
|
Nenue@30
|
486 if handler.currentBlock >= 1 then
|
Nenue@28
|
487 tracker.height = tracker.height + headerHeight
|
Nenue@28
|
488 tracker:Show()
|
Nenue@28
|
489
|
Nenue@28
|
490 if tracker.wasEmpty then
|
Nenue@28
|
491 tracker.headerFade:Play()
|
Nenue@28
|
492 tracker.wasEmpty = nil
|
Nenue@28
|
493 end
|
Nenue@28
|
494 if tracker.height ~= tracker.previousHeight then
|
Nenue@28
|
495 tracker:SetHeight(tracker.height)
|
Nenue@28
|
496 end
|
Nenue@29
|
497 print(' |cFFFFFF00', tracker.height, tracker:GetWidth())
|
Nenue@28
|
498 else
|
Nenue@28
|
499 tracker:Hide()
|
Nenue@28
|
500 tracker.wasEmpty = true
|
Nenue@28
|
501 end
|
Nenue@28
|
502
|
Nenue@28
|
503 return tracker.numWatched, tracker.numAll
|
Nenue@28
|
504 end
|
Nenue@28
|
505
|
Nenue@34
|
506
|
Nenue@28
|
507 --- Updates the selected block frame to display the given info batch
|
Nenue@28
|
508 -- If `previousBlock` is set, it will attempt to anchor to that
|
Nenue@28
|
509 -- @param blockNum the ordered block to be updated, not a watchIndex value
|
Nenue@28
|
510 -- @param info the reference returned by the GetXInfo functions
|
Nenue@28
|
511 -- REMEMBER: t.info and questData[questID] are the same table
|
Nenue@30
|
512 Default.UpdateBlock = function (handler, blockIndex, id, added)
|
Nenue@28
|
513 local print = bprint
|
Nenue@30
|
514 if not blockIndex then
|
Nenue@30
|
515 return
|
Nenue@30
|
516 end
|
Nenue@30
|
517 local info = handler:GetInfo(blockIndex) -- should match up with whatever the internal watch list has
|
Nenue@30
|
518 if not info then
|
Nenue@28
|
519 return
|
Nenue@28
|
520 end
|
Nenue@34
|
521 print(' Updating |cFF00FF00'..handler.displayName..'|r|cFF00FFFF'..blockIndex..'|r|cFF0099FF', info.id ,'|r')
|
Nenue@28
|
522 local frame = handler.frame
|
Nenue@34
|
523 local block = handler:GetBlock(info.id)
|
Nenue@30
|
524
|
Nenue@34
|
525 if added then
|
Nenue@34
|
526 -- do something if the block is being assigned a new thing
|
Nenue@30
|
527 end
|
Nenue@30
|
528
|
Nenue@28
|
529 block.handler = handler
|
Nenue@28
|
530 block.info = info
|
Nenue@28
|
531
|
Nenue@28
|
532 info.blockIndex = blockIndex
|
Nenue@28
|
533 if info.questID then handler.QuestBlock[info.questID] = block end
|
Nenue@34
|
534 if info.logIndex then handler.LogBlock[info.logIndex] = block end
|
Nenue@28
|
535 if info.watchIndex then handler.WatchBlock[info.watchIndex] = block end
|
Nenue@28
|
536 handler.BlockInfo[blockIndex] = info
|
Nenue@34
|
537 local newSchema = handler:UpdateObjectives(block)
|
Nenue@34
|
538 if newSchema and newSchema ~= blockSchema then
|
Nenue@34
|
539 Module.UpdateSchema('block', newSchema)
|
Nenue@34
|
540 end
|
Nenue@28
|
541
|
Nenue@28
|
542 block.title:SetText(info.title)
|
Nenue@28
|
543 local titleHeight = floor(block.title:GetHeight()+.5)
|
Nenue@28
|
544 local titlebgHeight = titleHeight + titleSpacing*2
|
Nenue@28
|
545 block.titlebg:SetHeight(titlebgHeight)
|
Nenue@28
|
546
|
Nenue@30
|
547 local statusHeight = floor(block.status:GetHeight()+.5)
|
Nenue@30
|
548 local statusbgHeight = statusHeight + textSpacing*2
|
Nenue@30
|
549 local attachmentHeight =floor(block.attachmentHeight + .5)
|
Nenue@28
|
550
|
Nenue@28
|
551 print(' |cFF0088FFanchor to', handler.currentAnchor:GetName())
|
Nenue@30
|
552 print(' |cFF00FF00attachment:|r', attachmentHeight, '|cFF00FF00title:|r', titlebgHeight, '('.. titleHeight..')')
|
Nenue@34
|
553 if attachmentHeight > 0 then
|
Nenue@34
|
554 attachmentHeight = attachmentHeight + textSpacing
|
Nenue@34
|
555 end
|
Nenue@34
|
556
|
Nenue@30
|
557 block.height = titlebgHeight + attachmentHeight
|
Nenue@28
|
558
|
Nenue@28
|
559 block:SetHeight(block.height)
|
Nenue@28
|
560
|
Nenue@28
|
561 print(' |cFFFFFF00height|r:', block.height)
|
Nenue@28
|
562 print(' |cFF00FFFF)|r -> ', block, block:GetHeight())
|
Nenue@28
|
563
|
Nenue@28
|
564 block:Show()
|
Nenue@28
|
565
|
Nenue@28
|
566 if info.specialItem and not info.itemButton then
|
Nenue@28
|
567 print(' - |cFF00FFFFgenerating item button for info set')
|
Nenue@30
|
568 info.itemButton = Module.SetItemButton(block, info)
|
Nenue@28
|
569 else
|
Nenue@28
|
570 --info.itemButton = nil
|
Nenue@28
|
571 end
|
Nenue@28
|
572
|
Nenue@32
|
573 local tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
|
Nenue@28
|
574
|
Nenue@32
|
575 local numCurrency = 0
|
Nenue@32
|
576 for i, rewardTile in ipairs(block.rewardTile) do
|
Nenue@33
|
577 if info.rewardInfo and info.rewardInfo[i] then
|
Nenue@33
|
578 local reward = info.rewardInfo[i]
|
Nenue@33
|
579 --rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2)
|
Nenue@32
|
580 rewardTile:SetTexture(reward.texture)
|
Nenue@32
|
581 rewardTile:Show()
|
Nenue@32
|
582
|
Nenue@32
|
583 print('updating reward tile #'.. i, reward.type, reward.count, reward.text, reward.texture)
|
Nenue@32
|
584 if reward.count and reward.count > 1 then
|
Nenue@32
|
585 block.rewardLabel[i]:SetText(reward.count)
|
Nenue@32
|
586 block.rewardLabel[i]:Show()
|
Nenue@32
|
587 end
|
Nenue@32
|
588
|
Nenue@32
|
589 rewardTile:ClearAllPoints()
|
Nenue@32
|
590 rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, x, y)
|
Nenue@32
|
591 tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', rewardTile, 'TOPLEFT', -2, 0
|
Nenue@32
|
592 else
|
Nenue@32
|
593 rewardTile:Hide()
|
Nenue@32
|
594 block.rewardLabel[i]:Hide()
|
Nenue@28
|
595 end
|
Nenue@28
|
596 end
|
Nenue@28
|
597
|
Nenue@28
|
598 if info.selected then
|
Nenue@28
|
599 block.SelectionOverlay:Show()
|
Nenue@28
|
600 else
|
Nenue@28
|
601 block.SelectionOverlay:Hide()
|
Nenue@28
|
602 end
|
Nenue@28
|
603 -- workaround for scrollchild issue where layers fall out of sync: in this case, it's by 1 vertical pixel
|
Nenue@28
|
604 --block.highlight:SetPoint('TOPLEFT', block, 'TOPLEFT', 0, 1)
|
Nenue@28
|
605 --block.lowlight:SetPoint('BOTTOMLEFT', block, 'BOTTOMLEFT', 0, 1)
|
Nenue@28
|
606
|
Nenue@31
|
607 if info.tagInfo then
|
Nenue@31
|
608 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'frequencyTag', tagPoint, tagAnchor, tagRelative)
|
Nenue@31
|
609 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'typeTag', tagPoint, tagAnchor, tagRelative)
|
Nenue@31
|
610 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'completionTag', tagPoint, tagAnchor, tagRelative)
|
Nenue@31
|
611 end
|
Nenue@34
|
612
|
Nenue@34
|
613 if info.statusKey and (Devian and Devian.InWorkspace()) then
|
Nenue@34
|
614 block.debugText:SetText(info.statusKey)
|
Nenue@34
|
615 block.debugText:Show()
|
Nenue@34
|
616 end
|
Nenue@28
|
617 return block
|
Nenue@28
|
618 end
|
Nenue@28
|
619
|
Nenue@28
|
620
|
Nenue@28
|
621
|
Nenue@28
|
622
|
Nenue@28
|
623 --- Does the main iterations for populating block content.
|
Nenue@28
|
624 -- Hooked by corresponding handler functions where additional details need to be sorted.
|
Nenue@34
|
625 Default.UpdateObjectives = function(handler, block, block_schema)
|
Nenue@28
|
626 local print = lprint
|
Nenue@28
|
627 local info = block.info
|
Nenue@31
|
628 print('|cFF00FF00default.objectives', block:GetName())
|
Nenue@31
|
629 -- reset the starting positions
|
Nenue@30
|
630 block.endPoint = block.titlebg
|
Nenue@30
|
631 block.attachmentHeight = 0
|
Nenue@30
|
632 block.currentLine = 0
|
Nenue@28
|
633
|
Nenue@28
|
634 local displayObjectiveHeader = false
|
Nenue@28
|
635
|
Nenue@31
|
636 block.attachmentHeight = 0
|
Nenue@31
|
637 local text, attachment, template
|
Nenue@28
|
638
|
Nenue@28
|
639
|
Nenue@28
|
640 if info.description and #info.description >= 1 then
|
Nenue@28
|
641 print(' |cFF00FFFF header line:|r', info.description)
|
Nenue@30
|
642 text = info.description
|
Nenue@30
|
643 handler:AddLine(block, text, nil)
|
Nenue@28
|
644 end
|
Nenue@28
|
645
|
Nenue@28
|
646 if (info.isComplete or info.numObjectives == 0) and info.completionText then
|
Nenue@28
|
647 print(' overriding line #1 for completion text:', info.completionText)
|
Nenue@30
|
648 text = info.completionText
|
Nenue@33
|
649 handler:AddLine(block, text, nil, 'completed')
|
Nenue@28
|
650 else
|
Nenue@28
|
651 if info.objectives then
|
Nenue@28
|
652 for i, data in ipairs(info.objectives) do
|
Nenue@30
|
653 local line = handler:GetLine(block)
|
Nenue@28
|
654 displayObjectiveHeader = true
|
Nenue@28
|
655 line.height = 0
|
Nenue@31
|
656 text, attachment, template = handler:UpdateLine(block, line, data)
|
Nenue@34
|
657 print(' |cFF88FF00#', i, data.type, text, attachment)
|
Nenue@31
|
658 handler:AddLine(block, text, attachment, template)
|
Nenue@28
|
659
|
Nenue@28
|
660 end
|
Nenue@28
|
661 end
|
Nenue@28
|
662 end
|
Nenue@28
|
663
|
Nenue@32
|
664
|
Nenue@34
|
665 if block.currentLine < block.numLines then
|
Nenue@34
|
666 print(' - cull', block.currentLine, block.numLines)
|
Nenue@34
|
667 for i = block.currentLine + 1, block.numLines do
|
Nenue@34
|
668 print(' - hide |cFFFF0088'..i..'|r', block.lines[i])
|
Nenue@34
|
669 block.lines[i]:ClearAllPoints()
|
Nenue@34
|
670 block.lines[i]:Hide()
|
Nenue@34
|
671 end
|
Nenue@28
|
672 end
|
Nenue@28
|
673
|
Nenue@30
|
674 if block.currentLine > 0 then
|
Nenue@31
|
675 block.attachmentHeight = block.attachmentHeight + textSpacing
|
Nenue@34
|
676 print(' |cFF00FF00attachment:', block.attachmentHeight)
|
Nenue@28
|
677 end
|
Nenue@34
|
678 return block_schema
|
Nenue@28
|
679 end
|
Nenue@28
|
680
|
Nenue@28
|
681
|
Nenue@28
|
682 --- Module-specific display variables
|
Nenue@28
|
683 -- * height - height of whatever display widget is involved in conveying the task
|
Nenue@28
|
684 -- * money - boolean that determines listening for money events or not
|
Nenue@28
|
685 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively
|
Nenue@28
|
686
|
Nenue@28
|
687
|
Nenue@31
|
688 Default.UpdateLine = function(handler, block, line, data)
|
Nenue@28
|
689 if line.finished then
|
Nenue@28
|
690 line.progress = 2
|
Nenue@28
|
691 elseif line.quantity > 0 then
|
Nenue@28
|
692 line.progress = 1
|
Nenue@28
|
693 else
|
Nenue@28
|
694 line.progress = 0
|
Nenue@28
|
695 end
|
Nenue@31
|
696 return data.text, line.widget, 'normal'
|
Nenue@28
|
697 end
|
Nenue@28
|
698 ----------
|
Nenue@28
|
699 --- Top level methods
|
Nenue@28
|
700
|
Nenue@28
|
701 --- Queue any active item buttons for update for that frame
|
Nenue@28
|
702 local iprint = B.print('ItemButton')
|
Nenue@30
|
703 Module.UpdateActionButtons = function(updateReason)
|
Nenue@28
|
704 local print = iprint
|
Nenue@28
|
705 Scroller.snap_upper = 0
|
Nenue@28
|
706 Scroller.snap_lower = 0
|
Nenue@28
|
707 local print = B.print('ItemButton')
|
Nenue@28
|
708 if updateReason then
|
Nenue@28
|
709 print = B.print('IB_'..updateReason)
|
Nenue@28
|
710 end
|
Nenue@28
|
711
|
Nenue@28
|
712 local previousItem
|
Nenue@28
|
713 for questID, itemButton in pairs(Quest.itemButtons) do
|
Nenue@30
|
714 local info= Module.Quest.Info[questID]
|
Nenue@28
|
715
|
Nenue@28
|
716 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName())
|
Nenue@30
|
717 local block = Module.Quest.QuestBlock[questID]
|
Nenue@28
|
718 if block then
|
Nenue@28
|
719 -- Dispatch the probe
|
Nenue@34
|
720 if IsQuestWatched(info.logIndex) then
|
Nenue@28
|
721 itemButton.previousItem = previousItem
|
Nenue@28
|
722 print(' |cFFFFFF00probing', block:GetName())
|
Nenue@28
|
723 block:SetScript('OnUpdate', function()
|
Nenue@28
|
724 if block:GetBottom() and not InCombatLockdown() then
|
Nenue@28
|
725 print(' '..block:GetName()..' |cFF00FF00probe hit!')
|
Nenue@30
|
726 Module.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope
|
Nenue@28
|
727 block:SetScript('OnUpdate', nil)
|
Nenue@28
|
728
|
Nenue@28
|
729 end
|
Nenue@28
|
730 end)
|
Nenue@28
|
731 previousItem = itemButton
|
Nenue@28
|
732 else
|
Nenue@28
|
733 print('hidden block or unwatched quest')
|
Nenue@28
|
734 itemButton.previousItem = nil
|
Nenue@28
|
735 itemButton:Hide()
|
Nenue@28
|
736 end
|
Nenue@28
|
737 elseif itemButton:IsVisible() then
|
Nenue@28
|
738 print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName())
|
Nenue@28
|
739 itemButton.previousItem = nil
|
Nenue@28
|
740 itemButton:Hide()
|
Nenue@28
|
741 else
|
Nenue@28
|
742 print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName())
|
Nenue@28
|
743 end
|
Nenue@28
|
744 end
|
Nenue@28
|
745 end
|
Nenue@28
|
746
|
Nenue@30
|
747 Module.UpdateBlockAction = function (block, itemButton)
|
Nenue@28
|
748 local print = iprint
|
Nenue@28
|
749 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()')
|
Nenue@28
|
750 if itemButton.questID ~= block.info.questID then
|
Nenue@28
|
751 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
|
Nenue@28
|
752 -- something happened between this and last frame, go back and set new probes
|
Nenue@30
|
753 return Module.UpdateActionButtons()
|
Nenue@28
|
754 end
|
Nenue@28
|
755
|
Nenue@28
|
756 local previousItem = itemButton.previousItem
|
Nenue@28
|
757 local upper_bound = Scroller:GetTop() + Scroller.snap_upper
|
Nenue@28
|
758 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize
|
Nenue@28
|
759 local point, anchor, relative
|
Nenue@28
|
760
|
Nenue@28
|
761 if block:GetBottom() < lower_bound then
|
Nenue@28
|
762 print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5))
|
Nenue@28
|
763 if previousItem then
|
Nenue@28
|
764 print('adjusting', previousItem:GetName())
|
Nenue@28
|
765 previousItem:ClearAllPoints()
|
Nenue@28
|
766 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing)
|
Nenue@28
|
767 end
|
Nenue@28
|
768 itemButton:ClearAllPoints()
|
Nenue@28
|
769 itemButton.x = Wrapper:GetLeft() -4
|
Nenue@28
|
770 itemButton.y = Wrapper:GetBottom()
|
Nenue@28
|
771 point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT'
|
Nenue@28
|
772 Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing
|
Nenue@28
|
773
|
Nenue@28
|
774 elseif block:GetTop() > upper_bound then
|
Nenue@28
|
775 print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5))
|
Nenue@28
|
776 itemButton:ClearAllPoints()
|
Nenue@28
|
777 if previousItem then
|
Nenue@28
|
778 print('latch onto another piece')
|
Nenue@28
|
779 point, anchor, relative ='TOP', previousItem, 'BOTTOM'
|
Nenue@28
|
780 itemButton.x = 0
|
Nenue@28
|
781 itemButton.y = -itemButtonSpacing
|
Nenue@28
|
782 else
|
Nenue@28
|
783 print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop())
|
Nenue@28
|
784 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
|
Nenue@28
|
785 itemButton.x = Scroller:GetLeft() -4
|
Nenue@28
|
786 itemButton.y = Scroller:GetTop()
|
Nenue@28
|
787 end
|
Nenue@28
|
788 itemButton:Show()
|
Nenue@28
|
789 Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing)
|
Nenue@28
|
790 else
|
Nenue@28
|
791 print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5))
|
Nenue@28
|
792 itemButton:ClearAllPoints()
|
Nenue@28
|
793 itemButton.x = block:GetLeft() - itemButtonSpacing
|
Nenue@28
|
794 itemButton.y = block:GetTop()
|
Nenue@28
|
795 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
|
Nenue@28
|
796 end
|
Nenue@28
|
797
|
Nenue@28
|
798 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y)
|
Nenue@28
|
799 itemButton:Show()
|
Nenue@28
|
800 end
|
Nenue@28
|
801
|
Nenue@30
|
802 Module.UpdateItemButtonCooldown = function(button)
|
Nenue@28
|
803
|
Nenue@28
|
804 end
|
Nenue@28
|
805
|
Nenue@34
|
806
|
Nenue@29
|
807 Default.Select = function(handler, block)
|
Nenue@30
|
808 Module:Update(handler.watchReasonModule)
|
Nenue@28
|
809 end
|
Nenue@29
|
810 Default.Open = function(handler, block)
|
Nenue@30
|
811 Module:Update(handler.watchReasonModule)
|
Nenue@28
|
812 end
|
Nenue@29
|
813 Default.Remove = function(handler, block)
|
Nenue@30
|
814 Module:Update(handler.watchReasonModule)
|
Nenue@28
|
815 end
|
Nenue@29
|
816 Default.Report = function(handler, block)
|
Nenue@29
|
817 print('Stats:', handler.numWatched,'items tracked,', handler.numBlocks,'blocks assigned.')
|
Nenue@28
|
818 end
|
Nenue@28
|
819
|
Nenue@28
|
820 Default.OnMouseUp = function(self, button)
|
Nenue@28
|
821 print(self.handler.name, self.mainStyle, self.subStyle)
|
Nenue@28
|
822 if button == 'LeftButton' then
|
Nenue@28
|
823 if IsModifiedClick("CHATLINK") and ChatEdit_GetActiveWindow() then
|
Nenue@29
|
824 self.Link(self.handler, self)
|
Nenue@28
|
825 elseif IsModifiedClick("QUESTWATCHTOGGLE") then
|
Nenue@29
|
826 self.Remove(self.handler, self)
|
Nenue@28
|
827 else
|
Nenue@29
|
828 self.Select(self.handler, self)
|
Nenue@28
|
829 end
|
Nenue@28
|
830 elseif button == 'RightButton' then
|
Nenue@29
|
831 self.Open(self.handler, self)
|
Nenue@28
|
832 end
|
Nenue@28
|
833 self.initialButton = nil
|
Nenue@28
|
834 self.modChatLink = nil
|
Nenue@28
|
835 self.modQuestWatch = nil
|
Nenue@30
|
836 Module:Update(self.handler.updateReasonModule)
|
Nenue@28
|
837 print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r')
|
Nenue@28
|
838 end
|
Nenue@28
|
839 Default.OnMouseDown = function(self, button)
|
Nenue@28
|
840 print(self.info.title)
|
Nenue@28
|
841 end
|