comparison ObjectiveStyle.lua @ 14:ed642234f017

ObjectiveFrame - implement proper tracker name text - expanded tracker prototypes to cover "objective lines" formatting and accommodation of widget variables - implement the progress bars for bonus objectives ObjectiveStyle - moved `UpdateWrapperStyle` over and renamed it to fit semantics - change the formula for block.`height` to measure non-widget content only - allows widgets to position relative to text - size FontString `status` to match block.`height` - full block height is acquired by adding block.`height` and block.`attachmentHeight` which is calculated during objective parsing ObjectiveWidgets - use string keys for generated widgets to deal with multiple objectives under the same questID, and maybe dungeon objectives - wrapper buttons use a common code path - specialized handlers for wheel scrolling moved over to fit semantics
author Nenue
date Mon, 04 Apr 2016 03:16:22 -0400
parents 9455693fc290
children 880828018bf4
comparison
equal deleted inserted replaced
13:9455693fc290 14:ed642234f017
3 local print = B.print('SetStyle') 3 local print = B.print('SetStyle')
4 ------------------------------------------------------------- 4 -------------------------------------------------------------
5 --- Deals with swapping between different color palettes 5 --- Deals with swapping between different color palettes
6 --- 6 ---
7 7
8 local itemButtonSize, itemButtonSpacing = 36, 1
9 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0}
10 local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]] 8 local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]]
11 local titleSize, textSize = 15, 15 9 local titleSize, textSize = 16, 15
12 local titleOutline, textOutline = "OUTLINE", "OUTLINE" 10 local titleOutline, textOutline = "OUTLINE", "OUTLINE"
13 local titleSpacing, textSpacing = 4, 3 11 local titleSpacing, textSpacing = 3, 1
14 local unpack, type, pairs, tconcat = unpack, type, pairs, table.concat 12 local unpack, type, pairs, tconcat = unpack, type, pairs, table.concat
15 local wrapperMaxWidth, wrapperMaxHeight = 280, 490 -- these are the hard bounds, actual *Height variables are changed
16 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' 13 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
17 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 14 local headerFont, headerSize = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 24
18 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 15 local headerOutline, headerSpacing = 'OUTLINE', 2
19 16
20 17
21 mod.defaults.ObjectiveWrapper = { 18 mod.defaults.Wrapper = {
22 ObjectiveTrackerFloat = {'BOTTOM', 'RIGHT'}, 19 WrapperPoint = 'TOPRIGHT',
23 ObjectiveTrackerParent = 'DebuffButton', 20 WrapperFloatX = -25,
24 ObjectiveTrackerSize = {250, 600}, 21 WrapperFloatV = 'TOP',
25 ObjectiveWrapperParent = '', 22 WrapperFloatY = -200,
23
24 WrapperWidth = 270,
25 WrapperHeight = 600,
26 } 26 }
27 mod.defaults.Tracker = {
28 HeaderHeight = 24,
29 }
30
27 mod.defaults.Style = { 31 mod.defaults.Style = {
28 Format = { 32 Format = {
29 Frame = { 33 Frame = {
30 Width = 270, 34 Width = 270,
31 }, 35 },
32 title = { 36 title = {
33 Indent = 0 37 Indent = 0,
38 Spacing = 0,
34 }, 39 },
35 status = { 40 status = {
36 Indent = 5 41 Indent = 5,
42 Spacing = 0,
37 } 43 }
38 }, 44 },
39 FontBank = { 45 FontBank = {
40 ['Normal'] = _G.VeneerCriteriaFontNormal, 46 ['Normal'] = _G.VeneerCriteriaFontNormal,
41 ['Progress'] = _G.VeneerCriteriaFontProgress, 47 ['Progress'] = _G.VeneerCriteriaFontProgress,
44 }, 50 },
45 Normal = { 51 Normal = {
46 title = { 52 title = {
47 TextColor = {1, 1, 1, 1}, 53 TextColor = {1, 1, 1, 1},
48 Width = 270, 54 Width = 270,
55 Spacing = 0,
56 Indent = 2,
49 }, 57 },
50 titlebg = { 58 titlebg = {
51 Background = {0, 0, 0, 1}, 59 Background = {0, 0, 0, 1},
52 Width = 270, 60 Width = 270,
53 }, 61 },
54 status = { 62 status = {
55 Width = 270, 63 Width = 270,
64 Spacing = 0,
56 }, 65 },
57 statusbg = { 66 statusbg = {
58 Width = 270, 67 Width = 270,
59 }, 68 },
60 Frame = { 69 Frame = {
61 Width = 270, 70 Width = 270,
62 } 71 }
63 }, 72 },
64 Wrapper = { 73 Wrapper = {
65 Frame = { 74 Frame = {
66 Point = {wrapperPosition},
67 MaxSize = {wrapperMaxWidth, wrapperMaxHeight},
68 BackgroundComplex = {Left = {'', 0, 0.4, 0,1, 100}, Right={'', 0.6,1,0,1}, Tile = {'', 0.4,.6,0,1, 100}}, }, 75 BackgroundComplex = {Left = {'', 0, 0.4, 0,1, 100}, Right={'', 0.6,1,0,1}, Tile = {'', 0.4,.6,0,1, 100}}, },
69 title = { 76 title = {
70 Font = {wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline}, 77 Font = {wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline},
71 Spacing = 4,} 78 Spacing = 4,}
72 }, 79 },
73 Tracker = { 80 Tracker = {
74 Normal = { 81 Normal = {
75 title = { 82 title = {
76 Font = {headerFont, headerSize, headerOutline}, Spacing = headerSpacing, 83 Font = {headerFont, headerSize, headerOutline}, Spacing = headerSpacing,
84 Indent = 2,
85 TextColor = {1, .9, .2, 1},
77 }, 86 },
78 titlebg = { 87 titlebg = {
79 Gradient = {MinColor = {0,0,0,0.7}, MaxColor = {0,0,0,.35}}, 88 Gradient = {MinColor = {0,0,0,0.25}, MaxColor = {0,0,0,.15}},
80 } 89 }
81 } 90 }
82 }, 91 },
83 TrackerBlock = { 92 TrackerBlock = {
84 Normal = { 93 Normal = {
85 titlebg = { 94 titlebg = {
86 Gradient = { MinColor = {0.2, .4, 1, 0.45}, MaxColor = {.7, 0, 0.9, .19}}, 95 Indent = 2,
96 Gradient = { MinColor = {0.2, .4, 1, 0}, MaxColor = {.7, 0, 0.9, .14}},
87 }, 97 },
88 title = { 98 title = {
99 TextColor = {1,1,1,0.5},
89 Font = {titleFont, titleSize, titleOutline}, 100 Font = {titleFont, titleSize, titleOutline},
90 Spacing = titleSpacing, 101 Spacing = titleSpacing,
91 }, 102 },
92 status = { 103 status = {
93 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, 104 TextColor = {1,1,1,0.5},
105 Font = {textFont, textSize, textOutline},
106 Spacing = textSpacing,
94 }, 107 },
95 statusbg = { 108 statusbg = {
96 Gradient = { MinColor = {0.2, .4, 1, 0.25}, MaxColor = {.7, 0, 0.9, .12}}, 109 Gradient = { MinColor = {0.2, .4, 1, 0}, MaxColor = {.7, 0, 0.9, .11}},
97 } 110 }
98 }, 111 },
99 Super = { 112 Super = {
100 title = { 113 title = {
114 TextColor = {1,1,1,1},
101 Font = {titleFont, titleSize, titleOutline}, 115 Font = {titleFont, titleSize, titleOutline},
102 Spacing = titleSpacing, BackgroundFullWidth = true 116 Spacing = titleSpacing, BackgroundFullWidth = true
103 }, 117 },
104 titlebg = { 118 titlebg = {
105 Gradient = { MinColor = {0, .7, .6, .8}, MaxColor = {0, .7, .6, 0.2}}, 119 Gradient = { MinColor = {0, .7, .6, .45}, MaxColor = {0, .7, .6, 0.23}},
106 }, 120 },
107 status = { 121 status = {
108 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, 122 TextColor = {1,1,1,1},
123 Font = {textFont, textSize, textOutline},
124 Spacing = textSpacing,
109 }, 125 },
110 statusbg = { 126 statusbg = {
111 Gradient = { MinColor = {0, .7, .6, 0.5}, MaxColor = {0, .7, .6, 0.1} }, 127 Gradient = { MinColor = {0, .7, .6, 0.40}, MaxColor = {0, .7, .6, 0.23} },
112 }, 128 },
113 }, 129 },
114 MouseDown = { 130 MouseDown = {
115 title = { 131 title = {
116 Font = {titleFont, titleSize, titleOutline}, 132 Font = {titleFont, titleSize, titleOutline},
127 Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, .2}, }, 143 Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, .2}, },
128 } 144 }
129 }, 145 },
130 Complete = { 146 Complete = {
131 title = { 147 title = {
148 TextColor = {1,1,1,0.5},
132 Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing, 149 Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing,
133 }, 150 },
134 titlebg = { 151 titlebg = {
135 Gradient = { MinColor = {0, 1, 0, 0.34}, MaxColor = {0, 1, 0, .17}, }, 152 Gradient = { MinColor = {0, 1, 0, 0.34}, MaxColor = {0, 1, 0, .17}, },
136 }, 153 },
137 status = { 154 status = {
155 TextColor = {1,1,1,0.5},
138 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, 156 Font = {textFont, textSize, textOutline}, Spacing = textSpacing,
139 }, 157 },
140 statusbg = { 158 statusbg = {
141 Gradient = { MinColor = {0, 1, 0, .25}, MaxColor = {0, 1, 0, 0.12}, }, 159 Gradient = { MinColor = {0, 1, 0, .25}, MaxColor = {0, 1, 0, 0.12}, },
142 } 160 }
201 local style_cache = mod.BlockStyleCache 219 local style_cache = mod.BlockStyleCache
202 mod.regions = {} 220 mod.regions = {}
203 mod.regionStyles = {} 221 mod.regionStyles = {}
204 mod.SetBlockStyle = function(frame, frameType, ...) 222 mod.SetBlockStyle = function(frame, frameType, ...)
205 -- var names intended to reflect argument order 223 -- var names intended to reflect argument order
224 print('|cFFFFFF00'..frame:GetName()..'|r')
206 --@debug@ 225 --@debug@
207 local c = mod.defaults.Normal 226 local c = mod.defaults.Normal
208 local style_list = {... } 227 local style_list = {... }
209 local styleName = frameType .. '-' .. table.concat(style_list,'') 228 local styleName = frameType .. '-' .. table.concat(style_list,'')
210 229
263 else 282 else
264 print(' |cFFFFFFFF' .. k ..'|r =', tostring(v)) 283 print(' |cFFFFFFFF' .. k ..'|r =', tostring(v))
265 end 284 end
266 end 285 end
267 style_cache[styleName] = style 286 style_cache[styleName] = style
268 else
269 print('Cache hit: ', styleName)
270 end 287 end
271 288
272 local style = style_cache[styleName] 289 local style = style_cache[styleName]
273 290
274 if not style_cache_func[styleName] then 291 if not style_cache_func[styleName] then
312 code = code .. "\nend" 329 code = code .. "\nend"
313 local result = assert(loadstring(code)) 330 local result = assert(loadstring(code))
314 print('storing style func', styleName, result()) 331 print('storing style func', styleName, result())
315 style_cache_func[styleName] = result() 332 style_cache_func[styleName] = result()
316 333
317 else
318 print('Cache function hit:', styleName)
319 end 334 end
320 style_cache_func[styleName](frame) 335 style_cache_func[styleName](frame)
321 336
322 --- Hardcoding the sizing vars for sanity 337 --- Hardcoding the sizing vars for sanity
323 local normalSettings = mod.defaults.Style.Format 338 local normalSettings = mod.defaults.Style.Format
324 frame.titleHeight = frame.title and (frame.title:GetStringHeight() + frame.title.spacing*2) or 0 339 frame.titleHeight = frame.title and (frame.title:GetStringHeight() + (frame.title.spacing or 0)*2) or 0
325 frame.statusHeight = frame.status and (frame.status:GetStringHeight() + frame.status.spacing*2 + frame.attachmentHeight) or 0 340 frame.statusHeight = frame.status and (frame.status:GetStringHeight() + (frame.status.spacing or 0)*2) or 0
326 frame.height = frame.titleHeight + frame.statusHeight 341 frame.height = frame.titleHeight + frame.statusHeight + (frame.attachmentHeight or 0)
327 frame.width = normalSettings.Frame.Width 342 frame.width = normalSettings.Frame.Width
328 frame.statusWidth = frame.width - normalSettings.status.Indent 343 frame.statusWidth = frame.width - normalSettings.status.Indent
329 frame.titleWidth = frame.width - normalSettings.title.Indent 344 frame.titleWidth = frame.width - normalSettings.title.Indent
330 345
331 if frame.status then 346 if frame.status then
332 print('status ', frame.statusHeight, normalSettings.status.Indent, 0) 347 print('status ', frame.statusHeight, normalSettings.status.Indent, 0, 'statusbg', frame.statusHeight)
333 frame.status:SetPoint('LEFT', frame, 'LEFT', normalSettings.status.Indent, 0) 348 frame.status:SetPoint('LEFT', frame, 'LEFT', normalSettings.status.Indent, 0)
334 frame.status:SetHeight(frame.statusHeight) 349 frame.status:SetHeight(frame.statusHeight)
335 if frame.statusbg then 350 if frame.statusbg then
336 351
337 print('statusbg', frame.statusHeight) 352 frame.statusbg:SetHeight(frame.statusHeight + (frame.attachmentHeight or 0))
338 frame.statusbg:SetHeight(frame.statusHeight)
339 frame.statusbg:SetWidth(frame.width) 353 frame.statusbg:SetWidth(frame.width)
340 end 354 end
341 end 355 end
342 if frame.title then 356 if frame.title then
343 print('title ',frame.titleHeight, normalSettings.title.Indent) 357 print('title ',frame.titleHeight, normalSettings.title.Indent, 'titlebg',frame.titleHeight)
344 frame.title:SetPoint('LEFT', frame, 'LEFT', normalSettings.title.Indent) 358 frame.title:SetPoint('LEFT', frame, 'LEFT', normalSettings.title.Indent)
345 frame.title:SetHeight(frame.titleHeight) 359 frame.title:SetHeight(frame.titleHeight)
346 if frame.titlebg then 360 if frame.titlebg then
347 print('titlebg',frame.titleHeight)
348 frame.titlebg:SetHeight(frame.titleHeight) 361 frame.titlebg:SetHeight(frame.titleHeight)
349 frame.titlebg:SetWidth(frame.width) 362 frame.titlebg:SetWidth(frame.width)
350 end 363 end
351 end 364 end
365 frame:SetSize(frame.width, frame.height)
352 print('sizing frame', frame.width, frame.height) 366 print('sizing frame', frame.width, frame.height)
353 frame:SetSize(frame.width, frame.height)
354 print(frame:GetSize())
355 --[[ 367 --[[
356 local titleSpacing, titleSpacing2 = c.Title.Spacing, (c.Title.Spacing * 2) 368 local titleSpacing, titleSpacing2 = c.Title.Spacing, (c.Title.Spacing * 2)
357 local textSpacing, textSpacing2 = c.Text.Spacing, (c.Text.Spacing * 2) 369 local textSpacing, textSpacing2 = c.Text.Spacing, (c.Text.Spacing * 2)
358 370
359 block.title:SetSpacing(titleSpacing) 371 block.title:SetSpacing(titleSpacing)
377 block.width = blockWidth 389 block.width = blockWidth
378 block.height = blockHeight 390 block.height = blockHeight
379 --]] 391 --]]
380 --print(' |cFF00FFFF'..block:GetName()..'|r:|cFF0088FFSetStyle|r(', blockWidth, 'x', blockHeight, '(textH', textHeight,', titleH', titleHeight, ')') 392 --print(' |cFF00FFFF'..block:GetName()..'|r:|cFF0088FFSetStyle|r(', blockWidth, 'x', blockHeight, '(textH', textHeight,', titleH', titleHeight, ')')
381 end 393 end
394 local segments = {'Left', 'Right', 'Tile' }
395 local Wrapper = _G.VeneerObjectiveWrapper
396 mod.UpdateWrapperStyle = function()
397 local c = mod.Conf.Wrapper
398 --Wrapper:ClearAllPoints()
399 --Wrapper:SetPoint(c.WrapperPoint, UIParent, c.WrapperPoint, c.WrapperFloatX, c.WrapperFloatY)
400 end
401
402 mod.Tracker.SetBlockTags = function(block, info)
403 if info.isComplete then
404 block.mainStyle = 'Complete'
405 end
406 if info.superTracked then
407 block.subStyle = 'Super'
408 elseif info.isDaily then
409 block.subStyle = 'Daily'
410 end
411 end
412 local unitLevel = UnitLevel('player')
413 mod.Quest.SetBlockTags = function(block, info)
414
415 mod.Tracker.SetBlockTags(block, info)
416 if info.level then
417 local levelDiff = unitLevel - info.level
418 if levelDiff > 9 then
419 block.title:SetTextColor(0.7, 0.7, 0.7, 1)
420 elseif levelDiff > 1 then
421 block.title:SetTextColor(0.5, 1, 0.5, 1)
422 elseif levelDiff < -1 then
423 block.title:SetTextColor(1, 0.4, 0.25, 1)
424 elseif levelDiff < -4 then
425 block.title:SetTextColor(1, 0, 0, 1)
426 else
427 block.title:SetTextColor(1,1,1,1)
428 end
429 end
430 end
431 mod.Cheevs.SetBlockTags = function(block, info)
432 mod.Tracker.SetBlockTags(block, info)
433 end
382 434
383 --- Argument containers 435 --- Argument containers
384 local o = "" -- text flag 436 local o -- text flag
385 local a1, a2, a3, a4, b1, b2, b3, b4 = 0,0,0,1, 0,0,0,1 -- color1, color2 437 local a1, a2, a3, a4, b1, b2, b3, b4 -- color1, color2
386 local f1, f2, f3 = "", 0, "" -- font 438 local f1, f2, f3 -- font
387 local w1, w2 = 0, 0 -- size 439 local w1, w2 -- size
388 local p1, p2, p3, x, y = "", "", "", 0, 0 -- path/point args 440 local p1, p2, p3, x, y -- path/point args
389 mod.SetBlockAttribute = {} 441 mod.SetBlockAttribute = {}
390 local sb = mod.SetBlockAttribute 442 local sb = mod.SetBlockAttribute
391 local print = B.print('Attribute') 443 local print = B.print('Attribute')
392 sb.Gradient = function(region, value) 444 sb.Gradient = function(region, value)
393 print('|cFF8844FFGradient|r', region:GetName(), unpack(value)) 445 print('|cFF8844FFGradient|r', region:GetName(), unpack(value))
413 print('|cFFFFFF00Font|r', f1, f2, f3) 465 print('|cFFFFFF00Font|r', f1, f2, f3)
414 region:SetFont(f1, f2, f3) 466 region:SetFont(f1, f2, f3)
415 end 467 end
416 468
417 sb.Spacing = function(region, value) 469 sb.Spacing = function(region, value)
418 print('FontSpacing', value) 470 print('FontSpacing', region:GetName(), value)
419 region:SetSpacing(value) 471 region:SetSpacing(value)
420 region.spacing = value 472 region.spacing = value
421 end 473 end
422 474
423 sb.TextColor = function(region, value) 475 sb.TextColor = function(region, value)
445 end 497 end
446 sb.Size = function(region, value) 498 sb.Size = function(region, value)
447 w1, w2 = unpack(value) 499 w1, w2 = unpack(value)
448 region:SetSize(w1, w2) 500 region:SetSize(w1, w2)
449 end 501 end
502