Mercurial > wow > buffalo2
comparison ObjectiveFrame.lua @ 7:5301c68f28d8
TrackerBlock
- use IsModifiedClick function to determine appropriate OnClick actions
- handle 'CHATLINK' modifier
- handle 'TOGGLEQUESTWATCH' modifier
TrackerBlockObjectives
- use a generic framework to manage frame creation for various criteria tracker types:
- ProgressBar when Blizzard flag data indicates so
- skip when Blizzard flag data indicates so
- DynamicText otherwise
- events related to the criteria are registered in the criteria frame, and unregistered when the frame is hidden, either by destruction of its parent or completion
| author | Nenue |
|---|---|
| date | Fri, 01 Apr 2016 12:27:05 -0400 |
| parents | 589de8ea05b9 |
| children | 7923243ae972 |
comparison
equal
deleted
inserted
replaced
| 6:589de8ea05b9 | 7:5301c68f28d8 |
|---|---|
| 81 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, | 81 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, |
| 82 }, | 82 }, |
| 83 }, | 83 }, |
| 84 Active = { | 84 Active = { |
| 85 Title = { | 85 Title = { |
| 86 Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, 1}, }, | 86 Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, .4}, }, |
| 87 Font = {titleFont, titleSize, titleOutline}, | 87 Font = {titleFont, titleSize, titleOutline}, |
| 88 Spacing = titleSpacing, | 88 Spacing = titleSpacing, |
| 89 BackgroundFullWidth = true | 89 BackgroundFullWidth = true |
| 90 }, | 90 }, |
| 91 Text = { | 91 Text = { |
| 92 Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, 1}, }, | 92 Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, .2}, }, |
| 93 Font = {textFont, textSize, textOutline}, | 93 Font = {textFont, textSize, textOutline}, |
| 94 Spacing = textSpacing, | 94 Spacing = textSpacing, |
| 95 BackgroundFullWidth = true | 95 BackgroundFullWidth = true |
| 96 } | 96 } |
| 97 }, | 97 }, |
| 105 Gradient = { MinColor = {0, 1, 0, .25}, MaxColor = {0, 1, 0, 0.12}, }, | 105 Gradient = { MinColor = {0, 1, 0, .25}, MaxColor = {0, 1, 0, 0.12}, }, |
| 106 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, | 106 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, |
| 107 BackgroundFullWidth = true | 107 BackgroundFullWidth = true |
| 108 } | 108 } |
| 109 }, | 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 } | |
| 110 } | 132 } |
| 111 } | 133 } |
| 112 | 134 |
| 113 local FontBank = { | 135 local FontBank = { |
| 114 ['Normal'] = VeneerCriteriaFontNormal, | 136 ['Normal'] = VeneerCriteriaFontNormal, |
| 135 end | 157 end |
| 136 end | 158 end |
| 137 | 159 |
| 138 local Scroller_OnMouseWheel = function(self, delta) | 160 local Scroller_OnMouseWheel = function(self, delta) |
| 139 local r = Scroll:GetHeight() - Scroller:GetHeight() | 161 local r = Scroll:GetHeight() - Scroller:GetHeight() |
| 140 local s = self:GetVerticalScroll() - delta * floor(r/5+.5) | 162 local s = B.Conf.ObjectiveScroll - delta * floor(r/5+.5) |
| 163 local from = self:GetVerticalScroll() | |
| 141 if r == 0 then return end | 164 if r == 0 then return end |
| 142 if s >= r then | 165 if s >= r then |
| 143 s = r | 166 s = r |
| 144 elseif s < 1 then | 167 elseif s < 1 then |
| 145 s = 0 | 168 s = 0 |
| 146 end | 169 end |
| 147 self:SetVerticalScroll(s) | 170 self:SetVerticalScroll(s) |
| 148 print(s, r, self:GetVerticalScroll()) | 171 B.Conf.ObjectiveScroll = s |
| 172 print('|cFF00FF00OnMouseWheel', 'from = ', from, 'scroll =', s, ' range =', r, 'current =', self:GetVerticalScroll()) | |
| 149 | 173 |
| 150 mod.UpdateActionButtons('SCROLLING') | 174 mod.UpdateActionButtons('SCROLLING') |
| 151 end | 175 end |
| 152 | 176 |
| 153 local WrapperCloseButton_OnClick = function(self) | 177 local WrapperCloseButton_OnClick = function(self) |
| 320 end | 344 end |
| 321 block.title:SetSpacing(titleSpacing) | 345 block.title:SetSpacing(titleSpacing) |
| 322 block.objectives:SetSpacing(textSpacing) | 346 block.objectives:SetSpacing(textSpacing) |
| 323 block.objectives:SetWordWrap(true) | 347 block.objectives:SetWordWrap(true) |
| 324 | 348 |
| 325 local titleHeight, textHeight = block.title:GetStringHeight(), block.objectives:GetStringHeight() | 349 local titleHeight, textHeight = block.title:GetStringHeight(), block.objectives:GetStringHeight() + block.attachmentHeight |
| 326 local blockHeight = titleHeight + titleSpacing2 + textHeight + textSpacing2 | 350 local blockHeight = titleHeight + titleSpacing2 + textHeight + textSpacing2 |
| 327 local blockWidth = wrapperMaxWidth | 351 local blockWidth = wrapperMaxWidth |
| 328 | 352 |
| 329 block.titlebg:SetSize(min(w1, w2), titleHeight + titleSpacing2) | 353 block.titlebg:SetSize(min(w1, w2), titleHeight + titleSpacing2) |
| 330 block.bg:SetSize(w1, textHeight + textSpacing2) | 354 block.bg:SetSize(w1, textHeight + textSpacing2) |
| 385 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = t end | 409 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = t end |
| 386 if info.watchIndex then handler.WatchBlock[info.watchIndex] = t end | 410 if info.watchIndex then handler.WatchBlock[info.watchIndex] = t end |
| 387 | 411 |
| 388 info.blockIndex = blockIndex | 412 info.blockIndex = blockIndex |
| 389 handler.BlockInfo[blockIndex] = info | 413 handler.BlockInfo[blockIndex] = info |
| 414 | |
| 390 t.Select = handler.Select | 415 t.Select = handler.Select |
| 391 t.Open = handler.Open | 416 t.Open = handler.Open |
| 392 t.Remove = handler.Remove | 417 t.Remove = handler.Remove |
| 393 t.Link = handler.Link | 418 t.Link = handler.Link |
| 394 t:SetScript('OnMouseUp', handler.OnMouseUp) | 419 t:SetScript('OnMouseUp', handler.OnMouseUp) |
| 395 t:SetScript('OnMouseDown', handler.OnMouseDown) | 420 t:SetScript('OnMouseDown', handler.OnMouseDown) |
| 396 t.title:SetText(info.title) | 421 t.title:SetText(info.title) |
| 397 | 422 |
| 423 t.attachmentHeight = 0 | |
| 398 if info.isComplete then | 424 if info.isComplete then |
| 399 t.objectives:Show() | 425 t.objectives:Show() |
| 400 t.objectives:SetText(info.completionText) | 426 t.objectives:SetText(info.completionText) |
| 401 elseif info.numObjectives >= 1 then | 427 elseif info.numObjectives >= 1 then |
| 428 t.attachmentHeight = textSpacing | |
| 402 t.objectives:Show() | 429 t.objectives:Show() |
| 403 print(' - objective lines:', info.numObjectives, 'can wrap:', t.objectives:CanWordWrap()) | 430 print(' - objective lines:', info.numObjectives, 'can wrap:', t.objectives:CanWordWrap()) |
| 404 | 431 |
| 405 local text = '' | 432 local text = '' |
| 406 if info.description then | |
| 407 print(' -- has description text:', select('#', info.description), info.description) | |
| 408 text = info.description | |
| 409 end | |
| 410 | 433 |
| 411 --- todo: implement objective displays | 434 --- todo: implement objective displays |
| 412 -- in an accumulator loop, call upon handler for the appropriate display frame, each defining: | 435 -- in an accumulator loop, call upon handler for the appropriate display frame, each defining: |
| 413 -- * height of whatever display widget is involved in conveying the task | 436 -- * height of whatever display widget is involved in conveying the task |
| 414 -- * number of non-wrapped text lines to account for line space; may be discarded depending on things | 437 -- * number of non-wrapped text lines to account for line space; may be discarded depending on things |
| 452 print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) | 475 print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) |
| 453 return t | 476 return t |
| 454 end | 477 end |
| 455 | 478 |
| 456 mod.UpdateObjectives = function(block, info, text) | 479 mod.UpdateObjectives = function(block, info, text) |
| 457 local attachmentHeight = 0 | 480 local attachmentHeight = block.attachmentHeight |
| 481 if info.description then | |
| 482 print(' -- has description text:', select('#', info.description), info.description) | |
| 483 text = info.description | |
| 484 end | |
| 458 for o, obj in ipairs(info.objectives) do | 485 for o, obj in ipairs(info.objectives) do |
| 459 --- achievement criteria | 486 --- achievement criteria |
| 460 if obj.flags then | 487 if obj.flags then |
| 461 | 488 |
| 462 | 489 |
| 463 if bit.band(obj.flags, 0x00000001) > 0 then | 490 if bit.band(obj.flags, 0x00000001) > 0 then |
| 464 obj.type = 'ProgressBar' | 491 obj.type = 'ProgressBar' |
| 465 obj.widget = mod.SetWidget(obj, info) | |
| 466 elseif bit.band(obj.flags, 0x00000002) then | 492 elseif bit.band(obj.flags, 0x00000002) then |
| 467 obj.type = 'Hidden' | 493 obj.type = 'Hidden' |
| 468 obj.widget = nil | 494 obj.widget = nil |
| 469 else | 495 else |
| 470 obj.type = 'Text' | 496 obj.type = 'Text' |
| 471 obj.widget = nil | 497 obj.widget = nil |
| 472 text = text .. ((text == '') and "" or "\n") .. obj.text | 498 text = text .. ((text == '') and "" or "\n") .. obj.text |
| 473 end | 499 end |
| 474 | 500 |
| 475 print(obj.type, obj.text, obj.quantityString) | 501 print('obj.type =', obj.type) |
| 502 print(' ** qtyStr:', obj.quantityString, 'qty:', obj.quantity, 'assetID:', obj.assetID) | |
| 503 obj.widget = mod.SetWidget(obj, info) | |
| 476 --- none of the above (most quests) | 504 --- none of the above (most quests) |
| 477 else | 505 else |
| 478 local line = obj.text | 506 local line = obj.text |
| 479 local color = '00FFFF' | 507 local color = '00FFFF' |
| 480 if obj.finished then | 508 if obj.finished then |
| 488 end | 516 end |
| 489 text = text .. ((text == '') and "" or "\n") .. '|cFF'..color.. line .. '|r' | 517 text = text .. ((text == '') and "" or "\n") .. '|cFF'..color.. line .. '|r' |
| 490 end | 518 end |
| 491 | 519 |
| 492 if obj.widget then | 520 if obj.widget then |
| 521 | |
| 522 obj.widget:Show() | |
| 523 obj.widget:SetPoint('TOPLEFT', block.objectives, 'BOTTOMLEFT', 0, -attachmentHeight) | |
| 524 print('have a widget, height is', obj.widget.height) | |
| 493 attachmentHeight = attachmentHeight + obj.widget.height | 525 attachmentHeight = attachmentHeight + obj.widget.height |
| 494 end | 526 end |
| 495 | 527 |
| 496 end | 528 end |
| 497 return attachmentHeight, text | 529 return attachmentHeight, text |
| 618 | 650 |
| 619 Scroller:SetSize(wrapperWidth, wrapperHeight) | 651 Scroller:SetSize(wrapperWidth, wrapperHeight) |
| 620 Scroller:SetPoint('TOPLEFT', Wrapper, 'TOPLEFT', 0, -headerHeight) | 652 Scroller:SetPoint('TOPLEFT', Wrapper, 'TOPLEFT', 0, -headerHeight) |
| 621 Scroller:SetPoint('BOTTOMRIGHT', Wrapper, 'BOTTOMRIGHT') | 653 Scroller:SetPoint('BOTTOMRIGHT', Wrapper, 'BOTTOMRIGHT') |
| 622 | 654 |
| 655 | |
| 623 Scroll:SetSize(scrollWidth, scrollHeight) | 656 Scroll:SetSize(scrollWidth, scrollHeight) |
| 624 Scroll:SetPoint('TOPLEFT', Scroller, 'TOPLEFT', 0, 0) | 657 Scroll:SetPoint('TOPLEFT', Scroller, 'TOPLEFT', 0, B.Conf.ObjectiveScroll or 0) |
| 625 Scroll:SetPoint('RIGHT', Scroller, 'RIGHT') | 658 Scroll:SetPoint('RIGHT', Scroller, 'RIGHT') |
| 626 | 659 |
| 627 --Scroller:UpdateScrollChildRect() | 660 --Scroller:UpdateScrollChildRect() |
| 628 Wrapper:SetSize(wrapperWidth, wrapperHeight + headerHeight) | 661 Wrapper:SetSize(wrapperWidth, wrapperHeight + headerHeight) |
| 629 | 662 |
