View Single Post
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