WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Adding an overlay to HealPrediction bars (https://www.wowinterface.com/forums/showthread.php?t=37893)

Talyrius 12-25-10 04:09 AM

Adding an overlay to HealPrediction bars
 
Merry Christmas, everyone!

I'm experiencing some complications by adding a one pixel wide overlay to the edge of the heal prediction bars. It works as expected, but the problem is they still display even when the heal prediction bars aren't visible (zero width).

Does anyone have any suggestions on how I should go about fixing this? Perhaps I need to use a Pre/PostUpdate or something? A code example would be helpful.

Thank you.

The code pertaining to my question:
lua Code:
  1. ------------------------------
  2. -- Element: Heal Prediction --
  3. ------------------------------
  4.  
  5. local mhpb = ns.CreateStatusBar(self.Health)
  6. mhpb:SetPoint('TOPLEFT', self.Health:GetStatusBarTexture(), 'TOPRIGHT', 0, 0)
  7. mhpb:SetPoint('BOTTOMLEFT', self.Health:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0)
  8. mhpb:SetWidth(self.Health:GetWidth())
  9. mhpb:SetStatusBarColor(0, 1, 0.5, 0.4)
  10. mhpb.bg:ClearAllPoints()
  11. mhpb.bg:SetTexture("")
  12. mhpb.bg:Hide()
  13. mhpb.bg = nil
  14. mhpb.spacer = mhpb:CreateTexture(nil, "OVERLAY")
  15. mhpb.spacer:SetTexture([[Interface\Buttons\WHITE8x8]])
  16. mhpb.spacer:SetPoint('TOPLEFT', mhpb:GetStatusBarTexture(), 'TOPRIGHT', -1, 0)
  17. mhpb.spacer:SetPoint('BOTTOMLEFT', mhpb:GetStatusBarTexture(), 'BOTTOMRIGHT', -1, 0)
  18. mhpb.spacer:SetVertexColor(0, 0, 0)
  19. mhpb.spacer:SetWidth(1)
  20.  
  21. local ohpb = ns.CreateStatusBar(self.Health)
  22. ohpb:SetPoint('TOPLEFT', mhpb:GetStatusBarTexture(), 'TOPRIGHT', 0, 0)
  23. ohpb:SetPoint('BOTTOMLEFT', mhpb:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0)
  24. ohpb:SetWidth(self.Health:GetWidth())
  25. ohpb:SetStatusBarColor(0, 1, 0, 0.4)
  26. ohpb.bg:ClearAllPoints()
  27. ohpb.bg:SetTexture("")
  28. ohpb.bg:Hide()
  29. ohpb.bg = nil
  30. ohpb.spacer = ohpb:CreateTexture(nil, "OVERLAY")
  31. ohpb.spacer:SetTexture([[Interface\Buttons\WHITE8x8]])
  32. ohpb.spacer:SetPoint('TOPLEFT', ohpb:GetStatusBarTexture(), 'TOPRIGHT', -1, 0)
  33. ohpb.spacer:SetPoint('BOTTOMLEFT', ohpb:GetStatusBarTexture(), 'BOTTOMRIGHT', -1, 0)
  34. ohpb.spacer:SetVertexColor(0, 0, 0)
  35. ohpb.spacer:SetWidth(1)
  36.  
  37. self.HealPrediction = { myBar = mhpb, otherBar = ohpb, maxOverflow = 1 }

yj589794 12-25-10 06:25 AM

The heal prediction bars are always displayed, it is just that they may be of zero width and therefore not actually visible. If you add an overlay, then that too will always be visible.

You will need to add in a PostUpdate() routine to show/hide the heal prediction bars, and all child elements, dependant upon the incoming heal values.

e.g.
Code:

self.HealPrediction.PostUpdate = function(element, unit)
        -- set visibility on incoming heals I cast
        if(element.myBar:GetValue() > 0) then
                element.myBar:Show()
        else
                element.myBar:Hide()
        end

        -- set visibility on incoming heals other people cast
        if(element.otherBar:GetValue() > 0) then
                element.otherBar:Show()
        else
                element.otherBar:Hide()
        end
end

The above is untested, but should be similar to what you want.


Merry Christmas

Talyrius 12-25-10 10:14 AM

Thank you. That's exactly what I needed!


All times are GMT -6. The time now is 01:29 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI