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@2
|
7 local ipairs, max, min, unpack, floor, pairs, tostring, type = ipairs, max, min, unpack, floor, pairs, tostring, type
|
Nenue@2
|
8 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion
|
Nenue@2
|
9 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent
|
Nenue@1
|
10 local CreateFrame = CreateFrame
|
Nenue@1
|
11 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
|
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@1
|
29 --- todo: map these into config table when its sorted out
|
Nenue@1
|
30 local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]]
|
Nenue@1
|
31 local titleSize, textSize = 15, 15
|
Nenue@1
|
32 local titleOutline, textOutline = "OUTLINE", "OUTLINE"
|
Nenue@1
|
33 local titleSpacing, textSpacing = 4, 3
|
Nenue@1
|
34 local textIndent = 5
|
Nenue@1
|
35 local wrapperMaxWidth, wrapperMaxHeight = 280, 490 -- these are the hard bounds, actual *Height variables are changed
|
Nenue@2
|
36 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
|
Nenue@1
|
37 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24
|
Nenue@2
|
38 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2
|
Nenue@1
|
39 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0}
|
Nenue@1
|
40
|
Nenue@2
|
41 --- These are mostly aesthetic choices so it lives here
|
Nenue@1
|
42 mod.defaults = {
|
Nenue@1
|
43 ObjectiveTrackerAnchor = {'BOTTOM', 'RIGHT'},
|
Nenue@1
|
44 ObjectiveTrackerParent = 'DebuffButton',
|
Nenue@1
|
45 ObjectiveTrackerSize = {250, 600},
|
Nenue@1
|
46 ObjectiveWrapperParent = '',
|
Nenue@2
|
47 WrapperStyle = {
|
Nenue@2
|
48 Header = {
|
Nenue@2
|
49 Background = {Left = [[Objective-Header]], Right = [[Objective-Header]], Tile = [[Objective-Header]]},
|
Nenue@2
|
50 BackgroundCrop = {Left = {0, 0.4, 0,1}, Right={0.6,1,0,1}, Tile = {0.4,.6,0,1,}},
|
Nenue@2
|
51 BackgroundScale = {Left = 100, Right = 100},
|
Nenue@2
|
52 Font = {wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline}
|
Nenue@2
|
53 }
|
Nenue@2
|
54 },
|
Nenue@2
|
55 ObjectiveHeaderStyle = {
|
Nenue@2
|
56 Normal = {
|
Nenue@3
|
57 Gradient = {MinColor = {0,0,0,0.5}, MaxColor = {0,0,0,.25}},
|
Nenue@2
|
58 Font = {headerFont, headerSize, headerOutline}, Spacing = headerSpacing,
|
Nenue@2
|
59 }
|
Nenue@2
|
60 },
|
Nenue@1
|
61 ObjectiveTrackerStyle = {
|
Nenue@1
|
62 Normal = {
|
Nenue@1
|
63 Title = {
|
Nenue@1
|
64 Gradient = { MinColor = {0.2, .4, 1, 0.45}, MaxColor = {.7, 0, 0.9, 0}},
|
Nenue@1
|
65 Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing,
|
Nenue@1
|
66 },
|
Nenue@1
|
67 Text = {
|
Nenue@1
|
68 Gradient = { MinColor = {0.2, .4, 1, 0.25}, MaxColor = {.7, 0, 0.9, 0}},
|
Nenue@1
|
69 Font = {textFont, textSize, textOutline}, Spacing = textSpacing,
|
Nenue@1
|
70 },
|
Nenue@1
|
71 },
|
Nenue@1
|
72 Super = {
|
Nenue@1
|
73 Title = {
|
Nenue@1
|
74 Gradient = { MinColor = {0, .7, .6, .8}, MaxColor = {0, .7, .6, 0.2}},
|
Nenue@1
|
75 Font = {titleFont, titleSize, titleOutline},
|
Nenue@1
|
76 Spacing = titleSpacing, BackgroundFullWidth = true
|
Nenue@1
|
77 },
|
Nenue@1
|
78 Text = {
|
Nenue@1
|
79 Gradient = { MinColor = {0, .7, .6, 0.5}, MaxColor = {0, .7, .6, 0.1} },
|
Nenue@1
|
80 Font = {textFont, textSize, textOutline}, Spacing = textSpacing,
|
Nenue@1
|
81 },
|
Nenue@1
|
82 },
|
Nenue@1
|
83 Active = {
|
Nenue@1
|
84 Title = {
|
Nenue@1
|
85 Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, 1}, },
|
Nenue@1
|
86 Font = {titleFont, titleSize, titleOutline},
|
Nenue@1
|
87 Spacing = titleSpacing,
|
Nenue@1
|
88 BackgroundFullWidth = true
|
Nenue@1
|
89 },
|
Nenue@1
|
90 Text = {
|
Nenue@1
|
91 Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, 1}, },
|
Nenue@1
|
92 Font = {textFont, textSize, textOutline},
|
Nenue@1
|
93 Spacing = textSpacing,
|
Nenue@1
|
94 BackgroundFullWidth = true
|
Nenue@1
|
95 }
|
Nenue@1
|
96 },
|
Nenue@1
|
97 Complete = {
|
Nenue@1
|
98 Title = {
|
Nenue@1
|
99 Gradient = { MinColor = {0, 1, 0, 0.34}, MaxColor = {0, 1, 0, .17}, },
|
Nenue@1
|
100 Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing,
|
Nenue@1
|
101 BackgroundFullWidth = true
|
Nenue@1
|
102 },
|
Nenue@1
|
103 Text = {
|
Nenue@1
|
104 Gradient = { MinColor = {0, 1, 0, .25}, MaxColor = {0, 1, 0, 0.12}, },
|
Nenue@1
|
105 Font = {textFont, textSize, textOutline}, Spacing = textSpacing,
|
Nenue@1
|
106 BackgroundFullWidth = true
|
Nenue@1
|
107 }
|
Nenue@1
|
108 },
|
Nenue@1
|
109 }
|
Nenue@1
|
110 }
|
Nenue@1
|
111
|
Nenue@3
|
112 local FontBank = {
|
Nenue@3
|
113 ['Normal'] = VeneerCriteriaFontNormal,
|
Nenue@3
|
114 ['Progress'] = VeneerCriteriaFontProgress,
|
Nenue@3
|
115 ['Complete'] = VeneerCriteriaFontComplete,
|
Nenue@3
|
116 ['Failed'] = VeneerCriteriaFontFailed,
|
Nenue@3
|
117 }
|
Nenue@3
|
118
|
Nenue@2
|
119 local Scroller_OnShow = function()
|
Nenue@2
|
120 Wrapper.watchMoneyReasons = 0;
|
Nenue@2
|
121 mod.UpdateWrapper()
|
Nenue@2
|
122 mod.SetEvents()
|
Nenue@2
|
123 for i, region in ipairs(Wrapper.header) do
|
Nenue@2
|
124 region:Show()
|
Nenue@2
|
125 end
|
Nenue@2
|
126 end
|
Nenue@2
|
127
|
Nenue@2
|
128 local Scroller_OnHide = function()
|
Nenue@2
|
129 local self = Wrapper
|
Nenue@2
|
130 Wrapper:UnregisterAllEvents()
|
Nenue@2
|
131 Wrapper:SetScript('OnEvent', nil)
|
Nenue@2
|
132 for i, region in ipairs(Wrapper.header) do
|
Nenue@2
|
133 region:Hide()
|
Nenue@2
|
134 end
|
Nenue@2
|
135 end
|
Nenue@2
|
136
|
Nenue@2
|
137 local Scroller_OnMouseWheel = function(self, delta)
|
Nenue@2
|
138 local r = Scroll:GetHeight() - Scroller:GetHeight()
|
Nenue@2
|
139 local s = self:GetVerticalScroll() - delta * floor(r/5+.5)
|
Nenue@2
|
140 if r == 0 then return end
|
Nenue@2
|
141 if s >= r then
|
Nenue@2
|
142 s = r
|
Nenue@2
|
143 elseif s < 1 then
|
Nenue@2
|
144 s = 0
|
Nenue@2
|
145 end
|
Nenue@2
|
146 self:SetVerticalScroll(s)
|
Nenue@2
|
147 print(s, r, self:GetVerticalScroll())
|
Nenue@2
|
148
|
Nenue@2
|
149 mod.UpdateActionButtons()
|
Nenue@2
|
150 end
|
Nenue@2
|
151
|
Nenue@2
|
152 local WrapperCloseButton_OnClick = function(self)
|
Nenue@2
|
153 if Scroller:IsVisible() then
|
Nenue@2
|
154 Scroller:Hide()
|
Nenue@2
|
155 else
|
Nenue@2
|
156 Scroller:Show()
|
Nenue@2
|
157 end
|
Nenue@2
|
158 end
|
Nenue@2
|
159
|
Nenue@2
|
160 mod.InitializeTrackers = function()
|
Nenue@2
|
161
|
Nenue@2
|
162 local c = mod.defaults.ObjectiveHeaderStyle.Normal
|
Nenue@2
|
163 local g1, g2, g3, g4 = unpack(c.Gradient.MinColor)
|
Nenue@2
|
164 local h1, h2, h3, h4 = unpack(c.Gradient.MaxColor)
|
Nenue@2
|
165
|
Nenue@2
|
166 for i, name in ipairs(orderedNames) do
|
Nenue@2
|
167 if not mod.orderedHandlers[i] then
|
Nenue@2
|
168 if mod.Tracker(name, i) then
|
Nenue@2
|
169 local handler = mod[name]
|
Nenue@2
|
170
|
Nenue@2
|
171 local tracker = CreateFrame('Frame', 'Veneer'..name..'Tracker', Scroll, 'VeneerTrackerTemplate')
|
Nenue@2
|
172 tracker.header:SetText(handler.name)
|
Nenue@2
|
173 tracker.header:SetHeight(headerHeight)
|
Nenue@2
|
174 tracker.header:SetFont(unpack(c.Font))
|
Nenue@2
|
175 tracker.header:SetTextColor(unpack(headerColor))
|
Nenue@2
|
176
|
Nenue@2
|
177 tracker.headerbg:SetGradientAlpha('HORIZONTAL', g1, g2 ,g3, g4, h1, h2, h3, h4)
|
Nenue@2
|
178 tracker.headerbg:SetHeight(headerHeight)
|
Nenue@2
|
179
|
Nenue@2
|
180 handler.Tracker = tracker
|
Nenue@2
|
181 mod.orderedTrackers[i] = tracker
|
Nenue@2
|
182 mod.namedTrackers[name] = tracker
|
Nenue@2
|
183 mod.indexedTrackers[handler] = tracker
|
Nenue@2
|
184 print('created new tracker frames for new handler')
|
Nenue@2
|
185 end
|
Nenue@2
|
186 end
|
Nenue@2
|
187 end
|
Nenue@2
|
188
|
Nenue@2
|
189 Scroller:SetScrollChild(Scroll)
|
Nenue@2
|
190 Scroller:SetScript('OnMouseWheel', Scroller_OnMouseWheel)
|
Nenue@2
|
191 Scroller:SetScript('OnShow', Scroller_OnShow)
|
Nenue@2
|
192 Scroller:SetScript('OnHide', Scroller_OnHide)
|
Nenue@2
|
193 Wrapper.close:SetScript('OnClick', WrapperCloseButton_OnClick)
|
Nenue@2
|
194 Wrapper:SetPoint(unpack(wrapperPosition))
|
Nenue@2
|
195 Scroller_OnShow(Scroller)
|
Nenue@2
|
196
|
Nenue@2
|
197 mod.UpdateWrapperStyle()
|
Nenue@2
|
198 end
|
Nenue@2
|
199
|
Nenue@2
|
200 mod.InitializeXPTracker = function()
|
Nenue@2
|
201 local XPBar = Wrapper.XPBar
|
Nenue@2
|
202 if UnitLevel('player') == 100 then
|
Nenue@2
|
203 XPBar:Hide()
|
Nenue@2
|
204 return
|
Nenue@2
|
205 end
|
Nenue@2
|
206
|
Nenue@2
|
207 --- xp bar
|
Nenue@2
|
208 XPBar:Show()
|
Nenue@2
|
209 XPBar.rested:SetTexture(2,.6,1,1)
|
Nenue@2
|
210 XPBar.fg:SetTexture(.3,.1,.95,1)
|
Nenue@2
|
211 XPBar.bg:SetTexture(0,0,0,.25)
|
Nenue@2
|
212 XPBar:RegisterEvent('PLAYER_XP_UPDATE')
|
Nenue@2
|
213 XPBar:RegisterEvent('PLAYER_LEVEL_UP')
|
Nenue@2
|
214 XPBar:RegisterEvent('PLAYER_UPDATE_RESTING')
|
Nenue@2
|
215 XPBar:SetScript('OnEvent', mod.UpdateXP)
|
Nenue@2
|
216 mod.UpdateXP(Wrapper.xpBar)
|
Nenue@2
|
217 end
|
Nenue@2
|
218
|
Nenue@2
|
219 mod.UpdateXP = function()
|
Nenue@2
|
220 local XPBar = Wrapper.XPBar
|
Nenue@2
|
221 local xp = UnitXP('player')
|
Nenue@2
|
222 local xpmax = UnitXPMax('player')
|
Nenue@2
|
223 local rest = GetXPExhaustion()
|
Nenue@2
|
224
|
Nenue@2
|
225 XPBar.bg:SetAllPoints(XPBar)
|
Nenue@2
|
226 XPBar.fg:SetWidth((xp/xpmax) * XPBar:GetWidth())
|
Nenue@2
|
227
|
Nenue@2
|
228 if IsResting() then
|
Nenue@2
|
229 XPBar.bg:SetTexture(.2,.8,.2,.5)
|
Nenue@2
|
230 else
|
Nenue@2
|
231 XPBar.bg:SetTexture(0,0,0,.25)
|
Nenue@2
|
232 end
|
Nenue@2
|
233
|
Nenue@2
|
234 if rest then
|
Nenue@2
|
235 XPBar.rested:ClearAllPoints()
|
Nenue@2
|
236 if xp == 0 then
|
Nenue@3
|
237 XPBar.rested:SetPoint('TOPLEFT', XPBar, 'TOPLEFT', 0, 0)
|
Nenue@2
|
238 else
|
Nenue@3
|
239 XPBar.rested:SetPoint('TOPLEFT', XPBar.fg, 'TOPRIGHT', 0, 0)
|
Nenue@2
|
240 end
|
Nenue@2
|
241
|
Nenue@2
|
242 if (xp + rest) > xpmax then
|
Nenue@3
|
243 XPBar.rested:SetPoint('BOTTOMRIGHT', XPBar, 'BOTTOMRIGHT', 0, 0)
|
Nenue@2
|
244 else
|
Nenue@3
|
245 XPBar.rested:SetWidth((rest/xpmax) * XPBar:GetWidth())
|
Nenue@2
|
246 end
|
Nenue@3
|
247 XPBar.rested:SetPoint('BOTTOM', XPBar, 'BOTTOM')
|
Nenue@2
|
248 XPBar.rested:Show()
|
Nenue@2
|
249 else
|
Nenue@2
|
250 XPBar.rested:Hide()
|
Nenue@2
|
251 end
|
Nenue@2
|
252
|
Nenue@2
|
253 XPBar.xpText:SetText(xp .. '/'.. xpmax .. (rest and (' ('..tostring(rest)..')') or ''))
|
Nenue@2
|
254 end
|
Nenue@2
|
255
|
Nenue@2
|
256 mod.UpdateReputation = function(self)
|
Nenue@2
|
257 end
|
Nenue@1
|
258
|
Nenue@1
|
259 --- Argument containers
|
Nenue@1
|
260 local a1, a2, a3, a4, b1, b2, b3, b4, f1, f2, f3, w1, w2
|
Nenue@1
|
261 mod.SetBlockStyle = function(block, name)
|
Nenue@1
|
262 -- var names intended to reflect argument order
|
Nenue@2
|
263 --@debug@
|
Nenue@1
|
264 local c = mod.defaults.ObjectiveTrackerStyle[name]
|
Nenue@2
|
265 --@end-debug@
|
Nenue@2
|
266 --[===[@non-debug
|
Nenue@2
|
267 local c = mod.Conf
|
Nenue@2
|
268 --@end-non-debug]===]
|
Nenue@1
|
269 a1, a2, a3, a4 = unpack(c.Title.Gradient.MinColor)
|
Nenue@1
|
270 b1, b2, b3, b4 = unpack(c.Title.Gradient.MaxColor)
|
Nenue@1
|
271 block.titlebg:SetGradientAlpha('HORIZONTAL', a1, a2, a3, a4, b1, b2, b3, b4)
|
Nenue@1
|
272
|
Nenue@1
|
273 a1, a2, a3, a4 = unpack(c.Text.Gradient.MinColor)
|
Nenue@1
|
274 b1, b2, b3, b4 = unpack(c.Text.Gradient.MaxColor)
|
Nenue@1
|
275 block.bg:SetGradientAlpha('HORIZONTAL', a1, a2, a3, a4, b1, b2, b3, b4)
|
Nenue@1
|
276
|
Nenue@1
|
277 f1, f2, f3 = unpack(c.Title.Font)
|
Nenue@1
|
278 block.title:SetFont(f1, f2, f3)
|
Nenue@1
|
279
|
Nenue@1
|
280 f1, f2 ,f3 = unpack(c.Text.Font)
|
Nenue@1
|
281 block.objectives:SetFont(f1,f2,f3)
|
Nenue@1
|
282
|
Nenue@1
|
283 w1 = Wrapper:GetWidth()
|
Nenue@1
|
284 w2 = (c.Title.BackgroundFullWidth and w1 or block.title:GetStringWidth())
|
Nenue@1
|
285
|
Nenue@1
|
286 local titleSpacing, titleSpacing2 = c.Title.Spacing, (c.Title.Spacing * 2)
|
Nenue@1
|
287 local textSpacing, textSpacing2 = c.Text.Spacing, (c.Text.Spacing * 2)
|
Nenue@1
|
288
|
Nenue@1
|
289 if block.info.isTrivial then
|
Nenue@1
|
290 block.title:SetTextColor(0.7, 0.7, 0.7, 1)
|
Nenue@1
|
291 elseif block.info.isComplete then
|
Nenue@1
|
292 block.title:SetTextColor(1,1,1,1)
|
Nenue@1
|
293 else
|
Nenue@1
|
294 block.title:SetTextColor(0,.7,1,1)
|
Nenue@1
|
295 end
|
Nenue@1
|
296 block.title:SetSpacing(titleSpacing)
|
Nenue@1
|
297 block.objectives:SetSpacing(textSpacing)
|
Nenue@1
|
298 block.objectives:SetWordWrap(true)
|
Nenue@1
|
299
|
Nenue@1
|
300 local titleHeight, textHeight = block.title:GetStringHeight(), block.objectives:GetStringHeight()
|
Nenue@1
|
301 local blockHeight = titleHeight + titleSpacing2 + textHeight + textSpacing2
|
Nenue@1
|
302 local blockWidth = wrapperMaxWidth
|
Nenue@1
|
303
|
Nenue@1
|
304 block.titlebg:SetSize(min(w1, w2), titleHeight + titleSpacing2)
|
Nenue@1
|
305 block.bg:SetSize(w1, textHeight + textSpacing2)
|
Nenue@1
|
306 block:SetSize(blockWidth, blockHeight)
|
Nenue@1
|
307
|
Nenue@1
|
308 block.title:SetPoint('TOPLEFT', block.titlebg, 'TOPLEFT', 0, -titleSpacing)
|
Nenue@1
|
309 block.objectives:SetPoint('TOPLEFT', block.titlebg, 'BOTTOMLEFT', textIndent, -textSpacing)
|
Nenue@1
|
310
|
Nenue@1
|
311 -- store
|
Nenue@1
|
312 block.titleHeight = titleHeight
|
Nenue@1
|
313 block.textHeight = textHeight
|
Nenue@1
|
314 block.width = blockWidth
|
Nenue@1
|
315 block.height = blockHeight
|
Nenue@1
|
316
|
Nenue@2
|
317 print(' |cFF00FFFF'..block:GetName()..'|r:|cFF0088FFSetStyle|r(', blockWidth, 'x', blockHeight, '(textH', textHeight,', titleH', titleHeight, ')')
|
Nenue@2
|
318 end
|
Nenue@2
|
319
|
Nenue@2
|
320 local segments = {'Left', 'Right', 'Tile'}
|
Nenue@2
|
321 mod.UpdateWrapperStyle = function()
|
Nenue@2
|
322 local c = mod.defaults.WrapperStyle
|
Nenue@2
|
323 for _, segment in ipairs(segments) do
|
Nenue@2
|
324 Wrapper['Background'..segment]:SetAtlas(c.Header.Background[segment])
|
Nenue@2
|
325 Wrapper['Background'..segment]:SetTexCoord(unpack(c.Header.BackgroundCrop[segment]))
|
Nenue@2
|
326 if c.Header.BackgroundScale[segment] then
|
Nenue@2
|
327 Wrapper['Background'..segment]:SetWidth(c.Header.BackgroundScale[segment])
|
Nenue@2
|
328 end
|
Nenue@2
|
329 end
|
Nenue@1
|
330 end
|
Nenue@1
|
331
|
Nenue@1
|
332 --- Updates the selected block frame to display the given info batch
|
Nenue@1
|
333 -- If `previousBlock` is set, it will attempt to anchor to that
|
Nenue@1
|
334 -- @param blockNum the ordered block to be updated, not a watchIndex value
|
Nenue@1
|
335 -- @param info the reference returned by the GetXInfo functions
|
Nenue@1
|
336 -- REMEMBER: t.info and questData[questID] are the same table
|
Nenue@1
|
337 mod.UpdateTrackerBlock = function (handler, blockIndex, info)
|
Nenue@2
|
338 print(' |cFF00FFFFUpdateTrackerBlock('..blockIndex..'|r')
|
Nenue@1
|
339 if not blockIndex or not info then
|
Nenue@1
|
340 return
|
Nenue@1
|
341 end
|
Nenue@1
|
342
|
Nenue@1
|
343 local tracker = handler.Tracker
|
Nenue@1
|
344
|
Nenue@1
|
345 local t = handler:GetBlock(blockIndex)
|
Nenue@1
|
346 if previousBlock then
|
Nenue@1
|
347 if blockIndex == 1 then
|
Nenue@1
|
348 t:SetPoint('TOPLEFT', previousBlock, 'TOPLEFT', 0, -headerHeight)
|
Nenue@1
|
349 else
|
Nenue@1
|
350 t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0)
|
Nenue@1
|
351 end
|
Nenue@1
|
352 t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
|
Nenue@1
|
353 end
|
Nenue@2
|
354 --print(t:GetName(), t:GetSize())
|
Nenue@2
|
355 --print(t:GetPoint(1))
|
Nenue@1
|
356
|
Nenue@1
|
357 t.info = info
|
Nenue@1
|
358
|
Nenue@1
|
359 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = t end
|
Nenue@1
|
360 if info.watchIndex then handler.WatchBlock[info.watchIndex] = t end
|
Nenue@1
|
361
|
Nenue@1
|
362 info.blockIndex = blockIndex
|
Nenue@1
|
363 handler.BlockInfo[blockIndex] = info
|
Nenue@1
|
364 t.Select = handler.Select
|
Nenue@1
|
365 t.Open = handler.Open
|
Nenue@1
|
366 t.Remove = handler.Remove
|
Nenue@1
|
367 t.Link = handler.Link
|
Nenue@1
|
368 t:SetScript('OnMouseUp', handler.OnMouseUp)
|
Nenue@1
|
369 t:SetScript('OnMouseDown', handler.OnMouseDown)
|
Nenue@1
|
370 t.title:SetText(info.title)
|
Nenue@1
|
371
|
Nenue@1
|
372 if info.isComplete then
|
Nenue@1
|
373 t.objectives:Show()
|
Nenue@1
|
374 t.objectives:SetText(info.completionText)
|
Nenue@1
|
375 elseif info.numObjectives >= 1 then
|
Nenue@1
|
376 t.objectives:Show()
|
Nenue@2
|
377 print(' - objective lines:', info.numObjectives, 'can wrap:', t.objectives:CanWordWrap())
|
Nenue@3
|
378
|
Nenue@1
|
379 local text = ''
|
Nenue@3
|
380 if info.description then
|
Nenue@3
|
381 print(' -- has description text:', select('#', info.description), info.description)
|
Nenue@3
|
382 text = info.description
|
Nenue@3
|
383 end
|
Nenue@3
|
384
|
Nenue@3
|
385 --- todo: implement objective displays
|
Nenue@3
|
386 -- in an accumulator loop, call upon handler for the appropriate display frame, each defining:
|
Nenue@3
|
387 -- * height of whatever display widget is involved in conveying the task
|
Nenue@3
|
388 -- * number of non-wrapped text lines to account for line space; may be discarded depending on things
|
Nenue@3
|
389 -- * boolean that determines listening for money events or not
|
Nenue@3
|
390 t.attachmentHeight = 0
|
Nenue@1
|
391 for o, obj in ipairs(t.info.objectives) do
|
Nenue@3
|
392 --- achievement criteria
|
Nenue@3
|
393 if obj.flags then
|
Nenue@3
|
394
|
Nenue@3
|
395 if bit.band(obj.flags, 0x00000001) > 0 then
|
Nenue@3
|
396 obj.type = 'ProgressBar'
|
Nenue@3
|
397 obj.widget = mod.SetWidget(obj, info)
|
Nenue@3
|
398 elseif bit.band(obj.flags, 0x00000002) then
|
Nenue@3
|
399 obj.type = 'Hidden'
|
Nenue@3
|
400 obj.widget = nil
|
Nenue@3
|
401 else
|
Nenue@3
|
402 obj.type = 'Text'
|
Nenue@3
|
403 obj.widget = nil
|
Nenue@3
|
404 text = text .. ((text == '') and "" or "\n") .. obj.text
|
Nenue@3
|
405 end
|
Nenue@3
|
406
|
Nenue@3
|
407 print(obj.type, obj.text, obj.quantityString)
|
Nenue@3
|
408 --- none of the above (most quests)
|
Nenue@3
|
409 else
|
Nenue@3
|
410 local line = obj.text
|
Nenue@3
|
411 if obj.type == 'monster' then
|
Nenue@3
|
412 line = '|cFFFFFF00' .. line .. '|r'
|
Nenue@3
|
413 elseif obj.type == 'item' then
|
Nenue@3
|
414 line = '|cFF44BBFF' .. line .. '|r'
|
Nenue@3
|
415 elseif obj.type == 'object' then
|
Nenue@3
|
416 line = '|cFFFFFFFF' .. line .. '|r'
|
Nenue@3
|
417 end
|
Nenue@3
|
418 text = text .. ((text == '') and "" or "\n") .. line
|
Nenue@1
|
419 end
|
Nenue@3
|
420
|
Nenue@3
|
421 if obj.widget then
|
Nenue@3
|
422 t.attachmentHeight = t.attachmentHeight + obj.widget.height
|
Nenue@3
|
423 end
|
Nenue@3
|
424
|
Nenue@1
|
425 end
|
Nenue@1
|
426 t.objectives:SetText(text)
|
Nenue@3
|
427 t.objectives:SetWordWrap(true)
|
Nenue@1
|
428
|
Nenue@1
|
429
|
Nenue@1
|
430 -- todo: set up a SecureActionButton template
|
Nenue@2
|
431 if info.specialItem and not info.itemButton then
|
Nenue@2
|
432 print(' - |cFF00FFFFupdate item button')
|
Nenue@1
|
433 mod.SetItemButton(t, info)
|
Nenue@1
|
434 end
|
Nenue@1
|
435
|
Nenue@1
|
436
|
Nenue@1
|
437 elseif info.description then
|
Nenue@1
|
438 t.objectives:SetText(info.description)
|
Nenue@1
|
439 t.objectives:SetWordWrap(true)
|
Nenue@1
|
440 else
|
Nenue@1
|
441 t.objectives:SetText(nil)
|
Nenue@1
|
442 end
|
Nenue@1
|
443 local style = 'Normal'
|
Nenue@1
|
444 if info.isComplete then
|
Nenue@1
|
445 style = 'Complete'
|
Nenue@1
|
446 elseif info.superTracked then
|
Nenue@1
|
447 style = 'Super'
|
Nenue@1
|
448 end
|
Nenue@1
|
449
|
Nenue@3
|
450 --- metrics are calculated in SetStyle
|
Nenue@1
|
451 t:SetStyle(style)
|
Nenue@3
|
452 t:Show()
|
Nenue@1
|
453
|
Nenue@3
|
454 print(' |cFF00FFFF)|r -> ', t, t:GetHeight())
|
Nenue@1
|
455 return t
|
Nenue@1
|
456 end
|
Nenue@1
|
457
|
Nenue@1
|
458 mod.UpdateTracker = function(handler)
|
Nenue@1
|
459 print('|cFF00FF88UpdateTracker(|r|cFFFF4400' .. type(handler) .. '|r :: |cFF88FFFF' .. tostring(handler) .. '|r')
|
Nenue@1
|
460 local tracker = handler.Tracker
|
Nenue@1
|
461 local blockIndex = 0
|
Nenue@1
|
462 local trackerHeight = headerHeight
|
Nenue@1
|
463 local w = 300
|
Nenue@1
|
464
|
Nenue@1
|
465 previousBlock = handler.Tracker
|
Nenue@1
|
466 local numWatched = handler.GetNumWatched()
|
Nenue@1
|
467 local numBlocks = handler.numBlocks
|
Nenue@1
|
468 local actualBlocks = handler.actualBlocks
|
Nenue@1
|
469 for watchIndex = 1, 25 do
|
Nenue@1
|
470 blockIndex = blockIndex + 1
|
Nenue@1
|
471 if watchIndex <= numWatched then
|
Nenue@1
|
472 local info = handler:GetInfo(watchIndex)
|
Nenue@1
|
473 if info then
|
Nenue@1
|
474 local currentBlock = mod.UpdateTrackerBlock(handler, blockIndex, info)
|
Nenue@1
|
475 previousBlock = currentBlock
|
Nenue@1
|
476 trackerHeight = trackerHeight + currentBlock.height
|
Nenue@1
|
477 numBlocks = max(numBlocks, watchIndex)
|
Nenue@1
|
478 actualBlocks = actualBlocks + 1
|
Nenue@1
|
479 else
|
Nenue@1
|
480 print('|cFFFF0000Failed to draw info for index #'..watchIndex)
|
Nenue@1
|
481 end
|
Nenue@1
|
482
|
Nenue@1
|
483 elseif watchIndex <= numBlocks then
|
Nenue@1
|
484 local used = handler.usedBlocks
|
Nenue@1
|
485 local free = handler.freeBlocks
|
Nenue@1
|
486 print('clean up dead quest block')
|
Nenue@1
|
487 if used[blockIndex] then
|
Nenue@1
|
488 used[blockIndex]:Hide()
|
Nenue@1
|
489 used[blockIndex]:ClearAllPoints()
|
Nenue@1
|
490 free[#free+1]= used[blockIndex]
|
Nenue@1
|
491 used[blockIndex] = nil
|
Nenue@1
|
492 end
|
Nenue@1
|
493 else
|
Nenue@1
|
494 print('Stopping scan at', blockIndex)
|
Nenue@1
|
495 break -- done with quest stuff
|
Nenue@1
|
496 end
|
Nenue@1
|
497 end
|
Nenue@1
|
498 handler.numWatched = numWatched
|
Nenue@1
|
499 handler.numBlocks = numBlocks
|
Nenue@1
|
500 handler.actualBlocks = actualBlocks
|
Nenue@1
|
501 handler:Report()
|
Nenue@1
|
502 previousBlock = nil
|
Nenue@1
|
503 if numBlocks > 0 then
|
Nenue@1
|
504 tracker.height = trackerHeight
|
Nenue@1
|
505 else
|
Nenue@1
|
506 tracker.height = 0
|
Nenue@1
|
507 end
|
Nenue@1
|
508
|
Nenue@1
|
509 print('|cFF00FF88)|r ->', numBlocks, 'blocks; height', tracker.height, 'last block: ')
|
Nenue@1
|
510 end
|
Nenue@1
|
511
|
Nenue@1
|
512 mod.Quest.numButtons = 0
|
Nenue@1
|
513 local usedButtons = mod.Quest.itemButtons
|
Nenue@1
|
514 local freeButtons = mod.Quest.freeButtons
|
Nenue@1
|
515 mod.UpdateWrapper = function()
|
Nenue@1
|
516 wrapperWidth = wrapperMaxWidth
|
Nenue@1
|
517 scrollWidth = wrapperWidth
|
Nenue@1
|
518 local wrapperBlocks = 0
|
Nenue@1
|
519 -- Update scroll child vertical size
|
Nenue@1
|
520 scrollHeight = 0
|
Nenue@1
|
521 for i, handler in ipairs(orderedHandlers) do
|
Nenue@1
|
522 mod.UpdateTracker(handler)
|
Nenue@1
|
523 if handler.actualBlocks >= 1 then
|
Nenue@1
|
524 local tracker = handler.Tracker
|
Nenue@1
|
525 print('setting', handler.Tracker, 'to anchor to offset', -scrollHeight)
|
Nenue@1
|
526 tracker:SetParent(Scroll) -- this doesn't do anything that relativeTo doesn't
|
Nenue@1
|
527 tracker:SetPoint('TOPLEFT', Scroll, 'TOPLEFT', 0, - scrollHeight)
|
Nenue@1
|
528 tracker:SetSize(wrapperWidth, tracker.height)
|
Nenue@1
|
529 print('adding ', tracker.height)
|
Nenue@1
|
530 scrollHeight = scrollHeight + tracker.height
|
Nenue@1
|
531 end
|
Nenue@1
|
532 wrapperBlocks = wrapperBlocks + handler.actualBlocks
|
Nenue@1
|
533 end
|
Nenue@1
|
534 print('final scrollHeight:', scrollHeight)
|
Nenue@1
|
535
|
Nenue@1
|
536
|
Nenue@1
|
537
|
Nenue@1
|
538 -- Update frame dimensions
|
Nenue@1
|
539 if scrollHeight > wrapperMaxHeight then
|
Nenue@1
|
540 print(' is larger than', wrapperMaxHeight)
|
Nenue@1
|
541 --ScrollBar:Show()
|
Nenue@1
|
542 --scrollWidth = wrapperMaxWidth - scrollBarWidth
|
Nenue@1
|
543 wrapperHeight = wrapperMaxHeight
|
Nenue@1
|
544 -- Make ThumbTexture reflect the viewing scale (smaller for longer scroll, bigger for shorter)
|
Nenue@1
|
545 --ScrollBar:GetThumbTexture():SetHeight((wrapperMaxHeight/scrollHeight) * (wrapperMaxHeight))
|
Nenue@1
|
546 --ScrollBar:SetWidth(scrollBarWidth)
|
Nenue@1
|
547 --ScrollBar:SetPoint('TOPRIGHT', Scroller, 'TOPRIGHT', 0, 0)
|
Nenue@1
|
548 --ScrollBar:SetPoint('BOTTOMLEFT', Scroller, 'BOTTOMRIGHT', -scrollBarWidth, 0)
|
Nenue@1
|
549 --ScrollBar:SetMinMaxValues(1, scrollHeight - wrapperMaxHeight)
|
Nenue@1
|
550 else
|
Nenue@1
|
551 --ScrollBar:Hide()
|
Nenue@1
|
552 wrapperHeight = scrollHeight
|
Nenue@1
|
553 end
|
Nenue@1
|
554 scrollWidth = floor(scrollWidth+.5)
|
Nenue@1
|
555 scrollHeight = floor(scrollHeight+.5)
|
Nenue@1
|
556 wrapperWidth = floor(wrapperWidth+.5)
|
Nenue@1
|
557 wrapperHeight = floor(wrapperHeight+.5)
|
Nenue@1
|
558 headerHeight = floor(headerHeight+.5)
|
Nenue@1
|
559
|
Nenue@1
|
560 if wrapperBlocks >= 1 then
|
Nenue@2
|
561 for i, region in ipairs(Wrapper.header) do
|
Nenue@2
|
562 region:Show()
|
Nenue@2
|
563 end
|
Nenue@1
|
564 else
|
Nenue@2
|
565 for i, region in ipairs(Wrapper.header) do
|
Nenue@2
|
566 region:Hide()
|
Nenue@2
|
567 end
|
Nenue@1
|
568 return
|
Nenue@1
|
569 end
|
Nenue@1
|
570 --wrapperHeight = scrollHeight
|
Nenue@1
|
571
|
Nenue@1
|
572 print('|cFFFFFF00params:|r scroller:', scrollWidth, 'x', scrollHeight)
|
Nenue@1
|
573 print('|cFFFFFF00params:|r scroll:', scrollWidth, 'x', scrollHeight)
|
Nenue@1
|
574 print('|cFFFFFF00params:|r wrapper:', wrapperWidth, 'x', wrapperHeight)
|
Nenue@1
|
575 print('|cFFFFFF00params:|r header:', headerHeight)
|
Nenue@1
|
576
|
Nenue@1
|
577 Scroller:SetSize(wrapperWidth, wrapperHeight)
|
Nenue@1
|
578 Scroller:SetPoint('TOPLEFT', Wrapper, 'TOPLEFT', 0, -headerHeight)
|
Nenue@1
|
579 Scroller:SetPoint('BOTTOMRIGHT', Wrapper, 'BOTTOMRIGHT')
|
Nenue@1
|
580
|
Nenue@1
|
581 Scroll:SetSize(scrollWidth, scrollHeight)
|
Nenue@1
|
582 Scroll:SetPoint('TOPLEFT', Scroller, 'TOPLEFT', 0, 0)
|
Nenue@1
|
583 Scroll:SetPoint('RIGHT', Scroller, 'RIGHT')
|
Nenue@1
|
584
|
Nenue@1
|
585 --Scroller:UpdateScrollChildRect()
|
Nenue@1
|
586 Wrapper:SetSize(wrapperWidth, wrapperHeight + headerHeight)
|
Nenue@1
|
587
|
Nenue@1
|
588 -- update action buttons
|
Nenue@1
|
589
|
Nenue@1
|
590
|
Nenue@1
|
591 print('scroll size:', Scroll:GetSize())
|
Nenue@1
|
592 print('scroller size:',Scroller:GetSize())
|
Nenue@1
|
593 print('wrapper size:', Wrapper:GetSize())
|
Nenue@1
|
594 print('scroll range :', floor(Scroller:GetVerticalScrollRange()+.5))
|
Nenue@1
|
595
|
Nenue@1
|
596
|
Nenue@1
|
597 mod.UpdateActionButtons()
|
Nenue@1
|
598 end
|
Nenue@1
|
599
|
Nenue@1
|
600 --- Queue any active item buttons for update for that frame
|
Nenue@1
|
601 mod.UpdateActionButtons = function()
|
Nenue@1
|
602 local previousItem
|
Nenue@2
|
603 for questID, itemButton in pairs(usedButtons) do
|
Nenue@2
|
604 local questIndex = mod.Quest.Info[questID].questLogIndex
|
Nenue@3
|
605 print('|cFF00FFFF', questID, itemButton:GetName())
|
Nenue@3
|
606 local block = mod.Quest.LogBlock[questID]
|
Nenue@1
|
607 print(block:GetTop())
|
Nenue@1
|
608 if block then
|
Nenue@1
|
609 if IsQuestWatched(questIndex) then
|
Nenue@1
|
610 -- Dispatch the probe
|
Nenue@1
|
611 block:SetScript('OnUpdate', function()
|
Nenue@1
|
612 print('|cFFFFFF00probing', block:GetName())
|
Nenue@1
|
613 if block:GetBottom() then
|
Nenue@1
|
614 print('|cFF00FF00ding ding ding!')
|
Nenue@1
|
615 mod.UpdateBlockAction(block, itemButton, previousItem)
|
Nenue@1
|
616 block:SetScript('OnUpdate', nil)
|
Nenue@1
|
617 end
|
Nenue@1
|
618 end)
|
Nenue@1
|
619 return
|
Nenue@1
|
620 else
|
Nenue@2
|
621 mod.FreeItemButtons(block)
|
Nenue@1
|
622 end
|
Nenue@1
|
623 end
|
Nenue@1
|
624 end
|
Nenue@1
|
625 end
|
Nenue@1
|
626
|
Nenue@1
|
627 mod.UpdateBlockAction = function (block, itemButton, previousItem)
|
Nenue@2
|
628 if block.itemButton ~= itemButton then
|
Nenue@2
|
629 block.itemButton = itemButton
|
Nenue@2
|
630 end
|
Nenue@2
|
631 if itemButton.block ~= block then
|
Nenue@2
|
632 itemButton.block = block
|
Nenue@2
|
633 end
|
Nenue@2
|
634
|
Nenue@1
|
635 if block:GetBottom() < Scroller:GetBottom() then
|
Nenue@1
|
636 print('|cFFFFFF00bottom not fully visible')
|
Nenue@1
|
637 if previousItem then
|
Nenue@1
|
638 previousItem:ClearAllPoints()
|
Nenue@1
|
639 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, 4)
|
Nenue@1
|
640 end
|
Nenue@1
|
641 itemButton:ClearAllPoints()
|
Nenue@1
|
642 itemButton:SetPoint('BOTTOMRIGHT', UIParent, 'BOTTOMLEFT', Wrapper:GetLeft(), Wrapper:GetBottom())
|
Nenue@1
|
643 itemButton:Show()
|
Nenue@1
|
644 else
|
Nenue@1
|
645 print('|cFF00FF00visible positions')
|
Nenue@1
|
646 itemButton:ClearAllPoints()
|
Nenue@1
|
647 itemButton:SetPoint('TOPRIGHT', UIParent, 'BOTTOMLEFT', block:GetLeft(), block:GetTop())
|
Nenue@1
|
648 itemButton:Show()
|
Nenue@1
|
649 end
|
Nenue@1
|
650 end
|
Nenue@1
|
651
|
Nenue@1
|
652 mod.UpdateItemButtonCooldown = function(button)
|
Nenue@1
|
653
|
Nenue@1
|
654 end
|