Thread Tools Display Modes
12-25-10, 04:09 AM   #1
Talyrius
An Onyxian Warder
 
Talyrius's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 363
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 }
  Reply With Quote
12-25-10, 06:25 AM   #2
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
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
  Reply With Quote
12-25-10, 10:14 AM   #3
Talyrius
An Onyxian Warder
 
Talyrius's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 363
Thank you. That's exactly what I needed!
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Adding an overlay to HealPrediction bars


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off