Thread Tools Display Modes
09-12-13, 08:36 AM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Fake statusbar setpoint

I got a question. I will test it later but maybe someone will know the answer already.

Is this possible?
Lua Code:
  1. local bar = self.HealthBar
  2. bar.texture = bar:GetStatusBarTexture() --texture object
  3. --new fake statusbar
  4. bar.newTexture = bar:CreateTexture(nil, "BACKGROUND",nil,-6)
  5. bar.newTexture:SetAllPoints(bar.texture)
  6. bar.newTexture:SetTexture(bar.texture:GetTexture()) --texture file path
  7. bar.newTexture:SetVertexColor(0,1,1)
  8. --old statusbar texture goodbye
  9. bar.texture:SetTexture(nil)
  10. --alternative test..this may destroy the texture reference though
  11. --bar:SetStatusBarTexture(nil)

Basically I want to hide the default statusbar texture and add a new one.
But I do not want to hook the OnValueChanged event to update the setpoint.
So I thought...maybe it is possible to set the setpoints of the new texture to points of the old statusbar texture object. Sounds like it could work.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 09-12-13 at 08:45 AM.
  Reply With Quote
09-12-13, 10:11 AM   #2
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
If setting the texture to nil doesn't work, setting the alpha to 0 will.

The rest of the code should work, but it's always safe to test.
  Reply With Quote
09-12-13, 10:15 AM   #3
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Not sure, but assuming Blizzard uses GetRegion() to select the first texture maybe some funky SetParent calls on the regions that are added after the healthbar texture will push the order of the new healthbar.
  Reply With Quote
09-12-13, 11:29 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Ok it is working like I thought it would which is good. But...statusbars use SetTexCoord internally. My texture will just get shrinked down. Alright for my needs though.
Lua Code:
  1. --plate.healthbar:SetStatusBarTexture(cfg.healthbarTexture)
  2.     plate.healthbar.texture = plate.healthbar:GetStatusBarTexture()
  3.     plate.healthbar.texture:SetTexture(nil)
  4.     --new fake healthbar
  5.     plate.healthbar._texture = plate.healthbar:CreateTexture(nil, "BACKGROUND",nil,-6)
  6.     plate.healthbar._texture:SetAllPoints(plate.healthbar.texture)
  7.     plate.healthbar._texture:SetTexture(cfg.healthbarTexture) --texture file path
  8.     plate.healthbar._texture:SetVertexColor(0,1,1)
  9.     --[[
  10.     --healthbar bg test
  11.     plate.healthbar.bg = plate.healthbar:CreateTexture(nil, "BACKGROUND",nil,-6)
  12.     plate.healthbar.bg:SetAllPoints(plate.healthbar)
  13.     plate.healthbar.bg:SetTexture(1,1,1)
  14.     plate.healthbar.bg:SetVertexColor(1,0,0,0.2)
  15.     ]]--
  16.     CreateBackdrop(plate.healthbar)
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Fake statusbar setpoint


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