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@39
|
6 --- Everything that involves directly placing elements on the screen goes here. Sizing, spacing, tiling, etc.
|
Nenue@28
|
7 local B = select(2,...).frame
|
Nenue@35
|
8 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
|
Nenue@28
|
9 local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band
|
Nenue@34
|
10 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion, tinsert, tremove = IsResting, UnitXP, UnitXPMax, GetXPExhaustion, table.insert, table.remove
|
Nenue@28
|
11 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent
|
Nenue@28
|
12 local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText
|
Nenue@28
|
13 local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent
|
Nenue@35
|
14 local Default, AutoQuest, Quest, Bonus, Cheevs = T.DefaultHandler, T.AutoQuest, T.Quest, T.Bonus, T.Cheevs
|
Nenue@28
|
15 local InCombatLockdown, format, lshift, CreateFrame = InCombatLockdown, format, bit.lshift, CreateFrame
|
Nenue@29
|
16 local IsModifiedClick, ChatEdit_GetActiveWindow = IsModifiedClick, ChatEdit_GetActiveWindow
|
Nenue@38
|
17 local band, bor = bit.band, bit.bor
|
Nenue@35
|
18 local print = B.print('Layout')
|
Nenue@34
|
19 local oprint = B.print('Objectives')
|
Nenue@34
|
20 local bprint = B.print('Block')
|
Nenue@34
|
21 local tprint = B.print('Tracker')
|
Nenue@35
|
22 local lprint = B.print('Layout')
|
Nenue@28
|
23 local unitLevel = 1
|
Nenue@38
|
24
|
Nenue@40
|
25 local REWARD_POPUP = _G.VeneerRewardsPopOut
|
Nenue@38
|
26 local ANIM_STATE = 'Animation: %04X'
|
Nenue@38
|
27 local INIT_STATE = 'Init: %04X'
|
Nenue@38
|
28
|
Nenue@38
|
29 --- Bitfields of import
|
Nenue@38
|
30 --- control value for everything
|
Nenue@38
|
31 local OBJECTIVE_TRACKER_UPDATE_REASON = _G.OBJECTIVE_TRACKER_UPDATE_REASON
|
Nenue@38
|
32 --- flags reason categories where frame layout requires initializing (starts high)
|
Nenue@38
|
33 local initReason = 0xFFFF
|
Nenue@38
|
34 --- flags reason categories where frame anchor updates must be delayed because of an ongoing animation (starts low)
|
Nenue@38
|
35 local animateReason = 0x0000
|
Nenue@28
|
36
|
Nenue@34
|
37 --- FRAMES
|
Nenue@28
|
38 local Wrapper = _G.VeneerObjectiveWrapper
|
Nenue@28
|
39 local Scroller = Wrapper.scrollArea
|
Nenue@28
|
40 local Scroll = _G.VeneerObjectiveScroll
|
Nenue@35
|
41 local orderedHandlers = T.orderedHandlers
|
Nenue@35
|
42 local orderedNames = T.orderedNames
|
Nenue@28
|
43
|
Nenue@34
|
44 --- FRAME TEMP VARIABLES
|
Nenue@37
|
45 local wrapperWidth, wrapperHeight = 0, 0
|
Nenue@28
|
46 local scrollWidth, scrollHeight
|
Nenue@34
|
47
|
Nenue@34
|
48 --- SCHEMA VARIABLES
|
Nenue@34
|
49 local schemaName, lastSchema = {
|
Nenue@34
|
50 tracker = '',
|
Nenue@34
|
51 block = '',
|
Nenue@34
|
52 line = ''
|
Nenue@34
|
53 }, {}
|
Nenue@34
|
54 local trackerSchema, blockSchema, lineSchema
|
Nenue@34
|
55
|
Nenue@28
|
56 local itemButtonSize, itemButtonSpacing = 36, 1
|
Nenue@34
|
57 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed
|
Nenue@34
|
58 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
|
Nenue@34
|
59 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 }
|
Nenue@34
|
60 local rewardSize = 24
|
Nenue@28
|
61
|
Nenue@30
|
62 local headerHeight, headerColor, headerSpacing = 16, {1,.75,0,1}, 2
|
Nenue@28
|
63 local headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0}
|
Nenue@28
|
64 local headerFont, headerSize, headerOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE'
|
Nenue@28
|
65
|
Nenue@31
|
66 local titlebg = {'HORIZONTAL', 1, 0, .7, 0, 1, 0, .7, .2}
|
Nenue@28
|
67 local titleFont, titleSize, titleOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE'
|
Nenue@34
|
68 local titleColor = {0,.7,1,1}
|
Nenue@28
|
69
|
Nenue@28
|
70 local textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 }
|
Nenue@28
|
71 local textFont, textSize, textOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]], 16, 'OUTLINE'
|
Nenue@39
|
72 local textColor = {1,1,1,1 }
|
Nenue@39
|
73
|
Nenue@39
|
74 local widgetTextFont, widgetTextSize, widgetTextOutline = [[Interface\Addons\SharedMedia_MyMedia\font\XOIREQE.TTF]], 11, 'OUTLINE'
|
Nenue@39
|
75 local widgetTextColor = {1,1,1,1 }
|
Nenue@39
|
76 local widgetHeight, widgetBorder = 17, 1
|
Nenue@39
|
77
|
Nenue@28
|
78
|
Nenue@28
|
79 local selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225}
|
Nenue@28
|
80 local titleSpacing, textSpacing, blockSpacing = 3, 3, 1
|
Nenue@28
|
81 local titleIndent, textIndent,selectionIndent = 2, 5, 50
|
Nenue@34
|
82 --- END SCHEMA
|
Nenue@35
|
83 local blockPosition
|
Nenue@35
|
84
|
Nenue@38
|
85
|
Nenue@38
|
86 local SetAnimate = function(reason, animate)
|
Nenue@38
|
87 print('comparing', animateReason, reason)
|
Nenue@38
|
88 if animate then
|
Nenue@38
|
89 if band(animateReason, reason) == 0 then
|
Nenue@38
|
90 animateReason = animateReason + reason
|
Nenue@38
|
91 end
|
Nenue@38
|
92 else
|
Nenue@38
|
93 if band(animateReason, reason) > 0 then
|
Nenue@38
|
94 animateReason = animateReason - reason
|
Nenue@38
|
95 end
|
Nenue@38
|
96 end
|
Nenue@38
|
97 Wrapper.AnimState:SetFormattedText(ANIM_STATE, animateReason)
|
Nenue@38
|
98 end
|
Nenue@38
|
99
|
Nenue@38
|
100
|
Nenue@34
|
101 --- schema swapper
|
Nenue@35
|
102 T.UpdateSchema = function(layer, newSchema)
|
Nenue@35
|
103 if not (T.Conf.Schema[layer] and T.Conf.Schema[layer][newSchema]) then
|
Nenue@34
|
104 return
|
Nenue@34
|
105 elseif schemaName[layer] == newSchema then
|
Nenue@34
|
106 return
|
Nenue@34
|
107 end
|
Nenue@34
|
108 lastSchema[layer] = schemaName[layer]
|
Nenue@34
|
109 schemaName[layer] = newSchema
|
Nenue@35
|
110 local c = T.Conf.Schema[layer][newSchema]
|
Nenue@28
|
111
|
Nenue@34
|
112 if layer == 'tracker' then
|
Nenue@34
|
113 headerHeight, headerSpacing = c.headerHeight, c.headerSpacing
|
Nenue@34
|
114 headerColor = c.headerColor
|
Nenue@34
|
115 headerbg = c.headerbg
|
Nenue@37
|
116 headerFont, headerSize, headerOutline = unpack(c.headerFont)
|
Nenue@34
|
117 trackerSchema = newSchema
|
Nenue@34
|
118 elseif layer == 'block' then
|
Nenue@34
|
119 titlebg = c.titlebg
|
Nenue@37
|
120 titleFont, titleSize, titleOutline = unpack(c.titleFont)
|
Nenue@34
|
121 selectionbg = c.selectionbg
|
Nenue@34
|
122 titleSpacing, textSpacing, blockSpacing = c.titleSpacing, c.textSpacing, c.blockSpacing
|
Nenue@37
|
123 titleIndent, textIndent,selectionIndent = c.titleIndex, c.textIndex, c.selectionIndent
|
Nenue@34
|
124 titleColor = c.titleColor
|
Nenue@37
|
125 print(unpack(c.titleColor))
|
Nenue@34
|
126 rewardSize = 24
|
Nenue@37
|
127 textFont, textSize, textOutline = unpack(c.textFont)
|
Nenue@34
|
128 textbg = c.textbg
|
Nenue@34
|
129 textIndent = c.textIndent
|
Nenue@34
|
130 rewardSize = c.rewardSize
|
Nenue@37
|
131 blockSchema = newSchema
|
Nenue@34
|
132 elseif layer == 'line' then
|
Nenue@34
|
133 textColor = c.textColor
|
Nenue@34
|
134 lineSchema = newSchema
|
Nenue@39
|
135 elseif layer == 'widget' then
|
Nenue@39
|
136 widgetTextColor = c.textSpacing
|
Nenue@39
|
137 widgetTextFont, widgetTextSize, widgetTextOutline = unpack(c.textFont)
|
Nenue@34
|
138 end
|
Nenue@38
|
139 tprint('|cFFFF0088 Schema:|r', layer, lastSchema[layer], '->', newSchema)
|
Nenue@34
|
140 end
|
Nenue@35
|
141 -- todo: figure out why objectives go invisible
|
Nenue@35
|
142 local anchorPoint, anchorFrame
|
Nenue@35
|
143 local abs, GetTime = math.abs, GetTime
|
Nenue@35
|
144 Default.AddTracker = function(handler, frame, index)
|
Nenue@38
|
145 local isInitialized = true
|
Nenue@38
|
146 if initReason and (band(initReason, handler.updateReason) > 0 ) then
|
Nenue@38
|
147 isInitialized = false
|
Nenue@38
|
148 initReason = initReason - handler.updateReason
|
Nenue@38
|
149 print('|cFF00FF00%%% initialization status update:', format('%04X', initReason))
|
Nenue@38
|
150
|
Nenue@38
|
151 frame.SlideIn:SetScript('OnPlay', function()
|
Nenue@38
|
152 SetAnimate(handler.updateReasonModule, true)
|
Nenue@38
|
153 end)
|
Nenue@38
|
154
|
Nenue@38
|
155 frame.SlideIn:SetScript('OnFinished', function()
|
Nenue@38
|
156 SetAnimate(handler.updateReasonModule, false)
|
Nenue@38
|
157 end)
|
Nenue@38
|
158
|
Nenue@38
|
159 if initReason == 0 then
|
Nenue@38
|
160 initReason = nil
|
Nenue@38
|
161 end
|
Nenue@38
|
162 end
|
Nenue@38
|
163
|
Nenue@35
|
164 if index == 1 then
|
Nenue@35
|
165 print('|cFF00FF00### beginning wrapper layout -----------------')
|
Nenue@35
|
166 anchorPoint, anchorFrame = 'TOP', Scroll
|
Nenue@40
|
167 wrapperHeight = 18
|
Nenue@35
|
168 end
|
Nenue@35
|
169
|
Nenue@35
|
170 frame.destinationOffset = -wrapperHeight
|
Nenue@35
|
171 print(frame.destinationOffset, frame.previousOffset)
|
Nenue@38
|
172 if isInitialized and (abs(frame.previousOffset - frame.destinationOffset) > 0.9) and frame:IsVisible() then
|
Nenue@35
|
173 if frame.wasEmpty then
|
Nenue@35
|
174 frame.previousOffset = -Wrapper:GetHeight()
|
Nenue@35
|
175 end
|
Nenue@35
|
176
|
Nenue@35
|
177 local postFrame, postPoint = anchorFrame, anchorPoint
|
Nenue@35
|
178 local delta = frame.destinationOffset - frame.previousOffset
|
Nenue@35
|
179 local _, _, _, _, offset = frame:GetPoint(1)
|
Nenue@35
|
180 print(' |cFF00FFBBpushing', frame:GetName(), delta, 'pixels, from', frame.previousOffset, '(', offset, ')')
|
Nenue@35
|
181 frame.SlideIn.translation:SetTarget(frame)
|
Nenue@35
|
182 frame.SlideIn.translation:SetOffset(0, delta)
|
Nenue@35
|
183 frame.SlideIn:Play()
|
Nenue@35
|
184 --for i, b in ipairs(handler.usedBlocks) do
|
Nenue@35
|
185 --b.SlideIn.translation:SetOffset(0, delta)
|
Nenue@35
|
186 -- b.SlideIn:Play()
|
Nenue@35
|
187 --end
|
Nenue@35
|
188 local start = GetTime()
|
Nenue@35
|
189 frame.SlideIn:SetScript('OnFinished', function()
|
Nenue@35
|
190 print(' |cFF00BBFF'..frame:GetName(), 'moved', delta, 'over duration of ', GetTime()-start)
|
Nenue@35
|
191 frame:SetParent(Scroll)
|
Nenue@35
|
192 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
|
Nenue@35
|
193 frame.previousOffset = frame.destinationOffset
|
Nenue@35
|
194 frame.SlideIn:SetScript('OnFinished', nil)
|
Nenue@35
|
195 if Wrapper.destinationHeight then
|
Nenue@35
|
196 Wrapper:SetHeight(Wrapper.destinationHeight)
|
Nenue@35
|
197 Scroller:SetHeight(Wrapper.destinationHeight)
|
Nenue@35
|
198 Scroll:SetHeight(Wrapper.destinationHeight)
|
Nenue@35
|
199 Wrapper.previousHeight = Wrapper.destinationHeight
|
Nenue@35
|
200 Wrapper.destinationHeight = nil
|
Nenue@35
|
201 end
|
Nenue@35
|
202
|
Nenue@35
|
203 end)
|
Nenue@35
|
204 else
|
Nenue@37
|
205 print(' |cFF00BBFFpinning '..handler.name..' to', anchorFrame:GetName(), anchorPoint, '|rcurrent frame height:', frame.height)
|
Nenue@35
|
206 print(' |cFFFF0088total height:', wrapperHeight)
|
Nenue@35
|
207 frame:ClearAllPoints()
|
Nenue@40
|
208 frame:Show()
|
Nenue@35
|
209 frame:SetParent(Scroll)
|
Nenue@35
|
210 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
|
Nenue@38
|
211 frame:SetPoint('LEFT', Scroll, 'LEFT')
|
Nenue@38
|
212 frame:SetPoint('RIGHT', Scroll, 'RIGHT')
|
Nenue@35
|
213 frame.previousOffset = frame.destinationOffset
|
Nenue@35
|
214 handler.initialized = true
|
Nenue@35
|
215 end
|
Nenue@35
|
216
|
Nenue@35
|
217 frame.title:SetFont(headerFont, headerSize, headerOutline)
|
Nenue@35
|
218 frame.titlebg:SetHeight(headerHeight)
|
Nenue@35
|
219 frame.title:SetTextColor(unpack(headerColor))
|
Nenue@35
|
220
|
Nenue@35
|
221 if frame.height ~= frame.previousHeight then
|
Nenue@35
|
222 frame:SetHeight(frame.height)
|
Nenue@35
|
223 end
|
Nenue@35
|
224
|
Nenue@35
|
225 if frame.wasEmpty then
|
Nenue@35
|
226 frame.headerFade:Play()
|
Nenue@35
|
227 frame.wasEmpty = nil
|
Nenue@35
|
228 end
|
Nenue@35
|
229
|
Nenue@35
|
230 wrapperHeight = wrapperHeight + frame.height
|
Nenue@35
|
231 anchorFrame = handler.frame
|
Nenue@35
|
232 anchorPoint = 'BOTTOM'
|
Nenue@35
|
233
|
Nenue@35
|
234 end
|
Nenue@28
|
235
|
Nenue@30
|
236 Default.AddBlock = function(self, block, blockIndex)
|
Nenue@30
|
237 local blockIndex = blockIndex or (self.currentBlock + 1)
|
Nenue@28
|
238 local print = bprint
|
Nenue@28
|
239 local tracker = self.frame
|
Nenue@28
|
240 local info = block.info
|
Nenue@30
|
241
|
Nenue@35
|
242 block.index = blockIndex
|
Nenue@44
|
243 print('blockschema', blockSchema, block.schema)
|
Nenue@44
|
244 if blockSchema ~= block.schema then
|
Nenue@44
|
245 T.UpdateSchema('block', block.schema)
|
Nenue@44
|
246 print(' ### activating block schema:|cFF0088FF', block.schema)
|
Nenue@37
|
247 end
|
Nenue@34
|
248
|
Nenue@44
|
249 block:SetWidth(T.Conf.Wrapper.Width)
|
Nenue@44
|
250 block.title:SetSpacing(titleSpacing)
|
Nenue@44
|
251 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing)
|
Nenue@44
|
252 block.title:SetPoint('LEFT', block, 'LEFT', titleIndent, 0)
|
Nenue@44
|
253 block.title:SetTextColor(unpack(titleColor))
|
Nenue@44
|
254 block.titlebg:SetTexture(1,1,1,1)
|
Nenue@44
|
255 block.titlebg:SetGradientAlpha(unpack(titlebg))
|
Nenue@44
|
256 block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0)
|
Nenue@44
|
257 block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing)
|
Nenue@44
|
258 block.status:SetSpacing(textSpacing)
|
Nenue@44
|
259 block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing)
|
Nenue@44
|
260 block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0)
|
Nenue@44
|
261 block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0)
|
Nenue@44
|
262 block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0)
|
Nenue@44
|
263 block.statusbg:SetTexture(1,1,1,1)
|
Nenue@44
|
264 block.statusbg:SetGradientAlpha(unpack(textbg))
|
Nenue@44
|
265 block.SelectionOverlay:SetGradientAlpha(unpack(selectionbg))
|
Nenue@44
|
266 block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
|
Nenue@44
|
267 block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
|
Nenue@44
|
268
|
Nenue@44
|
269
|
Nenue@44
|
270 local titleHeight = floor(block.title:GetHeight()+.5)
|
Nenue@44
|
271 local titlebgHeight = titleHeight + titleSpacing*2
|
Nenue@44
|
272 block.titlebg:SetHeight(titlebgHeight)
|
Nenue@44
|
273
|
Nenue@44
|
274 local statusHeight = floor(block.status:GetHeight()+.5)
|
Nenue@44
|
275 local statusbgHeight = statusHeight + textSpacing*2
|
Nenue@44
|
276 local attachmentHeight =floor(block.attachmentHeight + .5)
|
Nenue@44
|
277
|
Nenue@44
|
278 if attachmentHeight > 0 then
|
Nenue@44
|
279 attachmentHeight = attachmentHeight + textSpacing
|
Nenue@44
|
280 end
|
Nenue@44
|
281
|
Nenue@44
|
282 block.height = titlebgHeight + attachmentHeight
|
Nenue@44
|
283 block:SetHeight(block.height)
|
Nenue@44
|
284
|
Nenue@44
|
285 local anchor, target, point, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
|
Nenue@44
|
286 for i, tile in ipairs(block.rewardTile) do
|
Nenue@44
|
287 --print(rewardSize)
|
Nenue@44
|
288 tile:SetSize(rewardSize, rewardSize)
|
Nenue@44
|
289 tile:ClearAllPoints()
|
Nenue@44
|
290 tile:SetPoint(anchor, target, point, x, y)
|
Nenue@44
|
291 block.rewardLabel[i]:SetPoint('TOP', tile, 'TOP', 0, 0)
|
Nenue@44
|
292 anchor, target, point, x, y = 'TOPRIGHT', tile, 'TOPLEFT', -2, 0
|
Nenue@44
|
293 end
|
Nenue@44
|
294
|
Nenue@44
|
295 self.print('AddBlock', 'anchor to|cFF0088FF', self.currentAnchor:GetName())
|
Nenue@44
|
296 self.print('AddBlock', 'attachment:|cFF00FF00', attachmentHeight, '|rtitle:|cFF00FF00', titlebgHeight, '|r('.. titleHeight..')')
|
Nenue@34
|
297 if block.debug then
|
Nenue@34
|
298 local func = (B.Conf.GuidesMode == true) and 'Show' or 'Hide'
|
Nenue@34
|
299 for _, region in ipairs(block.debug) do
|
Nenue@34
|
300 region[func]()
|
Nenue@34
|
301 end
|
Nenue@34
|
302 end
|
Nenue@34
|
303
|
Nenue@35
|
304 --- Handler vars
|
Nenue@35
|
305 if blockIndex == 1 then
|
Nenue@35
|
306 tracker.previousHeight = tracker.height
|
Nenue@35
|
307 tracker.height = headerHeight
|
Nenue@35
|
308 blockPosition = -headerHeight
|
Nenue@40
|
309 self.print('AddBlock', 'new layout: headerHeight:|cFF00FF00', headerHeight, '|rpreviousHeight:|cFF00FF00', tracker.previousHeight)
|
Nenue@35
|
310 else
|
Nenue@35
|
311 blockPosition = blockPosition
|
Nenue@40
|
312 self.print('AddBlock', 'advancing: height:|cFF8888FF', tracker.height)
|
Nenue@35
|
313 end
|
Nenue@30
|
314 self.currentBlock = blockIndex
|
Nenue@29
|
315 self.currentAnchor = block
|
Nenue@35
|
316
|
Nenue@35
|
317 block:SetPoint('TOPLEFT', self.frame, 'TOPLEFT', 0, blockPosition)
|
Nenue@35
|
318 block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
|
Nenue@35
|
319 self.numBlocks = self.numBlocks + 1
|
Nenue@29
|
320 print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height)
|
Nenue@29
|
321 tracker.height = tracker.height + block.height
|
Nenue@35
|
322 blockPosition = blockPosition - block.height
|
Nenue@38
|
323
|
Nenue@40
|
324 block:Show()
|
Nenue@38
|
325
|
Nenue@38
|
326
|
Nenue@38
|
327 if Devian and Devian.InWorkspace() then
|
Nenue@38
|
328 block.DebugTab:SetParent(UIParent)
|
Nenue@44
|
329 block.DebugTab:SetPoint('RIGHT', block.titlebg, 'LEFT', 0, 0)
|
Nenue@38
|
330 block.DebugTab.status:SetText(tostring(block.schema) .. ' @|cFF00FF00' .. tostring(block.posIndex) .. '|r #|cFFFFFF00'.. tostring(info.logIndex or info.id) .. '|r'..
|
Nenue@44
|
331 ' H|cFFFFFF00' .. tostring(block.height) .. ' L|cFF00FFFF' .. tostring(block.numLines) ..'|r ' .. (info.statusKey or ''))
|
Nenue@38
|
332 block.DebugTab:Show()
|
Nenue@38
|
333 end
|
Nenue@28
|
334 end
|
Nenue@28
|
335
|
Nenue@44
|
336
|
Nenue@44
|
337 local tagOrder = {'completion', 'frequency', 'type'}
|
Nenue@28
|
338 --- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons)
|
Nenue@44
|
339 Default.AddTags = function (handler, block, tagInfo, tagCoords)
|
Nenue@28
|
340 local print = bprint
|
Nenue@30
|
341
|
Nenue@44
|
342 local tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block, 'TOPRIGHT'
|
Nenue@44
|
343 handler.print('AddTag', block:GetName(), tagInfo, tagCoords)
|
Nenue@44
|
344 for order, key in ipairs(tagOrder) do
|
Nenue@44
|
345 local tag = block[key .. 'Tag']
|
Nenue@44
|
346 if tag and tagInfo[key] then
|
Nenue@44
|
347 tag:SetTexCoord(unpack(tagInfo[key]))
|
Nenue@30
|
348 tag:Show()
|
Nenue@30
|
349 tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
|
Nenue@30
|
350 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT'
|
Nenue@30
|
351 else
|
Nenue@44
|
352 block[key .. 'Tag']:Hide()
|
Nenue@30
|
353 end
|
Nenue@28
|
354 end
|
Nenue@30
|
355
|
Nenue@28
|
356 return tagPoint, tagAnchor, tagRelative
|
Nenue@28
|
357 end
|
Nenue@28
|
358
|
Nenue@38
|
359
|
Nenue@28
|
360 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call.
|
Nenue@30
|
361 Default.AddLine = function(handler, block, text, attachment, template)
|
Nenue@28
|
362 local print = lprint
|
Nenue@30
|
363 local lineIndex = block.currentLine + 1
|
Nenue@34
|
364 local line = handler:GetLine(block, lineIndex)
|
Nenue@36
|
365
|
Nenue@31
|
366 line.index = lineIndex
|
Nenue@38
|
367 template = template or 'default'
|
Nenue@38
|
368 if template and lineSchema ~= template then
|
Nenue@35
|
369 print(' |cFF00FF00change schema', template)
|
Nenue@35
|
370 T.UpdateSchema('line', template)
|
Nenue@34
|
371 end
|
Nenue@38
|
372 line.status:SetSpacing(textSpacing)
|
Nenue@38
|
373 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
|
Nenue@38
|
374 line.status:SetPoint('RIGHT', line, 'RIGHT',0, 0)
|
Nenue@38
|
375 line.status:SetTextColor(unpack(textColor))
|
Nenue@34
|
376 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing)
|
Nenue@37
|
377 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
|
Nenue@37
|
378 line:SetPoint('LEFT', block, 'LEFT')
|
Nenue@37
|
379 line:SetPoint('RIGHT', block, 'RIGHT')
|
Nenue@28
|
380 line:Show()
|
Nenue@38
|
381 line:SetScript('OnMouseUp', function(self, button)
|
Nenue@38
|
382 handler.OnMouseUp(block, button)
|
Nenue@38
|
383 end)
|
Nenue@28
|
384
|
Nenue@34
|
385
|
Nenue@40
|
386 handler.print('AddLine', '|cFF00FFFF'..tostring(line.schema)..'|r', line:GetName())
|
Nenue@38
|
387 --[[
|
Nenue@38
|
388 for i = 1, line:GetNumPoints() do
|
Nenue@38
|
389 tprint(' - ', line:GetPoint(i))
|
Nenue@38
|
390 end
|
Nenue@38
|
391 tprint(' - ', line:GetSize())
|
Nenue@38
|
392 tprint(' - ', line:GetParent(), line:GetParent():IsVisible())
|
Nenue@38
|
393 tprint(' - ', line:IsVisible())
|
Nenue@38
|
394 --]]
|
Nenue@38
|
395
|
Nenue@38
|
396
|
Nenue@34
|
397
|
Nenue@34
|
398
|
Nenue@34
|
399 -- fill in the text, then derive pixel-rounded height
|
Nenue@30
|
400 line.status:SetText(text)
|
Nenue@34
|
401 line.height = floor(line.status:GetStringHeight()+.5)
|
Nenue@30
|
402
|
Nenue@30
|
403 -- For progressbar and timer lines, status text may be used as the title heading
|
Nenue@30
|
404 if attachment then
|
Nenue@38
|
405 attachment:SetPoint('TOP', line, 'TOP')
|
Nenue@38
|
406 attachment:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
|
Nenue@38
|
407 attachment:SetPoint('RIGHT', line, 'RIGHT')
|
Nenue@35
|
408 print(' |cFFFF0088doing things with a widget', attachment:GetSize())
|
Nenue@34
|
409 line.height = attachment:GetHeight()
|
Nenue@34
|
410 if text then
|
Nenue@34
|
411 line.height = max(line.height, line.status:GetStringHeight())
|
Nenue@31
|
412 end
|
Nenue@34
|
413 if attachment.status:GetText() then
|
Nenue@34
|
414 line.height = max(line.height, attachment.status:GetStringHeight())
|
Nenue@34
|
415 end
|
Nenue@30
|
416 attachment:Show()
|
Nenue@30
|
417 end
|
Nenue@30
|
418
|
Nenue@34
|
419 line:SetHeight(line.height)
|
Nenue@34
|
420 block.attachmentHeight = block.attachmentHeight + line.height + textSpacing
|
Nenue@35
|
421
|
Nenue@35
|
422 local debug_points = ''
|
Nenue@35
|
423 for i = 1, line:GetNumPoints() do
|
Nenue@35
|
424 local point, parent, anchor = line:GetPoint(i)
|
Nenue@35
|
425 debug_points = debug_points .. tostring(parent:GetName()) .. ', ' .. anchor .. ' '
|
Nenue@35
|
426 end
|
Nenue@35
|
427
|
Nenue@35
|
428 print(' |cFF0088FFsetting line #'..lineIndex..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height,
|
Nenue@35
|
429 "|cFF0088FFpoint:|r", debug_points, "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N'))
|
Nenue@30
|
430 block.currentLine = lineIndex
|
Nenue@36
|
431 block.endPoint = line -- edge used for the next block
|
Nenue@31
|
432
|
Nenue@31
|
433 return lineIndex
|
Nenue@28
|
434 end
|
Nenue@28
|
435
|
Nenue@34
|
436
|
Nenue@30
|
437
|
Nenue@28
|
438 ----------
|
Nenue@28
|
439 --- Top level methods
|
Nenue@28
|
440
|
Nenue@28
|
441
|
Nenue@40
|
442 T.UpdateItemButtonAnchor = function (block, itemButton)
|
Nenue@35
|
443 local print = bprint
|
Nenue@28
|
444 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()')
|
Nenue@28
|
445 if itemButton.questID ~= block.info.questID then
|
Nenue@28
|
446 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
|
Nenue@28
|
447 -- something happened between this and last frame, go back and set new probes
|
Nenue@35
|
448 return T.UpdateActionButtons()
|
Nenue@28
|
449 end
|
Nenue@28
|
450
|
Nenue@28
|
451 local previousItem = itemButton.previousItem
|
Nenue@28
|
452 local upper_bound = Scroller:GetTop() + Scroller.snap_upper
|
Nenue@28
|
453 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize
|
Nenue@28
|
454 local point, anchor, relative
|
Nenue@28
|
455
|
Nenue@28
|
456 if block:GetBottom() < lower_bound then
|
Nenue@28
|
457 print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5))
|
Nenue@28
|
458 if previousItem then
|
Nenue@28
|
459 print('adjusting', previousItem:GetName())
|
Nenue@28
|
460 previousItem:ClearAllPoints()
|
Nenue@28
|
461 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing)
|
Nenue@28
|
462 end
|
Nenue@28
|
463 itemButton:ClearAllPoints()
|
Nenue@28
|
464 itemButton.x = Wrapper:GetLeft() -4
|
Nenue@28
|
465 itemButton.y = Wrapper:GetBottom()
|
Nenue@28
|
466 point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT'
|
Nenue@28
|
467 Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing
|
Nenue@28
|
468
|
Nenue@28
|
469 elseif block:GetTop() > upper_bound then
|
Nenue@28
|
470 print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5))
|
Nenue@28
|
471 itemButton:ClearAllPoints()
|
Nenue@28
|
472 if previousItem then
|
Nenue@28
|
473 print('latch onto another piece')
|
Nenue@28
|
474 point, anchor, relative ='TOP', previousItem, 'BOTTOM'
|
Nenue@28
|
475 itemButton.x = 0
|
Nenue@28
|
476 itemButton.y = -itemButtonSpacing
|
Nenue@28
|
477 else
|
Nenue@28
|
478 print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop())
|
Nenue@28
|
479 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
|
Nenue@28
|
480 itemButton.x = Scroller:GetLeft() -4
|
Nenue@28
|
481 itemButton.y = Scroller:GetTop()
|
Nenue@28
|
482 end
|
Nenue@28
|
483 itemButton:Show()
|
Nenue@28
|
484 Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing)
|
Nenue@28
|
485 else
|
Nenue@28
|
486 print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5))
|
Nenue@28
|
487 itemButton:ClearAllPoints()
|
Nenue@28
|
488 itemButton.x = block:GetLeft() - itemButtonSpacing
|
Nenue@28
|
489 itemButton.y = block:GetTop()
|
Nenue@28
|
490 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
|
Nenue@28
|
491 end
|
Nenue@28
|
492
|
Nenue@28
|
493 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y)
|
Nenue@28
|
494 itemButton:Show()
|
Nenue@28
|
495 end
|
Nenue@28
|
496
|
Nenue@35
|
497 T.UpdateItemButtonCooldown = function(button)
|
Nenue@28
|
498
|
Nenue@28
|
499 end
|
Nenue@28
|
500
|
Nenue@35
|
501 function T:FinishWrapper ()
|
Nenue@35
|
502 if wrapperHeight > Wrapper.previousHeight then
|
Nenue@35
|
503 Wrapper:SetHeight(wrapperHeight)
|
Nenue@35
|
504 Scroller:SetHeight(wrapperHeight*3)
|
Nenue@35
|
505 Scroll:SetHeight(wrapperHeight)
|
Nenue@35
|
506 Wrapper.previousHeight = wrapperHeight
|
Nenue@35
|
507 Wrapper.destinationHeight = wrapperHeight
|
Nenue@35
|
508 end
|
Nenue@35
|
509 Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0)
|
Nenue@35
|
510 print('|cFF00FF00### end of wrapper layout', Wrapper:GetSize())
|
Nenue@35
|
511 print(' |cFF00FF00Scroller:', Scroller:GetSize())
|
Nenue@35
|
512 print(' |cFF00FF00Scroll:', Scroll:GetSize())
|
Nenue@35
|
513 for i = 1, Wrapper:GetNumPoints() do
|
Nenue@35
|
514 print('|cFF00FF00 ', Wrapper:GetPoint(i))
|
Nenue@35
|
515 end
|
Nenue@35
|
516 for i = 1, Scroller:GetNumPoints() do
|
Nenue@35
|
517 print('|cFF00FF00 ', Scroller:GetPoint(i))
|
Nenue@35
|
518 end
|
Nenue@35
|
519 for i = 1, Scroll:GetNumPoints() do
|
Nenue@35
|
520 print('|cFF00FF00 ', Scroll:GetPoint(i))
|
Nenue@35
|
521 end
|
Nenue@34
|
522
|
Nenue@38
|
523 if Devian and Devian.InWorkspace() then
|
Nenue@38
|
524 Wrapper.AnimState:SetFormattedText(ANIM_STATE, animateReason)
|
Nenue@43
|
525 Wrapper.AnimState:Show()
|
Nenue@38
|
526 end
|
Nenue@38
|
527
|
Nenue@35
|
528 Wrapper:Show()
|
Nenue@35
|
529 Scroller:Show()
|
Nenue@35
|
530 Scroll:Show()
|
Nenue@28
|
531 end
|
Nenue@28
|
532
|
Nenue@39
|
533
|
Nenue@39
|
534 -----------------------------------------
|
Nenue@39
|
535 -- Criteria frames
|
Nenue@39
|
536
|
Nenue@39
|
537 --[[
|
Nenue@39
|
538 text = description,
|
Nenue@39
|
539 type = type,
|
Nenue@39
|
540 finished = completed,
|
Nenue@39
|
541 quantity = quantity,
|
Nenue@39
|
542 requiredQuantity = requiredQuantity,
|
Nenue@39
|
543 characterName = characterName,
|
Nenue@39
|
544 flags = flags,
|
Nenue@39
|
545 assetID = assetID,
|
Nenue@39
|
546 quantityString = quantityString,
|
Nenue@39
|
547 criteriaID = criteriaID,
|
Nenue@39
|
548 ]]
|
Nenue@39
|
549 T.WidgetRegistry = {}
|
Nenue@39
|
550 local wr = T.WidgetRegistry
|
Nenue@39
|
551
|
Nenue@39
|
552 --- WidgetTemplate 'OnShow'
|
Nenue@39
|
553 local wrapperWidth, textIndent
|
Nenue@39
|
554 T.InitializeWidget = setmetatable({}, {
|
Nenue@39
|
555 __call = function(t, frame, isNew, ...)
|
Nenue@39
|
556 -- todo: config pull
|
Nenue@39
|
557 if not wrapperWidth then
|
Nenue@39
|
558 wrapperWidth = T.Conf.Wrapper.Width
|
Nenue@39
|
559 textIndent = T.Conf.Wrapper.TextIndent
|
Nenue@39
|
560 end
|
Nenue@39
|
561
|
Nenue@39
|
562 tprint('Initialize', frame:GetName(), isNew, ...)
|
Nenue@39
|
563 frame:SetWidth(wrapperWidth - textIndent * 2)
|
Nenue@39
|
564 frame:SetScript('OnEvent', T.UpdateWidget[frame.widgetType])
|
Nenue@39
|
565 frame:RegisterEvent('QUEST_LOG_UPDATE')
|
Nenue@39
|
566 frame:RegisterEvent('TRACKED_ACHIEVEMENT_UPDATE')
|
Nenue@39
|
567 frame:RegisterEvent('TRACKED_ACHIEVEMENT_LIST_CHANGED')
|
Nenue@39
|
568 frame:RegisterEvent('CRITERIA_UPDATE')
|
Nenue@39
|
569 frame:RegisterEvent('CRITERIA_COMPLETE')
|
Nenue@39
|
570 frame:RegisterEvent('CRITERIA_EARNED')
|
Nenue@39
|
571 t[frame.widgetType](frame, isNew)
|
Nenue@39
|
572 T.UpdateWidget[frame.widgetType](frame, isNew)
|
Nenue@39
|
573 end,
|
Nenue@39
|
574 })
|
Nenue@39
|
575
|
Nenue@39
|
576 --- WidgetTemplate 'OnEvent'
|
Nenue@39
|
577 T.UpdateWidget = setmetatable({}, {
|
Nenue@39
|
578 __call = function(t, frame, isNew, ...)
|
Nenue@39
|
579 tprint('Update', frame:GetName(), isNew, ...)
|
Nenue@39
|
580 if not frame.widgetType then
|
Nenue@39
|
581 return
|
Nenue@39
|
582 end
|
Nenue@39
|
583
|
Nenue@39
|
584 return t[frame.widgetType](frame, isNew)
|
Nenue@39
|
585 end
|
Nenue@39
|
586 })
|
Nenue@39
|
587
|
Nenue@39
|
588
|
Nenue@39
|
589 local progressHeight = 17
|
Nenue@39
|
590 local progressBorder = 1
|
Nenue@39
|
591 local progressFont = _G.VeneerCriteriaFontNormal
|
Nenue@39
|
592
|
Nenue@39
|
593 local lprint = B.print('Line')
|
Nenue@39
|
594 T.InitializeWidget.StatusBar = function(self, isNew)
|
Nenue@39
|
595 local print = lprint
|
Nenue@39
|
596 local c = T.Conf.Wrapper
|
Nenue@39
|
597
|
Nenue@39
|
598 tprint(self:GetName(), isNew)
|
Nenue@39
|
599 if isNew then
|
Nenue@39
|
600 self:SetMinMaxValues(0, self.maxValue)
|
Nenue@39
|
601
|
Nenue@39
|
602 self:SetHeight(widgetHeight)
|
Nenue@39
|
603 self.height = widgetHeight
|
Nenue@39
|
604
|
Nenue@39
|
605 self.status:SetFont(widgetTextFont, widgetTextSize, widgetTextOutline)
|
Nenue@39
|
606 self.status:SetTextColor(unpack(widgetTextColor))
|
Nenue@39
|
607 end
|
Nenue@39
|
608 self:SetValue(self.value)
|
Nenue@39
|
609
|
Nenue@39
|
610 self.status:SetText(self.objective.quantityString)
|
Nenue@39
|
611 end
|
Nenue@39
|
612
|
Nenue@39
|
613 T.UpdateWidget.StatusBar = function (self)
|
Nenue@39
|
614 local value, maxValue = self.value, self.maxValue
|
Nenue@39
|
615 print('update vals:')
|
Nenue@39
|
616 for k,v in pairs(self) do
|
Nenue@39
|
617 print(k, v)
|
Nenue@39
|
618 end
|
Nenue@39
|
619 self.width = self.width or self:GetWidth()
|
Nenue@39
|
620 self:SetValue(self.value)
|
Nenue@39
|
621 local format = self.format or '%d/%d'
|
Nenue@39
|
622 self.status:SetFormattedText(format, value, maxValue)
|
Nenue@39
|
623 local progress = (value / maxValue)
|
Nenue@39
|
624 if progress > 0 then
|
Nenue@39
|
625 print('color:', 1-progress*2 , progress*2 - 1,0,1)
|
Nenue@39
|
626 print('width:', (self.width -progressBorder * 2) * progress)
|
Nenue@39
|
627 self:SetStatusBarColor(1-progress*2 , progress*2,0,1)
|
Nenue@39
|
628 end
|
Nenue@39
|
629 end
|
Nenue@39
|
630
|
Nenue@39
|
631
|
Nenue@39
|
632 T.InitializeWidget.Hidden = function (self)
|
Nenue@39
|
633 self.height = 0
|
Nenue@39
|
634 end
|
Nenue@39
|
635 T.UpdateWidget.Hidden = function (self)
|
Nenue@39
|
636 self.height= 0
|
Nenue@39
|
637 end
|
Nenue@39
|
638
|
Nenue@39
|
639
|
Nenue@39
|
640 --- Queue any active item buttons for update for that frame
|
Nenue@39
|
641 local iprint = B.print('ItemButton')
|
Nenue@39
|
642 local Quest = T.Quest
|
Nenue@39
|
643 local IsQuestWatched, InCombatLockdown = IsQuestWatched, InCombatLockdown
|
Nenue@39
|
644 T.UpdateActionButtons = function(updateReason)
|
Nenue@39
|
645 local print = iprint
|
Nenue@39
|
646 Scroller.snap_upper = 0
|
Nenue@39
|
647 Scroller.snap_lower = 0
|
Nenue@39
|
648 local print = B.print('ItemButton')
|
Nenue@39
|
649 if updateReason then
|
Nenue@39
|
650 print = B.print('IB_'..updateReason)
|
Nenue@39
|
651 end
|
Nenue@39
|
652
|
Nenue@39
|
653 local previousItem
|
Nenue@39
|
654 for questID, itemButton in pairs(Quest.itemButtons) do
|
Nenue@39
|
655 local info= T.Quest.Info[questID]
|
Nenue@39
|
656
|
Nenue@39
|
657 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName())
|
Nenue@39
|
658 local block = T.Quest.QuestBlock[questID]
|
Nenue@39
|
659 if block then
|
Nenue@39
|
660 -- Dispatch the probe
|
Nenue@39
|
661 if IsQuestWatched(info.logIndex) then
|
Nenue@39
|
662 itemButton.previousItem = previousItem
|
Nenue@39
|
663 print(' |cFFFFFF00probing', block:GetName())
|
Nenue@39
|
664 block:SetScript('OnUpdate', function()
|
Nenue@39
|
665 if block:GetBottom() and not InCombatLockdown() then
|
Nenue@39
|
666 print(' '..block:GetName()..' |cFF00FF00probe hit!')
|
Nenue@40
|
667 T.UpdateItemButtonAnchor(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope
|
Nenue@39
|
668 block:SetScript('OnUpdate', nil)
|
Nenue@39
|
669
|
Nenue@39
|
670 end
|
Nenue@39
|
671 end)
|
Nenue@39
|
672 previousItem = itemButton
|
Nenue@39
|
673 else
|
Nenue@39
|
674 print('hidden block or unwatched quest')
|
Nenue@39
|
675 itemButton.previousItem = nil
|
Nenue@39
|
676 itemButton:Hide()
|
Nenue@39
|
677 end
|
Nenue@39
|
678 elseif itemButton:IsVisible() then
|
Nenue@39
|
679 print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName())
|
Nenue@39
|
680 itemButton.previousItem = nil
|
Nenue@39
|
681 itemButton:Hide()
|
Nenue@39
|
682 else
|
Nenue@39
|
683 print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName())
|
Nenue@39
|
684 end
|
Nenue@39
|
685 end
|
Nenue@40
|
686 end
|
Nenue@40
|
687
|
Nenue@40
|
688 Default.FadeOutBlock = function (handler, blockIndex)
|
Nenue@40
|
689
|
Nenue@39
|
690 end |