Nenue@1
|
1 --- ${PACKAGE_NAME}
|
Nenue@1
|
2 -- @file-author@
|
Nenue@1
|
3 -- @project-revision@ @project-hash@
|
Nenue@1
|
4 -- @file-revision@ @file-hash@
|
Nenue@1
|
5 -- Created: 3/30/2016 12:49 AM
|
Nenue@1
|
6 local B = select(2,...).frame
|
Nenue@10
|
7 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
|
Nenue@2
|
8 local ipairs, max, min, unpack, floor, pairs, tostring, type = ipairs, max, min, unpack, floor, pairs, tostring, type
|
Nenue@2
|
9 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion
|
Nenue@2
|
10 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent
|
Nenue@1
|
11 local CreateFrame = CreateFrame
|
Nenue@1
|
12 local print = B.print('Objectives')
|
Nenue@1
|
13 --------------------------------------------------------------------
|
Nenue@1
|
14 --- Global frame layout
|
Nenue@1
|
15 --------------------------------------------------------------------
|
Nenue@1
|
16
|
Nenue@1
|
17 --- Upvalues
|
Nenue@2
|
18 local Wrapper = VeneerObjectiveWrapper
|
Nenue@1
|
19 local Scroller = Wrapper.scrollArea
|
Nenue@2
|
20 local Scroll = VeneerObjectiveScroll
|
Nenue@1
|
21 local orderedHandlers = mod.orderedHandlers
|
Nenue@1
|
22 local orderedNames = mod.orderedNames
|
Nenue@1
|
23
|
Nenue@1
|
24 --- Temp values set during updates
|
Nenue@1
|
25 local wrapperWidth, wrapperHeight
|
Nenue@1
|
26 local scrollWidth, scrollHeight
|
Nenue@1
|
27 local previousBlock
|
Nenue@1
|
28 local currentBlock
|
Nenue@10
|
29 --- todo: source these from config
|
Nenue@6
|
30 local itemButtonSize, itemButtonSpacing = 36, 1
|
Nenue@1
|
31 local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]]
|
Nenue@1
|
32 local titleSize, textSize = 15, 15
|
Nenue@1
|
33 local titleOutline, textOutline = "OUTLINE", "OUTLINE"
|
Nenue@1
|
34 local titleSpacing, textSpacing = 4, 3
|
Nenue@1
|
35 local textIndent = 5
|
Nenue@12
|
36 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed
|
Nenue@2
|
37 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
|
Nenue@1
|
38 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24
|
Nenue@2
|
39 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2
|
Nenue@1
|
40 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0}
|
Nenue@1
|
41
|
Nenue@2
|
42 --- These are mostly aesthetic choices so it lives here
|
Nenue@7
|
43
|
Nenue@3
|
44
|
Nenue@2
|
45 local Scroller_OnShow = function()
|
Nenue@2
|
46 Wrapper.watchMoneyReasons = 0;
|
Nenue@2
|
47 mod.UpdateWrapper()
|
Nenue@2
|
48 mod.SetEvents()
|
Nenue@10
|
49 for i, region in ipairs(Wrapper.headerComplex) do
|
Nenue@2
|
50 region:Show()
|
Nenue@2
|
51 end
|
Nenue@2
|
52 end
|
Nenue@2
|
53
|
Nenue@2
|
54 local Scroller_OnHide = function()
|
Nenue@2
|
55 local self = Wrapper
|
Nenue@2
|
56 Wrapper:UnregisterAllEvents()
|
Nenue@2
|
57 Wrapper:SetScript('OnEvent', nil)
|
Nenue@10
|
58 for i, region in ipairs(Wrapper.headerComplex) do
|
Nenue@2
|
59 region:Hide()
|
Nenue@2
|
60 end
|
Nenue@2
|
61 end
|
Nenue@2
|
62
|
Nenue@2
|
63 local Scroller_OnMouseWheel = function(self, delta)
|
Nenue@2
|
64 local r = Scroll:GetHeight() - Scroller:GetHeight()
|
Nenue@7
|
65 local s = B.Conf.ObjectiveScroll - delta * floor(r/5+.5)
|
Nenue@7
|
66 local from = self:GetVerticalScroll()
|
Nenue@2
|
67 if s >= r then
|
Nenue@2
|
68 s = r
|
Nenue@2
|
69 elseif s < 1 then
|
Nenue@2
|
70 s = 0
|
Nenue@2
|
71 end
|
Nenue@2
|
72 self:SetVerticalScroll(s)
|
Nenue@7
|
73 B.Conf.ObjectiveScroll = s
|
Nenue@7
|
74 print('|cFF00FF00OnMouseWheel', 'from = ', from, 'scroll =', s, ' range =', r, 'current =', self:GetVerticalScroll())
|
Nenue@2
|
75
|
Nenue@6
|
76 mod.UpdateActionButtons('SCROLLING')
|
Nenue@2
|
77 end
|
Nenue@2
|
78
|
Nenue@2
|
79 local WrapperCloseButton_OnClick = function(self)
|
Nenue@2
|
80 if Scroller:IsVisible() then
|
Nenue@2
|
81 Scroller:Hide()
|
Nenue@2
|
82 else
|
Nenue@2
|
83 Scroller:Show()
|
Nenue@2
|
84 end
|
Nenue@2
|
85 end
|
Nenue@2
|
86
|
Nenue@2
|
87 mod.InitializeTrackers = function()
|
Nenue@2
|
88
|
Nenue@2
|
89
|
Nenue@2
|
90 for i, name in ipairs(orderedNames) do
|
Nenue@2
|
91 if not mod.orderedHandlers[i] then
|
Nenue@2
|
92 if mod.Tracker(name, i) then
|
Nenue@2
|
93 local handler = mod[name]
|
Nenue@2
|
94
|
Nenue@2
|
95 local tracker = CreateFrame('Frame', 'Veneer'..name..'Tracker', Scroll, 'VeneerTrackerTemplate')
|
Nenue@10
|
96 tracker.title:SetText(name)
|
Nenue@10
|
97 mod.SetBlockStyle(tracker, 'Tracker', 'Normal')
|
Nenue@2
|
98
|
Nenue@2
|
99 handler.Tracker = tracker
|
Nenue@2
|
100 mod.orderedTrackers[i] = tracker
|
Nenue@2
|
101 mod.namedTrackers[name] = tracker
|
Nenue@2
|
102 mod.indexedTrackers[handler] = tracker
|
Nenue@2
|
103 print('created new tracker frames for new handler')
|
Nenue@10
|
104
|
Nenue@10
|
105
|
Nenue@2
|
106 end
|
Nenue@2
|
107 end
|
Nenue@2
|
108 end
|
Nenue@2
|
109
|
Nenue@2
|
110 Scroller:SetScrollChild(Scroll)
|
Nenue@2
|
111 Scroller:SetScript('OnMouseWheel', Scroller_OnMouseWheel)
|
Nenue@2
|
112 Scroller:SetScript('OnShow', Scroller_OnShow)
|
Nenue@2
|
113 Scroller:SetScript('OnHide', Scroller_OnHide)
|
Nenue@2
|
114 Wrapper.close:SetScript('OnClick', WrapperCloseButton_OnClick)
|
Nenue@2
|
115 Wrapper:SetPoint(unpack(wrapperPosition))
|
Nenue@2
|
116 Scroller_OnShow(Scroller)
|
Nenue@2
|
117
|
Nenue@2
|
118 mod.UpdateWrapperStyle()
|
Nenue@2
|
119 end
|
Nenue@2
|
120
|
Nenue@2
|
121 mod.InitializeXPTracker = function()
|
Nenue@2
|
122 local XPBar = Wrapper.XPBar
|
Nenue@2
|
123 if UnitLevel('player') == 100 then
|
Nenue@2
|
124 XPBar:Hide()
|
Nenue@2
|
125 return
|
Nenue@2
|
126 end
|
Nenue@2
|
127
|
Nenue@2
|
128 --- xp bar
|
Nenue@6
|
129 XPBar:SetWidth(wrapperWidth - Wrapper.close:GetWidth())
|
Nenue@12
|
130 XPBar.statusbg:SetAllPoints(XPBar)
|
Nenue@6
|
131 XPBar:RegisterEvent('DISABLE_XP_GAIN')
|
Nenue@6
|
132 XPBar:RegisterEvent('ENABLE_XP_GAIN')
|
Nenue@2
|
133 XPBar:SetScript('OnEvent', mod.UpdateXP)
|
Nenue@6
|
134
|
Nenue@6
|
135 if not IsXPUserDisabled() then
|
Nenue@6
|
136 mod.EnableXP(XPBar)
|
Nenue@6
|
137 else
|
Nenue@6
|
138 mod.DisableXP(XPBar)
|
Nenue@6
|
139 end
|
Nenue@6
|
140
|
Nenue@6
|
141 mod.UpdateXP(XPBar)
|
Nenue@2
|
142 end
|
Nenue@2
|
143
|
Nenue@6
|
144 mod.EnableXP = function(self)
|
Nenue@6
|
145 self:RegisterEvent('PLAYER_XP_UPDATE')
|
Nenue@6
|
146 self:RegisterEvent('PLAYER_LEVEL_UP')
|
Nenue@6
|
147 self:RegisterEvent('PLAYER_UPDATE_RESTING')
|
Nenue@12
|
148 self.statusbg:SetTexture(0,0,0,.25)
|
Nenue@6
|
149 self:Show()
|
Nenue@6
|
150 end
|
Nenue@2
|
151
|
Nenue@6
|
152 mod.DisableXP = function(self)
|
Nenue@6
|
153 self:UnregisterEvent('PLAYER_XP_UPDATE')
|
Nenue@6
|
154 self:UnregisterEvent('PLAYER_LEVEL_UP')
|
Nenue@6
|
155 self:UnregisterEvent('PLAYER_UPDATE_RESTING')
|
Nenue@12
|
156 self.statusbg:SetTexture(0.5,0.5,0.5,0.5)
|
Nenue@6
|
157 self:Hide()
|
Nenue@6
|
158 end
|
Nenue@2
|
159
|
Nenue@6
|
160 mod.UpdateXP = function(self, event)
|
Nenue@6
|
161 if event == 'DISABLE_XP_GAIN' then
|
Nenue@6
|
162 mod.DisableXP(self)
|
Nenue@6
|
163 elseif event == 'ENABLE_XP_GAIN' then
|
Nenue@6
|
164 mod.EnableXP(self)
|
Nenue@2
|
165 end
|
Nenue@2
|
166
|
Nenue@6
|
167 if not IsXPUserDisabled() then
|
Nenue@6
|
168
|
Nenue@6
|
169 local xp = UnitXP('player')
|
Nenue@6
|
170 local xpmax = UnitXPMax('player')
|
Nenue@6
|
171 local rest = GetXPExhaustion()
|
Nenue@12
|
172 self.foreground:SetWidth((xp/xpmax) * self:GetWidth())
|
Nenue@6
|
173 if rest then
|
Nenue@6
|
174 self.rested:ClearAllPoints()
|
Nenue@6
|
175 if xp == 0 then
|
Nenue@6
|
176 self.rested:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
|
Nenue@6
|
177 else
|
Nenue@6
|
178 self.rested:SetPoint('TOPLEFT', self.fg, 'TOPRIGHT', 0, 0)
|
Nenue@6
|
179 end
|
Nenue@6
|
180
|
Nenue@6
|
181 if (xp + rest) > xpmax then
|
Nenue@6
|
182 self.rested:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, 0)
|
Nenue@6
|
183 else
|
Nenue@6
|
184 self.rested:SetWidth((rest/xpmax) * self:GetWidth())
|
Nenue@6
|
185 end
|
Nenue@6
|
186 self.rested:SetPoint('BOTTOM', self, 'BOTTOM')
|
Nenue@6
|
187 self.rested:Show()
|
Nenue@2
|
188 else
|
Nenue@6
|
189 self.rested:Hide()
|
Nenue@2
|
190 end
|
Nenue@2
|
191
|
Nenue@6
|
192 if IsResting() then
|
Nenue@12
|
193 self.statusbg:SetTexture(.2,.8,.2,.5)
|
Nenue@2
|
194 else
|
Nenue@12
|
195 self.statusbg:SetTexture(0,0,0,.25)
|
Nenue@2
|
196 end
|
Nenue@6
|
197 self.xpText:SetText(xp .. '/'.. xpmax .. (rest and (' ('..tostring(rest)..')') or ''))
|
Nenue@2
|
198 end
|
Nenue@2
|
199 end
|
Nenue@2
|
200
|
Nenue@1
|
201
|
Nenue@2
|
202
|
Nenue@2
|
203 local segments = {'Left', 'Right', 'Tile'}
|
Nenue@2
|
204 mod.UpdateWrapperStyle = function()
|
Nenue@10
|
205 --[[for _, segment in ipairs(segments) do
|
Nenue@10
|
206 local texture, a1, a2, a3, a4, width = unpack(mod.defaults.Style.Wrapper.BackgroundComplex[segment])
|
Nenue@10
|
207 Wrapper['Background'..segment]:SetAtlas(texture)
|
Nenue@10
|
208 Wrapper['Background'..segment]:SetTexCoord(a1, a2, a3, a4)
|
Nenue@10
|
209 if width then
|
Nenue@10
|
210 Wrapper['Background'..segment]:SetWidth(width)
|
Nenue@2
|
211 end
|
Nenue@10
|
212 end]]
|
Nenue@1
|
213 end
|
Nenue@1
|
214
|
Nenue@1
|
215 --- Updates the selected block frame to display the given info batch
|
Nenue@1
|
216 -- If `previousBlock` is set, it will attempt to anchor to that
|
Nenue@1
|
217 -- @param blockNum the ordered block to be updated, not a watchIndex value
|
Nenue@1
|
218 -- @param info the reference returned by the GetXInfo functions
|
Nenue@1
|
219 -- REMEMBER: t.info and questData[questID] are the same table
|
Nenue@1
|
220 mod.UpdateTrackerBlock = function (handler, blockIndex, info)
|
Nenue@10
|
221 local print = B.print('ObjectiveBlockParse')
|
Nenue@2
|
222 print(' |cFF00FFFFUpdateTrackerBlock('..blockIndex..'|r')
|
Nenue@1
|
223 if not blockIndex or not info then
|
Nenue@1
|
224 return
|
Nenue@1
|
225 end
|
Nenue@1
|
226
|
Nenue@10
|
227 local mainStyle = 'Normal'
|
Nenue@10
|
228 local subStyle
|
Nenue@1
|
229 local tracker = handler.Tracker
|
Nenue@1
|
230
|
Nenue@1
|
231 local t = handler:GetBlock(blockIndex)
|
Nenue@1
|
232 if previousBlock then
|
Nenue@10
|
233 t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0)
|
Nenue@1
|
234 t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
|
Nenue@1
|
235 end
|
Nenue@2
|
236 --print(t:GetName(), t:GetSize())
|
Nenue@2
|
237 --print(t:GetPoint(1))
|
Nenue@1
|
238
|
Nenue@1
|
239 t.info = info
|
Nenue@1
|
240
|
Nenue@5
|
241 if info.questID then handler.QuestBlock[info.questID] = t end
|
Nenue@1
|
242 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = t end
|
Nenue@1
|
243 if info.watchIndex then handler.WatchBlock[info.watchIndex] = t end
|
Nenue@1
|
244
|
Nenue@1
|
245 info.blockIndex = blockIndex
|
Nenue@1
|
246 handler.BlockInfo[blockIndex] = info
|
Nenue@7
|
247
|
Nenue@1
|
248 t.Select = handler.Select
|
Nenue@1
|
249 t.Open = handler.Open
|
Nenue@1
|
250 t.Remove = handler.Remove
|
Nenue@1
|
251 t.Link = handler.Link
|
Nenue@1
|
252 t:SetScript('OnMouseUp', handler.OnMouseUp)
|
Nenue@1
|
253 t:SetScript('OnMouseDown', handler.OnMouseDown)
|
Nenue@1
|
254 t.title:SetText(info.title)
|
Nenue@1
|
255
|
Nenue@7
|
256 t.attachmentHeight = 0
|
Nenue@1
|
257 if info.isComplete then
|
Nenue@10
|
258 t.status:Show()
|
Nenue@10
|
259 t.status:SetText(info.completionText)
|
Nenue@1
|
260 elseif info.numObjectives >= 1 then
|
Nenue@7
|
261 t.attachmentHeight = textSpacing
|
Nenue@10
|
262 t.status:Show()
|
Nenue@10
|
263 print(' - objective lines:', info.numObjectives, 'can wrap:', t.status:CanWordWrap())
|
Nenue@3
|
264
|
Nenue@1
|
265 local text = ''
|
Nenue@3
|
266
|
Nenue@3
|
267 --- todo: implement objective displays
|
Nenue@3
|
268 -- in an accumulator loop, call upon handler for the appropriate display frame, each defining:
|
Nenue@10
|
269 -- * height - height of whatever display widget is involved in conveying the task
|
Nenue@10
|
270 -- * lines - number of non-wrapped text lines to account for line space; may be discarded depending on things
|
Nenue@10
|
271 -- * money - boolean that determines listening for money events or not
|
Nenue@10
|
272 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively
|
Nenue@10
|
273 text = mod.UpdateObjectives(t, info, text)
|
Nenue@3
|
274
|
Nenue@10
|
275 t.status:SetText(text)
|
Nenue@10
|
276 t.status:SetWordWrap(true)
|
Nenue@1
|
277
|
Nenue@1
|
278 elseif info.description then
|
Nenue@10
|
279 t.status:SetText(info.description)
|
Nenue@10
|
280 t.status:SetWordWrap(true)
|
Nenue@1
|
281 else
|
Nenue@10
|
282 t.status:SetText(nil)
|
Nenue@1
|
283 end
|
Nenue@10
|
284
|
Nenue@1
|
285 if info.isComplete then
|
Nenue@10
|
286 mainStyle = 'Complete'
|
Nenue@10
|
287 end
|
Nenue@10
|
288 if info.superTracked then
|
Nenue@10
|
289 subStyle = 'Super'
|
Nenue@1
|
290 end
|
Nenue@1
|
291
|
Nenue@5
|
292 if info.specialItem and not info.itemButton then
|
Nenue@5
|
293 print(' - |cFF00FFFFgenerating item button for info set')
|
Nenue@4
|
294 info.itemButton = mod.SetItemButton(t, info)
|
Nenue@4
|
295 else
|
Nenue@4
|
296 --info.itemButton = nil
|
Nenue@4
|
297 end
|
Nenue@4
|
298
|
Nenue@6
|
299 if Devian and Devian.InWorkspace() then
|
Nenue@6
|
300 t.debugText:Show()
|
Nenue@6
|
301 t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName()))
|
Nenue@6
|
302 end
|
Nenue@6
|
303
|
Nenue@3
|
304 --- metrics are calculated in SetStyle
|
Nenue@10
|
305 t:SetStyle('TrackerBlock', handler.name, mainStyle, subStyle)
|
Nenue@3
|
306 t:Show()
|
Nenue@1
|
307
|
Nenue@3
|
308 print(' |cFF00FFFF)|r -> ', t, t:GetHeight())
|
Nenue@1
|
309 return t
|
Nenue@1
|
310 end
|
Nenue@1
|
311
|
Nenue@4
|
312 mod.UpdateObjectives = function(block, info, text)
|
Nenue@10
|
313 local print = B.print('ObjectiveBlockParse')
|
Nenue@10
|
314
|
Nenue@7
|
315 local attachmentHeight = block.attachmentHeight
|
Nenue@7
|
316 if info.description then
|
Nenue@7
|
317 print(' -- has description text:', select('#', info.description), info.description)
|
Nenue@7
|
318 text = info.description
|
Nenue@7
|
319 end
|
Nenue@10
|
320 local completionScore, completionMax = 0, 0
|
Nenue@4
|
321 for o, obj in ipairs(info.objectives) do
|
Nenue@4
|
322 --- achievement criteria
|
Nenue@4
|
323 if obj.flags then
|
Nenue@4
|
324
|
Nenue@4
|
325
|
Nenue@4
|
326 if bit.band(obj.flags, 0x00000001) > 0 then
|
Nenue@4
|
327 obj.type = 'ProgressBar'
|
Nenue@4
|
328 elseif bit.band(obj.flags, 0x00000002) then
|
Nenue@4
|
329 obj.type = 'Hidden'
|
Nenue@4
|
330 obj.widget = nil
|
Nenue@4
|
331 else
|
Nenue@4
|
332 obj.type = 'Text'
|
Nenue@4
|
333 obj.widget = nil
|
Nenue@4
|
334 text = text .. ((text == '') and "" or "\n") .. obj.text
|
Nenue@4
|
335 end
|
Nenue@4
|
336
|
Nenue@7
|
337 print('obj.type =', obj.type)
|
Nenue@7
|
338 print(' ** qtyStr:', obj.quantityString, 'qty:', obj.quantity, 'assetID:', obj.assetID)
|
Nenue@7
|
339 obj.widget = mod.SetWidget(obj, info)
|
Nenue@10
|
340 if obj.finished then
|
Nenue@10
|
341 obj.progress = 2
|
Nenue@10
|
342 elseif obj.quantity > 0 then
|
Nenue@10
|
343 obj.progress = 1
|
Nenue@10
|
344 else
|
Nenue@10
|
345 obj.progress = 0
|
Nenue@10
|
346 end
|
Nenue@10
|
347
|
Nenue@10
|
348
|
Nenue@4
|
349 --- none of the above (most quests)
|
Nenue@4
|
350 else
|
Nenue@4
|
351 local line = obj.text
|
Nenue@4
|
352 local color = '00FFFF'
|
Nenue@4
|
353 if obj.finished then
|
Nenue@10
|
354 obj.progress = 2
|
Nenue@4
|
355 color = 'FFFFFF'
|
Nenue@4
|
356 elseif obj.type == 'monster' then
|
Nenue@4
|
357 color = 'FFFF00'
|
Nenue@4
|
358 elseif obj.type == 'item' then
|
Nenue@4
|
359 color = '44DDFF'
|
Nenue@4
|
360 elseif obj.type == 'object' then
|
Nenue@4
|
361 color = 'FF44DD'
|
Nenue@4
|
362 end
|
Nenue@4
|
363 text = text .. ((text == '') and "" or "\n") .. '|cFF'..color.. line .. '|r'
|
Nenue@4
|
364 end
|
Nenue@4
|
365
|
Nenue@4
|
366 if obj.widget then
|
Nenue@7
|
367
|
Nenue@7
|
368 obj.widget:Show()
|
Nenue@7
|
369 obj.widget:SetPoint('TOPLEFT', block.objectives, 'BOTTOMLEFT', 0, -attachmentHeight)
|
Nenue@7
|
370 print('have a widget, height is', obj.widget.height)
|
Nenue@4
|
371 attachmentHeight = attachmentHeight + obj.widget.height
|
Nenue@10
|
372 completionScore = completionScore + obj.progress
|
Nenue@10
|
373 completionMax = completionMax + 2
|
Nenue@4
|
374 end
|
Nenue@4
|
375
|
Nenue@4
|
376 end
|
Nenue@10
|
377
|
Nenue@10
|
378 block.completionScore = completionScore / completionMax
|
Nenue@10
|
379 block.attachmentHeight = attachmentHeight
|
Nenue@10
|
380
|
Nenue@10
|
381 return text
|
Nenue@4
|
382 end
|
Nenue@4
|
383
|
Nenue@1
|
384 mod.UpdateTracker = function(handler)
|
Nenue@1
|
385 print('|cFF00FF88UpdateTracker(|r|cFFFF4400' .. type(handler) .. '|r :: |cFF88FFFF' .. tostring(handler) .. '|r')
|
Nenue@1
|
386 local tracker = handler.Tracker
|
Nenue@1
|
387 local blockIndex = 0
|
Nenue@1
|
388 local trackerHeight = headerHeight
|
Nenue@1
|
389 local w = 300
|
Nenue@1
|
390
|
Nenue@10
|
391 previousBlock = tracker.title
|
Nenue@1
|
392 local numWatched = handler.GetNumWatched()
|
Nenue@1
|
393 local numBlocks = handler.numBlocks
|
Nenue@9
|
394 local actualBlocks = 0
|
Nenue@1
|
395 for watchIndex = 1, 25 do
|
Nenue@1
|
396 blockIndex = blockIndex + 1
|
Nenue@1
|
397 if watchIndex <= numWatched then
|
Nenue@1
|
398 local info = handler:GetInfo(watchIndex)
|
Nenue@1
|
399 if info then
|
Nenue@1
|
400 local currentBlock = mod.UpdateTrackerBlock(handler, blockIndex, info)
|
Nenue@1
|
401 previousBlock = currentBlock
|
Nenue@10
|
402 print('|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height)
|
Nenue@1
|
403 trackerHeight = trackerHeight + currentBlock.height
|
Nenue@1
|
404 numBlocks = max(numBlocks, watchIndex)
|
Nenue@1
|
405 actualBlocks = actualBlocks + 1
|
Nenue@1
|
406 else
|
Nenue@1
|
407 print('|cFFFF0000Failed to draw info for index #'..watchIndex)
|
Nenue@1
|
408 end
|
Nenue@1
|
409
|
Nenue@1
|
410 elseif watchIndex <= numBlocks then
|
Nenue@1
|
411 local used = handler.usedBlocks
|
Nenue@1
|
412 local free = handler.freeBlocks
|
Nenue@1
|
413 print('clean up dead quest block')
|
Nenue@1
|
414 if used[blockIndex] then
|
Nenue@1
|
415 used[blockIndex]:Hide()
|
Nenue@1
|
416 used[blockIndex]:ClearAllPoints()
|
Nenue@1
|
417 free[#free+1]= used[blockIndex]
|
Nenue@1
|
418 used[blockIndex] = nil
|
Nenue@1
|
419 end
|
Nenue@1
|
420 else
|
Nenue@1
|
421 print('Stopping scan at', blockIndex)
|
Nenue@1
|
422 break -- done with quest stuff
|
Nenue@1
|
423 end
|
Nenue@1
|
424 end
|
Nenue@1
|
425 handler.numWatched = numWatched
|
Nenue@1
|
426 handler.numBlocks = numBlocks
|
Nenue@1
|
427 handler.actualBlocks = actualBlocks
|
Nenue@1
|
428 handler:Report()
|
Nenue@1
|
429 previousBlock = nil
|
Nenue@1
|
430 if numBlocks > 0 then
|
Nenue@1
|
431 tracker.height = trackerHeight
|
Nenue@1
|
432 else
|
Nenue@1
|
433 tracker.height = 0
|
Nenue@1
|
434 end
|
Nenue@1
|
435
|
Nenue@1
|
436 print('|cFF00FF88)|r ->', numBlocks, 'blocks; height', tracker.height, 'last block: ')
|
Nenue@1
|
437 end
|
Nenue@1
|
438
|
Nenue@1
|
439 mod.Quest.numButtons = 0
|
Nenue@1
|
440 local usedButtons = mod.Quest.itemButtons
|
Nenue@1
|
441 local freeButtons = mod.Quest.freeButtons
|
Nenue@1
|
442 mod.UpdateWrapper = function()
|
Nenue@1
|
443 wrapperWidth = wrapperMaxWidth
|
Nenue@1
|
444 scrollWidth = wrapperWidth
|
Nenue@1
|
445 local wrapperBlocks = 0
|
Nenue@1
|
446 -- Update scroll child vertical size
|
Nenue@1
|
447 scrollHeight = 0
|
Nenue@1
|
448 for i, handler in ipairs(orderedHandlers) do
|
Nenue@1
|
449 mod.UpdateTracker(handler)
|
Nenue@1
|
450 if handler.actualBlocks >= 1 then
|
Nenue@1
|
451 local tracker = handler.Tracker
|
Nenue@1
|
452 print('setting', handler.Tracker, 'to anchor to offset', -scrollHeight)
|
Nenue@10
|
453 tracker:SetParent(Scroll)
|
Nenue@1
|
454 tracker:SetPoint('TOPLEFT', Scroll, 'TOPLEFT', 0, - scrollHeight)
|
Nenue@1
|
455 tracker:SetSize(wrapperWidth, tracker.height)
|
Nenue@1
|
456 print('adding ', tracker.height)
|
Nenue@1
|
457 scrollHeight = scrollHeight + tracker.height
|
Nenue@1
|
458 end
|
Nenue@1
|
459 wrapperBlocks = wrapperBlocks + handler.actualBlocks
|
Nenue@1
|
460 end
|
Nenue@1
|
461 print('final scrollHeight:', scrollHeight)
|
Nenue@1
|
462
|
Nenue@1
|
463
|
Nenue@1
|
464
|
Nenue@1
|
465 -- Update frame dimensions
|
Nenue@1
|
466 if scrollHeight > wrapperMaxHeight then
|
Nenue@1
|
467 print(' is larger than', wrapperMaxHeight)
|
Nenue@1
|
468 wrapperHeight = wrapperMaxHeight
|
Nenue@1
|
469 else
|
Nenue@1
|
470 wrapperHeight = scrollHeight
|
Nenue@9
|
471 B.Conf.ObjectiveScroll = 0
|
Nenue@1
|
472 end
|
Nenue@1
|
473 scrollWidth = floor(scrollWidth+.5)
|
Nenue@1
|
474 scrollHeight = floor(scrollHeight+.5)
|
Nenue@1
|
475 wrapperWidth = floor(wrapperWidth+.5)
|
Nenue@1
|
476 wrapperHeight = floor(wrapperHeight+.5)
|
Nenue@1
|
477 headerHeight = floor(headerHeight+.5)
|
Nenue@1
|
478
|
Nenue@1
|
479 if wrapperBlocks >= 1 then
|
Nenue@10
|
480 for i, region in ipairs(Wrapper.headerComplex) do
|
Nenue@2
|
481 region:Show()
|
Nenue@2
|
482 end
|
Nenue@1
|
483 else
|
Nenue@10
|
484 for i, region in ipairs(Wrapper.headerComplex) do
|
Nenue@2
|
485 region:Hide()
|
Nenue@2
|
486 end
|
Nenue@1
|
487 return
|
Nenue@1
|
488 end
|
Nenue@1
|
489 --wrapperHeight = scrollHeight
|
Nenue@1
|
490
|
Nenue@1
|
491 print('|cFFFFFF00params:|r scroller:', scrollWidth, 'x', scrollHeight)
|
Nenue@1
|
492 print('|cFFFFFF00params:|r scroll:', scrollWidth, 'x', scrollHeight)
|
Nenue@1
|
493 print('|cFFFFFF00params:|r wrapper:', wrapperWidth, 'x', wrapperHeight)
|
Nenue@1
|
494 print('|cFFFFFF00params:|r header:', headerHeight)
|
Nenue@1
|
495
|
Nenue@10
|
496 mod.SetBlockStyle(Scroller, 'Scroller', 'Normal')
|
Nenue@10
|
497 mod.SetBlockStyle(Scroller, 'Scroll', 'Normal')
|
Nenue@10
|
498 mod.SetBlockStyle(Wrapper, 'Wrapper', 'Normal')
|
Nenue@10
|
499
|
Nenue@1
|
500 Scroller:SetSize(wrapperWidth, wrapperHeight)
|
Nenue@1
|
501 Scroller:SetPoint('TOPLEFT', Wrapper, 'TOPLEFT', 0, -headerHeight)
|
Nenue@1
|
502 Scroller:SetPoint('BOTTOMRIGHT', Wrapper, 'BOTTOMRIGHT')
|
Nenue@1
|
503
|
Nenue@7
|
504
|
Nenue@1
|
505 Scroll:SetSize(scrollWidth, scrollHeight)
|
Nenue@7
|
506 Scroll:SetPoint('TOPLEFT', Scroller, 'TOPLEFT', 0, B.Conf.ObjectiveScroll or 0)
|
Nenue@1
|
507 Scroll:SetPoint('RIGHT', Scroller, 'RIGHT')
|
Nenue@1
|
508
|
Nenue@1
|
509 --Scroller:UpdateScrollChildRect()
|
Nenue@1
|
510 Wrapper:SetSize(wrapperWidth, wrapperHeight + headerHeight)
|
Nenue@1
|
511
|
Nenue@1
|
512 -- update action buttons
|
Nenue@6
|
513 print('|cFF00FF00'..Scroll:GetName()..'|r:', Scroll:GetWidth(), Scroll:GetHeight(),
|
Nenue@6
|
514 '|cFF00FF00'..Scroller:GetName()..'|r:', Scroller:GetWidth(), Scroller:GetHeight(),
|
Nenue@6
|
515 '|cFF00FF00'..Wrapper:GetName()..'|r:', Wrapper:GetWidth(), Wrapper:GetHeight(),
|
Nenue@6
|
516 '|cFF0088FFvScrollRange|r:', floor(Scroller:GetVerticalScrollRange()+.5)
|
Nenue@6
|
517 )
|
Nenue@6
|
518 mod.UpdateActionButtons('FULL_UPDATE')
|
Nenue@1
|
519
|
Nenue@1
|
520 end
|
Nenue@1
|
521
|
Nenue@1
|
522 --- Queue any active item buttons for update for that frame
|
Nenue@6
|
523 mod.UpdateActionButtons = function(updateReason)
|
Nenue@6
|
524 Scroller.snap_upper = 0
|
Nenue@6
|
525 Scroller.snap_lower = 0
|
Nenue@6
|
526 local print = B.print('ItemButton')
|
Nenue@6
|
527 if updateReason then
|
Nenue@6
|
528 print = B.print('IB_'..updateReason)
|
Nenue@6
|
529 end
|
Nenue@6
|
530
|
Nenue@1
|
531 local previousItem
|
Nenue@2
|
532 for questID, itemButton in pairs(usedButtons) do
|
Nenue@6
|
533 local info= mod.Quest.Info[questID]
|
Nenue@6
|
534
|
Nenue@5
|
535 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName())
|
Nenue@5
|
536 local block = mod.Quest.QuestBlock[questID]
|
Nenue@1
|
537 if block then
|
Nenue@5
|
538 -- Dispatch the probe
|
Nenue@6
|
539 if IsQuestWatched(info.questLogIndex) then
|
Nenue@6
|
540 itemButton.previousItem = previousItem
|
Nenue@5
|
541 print(' |cFFFFFF00probing', block:GetName())
|
Nenue@1
|
542 block:SetScript('OnUpdate', function()
|
Nenue@5
|
543 if block:GetBottom() and not InCombatLockdown() then
|
Nenue@5
|
544 print(' '..block:GetName()..' |cFF00FF00probe hit!')
|
Nenue@6
|
545 mod.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope
|
Nenue@5
|
546 block:SetScript('OnUpdate', nil)
|
Nenue@5
|
547 end
|
Nenue@5
|
548 end)
|
Nenue@6
|
549 previousItem = itemButton
|
Nenue@1
|
550 else
|
Nenue@5
|
551 print('hidden block or unwatched quest')
|
Nenue@6
|
552 itemButton.previousItem = nil
|
Nenue@5
|
553 itemButton:Hide()
|
Nenue@1
|
554 end
|
Nenue@8
|
555 elseif itemButton:IsVisible() then
|
Nenue@8
|
556 print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName())
|
Nenue@6
|
557 itemButton.previousItem = nil
|
Nenue@6
|
558 itemButton:Hide()
|
Nenue@8
|
559 else
|
Nenue@8
|
560 print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName())
|
Nenue@1
|
561 end
|
Nenue@1
|
562 end
|
Nenue@1
|
563 end
|
Nenue@1
|
564
|
Nenue@6
|
565 mod.UpdateBlockAction = function (block, itemButton)
|
Nenue@5
|
566 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()')
|
Nenue@5
|
567 if itemButton.questID ~= block.info.questID then
|
Nenue@5
|
568 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
|
Nenue@6
|
569 -- something happened between this and last frame, go back and set new probes
|
Nenue@5
|
570 return mod.UpdateActionButtons()
|
Nenue@2
|
571 end
|
Nenue@2
|
572
|
Nenue@6
|
573 local previousItem = itemButton.previousItem
|
Nenue@6
|
574 local upper_bound = Scroller:GetTop() + Scroller.snap_upper
|
Nenue@6
|
575 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize
|
Nenue@6
|
576 local point, anchor, relative
|
Nenue@6
|
577
|
Nenue@6
|
578 if block:GetBottom() < lower_bound then
|
Nenue@6
|
579 print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5))
|
Nenue@1
|
580 if previousItem then
|
Nenue@6
|
581 print('adjusting', previousItem:GetName())
|
Nenue@1
|
582 previousItem:ClearAllPoints()
|
Nenue@6
|
583 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing)
|
Nenue@1
|
584 end
|
Nenue@1
|
585 itemButton:ClearAllPoints()
|
Nenue@6
|
586 itemButton.x = Wrapper:GetLeft() -4
|
Nenue@6
|
587 itemButton.y = Wrapper:GetBottom()
|
Nenue@6
|
588 point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT'
|
Nenue@6
|
589 Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing
|
Nenue@6
|
590
|
Nenue@6
|
591 elseif block:GetTop() > upper_bound then
|
Nenue@6
|
592 print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5))
|
Nenue@6
|
593 itemButton:ClearAllPoints()
|
Nenue@6
|
594 if previousItem then
|
Nenue@6
|
595 print('latch onto another piece')
|
Nenue@6
|
596 point, anchor, relative ='TOP', previousItem, 'BOTTOM'
|
Nenue@6
|
597 itemButton.x = 0
|
Nenue@6
|
598 itemButton.y = -itemButtonSpacing
|
Nenue@6
|
599 else
|
Nenue@6
|
600 print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop())
|
Nenue@6
|
601 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
|
Nenue@6
|
602 itemButton.x = Scroller:GetLeft() -4
|
Nenue@6
|
603 itemButton.y = Scroller:GetTop()
|
Nenue@6
|
604 end
|
Nenue@1
|
605 itemButton:Show()
|
Nenue@6
|
606 Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing)
|
Nenue@1
|
607 else
|
Nenue@6
|
608 print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5))
|
Nenue@1
|
609 itemButton:ClearAllPoints()
|
Nenue@6
|
610 itemButton.x = block:GetLeft() - itemButtonSpacing
|
Nenue@6
|
611 itemButton.y = block:GetTop()
|
Nenue@6
|
612 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
|
Nenue@1
|
613 end
|
Nenue@6
|
614
|
Nenue@6
|
615 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y)
|
Nenue@6
|
616 itemButton:Show()
|
Nenue@1
|
617 end
|
Nenue@1
|
618
|
Nenue@1
|
619 mod.UpdateItemButtonCooldown = function(button)
|
Nenue@1
|
620
|
Nenue@1
|
621 end
|