Thread Tools Display Modes
11-25-10, 10:34 AM   #1
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Hud status bar questions.

Okay so i have been fiddling around and i can not for the life of me figure out how it is people get status bars that are not just straight. Like IceHud and DHUD. Someone point me in the right direction? I tried things like using setmask and simple setstatus bar textures with my status bar masks but they dont fill the way you would think... the texture appears to grow rather then "fill" the background texture.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
11-25-10, 11:30 AM   #2
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Try to use

yourbar:GetStatusBarTexture():SetHorizTile(true / false)

While you can set it to true or false. True should work, iirc.

And you need a texture with an alpha channel or a transparent blp, ofc.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
11-25-10, 12:44 PM   #3
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
is there a setvertictile to?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
11-25-10, 01:03 PM   #4
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Hmm i think i need to use the animation system for what im after...
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
11-25-10, 01:33 PM   #5
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Yes that works for vertical, too.

Texture:SetVertTile()
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
11-25-10, 01:40 PM   #6
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
its still not working like it should. If you have a curved background and you want it to look like it fills up how do you do that?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
11-25-10, 01:46 PM   #7
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
I have to use the animation system stuff from the looks of all the other huds. Anyone know of any good tutorials on that stuff?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
11-25-10, 02:57 PM   #8
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
I've been working on my own HUD addon system and honestly, it's a clever combination of setting the right anchor point depending on the direction the bar fills, texcoords, and texture resizing. In the end, you have the illusion of a statusbar of your own design.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
11-25-10, 03:43 PM   #9
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Is that how things like the dragon skinned hud bars are done to? So its not the anim system?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
11-25-10, 07:46 PM   #10
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
That's how I've always done it. I honestly can't think of a way the animation system can be used to do the same thing. It technically isn't an animation at all. It's two textures sharing a base point and you use texcoord/resizing on the overlaying texture. If you use a greyscale image, you can use texture:SetVertexColor() on the overlay texture to set its color.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
11-25-10, 08:09 PM   #11
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by SDPhantom View Post
That's how I've always done it. I honestly can't think of a way the animation system can be used to do the same thing. It technically isn't an animation at all. It's two textures sharing a base point and you use texcoord/resizing on the overlaying texture. If you use a greyscale image, you can use texture:SetVertexColor() on the overlay texture to set its color.
So you do not do SetStatusBarTexture? because as far as i can tell when you set it via that method the setvertex do not work on it. So make a regular texture and then just make it setvertex and resize according to the health/mana values?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
11-25-10, 08:34 PM   #12
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Nope, StatusBars are great for beginners, but when you want precise control of how your textures are drawn or if you want multiple or partial bars, managing the textures yourself is pretty much the only thing you have left.

StatusBars stretch their bar texture to the size of the bar, it doesn't offer the "cut away" look that's required for more elegant bar art. If you're set on using StatusBars, the method for colors on that is statusbar:SetBarColor().
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 11-25-10 at 08:37 PM.
  Reply With Quote
11-25-10, 11:41 PM   #13
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by SDPhantom View Post
Nope, StatusBars are great for beginners, but when you want precise control of how your textures are drawn or if you want multiple or partial bars, managing the textures yourself is pretty much the only thing you have left.

StatusBars stretch their bar texture to the size of the bar, it doesn't offer the "cut away" look that's required for more elegant bar art. If you're set on using StatusBars, the method for colors on that is statusbar:SetBarColor().
Okay so that answers my question. Forget the setstatus bar part. Now to figure out how to adjust using sizing and texcords.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
11-26-10, 07:06 AM   #14
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Here's an example of some some code that I've used in my HUD addons. I've made a couple that haven't made it to release phase due to laziness or I abandoned it in mid-project (both happen a lot ). This was rewritten from scratch, but it follows the same idea. I haven't run it through the game client, so there might be some glitches. I don't have access to an active WoW account right now.

lua Code:
  1. local frame=CreateFrame("Frame",nil,UIParent);
  2. frame:SetPoint("CENTER");-- Place frame wherever
  3. frame:SetWidth(128);--      Width
  4. frame:SetHeight(16);--      Height
  5. --  Note: It's generally a good idea to use the same dimensions as your image file for your frame size
  6.  
  7. --  Background texture
  8. frame.Background=frame:CreateTexture(nil,"BACKGROUND");
  9. frame.Background:SetAllPoints(frame);--                     We want the texture spread to match the dimensions of the frame.
  10. frame.Background:SetTexture("Interface\\AddOns\\AddOnName\\ImageName");--   Your bar image
  11. frame.Background:SetVertexColor(0,0,0,0.25)--                   Special suprize (black background at a quarter alpha)
  12.  
  13. --  Health texture
  14. frame.HealthBar=frame:CreateTexture(nil,"ARTWORK");--               Notice the change in layers, this makes the bar draw on top of the background
  15. frame.HealthBar:SetPoint("LEFT");--                     We need only one point set, in this example, the bar fills toward the right, so we need it left-aligned
  16. frame.HealthBar:SetWidth(128);--                        Match frame width for now
  17. frame.HealthBar:SetHeight(16);--                        Match frame height for now
  18. frame.HealthBar:SetTexture("Interface\\AddOns\\AddOnName\\ImageName");--    Be sure to use the same image or one derived from the background
  19.  
  20. --  Heal prediction texture (this'll be my example of a partial bar)
  21. frame.HealBar=frame:CreateTexture(nil,"ARTWORK");--         Use the same layer as Healthbar
  22. frame.HealBar:SetPoint("LEFT");--                   Use the same point for the HealthBar
  23. frame.HealthBar:SetWidth(128);--                    Match frame width for now
  24. frame.HealthBar:SetHeight(16);--                    Match frame height for now
  25. frame.HealBar:SetTexture("Interface\\AddOns\\AddOnName\\ImageName");--  Be sure to use the same image or one derived from the background
  26.  
  27. --  Bar positioning func
  28. local function SetBarValue(bar,val1,val2)-- Accepts 3 values, bar texture, start value, and end value
  29. --  Keep the values within a 0-1 range
  30.     val1=math.min(math.max(val1,0),1);
  31.     val2=math.min(math.max(val2,0),1);
  32.  
  33. --  Sometimes textures glitch when trying to set a width or height of 0, so handle it here
  34.     if val1==val2 then
  35.         bar:Hide();
  36.         return;
  37.     else
  38.         bar:Show();
  39.     end
  40.  
  41. --  Set our low and high values
  42.     local low,high=math.min(val1,val2),math.max(val1,val2);
  43.  
  44. --  Find our parent width and height
  45.     local parent=bar:GetParent();
  46.     local w,h=parent:GetWidth(),parent:GetHeight();
  47.  
  48. --  Get our point set, we'll use this to get our bar orientation
  49.     local point=bar:GetPoint(1);
  50.     if not point then return; end-- Handle if point isn't set, perhaps cleared?
  51.  
  52. --  These are our temp origin variables (note one of these pairs can have both vars nil, just use default texcoords for those)
  53.     local origL=point:find("LEFT$");
  54.     local origR=point:find("RIGHT$");
  55.     local origT=point:find("^TOP");
  56.     local origB=point:find("^BOTTOM");
  57.  
  58. --  Reset point (logic nightmare)
  59.     bar:SetPoint(point
  60.         ,(origL or origR) and (origL and low*w or -low*w) or 0--    X offset
  61.         ,(origT or origB) and (origB and low*h or -low*h) or 0--    Y offset
  62.     );
  63.  
  64. --  Texcoord/Size set (this is actually the easy part)
  65.     local l,r,t,b=0,1,0,1;--    Texcoords are in the range of 0-1 with their origin at top left
  66.     if origL then
  67.         l,r=high,low;
  68.     elseif origR then
  69.         l,r=1-high,1-low;
  70.     end
  71.     if origT then
  72.         t,b=high,low;
  73.     elseif origB then
  74.         t,b=1-high,1-low;
  75.     end
  76.     bar:SetTexCoord(l,r,t,b);
  77.     bar:SetWidth(w*(r-l));
  78.     bar:SetHeight(h*(b-t));
  79. end
  80.  
  81. frame:RegisterEvent("UNIT_HEALTH");
  82. frame:RegisterEvent("UNIT_HEALTH_PREDICTION");
  83. frame:SetScript("OnEvent",function(self,event,unit)
  84. --  Stop handler if unit not player
  85.     if not UnitIsUnit(unit,"player") then return; end
  86.  
  87. --  Temp vars
  88.     local hcur,hmax,heal=UnitHealth(unit),UnitHealthMax(unit),UnitGetIncomingHeals(unit) or 0;--    UnitGetIncomingHeals() can return nil for unsupported units
  89.     local hppcnt=hcur/math.max(1,hmax);
  90.     local healpcnt=heal/math.max(1,hmax);
  91.  
  92. --  Set our bars (notice the HealBar is a partial bar since it has a start value greater than zero)
  93.     SetBarValue(self.HealthBar,0,hppcnt);
  94.     SetBarValue(self.HealBar,hppcnt,hppcnt+healpcnt);
  95.  
  96. --  Color HealthBar (we're keeping HealBar white)
  97. --  This color formula has been reused from my HUD projects, it ranges in color from green, to yellow, to red
  98.     self.HealthBar:SetVertexColor(math.min(2-2*hppcnt,1),math.min(2*hppcnt,1),0);
  99. end
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 11-27-10 at 10:40 PM.
  Reply With Quote
11-27-10, 05:41 PM   #15
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
need to add something to the function for bars that show up on the opposite side. Maybe another variable to check if its a left oriented bar or right oriented bar.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
11-27-10, 07:46 PM   #16
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Originally Posted by Grimsin View Post
need to add something to the function for bars that show up on the opposite side. Maybe another variable to check if its a left oriented bar or right oriented bar.
The function does this automatically by checking the point set, an experimental feature I haven't used before, but theoretically should work. To switch to right-aligned, change the bar points to RIGHT instead of LEFT. You can also do TOP or BOTTOM for vertical bars or any corner for diagonal orientation.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
11-27-10, 09:27 PM   #17
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by SDPhantom View Post
The function does this automatically by checking the point set, an experimental feature I haven't used before, but theoretically should work. To switch to right-aligned, change the bar points to RIGHT instead of LEFT. You can also do TOP or BOTTOM for vertical bars or any corner for diagonal orientation.

Those points dictate what direction the bar fills to not what direction the texture sits. I need to switch the texcoords on the right side... Also it does not understand diagonal points like BOTTOMLEFT or TOPLEFT so on and so forth. Or at lest... because all it does is dictate the bar growth direction you do not notice any difference when setting a diagonal point. I need the bar fill texture to actually flop over IE SetTexCoords(1,0,0,1) but because it uses the texcoords for the bar fill its an issue. There is a way i know that im just not sure how.

i have texture A which looks like ( well rather then make another texture that looks like ) i want to swap the texcords on A so it sites like ) instead of (
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
11-27-10, 10:09 PM   #18
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Ah, I had forgotten about that aspect, I edited the code above with the fix.
Texture coordinate block changed starting at line 65.
Note, I'm unable to debug the impact of the formula change right now, but I would suggest manually setting the texcoord of the background texture to match the bar flip.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 11-27-10 at 10:13 PM.
  Reply With Quote
11-27-10, 10:26 PM   #19
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
that did not work either... and that would mess up the bars set on the left side. it needs to look more like this... the big question is... the key line at 53 needs to read different i have tried a number of combination's none place it right.


lua Code:
  1. function addon:SetBarValue(bar,val1,val2, setR)-- Accepts 3 values, bar texture, start value, and end value
  2.     --  Keep the values within a 0-1 range
  3.     val1=math.min(math.max(val1,0),1);
  4.     val2=math.min(math.max(val2,0),1);
  5.     --  Sometimes textures glitch when trying to set a width or height of 0, so handle it here
  6.     if val1==val2 then
  7.         bar:Hide();
  8.         return;
  9.     else
  10.         bar:Show();
  11.     end
  12.  
  13.     --  Set our low and high values
  14.     local low,high=math.min(val1,val2),math.max(val1,val2);
  15.     --  Find our parent width and height
  16.     local parent=bar:GetParent();
  17.     local w,h=parent:GetWidth(),parent:GetHeight();
  18.     --  Get our point set, we'll use this to get our bar orientation
  19.     local point=bar:GetPoint(1);
  20.     if not point then return; end-- Handle if point isn't set, perhaps cleared?
  21.     --  These are our temp origin variables (note one of these pairs can have both vars nil, just use default texcoords for those)
  22.     local origL=point:find("LEFT$");
  23.     local origR=point:find("RIGHT$");
  24.     local origT=point:find("^TOP");
  25.     local origB=point:find("^BOTTOM");
  26.     --  Reset point (logic nightmare)
  27.     bar:SetPoint(point
  28.         ,(origL or origR) and (origL and low*w or -low*w) or 0--    X offset
  29.         ,(origT or origB) and (origB and low*h or -low*h) or 0--    Y offset
  30.     );
  31.     local l,r,t,b
  32.     --  Texcoord/Size set (this is actually the easy part)
  33.     if setR == false then
  34.         l,r,t,b = 0,1,0,1;--    Texcoords are in the range of 0-1 with their origin at top left
  35.     elseif setR == true then
  36.         l,r,t,b = 1,0,0,1;
  37.     end
  38.     if origL then
  39.         l,r = low,high;
  40.     elseif origR then
  41.         l,r = 1-high,1-low;
  42.     end
  43.     if setR == false then
  44.         if origT then
  45.             t,b = low,high;
  46.         elseif origB then
  47.             t,b = 1-high,1-low;
  48.         end
  49.     elseif setR == true then
  50.         if origT then
  51.             t,b = low,high;
  52.         elseif origB then
  53.             t,b = low, high;
  54.         end
  55.     end
  56.    
  57.    
  58.     bar:SetTexCoord(l,r,t,b);
  59.    
  60.         --bar:SetTexCoord(1,r,t,b);
  61.    
  62.     bar:SetWidth(w*(r-l));
  63.     bar:SetHeight(h*(b-t));
  64. end
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
11-27-10, 10:44 PM   #20
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Heh... swapped the wrong values in my previous fix. Should be corrected now. The aim of the experimental code is to make storing orientation obsolete since it could be derived from the point set. The texture flip was intended to be in the design from the start, but my original formulas were glitched.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 11-27-10 at 10:46 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Hud status bar questions.

Thread Tools
Display Modes

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