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@35
|
7 local T = 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@35
|
13 local Default, AutoQuest, Quest, Bonus, Cheevs = T.DefaultHandler, T.AutoQuest, T.Quest, T.Bonus, T.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@35
|
16 local print = B.print('Layout')
|
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@35
|
20 local lprint = B.print('Layout')
|
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@35
|
29 local orderedHandlers = T.orderedHandlers
|
Nenue@35
|
30 local orderedNames = T.orderedNames
|
Nenue@28
|
31
|
Nenue@34
|
32 --- FRAME TEMP VARIABLES
|
Nenue@37
|
33 local wrapperWidth, wrapperHeight = 0, 0
|
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@35
|
66 local blockPosition
|
Nenue@35
|
67
|
Nenue@34
|
68 --- schema swapper
|
Nenue@35
|
69 T.UpdateSchema = function(layer, newSchema)
|
Nenue@35
|
70 if not (T.Conf.Schema[layer] and T.Conf.Schema[layer][newSchema]) then
|
Nenue@34
|
71 return
|
Nenue@34
|
72 elseif schemaName[layer] == newSchema then
|
Nenue@34
|
73 return
|
Nenue@34
|
74 end
|
Nenue@34
|
75 lastSchema[layer] = schemaName[layer]
|
Nenue@34
|
76 schemaName[layer] = newSchema
|
Nenue@35
|
77 local c = T.Conf.Schema[layer][newSchema]
|
Nenue@28
|
78
|
Nenue@34
|
79 if layer == 'tracker' then
|
Nenue@34
|
80 headerHeight, headerSpacing = c.headerHeight, c.headerSpacing
|
Nenue@34
|
81 headerColor = c.headerColor
|
Nenue@34
|
82 headerbg = c.headerbg
|
Nenue@37
|
83 headerFont, headerSize, headerOutline = unpack(c.headerFont)
|
Nenue@34
|
84 trackerSchema = newSchema
|
Nenue@34
|
85 elseif layer == 'block' then
|
Nenue@34
|
86 titlebg = c.titlebg
|
Nenue@37
|
87 titleFont, titleSize, titleOutline = unpack(c.titleFont)
|
Nenue@34
|
88 selectionbg = c.selectionbg
|
Nenue@34
|
89 titleSpacing, textSpacing, blockSpacing = c.titleSpacing, c.textSpacing, c.blockSpacing
|
Nenue@37
|
90 titleIndent, textIndent,selectionIndent = c.titleIndex, c.textIndex, c.selectionIndent
|
Nenue@34
|
91 titleColor = c.titleColor
|
Nenue@37
|
92 print(unpack(c.titleColor))
|
Nenue@34
|
93 rewardSize = 24
|
Nenue@37
|
94 textFont, textSize, textOutline = unpack(c.textFont)
|
Nenue@34
|
95 textbg = c.textbg
|
Nenue@34
|
96 textIndent = c.textIndent
|
Nenue@34
|
97 rewardSize = c.rewardSize
|
Nenue@37
|
98 blockSchema = newSchema
|
Nenue@34
|
99 elseif layer == 'line' then
|
Nenue@34
|
100 textColor = c.textColor
|
Nenue@34
|
101 lineSchema = newSchema
|
Nenue@34
|
102 end
|
Nenue@37
|
103 tprint('|cFFFF0088UpdateSchema:|r', layer, lastSchema[layer], '->', newSchema)
|
Nenue@34
|
104 end
|
Nenue@35
|
105 -- todo: figure out why objectives go invisible
|
Nenue@35
|
106 local anchorPoint, anchorFrame
|
Nenue@35
|
107 local abs, GetTime = math.abs, GetTime
|
Nenue@35
|
108 Default.AddTracker = function(handler, frame, index)
|
Nenue@35
|
109 if index == 1 then
|
Nenue@35
|
110 print('|cFF00FF00### beginning wrapper layout -----------------')
|
Nenue@35
|
111 anchorPoint, anchorFrame = 'TOP', Scroll
|
Nenue@35
|
112 wrapperHeight = 0
|
Nenue@35
|
113 end
|
Nenue@35
|
114
|
Nenue@35
|
115 frame.destinationOffset = -wrapperHeight
|
Nenue@35
|
116 print(frame.destinationOffset, frame.previousOffset)
|
Nenue@35
|
117 if handler.initialized and (abs(frame.previousOffset - frame.destinationOffset) > 0.9) and frame:IsVisible() then
|
Nenue@35
|
118 if frame.wasEmpty then
|
Nenue@35
|
119 frame.previousOffset = -Wrapper:GetHeight()
|
Nenue@35
|
120 end
|
Nenue@35
|
121
|
Nenue@35
|
122 local postFrame, postPoint = anchorFrame, anchorPoint
|
Nenue@35
|
123 local delta = frame.destinationOffset - frame.previousOffset
|
Nenue@35
|
124 local _, _, _, _, offset = frame:GetPoint(1)
|
Nenue@35
|
125 print(' |cFF00FFBBpushing', frame:GetName(), delta, 'pixels, from', frame.previousOffset, '(', offset, ')')
|
Nenue@35
|
126 frame.SlideIn.translation:SetTarget(frame)
|
Nenue@35
|
127 frame.SlideIn.translation:SetOffset(0, delta)
|
Nenue@35
|
128 frame.SlideIn:Play()
|
Nenue@35
|
129 --for i, b in ipairs(handler.usedBlocks) do
|
Nenue@35
|
130 --b.SlideIn.translation:SetOffset(0, delta)
|
Nenue@35
|
131 -- b.SlideIn:Play()
|
Nenue@35
|
132 --end
|
Nenue@35
|
133 local start = GetTime()
|
Nenue@35
|
134 frame.SlideIn:SetScript('OnFinished', function()
|
Nenue@35
|
135 print(' |cFF00BBFF'..frame:GetName(), 'moved', delta, 'over duration of ', GetTime()-start)
|
Nenue@35
|
136 frame:SetParent(Scroll)
|
Nenue@35
|
137 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
|
Nenue@35
|
138 frame.previousOffset = frame.destinationOffset
|
Nenue@35
|
139 frame.SlideIn:SetScript('OnFinished', nil)
|
Nenue@35
|
140 if Wrapper.destinationHeight then
|
Nenue@35
|
141 Wrapper:SetHeight(Wrapper.destinationHeight)
|
Nenue@35
|
142 Scroller:SetHeight(Wrapper.destinationHeight)
|
Nenue@35
|
143 Scroll:SetHeight(Wrapper.destinationHeight)
|
Nenue@35
|
144 Wrapper.previousHeight = Wrapper.destinationHeight
|
Nenue@35
|
145 Wrapper.destinationHeight = nil
|
Nenue@35
|
146 end
|
Nenue@35
|
147
|
Nenue@35
|
148 end)
|
Nenue@35
|
149 else
|
Nenue@37
|
150 print(' |cFF00BBFFpinning '..handler.name..' to', anchorFrame:GetName(), anchorPoint, '|rcurrent frame height:', frame.height)
|
Nenue@35
|
151 print(' |cFFFF0088total height:', wrapperHeight)
|
Nenue@35
|
152 frame:ClearAllPoints()
|
Nenue@35
|
153 frame:SetParent(Scroll)
|
Nenue@35
|
154 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
|
Nenue@35
|
155 frame.previousOffset = frame.destinationOffset
|
Nenue@35
|
156 handler.initialized = true
|
Nenue@35
|
157 end
|
Nenue@35
|
158
|
Nenue@35
|
159 frame.title:SetFont(headerFont, headerSize, headerOutline)
|
Nenue@35
|
160 frame.titlebg:SetHeight(headerHeight)
|
Nenue@35
|
161 frame.title:SetTextColor(unpack(headerColor))
|
Nenue@35
|
162
|
Nenue@35
|
163 if frame.height ~= frame.previousHeight then
|
Nenue@35
|
164 frame:SetHeight(frame.height)
|
Nenue@35
|
165 end
|
Nenue@35
|
166
|
Nenue@35
|
167 frame:Show()
|
Nenue@35
|
168 if frame.wasEmpty then
|
Nenue@35
|
169 frame.headerFade:Play()
|
Nenue@35
|
170 frame.wasEmpty = nil
|
Nenue@35
|
171 end
|
Nenue@35
|
172
|
Nenue@35
|
173 wrapperHeight = wrapperHeight + frame.height
|
Nenue@35
|
174 anchorFrame = handler.frame
|
Nenue@35
|
175 anchorPoint = 'BOTTOM'
|
Nenue@35
|
176
|
Nenue@35
|
177 end
|
Nenue@28
|
178
|
Nenue@30
|
179 Default.AddBlock = function(self, block, blockIndex)
|
Nenue@30
|
180 local blockIndex = blockIndex or (self.currentBlock + 1)
|
Nenue@28
|
181 local print = bprint
|
Nenue@28
|
182 local tracker = self.frame
|
Nenue@28
|
183 local info = block.info
|
Nenue@30
|
184
|
Nenue@35
|
185 block.index = blockIndex
|
Nenue@35
|
186
|
Nenue@37
|
187 print('blockschema', blockSchema, block.schema)
|
Nenue@34
|
188 if blockSchema ~= block.schema then
|
Nenue@37
|
189 T.UpdateSchema('block', block.schema)
|
Nenue@34
|
190 print('new schema detected, applicating...')
|
Nenue@37
|
191 end
|
Nenue@34
|
192
|
Nenue@37
|
193 block:SetWidth(T.Conf.Wrapper.Width)
|
Nenue@37
|
194 block.title:SetSpacing(titleSpacing)
|
Nenue@37
|
195 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing)
|
Nenue@37
|
196 block.title:SetPoint('LEFT', block, 'LEFT', titleIndent, 0)
|
Nenue@37
|
197 block.title:SetTextColor(unpack(titleColor))
|
Nenue@37
|
198 block.titlebg:SetTexture(1,1,1,1)
|
Nenue@37
|
199 block.titlebg:SetGradientAlpha(unpack(titlebg))
|
Nenue@37
|
200 block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0)
|
Nenue@37
|
201 block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing)
|
Nenue@37
|
202 block.status:SetSpacing(textSpacing)
|
Nenue@37
|
203 block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing)
|
Nenue@37
|
204 block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0)
|
Nenue@37
|
205 block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0)
|
Nenue@37
|
206 block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0)
|
Nenue@37
|
207 block.statusbg:SetTexture(1,1,1,1)
|
Nenue@37
|
208 block.statusbg:SetGradientAlpha(unpack(textbg))
|
Nenue@37
|
209 block.SelectionOverlay:SetGradientAlpha(unpack(selectionbg))
|
Nenue@37
|
210 block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
|
Nenue@37
|
211 block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
|
Nenue@37
|
212
|
Nenue@37
|
213 local anchor, target, point, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
|
Nenue@37
|
214 for i, tile in ipairs(block.rewardTile) do
|
Nenue@37
|
215 --print(rewardSize)
|
Nenue@37
|
216 tile:SetSize(rewardSize, rewardSize)
|
Nenue@37
|
217 tile:ClearAllPoints()
|
Nenue@37
|
218 tile:SetPoint(anchor, target, point, x, y)
|
Nenue@37
|
219 block.rewardLabel[i]:SetPoint('TOP', tile, 'TOP', 0, 0)
|
Nenue@37
|
220 anchor, target, point, x, y = 'TOPRIGHT', tile, 'TOPLEFT', -2, 0
|
Nenue@34
|
221 end
|
Nenue@34
|
222
|
Nenue@35
|
223
|
Nenue@35
|
224 local titleHeight = floor(block.title:GetHeight()+.5)
|
Nenue@35
|
225 local titlebgHeight = titleHeight + titleSpacing*2
|
Nenue@35
|
226 block.titlebg:SetHeight(titlebgHeight)
|
Nenue@35
|
227
|
Nenue@35
|
228 local statusHeight = floor(block.status:GetHeight()+.5)
|
Nenue@35
|
229 local statusbgHeight = statusHeight + textSpacing*2
|
Nenue@35
|
230 local attachmentHeight =floor(block.attachmentHeight + .5)
|
Nenue@35
|
231
|
Nenue@35
|
232 print(' |cFF0088FFanchor to', self.currentAnchor:GetName())
|
Nenue@35
|
233 print(' |cFF00FF00attachment:|r', attachmentHeight, '|cFF00FF00title:|r', titlebgHeight, '('.. titleHeight..')')
|
Nenue@35
|
234 if attachmentHeight > 0 then
|
Nenue@35
|
235 attachmentHeight = attachmentHeight + textSpacing
|
Nenue@35
|
236 end
|
Nenue@35
|
237
|
Nenue@35
|
238 block.height = titlebgHeight + attachmentHeight
|
Nenue@35
|
239 block:SetHeight(block.height)
|
Nenue@35
|
240
|
Nenue@34
|
241 if block.debug then
|
Nenue@34
|
242 local func = (B.Conf.GuidesMode == true) and 'Show' or 'Hide'
|
Nenue@34
|
243 for _, region in ipairs(block.debug) do
|
Nenue@34
|
244 region[func]()
|
Nenue@34
|
245 end
|
Nenue@34
|
246 end
|
Nenue@34
|
247
|
Nenue@35
|
248 --- Handler vars
|
Nenue@35
|
249 if blockIndex == 1 then
|
Nenue@35
|
250 tracker.previousHeight = tracker.height
|
Nenue@35
|
251 tracker.height = headerHeight
|
Nenue@35
|
252 blockPosition = -headerHeight
|
Nenue@35
|
253 tprint(' |cFF88FF00AddBlock:|r new layout: headerHeight =', headerHeight, 'previousHeight =', tracker.previousHeight)
|
Nenue@35
|
254 else
|
Nenue@35
|
255 blockPosition = blockPosition
|
Nenue@35
|
256 tprint(' |cFF8888FFAddBlock:|r advancing: height =', tracker.height)
|
Nenue@35
|
257 end
|
Nenue@30
|
258 self.currentBlock = blockIndex
|
Nenue@29
|
259 self.currentAnchor = block
|
Nenue@35
|
260
|
Nenue@35
|
261 block:SetPoint('TOPLEFT', self.frame, 'TOPLEFT', 0, blockPosition)
|
Nenue@35
|
262 block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
|
Nenue@35
|
263 self.numBlocks = self.numBlocks + 1
|
Nenue@29
|
264 print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height)
|
Nenue@29
|
265 tracker.height = tracker.height + block.height
|
Nenue@35
|
266 blockPosition = blockPosition - block.height
|
Nenue@28
|
267 end
|
Nenue@28
|
268
|
Nenue@28
|
269 --- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons)
|
Nenue@30
|
270 Default.AddTag = function (handler, block, tagInfo, tagPoint, tagAnchor, tagRelative)
|
Nenue@28
|
271 local print = bprint
|
Nenue@30
|
272
|
Nenue@30
|
273 for order, tagName in ipairs(block.info.tagInfo) do
|
Nenue@30
|
274 local tag = block[tagName]
|
Nenue@30
|
275 if block.tagCoords[tagName] and tag then
|
Nenue@30
|
276 tag:SetTexCoord(unpack(block.tagCoords[tagName]))
|
Nenue@30
|
277 tag:Show()
|
Nenue@30
|
278 tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
|
Nenue@30
|
279 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT'
|
Nenue@30
|
280 else
|
Nenue@30
|
281 block[tagName]:Hide()
|
Nenue@30
|
282 end
|
Nenue@28
|
283 end
|
Nenue@30
|
284
|
Nenue@28
|
285 return tagPoint, tagAnchor, tagRelative
|
Nenue@28
|
286 end
|
Nenue@28
|
287
|
Nenue@28
|
288 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call.
|
Nenue@30
|
289 Default.AddLine = function(handler, block, text, attachment, template)
|
Nenue@28
|
290 local print = lprint
|
Nenue@30
|
291 local lineIndex = block.currentLine + 1
|
Nenue@34
|
292 local line = handler:GetLine(block, lineIndex)
|
Nenue@36
|
293
|
Nenue@31
|
294 line.index = lineIndex
|
Nenue@35
|
295 if template then
|
Nenue@35
|
296 if line.schema ~= template then
|
Nenue@35
|
297 print(' |cFF00FF00change schema', template)
|
Nenue@35
|
298 T.UpdateSchema('line', template)
|
Nenue@35
|
299 line.status:SetSpacing(textSpacing)
|
Nenue@35
|
300 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
|
Nenue@35
|
301 line.status:SetPoint('RIGHT', line, 'RIGHT',0, 0)
|
Nenue@35
|
302 line.status:SetTextColor(unpack(textColor))
|
Nenue@35
|
303 line.schema = template
|
Nenue@35
|
304 else
|
Nenue@35
|
305 print(' |cFFFFFF00keep schema', line.schema)
|
Nenue@35
|
306 end
|
Nenue@34
|
307 end
|
Nenue@34
|
308 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing)
|
Nenue@37
|
309 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
|
Nenue@37
|
310 line:SetPoint('LEFT', block, 'LEFT')
|
Nenue@37
|
311 line:SetPoint('RIGHT', block, 'RIGHT')
|
Nenue@28
|
312 line:Show()
|
Nenue@28
|
313
|
Nenue@34
|
314
|
Nenue@35
|
315 tprint(' |cFF0088FFAddLine|r (|cFF00FFFF'..tostring(line.schema)..'|r):', line:GetName())
|
Nenue@34
|
316
|
Nenue@34
|
317
|
Nenue@34
|
318 -- fill in the text, then derive pixel-rounded height
|
Nenue@30
|
319 line.status:SetText(text)
|
Nenue@34
|
320 line.height = floor(line.status:GetStringHeight()+.5)
|
Nenue@30
|
321
|
Nenue@30
|
322 -- For progressbar and timer lines, status text may be used as the title heading
|
Nenue@30
|
323 if attachment then
|
Nenue@35
|
324 print(' |cFFFF0088doing things with a widget', attachment:GetSize())
|
Nenue@34
|
325 line.height = attachment:GetHeight()
|
Nenue@34
|
326 if text then
|
Nenue@34
|
327 line.height = max(line.height, line.status:GetStringHeight())
|
Nenue@31
|
328 end
|
Nenue@34
|
329 if attachment.status:GetText() then
|
Nenue@34
|
330 line.height = max(line.height, attachment.status:GetStringHeight())
|
Nenue@34
|
331 end
|
Nenue@30
|
332 attachment:Show()
|
Nenue@30
|
333 end
|
Nenue@30
|
334
|
Nenue@34
|
335 line:SetHeight(line.height)
|
Nenue@34
|
336 block.attachmentHeight = block.attachmentHeight + line.height + textSpacing
|
Nenue@35
|
337
|
Nenue@35
|
338 local debug_points = ''
|
Nenue@35
|
339 for i = 1, line:GetNumPoints() do
|
Nenue@35
|
340 local point, parent, anchor = line:GetPoint(i)
|
Nenue@35
|
341 debug_points = debug_points .. tostring(parent:GetName()) .. ', ' .. anchor .. ' '
|
Nenue@35
|
342 end
|
Nenue@35
|
343
|
Nenue@35
|
344 print(' |cFF0088FFsetting line #'..lineIndex..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height,
|
Nenue@35
|
345 "|cFF0088FFpoint:|r", debug_points, "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N'))
|
Nenue@30
|
346 block.currentLine = lineIndex
|
Nenue@36
|
347 block.endPoint = line -- edge used for the next block
|
Nenue@31
|
348
|
Nenue@31
|
349 return lineIndex
|
Nenue@28
|
350 end
|
Nenue@28
|
351
|
Nenue@28
|
352 --- Creates or retrieves a complete line data object
|
Nenue@30
|
353 Default.GetLine = function(handler, block, lineIndex)
|
Nenue@28
|
354 local print = lprint
|
Nenue@28
|
355 local blockIndex = block.index
|
Nenue@30
|
356 local lines = block.lines
|
Nenue@30
|
357 if not lineIndex then
|
Nenue@30
|
358 lineIndex = block.currentLine + 1
|
Nenue@34
|
359 print(' |cFFFFFF00generating a frame')
|
Nenue@28
|
360 end
|
Nenue@30
|
361
|
Nenue@30
|
362 block.numLines = max(block.numLines, lineIndex)
|
Nenue@30
|
363
|
Nenue@28
|
364 if not lines[lineIndex] then
|
Nenue@28
|
365 print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex)
|
Nenue@28
|
366 lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, block, 'VeneerTrackerObjective')
|
Nenue@28
|
367 local line = lines[lineIndex]
|
Nenue@28
|
368 line.index = lineIndex
|
Nenue@28
|
369 line.height = 0
|
Nenue@37
|
370 line.schema = ''
|
Nenue@28
|
371 B.SetConfigLayers(line)
|
Nenue@28
|
372
|
Nenue@28
|
373 if debug then
|
Nenue@28
|
374 for _, region in ipairs(lines[lineIndex].debug) do
|
Nenue@28
|
375 region:Show()
|
Nenue@28
|
376 end
|
Nenue@28
|
377 end
|
Nenue@28
|
378
|
Nenue@28
|
379 end
|
Nenue@28
|
380 return lines[lineIndex]
|
Nenue@28
|
381 end
|
Nenue@28
|
382
|
Nenue@29
|
383
|
Nenue@29
|
384
|
Nenue@28
|
385 --- Creates or retrieves a complete block frame object
|
Nenue@34
|
386 --- todo: make it use data index to avoid re-coloring every block
|
Nenue@37
|
387 Default.GetBlock = function(handler, index)
|
Nenue@28
|
388 local print = bprint
|
Nenue@37
|
389 print('|cFF0088FFgetting a block for index', index ..',', #handler.usedBlocks,'used', #handler.freeBlocks, 'free')
|
Nenue@37
|
390 local block = handler.InfoBlock[index]
|
Nenue@35
|
391 local used = handler.usedBlocks
|
Nenue@28
|
392
|
Nenue@34
|
393 if not block then
|
Nenue@28
|
394 if #handler.freeBlocks >= 1 then
|
Nenue@34
|
395 block = tremove(handler.freeBlocks)
|
Nenue@35
|
396 tinsert(handler.usedBlocks, block)
|
Nenue@35
|
397 block.posIndex = #handler.usedBlocks
|
Nenue@35
|
398 print(' |cFF00FF00 assigning from free heap', block:GetName())
|
Nenue@28
|
399 else
|
Nenue@34
|
400
|
Nenue@35
|
401 local blockIndex = (#handler.usedBlocks + #handler.freeBlocks) + 1
|
Nenue@30
|
402 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, handler.frame, 'VeneerTrackerBlock')
|
Nenue@35
|
403 --block:SetParent()
|
Nenue@37
|
404 block.schema = ''
|
Nenue@30
|
405 block.lines = {}
|
Nenue@30
|
406 block.numLines = 0
|
Nenue@30
|
407 block.currentLine = 0
|
Nenue@34
|
408 block.attachmentHeight = 0
|
Nenue@35
|
409 block.offset = 0
|
Nenue@34
|
410 B.SetConfigLayers(block)
|
Nenue@28
|
411 --- methods for event handlers
|
Nenue@28
|
412
|
Nenue@28
|
413 block.Select = handler.Select
|
Nenue@28
|
414 block.Open = handler.Open
|
Nenue@28
|
415 block.Remove = handler.Remove
|
Nenue@28
|
416 block.Link = handler.Link
|
Nenue@28
|
417 block.clickZone:SetScript('OnMouseUp', function(self, ...) handler.OnMouseUp(block, ...) end)
|
Nenue@28
|
418 block.clickZone:SetScript('OnMouseDown', function(self, ...) handler.OnMouseDown(block, ...) end)
|
Nenue@28
|
419 block:ClearAllPoints()
|
Nenue@34
|
420 block.index = blockIndex
|
Nenue@35
|
421 print(' |cFF00FFBBcreating new|r', block:GetName())
|
Nenue@28
|
422 end
|
Nenue@37
|
423 handler.InfoBlock[index] = block
|
Nenue@34
|
424 tinsert(handler.usedBlocks, block)
|
Nenue@35
|
425 block.posIndex = #handler.usedBlocks
|
Nenue@34
|
426 else
|
Nenue@34
|
427 print(' |cFFFFFF00use existing block|r', block:GetName())
|
Nenue@35
|
428 local found = false
|
Nenue@35
|
429 for i, entry in ipairs(used) do
|
Nenue@35
|
430 if entry == block then
|
Nenue@35
|
431 found = true
|
Nenue@35
|
432 break
|
Nenue@35
|
433 end
|
Nenue@35
|
434 end
|
Nenue@35
|
435 if not found then
|
Nenue@35
|
436 tinsert(used, block)
|
Nenue@35
|
437 block.posIndex = #used
|
Nenue@35
|
438 end
|
Nenue@28
|
439 end
|
Nenue@34
|
440 return block
|
Nenue@28
|
441 end
|
Nenue@28
|
442
|
Nenue@34
|
443
|
Nenue@30
|
444
|
Nenue@30
|
445
|
Nenue@28
|
446 ----------
|
Nenue@28
|
447 --- Top level methods
|
Nenue@28
|
448
|
Nenue@28
|
449
|
Nenue@35
|
450 T.UpdateBlockAction = function (block, itemButton)
|
Nenue@35
|
451 local print = bprint
|
Nenue@28
|
452 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()')
|
Nenue@28
|
453 if itemButton.questID ~= block.info.questID then
|
Nenue@28
|
454 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
|
Nenue@28
|
455 -- something happened between this and last frame, go back and set new probes
|
Nenue@35
|
456 return T.UpdateActionButtons()
|
Nenue@28
|
457 end
|
Nenue@28
|
458
|
Nenue@28
|
459 local previousItem = itemButton.previousItem
|
Nenue@28
|
460 local upper_bound = Scroller:GetTop() + Scroller.snap_upper
|
Nenue@28
|
461 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize
|
Nenue@28
|
462 local point, anchor, relative
|
Nenue@28
|
463
|
Nenue@28
|
464 if block:GetBottom() < lower_bound then
|
Nenue@28
|
465 print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5))
|
Nenue@28
|
466 if previousItem then
|
Nenue@28
|
467 print('adjusting', previousItem:GetName())
|
Nenue@28
|
468 previousItem:ClearAllPoints()
|
Nenue@28
|
469 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing)
|
Nenue@28
|
470 end
|
Nenue@28
|
471 itemButton:ClearAllPoints()
|
Nenue@28
|
472 itemButton.x = Wrapper:GetLeft() -4
|
Nenue@28
|
473 itemButton.y = Wrapper:GetBottom()
|
Nenue@28
|
474 point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT'
|
Nenue@28
|
475 Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing
|
Nenue@28
|
476
|
Nenue@28
|
477 elseif block:GetTop() > upper_bound then
|
Nenue@28
|
478 print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5))
|
Nenue@28
|
479 itemButton:ClearAllPoints()
|
Nenue@28
|
480 if previousItem then
|
Nenue@28
|
481 print('latch onto another piece')
|
Nenue@28
|
482 point, anchor, relative ='TOP', previousItem, 'BOTTOM'
|
Nenue@28
|
483 itemButton.x = 0
|
Nenue@28
|
484 itemButton.y = -itemButtonSpacing
|
Nenue@28
|
485 else
|
Nenue@28
|
486 print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop())
|
Nenue@28
|
487 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
|
Nenue@28
|
488 itemButton.x = Scroller:GetLeft() -4
|
Nenue@28
|
489 itemButton.y = Scroller:GetTop()
|
Nenue@28
|
490 end
|
Nenue@28
|
491 itemButton:Show()
|
Nenue@28
|
492 Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing)
|
Nenue@28
|
493 else
|
Nenue@28
|
494 print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5))
|
Nenue@28
|
495 itemButton:ClearAllPoints()
|
Nenue@28
|
496 itemButton.x = block:GetLeft() - itemButtonSpacing
|
Nenue@28
|
497 itemButton.y = block:GetTop()
|
Nenue@28
|
498 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
|
Nenue@28
|
499 end
|
Nenue@28
|
500
|
Nenue@28
|
501 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y)
|
Nenue@28
|
502 itemButton:Show()
|
Nenue@28
|
503 end
|
Nenue@28
|
504
|
Nenue@35
|
505 T.UpdateItemButtonCooldown = function(button)
|
Nenue@28
|
506
|
Nenue@28
|
507 end
|
Nenue@28
|
508
|
Nenue@35
|
509 function T:FinishWrapper ()
|
Nenue@35
|
510 if wrapperHeight > Wrapper.previousHeight then
|
Nenue@35
|
511 Wrapper:SetHeight(wrapperHeight)
|
Nenue@35
|
512 Scroller:SetHeight(wrapperHeight*3)
|
Nenue@35
|
513 Scroll:SetHeight(wrapperHeight)
|
Nenue@35
|
514 Wrapper.previousHeight = wrapperHeight
|
Nenue@35
|
515 Wrapper.destinationHeight = wrapperHeight
|
Nenue@35
|
516 end
|
Nenue@35
|
517 Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0)
|
Nenue@35
|
518 print('|cFF00FF00### end of wrapper layout', Wrapper:GetSize())
|
Nenue@35
|
519 print(' |cFF00FF00Scroller:', Scroller:GetSize())
|
Nenue@35
|
520 print(' |cFF00FF00Scroll:', Scroll:GetSize())
|
Nenue@35
|
521 for i = 1, Wrapper:GetNumPoints() do
|
Nenue@35
|
522 print('|cFF00FF00 ', Wrapper:GetPoint(i))
|
Nenue@35
|
523 end
|
Nenue@35
|
524 for i = 1, Scroller:GetNumPoints() do
|
Nenue@35
|
525 print('|cFF00FF00 ', Scroller:GetPoint(i))
|
Nenue@35
|
526 end
|
Nenue@35
|
527 for i = 1, Scroll:GetNumPoints() do
|
Nenue@35
|
528 print('|cFF00FF00 ', Scroll:GetPoint(i))
|
Nenue@35
|
529 end
|
Nenue@34
|
530
|
Nenue@35
|
531 Wrapper:Show()
|
Nenue@35
|
532 Scroller:Show()
|
Nenue@35
|
533 Scroll:Show()
|
Nenue@28
|
534 end
|
Nenue@28
|
535
|