Mercurial > wow > buffalo2
comparison ObjectiveFrame.lua @ 6:589de8ea05b9
- validate tracked objects' existence by use of those handler.Info tables we made
- apply collision checking to action buttons when their corresponding entry has scrolled out
author | Nenue |
---|---|
date | Fri, 01 Apr 2016 01:30:42 -0400 |
parents | e9b61fd5f607 |
children | 5301c68f28d8 |
comparison
equal
deleted
inserted
replaced
5:e9b61fd5f607 | 6:589de8ea05b9 |
---|---|
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: map these into config table when its sorted out |
30 local itemButtonSize, itemButtonSpacing = 36, 1 | |
30 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]] |
31 local titleSize, textSize = 15, 15 | 32 local titleSize, textSize = 15, 15 |
32 local titleOutline, textOutline = "OUTLINE", "OUTLINE" | 33 local titleOutline, textOutline = "OUTLINE", "OUTLINE" |
33 local titleSpacing, textSpacing = 4, 3 | 34 local titleSpacing, textSpacing = 4, 3 |
34 local textIndent = 5 | 35 local textIndent = 5 |
44 ObjectiveTrackerParent = 'DebuffButton', | 45 ObjectiveTrackerParent = 'DebuffButton', |
45 ObjectiveTrackerSize = {250, 600}, | 46 ObjectiveTrackerSize = {250, 600}, |
46 ObjectiveWrapperParent = '', | 47 ObjectiveWrapperParent = '', |
47 WrapperStyle = { | 48 WrapperStyle = { |
48 Header = { | 49 Header = { |
49 Background = {Left = [[Objective-Header]], Right = [[Objective-Header]], Tile = [[Objective-Header]]}, | 50 Background = {Left = '', Right = '', Tile = ''}, |
50 BackgroundCrop = {Left = {0, 0.4, 0,1}, Right={0.6,1,0,1}, Tile = {0.4,.6,0,1,}}, | 51 BackgroundCrop = {Left = {0, 0.4, 0,1}, Right={0.6,1,0,1}, Tile = {0.4,.6,0,1,}}, |
51 BackgroundScale = {Left = 100, Right = 100}, | 52 BackgroundScale = {Left = 100, Right = 100}, |
52 Font = {wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline} | 53 Font = {wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline} |
53 } | 54 } |
54 }, | 55 }, |
55 ObjectiveHeaderStyle = { | 56 ObjectiveHeaderStyle = { |
56 Normal = { | 57 Normal = { |
57 Gradient = {MinColor = {0,0,0,0.5}, MaxColor = {0,0,0,.25}}, | 58 Gradient = {MinColor = {.05,.15,0.5,0.7}, MaxColor = {.05,.15,0.5,.35}}, |
58 Font = {headerFont, headerSize, headerOutline}, Spacing = headerSpacing, | 59 Font = {headerFont, headerSize, headerOutline}, Spacing = headerSpacing, |
59 } | 60 } |
60 }, | 61 }, |
61 ObjectiveTrackerStyle = { | 62 ObjectiveTrackerStyle = { |
62 Normal = { | 63 Normal = { |
63 Title = { | 64 Title = { |
64 Gradient = { MinColor = {0.2, .4, 1, 0.45}, MaxColor = {.7, 0, 0.9, 0}}, | 65 Gradient = { MinColor = {0.2, .4, 1, 0.45}, MaxColor = {.7, 0, 0.9, .19}}, |
65 Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing, | 66 Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing, |
66 }, | 67 }, |
67 Text = { | 68 Text = { |
68 Gradient = { MinColor = {0.2, .4, 1, 0.25}, MaxColor = {.7, 0, 0.9, 0}}, | 69 Gradient = { MinColor = {0.2, .4, 1, 0.25}, MaxColor = {.7, 0, 0.9, .12}}, |
69 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, | 70 Font = {textFont, textSize, textOutline}, Spacing = textSpacing, |
70 }, | 71 }, |
71 }, | 72 }, |
72 Super = { | 73 Super = { |
73 Title = { | 74 Title = { |
144 s = 0 | 145 s = 0 |
145 end | 146 end |
146 self:SetVerticalScroll(s) | 147 self:SetVerticalScroll(s) |
147 print(s, r, self:GetVerticalScroll()) | 148 print(s, r, self:GetVerticalScroll()) |
148 | 149 |
149 mod.UpdateActionButtons() | 150 mod.UpdateActionButtons('SCROLLING') |
150 end | 151 end |
151 | 152 |
152 local WrapperCloseButton_OnClick = function(self) | 153 local WrapperCloseButton_OnClick = function(self) |
153 if Scroller:IsVisible() then | 154 if Scroller:IsVisible() then |
154 Scroller:Hide() | 155 Scroller:Hide() |
203 XPBar:Hide() | 204 XPBar:Hide() |
204 return | 205 return |
205 end | 206 end |
206 | 207 |
207 --- xp bar | 208 --- xp bar |
208 XPBar:Show() | 209 XPBar:SetWidth(wrapperWidth - Wrapper.close:GetWidth()) |
209 XPBar.rested:SetTexture(2,.6,1,1) | 210 XPBar.bg:SetAllPoints(XPBar) |
210 XPBar.fg:SetTexture(.3,.1,.95,1) | 211 XPBar:RegisterEvent('DISABLE_XP_GAIN') |
211 XPBar.bg:SetTexture(0,0,0,.25) | 212 XPBar:RegisterEvent('ENABLE_XP_GAIN') |
212 XPBar:RegisterEvent('PLAYER_XP_UPDATE') | |
213 XPBar:RegisterEvent('PLAYER_LEVEL_UP') | |
214 XPBar:RegisterEvent('PLAYER_UPDATE_RESTING') | |
215 XPBar:SetScript('OnEvent', mod.UpdateXP) | 213 XPBar:SetScript('OnEvent', mod.UpdateXP) |
216 mod.UpdateXP(Wrapper.xpBar) | 214 |
217 end | 215 if not IsXPUserDisabled() then |
218 | 216 mod.EnableXP(XPBar) |
219 mod.UpdateXP = function() | 217 else |
220 local XPBar = Wrapper.XPBar | 218 mod.DisableXP(XPBar) |
221 local xp = UnitXP('player') | 219 end |
222 local xpmax = UnitXPMax('player') | 220 |
223 local rest = GetXPExhaustion() | 221 mod.UpdateXP(XPBar) |
224 | 222 end |
225 XPBar.bg:SetAllPoints(XPBar) | 223 |
226 XPBar.fg:SetWidth((xp/xpmax) * XPBar:GetWidth()) | 224 mod.EnableXP = function(self) |
227 | 225 self:RegisterEvent('PLAYER_XP_UPDATE') |
228 if IsResting() then | 226 self:RegisterEvent('PLAYER_LEVEL_UP') |
229 XPBar.bg:SetTexture(.2,.8,.2,.5) | 227 self:RegisterEvent('PLAYER_UPDATE_RESTING') |
230 else | 228 self.bg:SetTexture(0,0,0,.25) |
231 XPBar.bg:SetTexture(0,0,0,.25) | 229 self:Show() |
232 end | 230 end |
233 | 231 |
234 if rest then | 232 mod.DisableXP = function(self) |
235 XPBar.rested:ClearAllPoints() | 233 self:UnregisterEvent('PLAYER_XP_UPDATE') |
236 if xp == 0 then | 234 self:UnregisterEvent('PLAYER_LEVEL_UP') |
237 XPBar.rested:SetPoint('TOPLEFT', XPBar, 'TOPLEFT', 0, 0) | 235 self:UnregisterEvent('PLAYER_UPDATE_RESTING') |
236 self.bg:SetTexture(0.5,0.5,0.5,0.5) | |
237 self:Hide() | |
238 end | |
239 | |
240 mod.UpdateXP = function(self, event) | |
241 if event == 'DISABLE_XP_GAIN' then | |
242 mod.DisableXP(self) | |
243 elseif event == 'ENABLE_XP_GAIN' then | |
244 mod.EnableXP(self) | |
245 end | |
246 | |
247 if not IsXPUserDisabled() then | |
248 | |
249 local xp = UnitXP('player') | |
250 local xpmax = UnitXPMax('player') | |
251 local rest = GetXPExhaustion() | |
252 self.fg:SetWidth((xp/xpmax) * self:GetWidth()) | |
253 if rest then | |
254 self.rested:ClearAllPoints() | |
255 if xp == 0 then | |
256 self.rested:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0) | |
257 else | |
258 self.rested:SetPoint('TOPLEFT', self.fg, 'TOPRIGHT', 0, 0) | |
259 end | |
260 | |
261 if (xp + rest) > xpmax then | |
262 self.rested:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, 0) | |
263 else | |
264 self.rested:SetWidth((rest/xpmax) * self:GetWidth()) | |
265 end | |
266 self.rested:SetPoint('BOTTOM', self, 'BOTTOM') | |
267 self.rested:Show() | |
238 else | 268 else |
239 XPBar.rested:SetPoint('TOPLEFT', XPBar.fg, 'TOPRIGHT', 0, 0) | 269 self.rested:Hide() |
240 end | 270 end |
241 | 271 |
242 if (xp + rest) > xpmax then | 272 if IsResting() then |
243 XPBar.rested:SetPoint('BOTTOMRIGHT', XPBar, 'BOTTOMRIGHT', 0, 0) | 273 self.bg:SetTexture(.2,.8,.2,.5) |
244 else | 274 else |
245 XPBar.rested:SetWidth((rest/xpmax) * XPBar:GetWidth()) | 275 self.bg:SetTexture(0,0,0,.25) |
246 end | 276 end |
247 XPBar.rested:SetPoint('BOTTOM', XPBar, 'BOTTOM') | 277 self.xpText:SetText(xp .. '/'.. xpmax .. (rest and (' ('..tostring(rest)..')') or '')) |
248 XPBar.rested:Show() | 278 end |
249 else | |
250 XPBar.rested:Hide() | |
251 end | |
252 | |
253 XPBar.xpText:SetText(xp .. '/'.. xpmax .. (rest and (' ('..tostring(rest)..')') or '')) | |
254 end | 279 end |
255 | 280 |
256 mod.UpdateReputation = function(self) | 281 mod.UpdateReputation = function(self) |
257 end | 282 end |
258 | 283 |
411 if info.specialItem and not info.itemButton then | 436 if info.specialItem and not info.itemButton then |
412 print(' - |cFF00FFFFgenerating item button for info set') | 437 print(' - |cFF00FFFFgenerating item button for info set') |
413 info.itemButton = mod.SetItemButton(t, info) | 438 info.itemButton = mod.SetItemButton(t, info) |
414 else | 439 else |
415 --info.itemButton = nil | 440 --info.itemButton = nil |
441 end | |
442 | |
443 if Devian and Devian.InWorkspace() then | |
444 t.debugText:Show() | |
445 t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName())) | |
416 end | 446 end |
417 | 447 |
418 --- metrics are calculated in SetStyle | 448 --- metrics are calculated in SetStyle |
419 t:SetStyle(style) | 449 t:SetStyle(style) |
420 t:Show() | 450 t:Show() |
596 | 626 |
597 --Scroller:UpdateScrollChildRect() | 627 --Scroller:UpdateScrollChildRect() |
598 Wrapper:SetSize(wrapperWidth, wrapperHeight + headerHeight) | 628 Wrapper:SetSize(wrapperWidth, wrapperHeight + headerHeight) |
599 | 629 |
600 -- update action buttons | 630 -- update action buttons |
601 | 631 print('|cFF00FF00'..Scroll:GetName()..'|r:', Scroll:GetWidth(), Scroll:GetHeight(), |
602 | 632 '|cFF00FF00'..Scroller:GetName()..'|r:', Scroller:GetWidth(), Scroller:GetHeight(), |
603 print('scroll size:', Scroll:GetSize()) | 633 '|cFF00FF00'..Wrapper:GetName()..'|r:', Wrapper:GetWidth(), Wrapper:GetHeight(), |
604 print('scroller size:',Scroller:GetSize()) | 634 '|cFF0088FFvScrollRange|r:', floor(Scroller:GetVerticalScrollRange()+.5) |
605 print('wrapper size:', Wrapper:GetSize()) | 635 ) |
606 print('scroll range :', floor(Scroller:GetVerticalScrollRange()+.5)) | 636 mod.UpdateActionButtons('FULL_UPDATE') |
607 | 637 |
608 | 638 QuestPOIUpdateIcons() |
609 mod.UpdateActionButtons() | |
610 end | 639 end |
611 | 640 |
612 --- Queue any active item buttons for update for that frame | 641 --- Queue any active item buttons for update for that frame |
613 mod.UpdateActionButtons = function() | 642 mod.UpdateActionButtons = function(updateReason) |
643 Scroller.snap_upper = 0 | |
644 Scroller.snap_lower = 0 | |
645 local print = B.print('ItemButton') | |
646 if updateReason then | |
647 print = B.print('IB_'..updateReason) | |
648 end | |
649 | |
614 local previousItem | 650 local previousItem |
615 for questID, itemButton in pairs(usedButtons) do | 651 for questID, itemButton in pairs(usedButtons) do |
616 local questIndex = mod.Quest.Info[questID].questLogIndex | 652 local info= mod.Quest.Info[questID] |
653 | |
617 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName()) | 654 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName()) |
618 local block = mod.Quest.QuestBlock[questID] | 655 local block = mod.Quest.QuestBlock[questID] |
619 if block then | 656 if block then |
620 -- Dispatch the probe | 657 -- Dispatch the probe |
621 if IsQuestWatched(questIndex) then | 658 if IsQuestWatched(info.questLogIndex) then |
622 | 659 itemButton.previousItem = previousItem |
623 print(' |cFFFFFF00probing', block:GetName()) | 660 print(' |cFFFFFF00probing', block:GetName()) |
624 block:SetScript('OnUpdate', function() | 661 block:SetScript('OnUpdate', function() |
625 if block:GetBottom() and not InCombatLockdown() then | 662 if block:GetBottom() and not InCombatLockdown() then |
626 print(' '..block:GetName()..' |cFF00FF00probe hit!') | 663 print(' '..block:GetName()..' |cFF00FF00probe hit!') |
627 mod.UpdateBlockAction(block, itemButton, previousItem) | 664 mod.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope |
628 block:SetScript('OnUpdate', nil) | 665 block:SetScript('OnUpdate', nil) |
629 end | 666 end |
630 end) | 667 end) |
668 previousItem = itemButton | |
631 else | 669 else |
632 print('hidden block or unwatched quest') | 670 print('hidden block or unwatched quest') |
671 itemButton.previousItem = nil | |
633 itemButton:Hide() | 672 itemButton:Hide() |
634 end | 673 end |
635 else | 674 else |
636 print(' |cFFFF0088missing block data', itemButton:GetName()) | 675 print(' |cFFFF0088missing block data', itemButton:GetName()) |
637 end | 676 itemButton.previousItem = nil |
638 end | 677 itemButton:Hide() |
639 end | 678 end |
640 | 679 end |
641 mod.UpdateBlockAction = function (block, itemButton, previousItem) | 680 end |
681 | |
682 mod.UpdateBlockAction = function (block, itemButton) | |
642 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()') | 683 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()') |
643 if itemButton.questID ~= block.info.questID then | 684 if itemButton.questID ~= block.info.questID then |
644 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID) | 685 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID) |
645 | 686 -- something happened between this and last frame, go back and set new probes |
646 return mod.UpdateActionButtons() | 687 return mod.UpdateActionButtons() |
647 end | 688 end |
648 | 689 |
649 if block:GetBottom() < Scroller:GetBottom() then | 690 local previousItem = itemButton.previousItem |
650 print('** ',block:GetName() ,'|cFFFFFF00bottom not fully visible') | 691 local upper_bound = Scroller:GetTop() + Scroller.snap_upper |
692 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize | |
693 local point, anchor, relative | |
694 | |
695 if block:GetBottom() < lower_bound then | |
696 print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5)) | |
651 if previousItem then | 697 if previousItem then |
698 print('adjusting', previousItem:GetName()) | |
652 previousItem:ClearAllPoints() | 699 previousItem:ClearAllPoints() |
653 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, 4) | 700 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing) |
654 end | 701 end |
655 itemButton:ClearAllPoints() | 702 itemButton:ClearAllPoints() |
656 itemButton:SetPoint('BOTTOMRIGHT', UIParent, 'BOTTOMLEFT', Wrapper:GetLeft(), Wrapper:GetBottom()) | 703 itemButton.x = Wrapper:GetLeft() -4 |
704 itemButton.y = Wrapper:GetBottom() | |
705 point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT' | |
706 Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing | |
707 | |
708 elseif block:GetTop() > upper_bound then | |
709 print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5)) | |
710 itemButton:ClearAllPoints() | |
711 if previousItem then | |
712 print('latch onto another piece') | |
713 point, anchor, relative ='TOP', previousItem, 'BOTTOM' | |
714 itemButton.x = 0 | |
715 itemButton.y = -itemButtonSpacing | |
716 else | |
717 print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop()) | |
718 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT' | |
719 itemButton.x = Scroller:GetLeft() -4 | |
720 itemButton.y = Scroller:GetTop() | |
721 end | |
657 itemButton:Show() | 722 itemButton:Show() |
658 else | 723 Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing) |
659 print('** ',block:GetName() ,'|cFF00FF00visible positions') | 724 else |
725 print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5)) | |
660 itemButton:ClearAllPoints() | 726 itemButton:ClearAllPoints() |
661 itemButton:SetPoint('TOPRIGHT', UIParent, 'BOTTOMLEFT', block:GetLeft(), block:GetTop()) | 727 itemButton.x = block:GetLeft() - itemButtonSpacing |
662 itemButton:Show() | 728 itemButton.y = block:GetTop() |
663 end | 729 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT' |
730 end | |
731 | |
732 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y) | |
733 itemButton:Show() | |
664 end | 734 end |
665 | 735 |
666 mod.UpdateItemButtonCooldown = function(button) | 736 mod.UpdateItemButtonCooldown = function(button) |
667 | 737 |
668 end | 738 end |