Mercurial > wow > buffalo2
comparison ObjectiveFrame.lua @ 10:f03c75f63566
ObjectiveStyle & ObjectiveFrame
- abstract aesthetic details away from ObjectiveFrame
- revise SetBlockStyle into a more general algorithm for every frame
- implement caching of resolved attribute combinations
- use loadstring functions to store resolved attributes and call upon those when, for example, a MouseUp leads a tracker block to restore its original style
| author | Nenue |
|---|---|
| date | Sat, 02 Apr 2016 03:19:25 -0400 |
| parents | 2698173edd40 |
| children | 8238cddaddb1 |
comparison
equal
deleted
inserted
replaced
| 9:2698173edd40 | 10:f03c75f63566 |
|---|---|
| 2 -- @file-author@ | 2 -- @file-author@ |
| 3 -- @project-revision@ @project-hash@ | 3 -- @project-revision@ @project-hash@ |
| 4 -- @file-revision@ @file-hash@ | 4 -- @file-revision@ @file-hash@ |
| 5 -- Created: 3/30/2016 12:49 AM | 5 -- Created: 3/30/2016 12:49 AM |
| 6 local B = select(2,...).frame | 6 local B = select(2,...).frame |
| 7 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') | |
| 7 local ipairs, max, min, unpack, floor, pairs, tostring, type = ipairs, max, min, unpack, floor, pairs, tostring, type | 8 local ipairs, max, min, unpack, floor, pairs, tostring, type = ipairs, max, min, unpack, floor, pairs, tostring, type |
| 8 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion | 9 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion |
| 9 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent | 10 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent |
| 10 local CreateFrame = CreateFrame | 11 local CreateFrame = CreateFrame |
| 11 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') | |
| 12 local print = B.print('Objectives') | 12 local print = B.print('Objectives') |
| 13 -------------------------------------------------------------------- | 13 -------------------------------------------------------------------- |
| 14 --- Global frame layout | 14 --- Global frame layout |
| 15 -------------------------------------------------------------------- | 15 -------------------------------------------------------------------- |
| 16 | 16 |
| 24 --- Temp values set during updates | 24 --- Temp values set during updates |
| 25 local wrapperWidth, wrapperHeight | 25 local wrapperWidth, wrapperHeight |
| 26 local scrollWidth, scrollHeight | 26 local scrollWidth, scrollHeight |
| 27 local previousBlock | 27 local previousBlock |
| 28 local currentBlock | 28 local currentBlock |
| 29 --- todo: map these into config table when its sorted out | 29 --- todo: source these from config |
| 30 local itemButtonSize, itemButtonSpacing = 36, 1 | 30 local itemButtonSize, itemButtonSpacing = 36, 1 |
| 31 local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]] | 31 local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]] |
| 32 local titleSize, textSize = 15, 15 | 32 local titleSize, textSize = 15, 15 |
| 33 local titleOutline, textOutline = "OUTLINE", "OUTLINE" | 33 local titleOutline, textOutline = "OUTLINE", "OUTLINE" |
| 34 local titleSpacing, textSpacing = 4, 3 | 34 local titleSpacing, textSpacing = 4, 3 |
| 38 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 | 38 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 |
| 39 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 | 39 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 |
| 40 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0} | 40 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0} |
| 41 | 41 |
| 42 --- These are mostly aesthetic choices so it lives here | 42 --- These are mostly aesthetic choices so it lives here |
| 43 mod.defaults = { | 43 |
| 44 ObjectiveTrackerAnchor = {'BOTTOM', 'RIGHT'}, | |
| 45 ObjectiveTrackerParent = 'DebuffButton', | |
| 46 ObjectiveTrackerSize = {250, 600}, | |
| 47 ObjectiveWrapperParent = '', | |
| 48 WrapperStyle = { | |
| 49 Header = { | |
| 50 Background = {Left = '', Right = '', Tile = ''}, | |
| 51 BackgroundCrop = {Left = {0, 0.4, 0,1}, Right={0.6,1,0,1}, Tile = {0.4,.6,0,1,}}, | |
| 52 BackgroundScale = {Left = 100, Right = 100}, | |
| 53 Font = {wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline} | |
| 54 } | |
| 55 }, | |
| 56 ObjectiveHeaderStyle = { | |
| 57 Normal = { | |
| 58 Gradient = {MinColor = {.05,.15,0.5,0.7}, MaxColor = {.05,.15,0.5,.35}}, | |
| 59 Font = {headerFont, headerSize, headerOutline}, Spacing = headerSpacing, | |
| 60 } | |
| 61 }, | |
| 62 ObjectiveTrackerStyle = { | |
| 63 Normal = { | |
| 64 Title = { | |
| 65 Gradient = { MinColor = {0.2, .4, 1, 0.45}, MaxColor = {.7, 0, 0.9, .19}}, | |
| 66 Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing, | |
| 67 }, | |
| 68 Text = { | |
| 69 Gradient = { MinColor = {0.2, .4, 1, 0.25}, MaxColor = {.7, 0, 0.9, .12}}, | |
| 70 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, | |
| 71 }, | |
| 72 }, | |
| 73 Super = { | |
| 74 Title = { | |
| 75 Gradient = { MinColor = {0, .7, .6, .8}, MaxColor = {0, .7, .6, 0.2}}, | |
| 76 Font = {titleFont, titleSize, titleOutline}, | |
| 77 Spacing = titleSpacing, BackgroundFullWidth = true | |
| 78 }, | |
| 79 Text = { | |
| 80 Gradient = { MinColor = {0, .7, .6, 0.5}, MaxColor = {0, .7, .6, 0.1} }, | |
| 81 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, | |
| 82 }, | |
| 83 }, | |
| 84 Active = { | |
| 85 Title = { | |
| 86 Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, .4}, }, | |
| 87 Font = {titleFont, titleSize, titleOutline}, | |
| 88 Spacing = titleSpacing, | |
| 89 BackgroundFullWidth = true | |
| 90 }, | |
| 91 Text = { | |
| 92 Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, .2}, }, | |
| 93 Font = {textFont, textSize, textOutline}, | |
| 94 Spacing = textSpacing, | |
| 95 BackgroundFullWidth = true | |
| 96 } | |
| 97 }, | |
| 98 Complete = { | |
| 99 Title = { | |
| 100 Gradient = { MinColor = {0, 1, 0, 0.34}, MaxColor = {0, 1, 0, .17}, }, | |
| 101 Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing, | |
| 102 BackgroundFullWidth = true | |
| 103 }, | |
| 104 Text = { | |
| 105 Gradient = { MinColor = {0, 1, 0, .25}, MaxColor = {0, 1, 0, 0.12}, }, | |
| 106 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, | |
| 107 BackgroundFullWidth = true | |
| 108 } | |
| 109 }, | |
| 110 CheevNormal = { | |
| 111 | |
| 112 Title = { | |
| 113 Gradient = { MinColor = {0.2, .4, 1, 0.45}, MaxColor = {.7, 0, 0.9, .19}}, | |
| 114 Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing, | |
| 115 }, | |
| 116 Text = { | |
| 117 Gradient = { MinColor = {0.2, .4, 1, 0.25}, MaxColor = {.7, 0, 0.9, .12}}, | |
| 118 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, | |
| 119 }, | |
| 120 }, | |
| 121 CheevComplete = { | |
| 122 | |
| 123 Title = { | |
| 124 Gradient = { MinColor = {0.2, .4, 1, 0.45}, MaxColor = {.7, 0, 0.9, .19}}, | |
| 125 Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing, | |
| 126 }, | |
| 127 Text = { | |
| 128 Gradient = { MinColor = {0.2, .4, 1, 0.25}, MaxColor = {.7, 0, 0.9, .12}}, | |
| 129 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, | |
| 130 }, | |
| 131 } | |
| 132 } | |
| 133 } | |
| 134 | |
| 135 local FontBank = { | |
| 136 ['Normal'] = VeneerCriteriaFontNormal, | |
| 137 ['Progress'] = VeneerCriteriaFontProgress, | |
| 138 ['Complete'] = VeneerCriteriaFontComplete, | |
| 139 ['Failed'] = VeneerCriteriaFontFailed, | |
| 140 } | |
| 141 | 44 |
| 142 local Scroller_OnShow = function() | 45 local Scroller_OnShow = function() |
| 143 Wrapper.watchMoneyReasons = 0; | 46 Wrapper.watchMoneyReasons = 0; |
| 144 mod.UpdateWrapper() | 47 mod.UpdateWrapper() |
| 145 mod.SetEvents() | 48 mod.SetEvents() |
| 146 for i, region in ipairs(Wrapper.header) do | 49 for i, region in ipairs(Wrapper.headerComplex) do |
| 147 region:Show() | 50 region:Show() |
| 148 end | 51 end |
| 149 end | 52 end |
| 150 | 53 |
| 151 local Scroller_OnHide = function() | 54 local Scroller_OnHide = function() |
| 152 local self = Wrapper | 55 local self = Wrapper |
| 153 Wrapper:UnregisterAllEvents() | 56 Wrapper:UnregisterAllEvents() |
| 154 Wrapper:SetScript('OnEvent', nil) | 57 Wrapper:SetScript('OnEvent', nil) |
| 155 for i, region in ipairs(Wrapper.header) do | 58 for i, region in ipairs(Wrapper.headerComplex) do |
| 156 region:Hide() | 59 region:Hide() |
| 157 end | 60 end |
| 158 end | 61 end |
| 159 | 62 |
| 160 local Scroller_OnMouseWheel = function(self, delta) | 63 local Scroller_OnMouseWheel = function(self, delta) |
| 181 end | 84 end |
| 182 end | 85 end |
| 183 | 86 |
| 184 mod.InitializeTrackers = function() | 87 mod.InitializeTrackers = function() |
| 185 | 88 |
| 186 local c = mod.defaults.ObjectiveHeaderStyle.Normal | |
| 187 local g1, g2, g3, g4 = unpack(c.Gradient.MinColor) | |
| 188 local h1, h2, h3, h4 = unpack(c.Gradient.MaxColor) | |
| 189 | 89 |
| 190 for i, name in ipairs(orderedNames) do | 90 for i, name in ipairs(orderedNames) do |
| 191 if not mod.orderedHandlers[i] then | 91 if not mod.orderedHandlers[i] then |
| 192 if mod.Tracker(name, i) then | 92 if mod.Tracker(name, i) then |
| 193 local handler = mod[name] | 93 local handler = mod[name] |
| 194 | 94 |
| 195 local tracker = CreateFrame('Frame', 'Veneer'..name..'Tracker', Scroll, 'VeneerTrackerTemplate') | 95 local tracker = CreateFrame('Frame', 'Veneer'..name..'Tracker', Scroll, 'VeneerTrackerTemplate') |
| 196 tracker.header:SetText(handler.name) | 96 tracker.title:SetText(name) |
| 197 tracker.header:SetHeight(headerHeight) | 97 mod.SetBlockStyle(tracker, 'Tracker', 'Normal') |
| 198 tracker.header:SetFont(unpack(c.Font)) | |
| 199 tracker.header:SetTextColor(unpack(headerColor)) | |
| 200 | |
| 201 tracker.headerbg:SetGradientAlpha('HORIZONTAL', g1, g2 ,g3, g4, h1, h2, h3, h4) | |
| 202 tracker.headerbg:SetHeight(headerHeight) | |
| 203 | 98 |
| 204 handler.Tracker = tracker | 99 handler.Tracker = tracker |
| 205 mod.orderedTrackers[i] = tracker | 100 mod.orderedTrackers[i] = tracker |
| 206 mod.namedTrackers[name] = tracker | 101 mod.namedTrackers[name] = tracker |
| 207 mod.indexedTrackers[handler] = tracker | 102 mod.indexedTrackers[handler] = tracker |
| 208 print('created new tracker frames for new handler') | 103 print('created new tracker frames for new handler') |
| 104 | |
| 105 | |
| 209 end | 106 end |
| 210 end | 107 end |
| 211 end | 108 end |
| 212 | 109 |
| 213 Scroller:SetScrollChild(Scroll) | 110 Scroller:SetScrollChild(Scroll) |
| 299 end | 196 end |
| 300 self.xpText:SetText(xp .. '/'.. xpmax .. (rest and (' ('..tostring(rest)..')') or '')) | 197 self.xpText:SetText(xp .. '/'.. xpmax .. (rest and (' ('..tostring(rest)..')') or '')) |
| 301 end | 198 end |
| 302 end | 199 end |
| 303 | 200 |
| 304 mod.UpdateReputation = function(self) | 201 |
| 305 end | |
| 306 | |
| 307 --- Argument containers | |
| 308 local a1, a2, a3, a4, b1, b2, b3, b4, f1, f2, f3, w1, w2 | |
| 309 mod.SetBlockStyle = function(block, name) | |
| 310 -- var names intended to reflect argument order | |
| 311 --@debug@ | |
| 312 local c = mod.defaults.ObjectiveTrackerStyle[name] | |
| 313 --@end-debug@ | |
| 314 --[===[@non-debug | |
| 315 local c = mod.Conf | |
| 316 --@end-non-debug]===] | |
| 317 a1, a2, a3, a4 = unpack(c.Title.Gradient.MinColor) | |
| 318 b1, b2, b3, b4 = unpack(c.Title.Gradient.MaxColor) | |
| 319 block.titlebg:SetGradientAlpha('HORIZONTAL', a1, a2, a3, a4, b1, b2, b3, b4) | |
| 320 | |
| 321 a1, a2, a3, a4 = unpack(c.Text.Gradient.MinColor) | |
| 322 b1, b2, b3, b4 = unpack(c.Text.Gradient.MaxColor) | |
| 323 block.bg:SetGradientAlpha('HORIZONTAL', a1, a2, a3, a4, b1, b2, b3, b4) | |
| 324 | |
| 325 f1, f2, f3 = unpack(c.Title.Font) | |
| 326 block.title:SetFont(f1, f2, f3) | |
| 327 | |
| 328 f1, f2 ,f3 = unpack(c.Text.Font) | |
| 329 block.objectives:SetFont(f1,f2,f3) | |
| 330 | |
| 331 w1 = Wrapper:GetWidth() | |
| 332 w2 = (c.Title.BackgroundFullWidth and w1 or block.title:GetStringWidth()) | |
| 333 | |
| 334 local titleSpacing, titleSpacing2 = c.Title.Spacing, (c.Title.Spacing * 2) | |
| 335 local textSpacing, textSpacing2 = c.Text.Spacing, (c.Text.Spacing * 2) | |
| 336 | |
| 337 if block.info.isTrivial then | |
| 338 block.title:SetTextColor(0.7, 0.7, 0.7, 1) | |
| 339 elseif block.info.isComplete then | |
| 340 block.title:SetTextColor(1,1,1,1) | |
| 341 else | |
| 342 block.title:SetTextColor(0,.7,1,1) | |
| 343 end | |
| 344 block.title:SetSpacing(titleSpacing) | |
| 345 block.objectives:SetSpacing(textSpacing) | |
| 346 block.objectives:SetWordWrap(true) | |
| 347 | |
| 348 local titleHeight, textHeight = block.title:GetStringHeight(), block.objectives:GetStringHeight() + block.attachmentHeight | |
| 349 local blockHeight = titleHeight + titleSpacing2 + textHeight + textSpacing2 | |
| 350 local blockWidth = wrapperMaxWidth | |
| 351 | |
| 352 block.titlebg:SetSize(min(w1, w2), titleHeight + titleSpacing2) | |
| 353 block.bg:SetSize(w1, textHeight + textSpacing2) | |
| 354 block:SetSize(blockWidth, blockHeight) | |
| 355 | |
| 356 block.title:SetPoint('TOPLEFT', block.titlebg, 'TOPLEFT', 0, -titleSpacing) | |
| 357 block.objectives:SetPoint('TOPLEFT', block.titlebg, 'BOTTOMLEFT', textIndent, -textSpacing) | |
| 358 | |
| 359 -- store | |
| 360 block.titleHeight = titleHeight | |
| 361 block.textHeight = textHeight | |
| 362 block.width = blockWidth | |
| 363 block.height = blockHeight | |
| 364 | |
| 365 print(' |cFF00FFFF'..block:GetName()..'|r:|cFF0088FFSetStyle|r(', blockWidth, 'x', blockHeight, '(textH', textHeight,', titleH', titleHeight, ')') | |
| 366 end | |
| 367 | 202 |
| 368 local segments = {'Left', 'Right', 'Tile'} | 203 local segments = {'Left', 'Right', 'Tile'} |
| 369 mod.UpdateWrapperStyle = function() | 204 mod.UpdateWrapperStyle = function() |
| 370 local c = mod.defaults.WrapperStyle | 205 --[[for _, segment in ipairs(segments) do |
| 371 for _, segment in ipairs(segments) do | 206 local texture, a1, a2, a3, a4, width = unpack(mod.defaults.Style.Wrapper.BackgroundComplex[segment]) |
| 372 Wrapper['Background'..segment]:SetAtlas(c.Header.Background[segment]) | 207 Wrapper['Background'..segment]:SetAtlas(texture) |
| 373 Wrapper['Background'..segment]:SetTexCoord(unpack(c.Header.BackgroundCrop[segment])) | 208 Wrapper['Background'..segment]:SetTexCoord(a1, a2, a3, a4) |
| 374 if c.Header.BackgroundScale[segment] then | 209 if width then |
| 375 Wrapper['Background'..segment]:SetWidth(c.Header.BackgroundScale[segment]) | 210 Wrapper['Background'..segment]:SetWidth(width) |
| 376 end | 211 end |
| 377 end | 212 end]] |
| 378 end | 213 end |
| 379 | 214 |
| 380 --- Updates the selected block frame to display the given info batch | 215 --- Updates the selected block frame to display the given info batch |
| 381 -- If `previousBlock` is set, it will attempt to anchor to that | 216 -- If `previousBlock` is set, it will attempt to anchor to that |
| 382 -- @param blockNum the ordered block to be updated, not a watchIndex value | 217 -- @param blockNum the ordered block to be updated, not a watchIndex value |
| 383 -- @param info the reference returned by the GetXInfo functions | 218 -- @param info the reference returned by the GetXInfo functions |
| 384 -- REMEMBER: t.info and questData[questID] are the same table | 219 -- REMEMBER: t.info and questData[questID] are the same table |
| 385 mod.UpdateTrackerBlock = function (handler, blockIndex, info) | 220 mod.UpdateTrackerBlock = function (handler, blockIndex, info) |
| 221 local print = B.print('ObjectiveBlockParse') | |
| 386 print(' |cFF00FFFFUpdateTrackerBlock('..blockIndex..'|r') | 222 print(' |cFF00FFFFUpdateTrackerBlock('..blockIndex..'|r') |
| 387 if not blockIndex or not info then | 223 if not blockIndex or not info then |
| 388 return | 224 return |
| 389 end | 225 end |
| 390 | 226 |
| 227 local mainStyle = 'Normal' | |
| 228 local subStyle | |
| 391 local tracker = handler.Tracker | 229 local tracker = handler.Tracker |
| 392 | 230 |
| 393 local t = handler:GetBlock(blockIndex) | 231 local t = handler:GetBlock(blockIndex) |
| 394 if previousBlock then | 232 if previousBlock then |
| 395 if blockIndex == 1 then | 233 t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0) |
| 396 t:SetPoint('TOPLEFT', previousBlock, 'TOPLEFT', 0, -headerHeight) | |
| 397 else | |
| 398 t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0) | |
| 399 end | |
| 400 t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) | 234 t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) |
| 401 end | 235 end |
| 402 --print(t:GetName(), t:GetSize()) | 236 --print(t:GetName(), t:GetSize()) |
| 403 --print(t:GetPoint(1)) | 237 --print(t:GetPoint(1)) |
| 404 | 238 |
| 419 t:SetScript('OnMouseDown', handler.OnMouseDown) | 253 t:SetScript('OnMouseDown', handler.OnMouseDown) |
| 420 t.title:SetText(info.title) | 254 t.title:SetText(info.title) |
| 421 | 255 |
| 422 t.attachmentHeight = 0 | 256 t.attachmentHeight = 0 |
| 423 if info.isComplete then | 257 if info.isComplete then |
| 424 t.objectives:Show() | 258 t.status:Show() |
| 425 t.objectives:SetText(info.completionText) | 259 t.status:SetText(info.completionText) |
| 426 elseif info.numObjectives >= 1 then | 260 elseif info.numObjectives >= 1 then |
| 427 t.attachmentHeight = textSpacing | 261 t.attachmentHeight = textSpacing |
| 428 t.objectives:Show() | 262 t.status:Show() |
| 429 print(' - objective lines:', info.numObjectives, 'can wrap:', t.objectives:CanWordWrap()) | 263 print(' - objective lines:', info.numObjectives, 'can wrap:', t.status:CanWordWrap()) |
| 430 | 264 |
| 431 local text = '' | 265 local text = '' |
| 432 | 266 |
| 433 --- todo: implement objective displays | 267 --- todo: implement objective displays |
| 434 -- in an accumulator loop, call upon handler for the appropriate display frame, each defining: | 268 -- in an accumulator loop, call upon handler for the appropriate display frame, each defining: |
| 435 -- * height of whatever display widget is involved in conveying the task | 269 -- * height - height of whatever display widget is involved in conveying the task |
| 436 -- * number of non-wrapped text lines to account for line space; may be discarded depending on things | 270 -- * lines - number of non-wrapped text lines to account for line space; may be discarded depending on things |
| 437 -- * boolean that determines listening for money events or not | 271 -- * money - boolean that determines listening for money events or not |
| 438 t.attachmentHeight, text = mod.UpdateObjectives(t, info, text) | 272 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively |
| 439 | 273 text = mod.UpdateObjectives(t, info, text) |
| 440 t.objectives:SetText(text) | 274 |
| 441 t.objectives:SetWordWrap(true) | 275 t.status:SetText(text) |
| 442 | 276 t.status:SetWordWrap(true) |
| 443 | |
| 444 | 277 |
| 445 elseif info.description then | 278 elseif info.description then |
| 446 t.objectives:SetText(info.description) | 279 t.status:SetText(info.description) |
| 447 t.objectives:SetWordWrap(true) | 280 t.status:SetWordWrap(true) |
| 448 else | 281 else |
| 449 t.objectives:SetText(nil) | 282 t.status:SetText(nil) |
| 450 end | 283 end |
| 451 local style = 'Normal' | 284 |
| 452 if info.isComplete then | 285 if info.isComplete then |
| 453 style = 'Complete' | 286 mainStyle = 'Complete' |
| 454 elseif info.superTracked then | 287 end |
| 455 style = 'Super' | 288 if info.superTracked then |
| 289 subStyle = 'Super' | |
| 456 end | 290 end |
| 457 | 291 |
| 458 if info.specialItem and not info.itemButton then | 292 if info.specialItem and not info.itemButton then |
| 459 print(' - |cFF00FFFFgenerating item button for info set') | 293 print(' - |cFF00FFFFgenerating item button for info set') |
| 460 info.itemButton = mod.SetItemButton(t, info) | 294 info.itemButton = mod.SetItemButton(t, info) |
| 466 t.debugText:Show() | 300 t.debugText:Show() |
| 467 t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName())) | 301 t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName())) |
| 468 end | 302 end |
| 469 | 303 |
| 470 --- metrics are calculated in SetStyle | 304 --- metrics are calculated in SetStyle |
| 471 t:SetStyle(style) | 305 t:SetStyle('TrackerBlock', handler.name, mainStyle, subStyle) |
| 472 t:Show() | 306 t:Show() |
| 473 | 307 |
| 474 print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) | 308 print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) |
| 475 return t | 309 return t |
| 476 end | 310 end |
| 477 | 311 |
| 478 mod.UpdateObjectives = function(block, info, text) | 312 mod.UpdateObjectives = function(block, info, text) |
| 313 local print = B.print('ObjectiveBlockParse') | |
| 314 | |
| 479 local attachmentHeight = block.attachmentHeight | 315 local attachmentHeight = block.attachmentHeight |
| 480 if info.description then | 316 if info.description then |
| 481 print(' -- has description text:', select('#', info.description), info.description) | 317 print(' -- has description text:', select('#', info.description), info.description) |
| 482 text = info.description | 318 text = info.description |
| 483 end | 319 end |
| 320 local completionScore, completionMax = 0, 0 | |
| 484 for o, obj in ipairs(info.objectives) do | 321 for o, obj in ipairs(info.objectives) do |
| 485 --- achievement criteria | 322 --- achievement criteria |
| 486 if obj.flags then | 323 if obj.flags then |
| 487 | 324 |
| 488 | 325 |
| 498 end | 335 end |
| 499 | 336 |
| 500 print('obj.type =', obj.type) | 337 print('obj.type =', obj.type) |
| 501 print(' ** qtyStr:', obj.quantityString, 'qty:', obj.quantity, 'assetID:', obj.assetID) | 338 print(' ** qtyStr:', obj.quantityString, 'qty:', obj.quantity, 'assetID:', obj.assetID) |
| 502 obj.widget = mod.SetWidget(obj, info) | 339 obj.widget = mod.SetWidget(obj, info) |
| 340 if obj.finished then | |
| 341 obj.progress = 2 | |
| 342 elseif obj.quantity > 0 then | |
| 343 obj.progress = 1 | |
| 344 else | |
| 345 obj.progress = 0 | |
| 346 end | |
| 347 | |
| 348 | |
| 503 --- none of the above (most quests) | 349 --- none of the above (most quests) |
| 504 else | 350 else |
| 505 local line = obj.text | 351 local line = obj.text |
| 506 local color = '00FFFF' | 352 local color = '00FFFF' |
| 507 if obj.finished then | 353 if obj.finished then |
| 354 obj.progress = 2 | |
| 508 color = 'FFFFFF' | 355 color = 'FFFFFF' |
| 509 elseif obj.type == 'monster' then | 356 elseif obj.type == 'monster' then |
| 510 color = 'FFFF00' | 357 color = 'FFFF00' |
| 511 elseif obj.type == 'item' then | 358 elseif obj.type == 'item' then |
| 512 color = '44DDFF' | 359 color = '44DDFF' |
| 520 | 367 |
| 521 obj.widget:Show() | 368 obj.widget:Show() |
| 522 obj.widget:SetPoint('TOPLEFT', block.objectives, 'BOTTOMLEFT', 0, -attachmentHeight) | 369 obj.widget:SetPoint('TOPLEFT', block.objectives, 'BOTTOMLEFT', 0, -attachmentHeight) |
| 523 print('have a widget, height is', obj.widget.height) | 370 print('have a widget, height is', obj.widget.height) |
| 524 attachmentHeight = attachmentHeight + obj.widget.height | 371 attachmentHeight = attachmentHeight + obj.widget.height |
| 525 end | 372 completionScore = completionScore + obj.progress |
| 526 | 373 completionMax = completionMax + 2 |
| 527 end | 374 end |
| 528 return attachmentHeight, text | 375 |
| 376 end | |
| 377 | |
| 378 block.completionScore = completionScore / completionMax | |
| 379 block.attachmentHeight = attachmentHeight | |
| 380 | |
| 381 return text | |
| 529 end | 382 end |
| 530 | 383 |
| 531 mod.UpdateTracker = function(handler) | 384 mod.UpdateTracker = function(handler) |
| 532 print('|cFF00FF88UpdateTracker(|r|cFFFF4400' .. type(handler) .. '|r :: |cFF88FFFF' .. tostring(handler) .. '|r') | 385 print('|cFF00FF88UpdateTracker(|r|cFFFF4400' .. type(handler) .. '|r :: |cFF88FFFF' .. tostring(handler) .. '|r') |
| 533 local tracker = handler.Tracker | 386 local tracker = handler.Tracker |
| 534 local blockIndex = 0 | 387 local blockIndex = 0 |
| 535 local trackerHeight = headerHeight | 388 local trackerHeight = headerHeight |
| 536 local w = 300 | 389 local w = 300 |
| 537 | 390 |
| 538 previousBlock = handler.Tracker | 391 previousBlock = tracker.title |
| 539 local numWatched = handler.GetNumWatched() | 392 local numWatched = handler.GetNumWatched() |
| 540 local numBlocks = handler.numBlocks | 393 local numBlocks = handler.numBlocks |
| 541 local actualBlocks = 0 | 394 local actualBlocks = 0 |
| 542 for watchIndex = 1, 25 do | 395 for watchIndex = 1, 25 do |
| 543 blockIndex = blockIndex + 1 | 396 blockIndex = blockIndex + 1 |
| 544 if watchIndex <= numWatched then | 397 if watchIndex <= numWatched then |
| 545 local info = handler:GetInfo(watchIndex) | 398 local info = handler:GetInfo(watchIndex) |
| 546 if info then | 399 if info then |
| 547 local currentBlock = mod.UpdateTrackerBlock(handler, blockIndex, info) | 400 local currentBlock = mod.UpdateTrackerBlock(handler, blockIndex, info) |
| 548 previousBlock = currentBlock | 401 previousBlock = currentBlock |
| 402 print('|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height) | |
| 549 trackerHeight = trackerHeight + currentBlock.height | 403 trackerHeight = trackerHeight + currentBlock.height |
| 550 numBlocks = max(numBlocks, watchIndex) | 404 numBlocks = max(numBlocks, watchIndex) |
| 551 actualBlocks = actualBlocks + 1 | 405 actualBlocks = actualBlocks + 1 |
| 552 else | 406 else |
| 553 print('|cFFFF0000Failed to draw info for index #'..watchIndex) | 407 print('|cFFFF0000Failed to draw info for index #'..watchIndex) |
| 594 for i, handler in ipairs(orderedHandlers) do | 448 for i, handler in ipairs(orderedHandlers) do |
| 595 mod.UpdateTracker(handler) | 449 mod.UpdateTracker(handler) |
| 596 if handler.actualBlocks >= 1 then | 450 if handler.actualBlocks >= 1 then |
| 597 local tracker = handler.Tracker | 451 local tracker = handler.Tracker |
| 598 print('setting', handler.Tracker, 'to anchor to offset', -scrollHeight) | 452 print('setting', handler.Tracker, 'to anchor to offset', -scrollHeight) |
| 599 tracker:SetParent(Scroll) -- this doesn't do anything that relativeTo doesn't | 453 tracker:SetParent(Scroll) |
| 600 tracker:SetPoint('TOPLEFT', Scroll, 'TOPLEFT', 0, - scrollHeight) | 454 tracker:SetPoint('TOPLEFT', Scroll, 'TOPLEFT', 0, - scrollHeight) |
| 601 tracker:SetSize(wrapperWidth, tracker.height) | 455 tracker:SetSize(wrapperWidth, tracker.height) |
| 602 print('adding ', tracker.height) | 456 print('adding ', tracker.height) |
| 603 scrollHeight = scrollHeight + tracker.height | 457 scrollHeight = scrollHeight + tracker.height |
| 604 end | 458 end |
| 621 wrapperWidth = floor(wrapperWidth+.5) | 475 wrapperWidth = floor(wrapperWidth+.5) |
| 622 wrapperHeight = floor(wrapperHeight+.5) | 476 wrapperHeight = floor(wrapperHeight+.5) |
| 623 headerHeight = floor(headerHeight+.5) | 477 headerHeight = floor(headerHeight+.5) |
| 624 | 478 |
| 625 if wrapperBlocks >= 1 then | 479 if wrapperBlocks >= 1 then |
| 626 for i, region in ipairs(Wrapper.header) do | 480 for i, region in ipairs(Wrapper.headerComplex) do |
| 627 region:Show() | 481 region:Show() |
| 628 end | 482 end |
| 629 else | 483 else |
| 630 for i, region in ipairs(Wrapper.header) do | 484 for i, region in ipairs(Wrapper.headerComplex) do |
| 631 region:Hide() | 485 region:Hide() |
| 632 end | 486 end |
| 633 return | 487 return |
| 634 end | 488 end |
| 635 --wrapperHeight = scrollHeight | 489 --wrapperHeight = scrollHeight |
| 636 | 490 |
| 637 print('|cFFFFFF00params:|r scroller:', scrollWidth, 'x', scrollHeight) | 491 print('|cFFFFFF00params:|r scroller:', scrollWidth, 'x', scrollHeight) |
| 638 print('|cFFFFFF00params:|r scroll:', scrollWidth, 'x', scrollHeight) | 492 print('|cFFFFFF00params:|r scroll:', scrollWidth, 'x', scrollHeight) |
| 639 print('|cFFFFFF00params:|r wrapper:', wrapperWidth, 'x', wrapperHeight) | 493 print('|cFFFFFF00params:|r wrapper:', wrapperWidth, 'x', wrapperHeight) |
| 640 print('|cFFFFFF00params:|r header:', headerHeight) | 494 print('|cFFFFFF00params:|r header:', headerHeight) |
| 495 | |
| 496 mod.SetBlockStyle(Scroller, 'Scroller', 'Normal') | |
| 497 mod.SetBlockStyle(Scroller, 'Scroll', 'Normal') | |
| 498 mod.SetBlockStyle(Wrapper, 'Wrapper', 'Normal') | |
| 641 | 499 |
| 642 Scroller:SetSize(wrapperWidth, wrapperHeight) | 500 Scroller:SetSize(wrapperWidth, wrapperHeight) |
| 643 Scroller:SetPoint('TOPLEFT', Wrapper, 'TOPLEFT', 0, -headerHeight) | 501 Scroller:SetPoint('TOPLEFT', Wrapper, 'TOPLEFT', 0, -headerHeight) |
| 644 Scroller:SetPoint('BOTTOMRIGHT', Wrapper, 'BOTTOMRIGHT') | 502 Scroller:SetPoint('BOTTOMRIGHT', Wrapper, 'BOTTOMRIGHT') |
| 645 | 503 |
