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:
function addon:SetBarValue(bar,val1,val2, setR)-- Accepts 3 values, bar texture, start value, and end value
-- Keep the values within a 0-1 range
val1=math.min(math.max(val1,0),1);
val2=math.min(math.max(val2,0),1);
-- Sometimes textures glitch when trying to set a width or height of 0, so handle it here
if val1==val2 then
bar:Hide();
return;
else
bar:Show();
end
-- Set our low and high values
local low,high=math.min(val1,val2),math.max(val1,val2);
-- Find our parent width and height
local parent=bar:GetParent();
local w,h=parent:GetWidth(),parent:GetHeight();
-- Get our point set, we'll use this to get our bar orientation
local point=bar:GetPoint(1);
if not point then return; end-- Handle if point isn't set, perhaps cleared?
-- These are our temp origin variables (note one of these pairs can have both vars nil, just use default texcoords for those)
local origL=point:find("LEFT$");
local origR=point:find("RIGHT$");
local origT=point:find("^TOP");
local origB=point:find("^BOTTOM");
-- Reset point (logic nightmare)
bar:SetPoint(point
,(origL or origR) and (origL and low*w or -low*w) or 0-- X offset
,(origT or origB) and (origB and low*h or -low*h) or 0-- Y offset
);
local l,r,t,b
-- Texcoord/Size set (this is actually the easy part)
if setR == false then
l,r,t,b = 0,1,0,1;-- Texcoords are in the range of 0-1 with their origin at top left
elseif setR == true then
l,r,t,b = 1,0,0,1;
end
if origL then
l,r = low,high;
elseif origR then
l,r = 1-high,1-low;
end
if setR == false then
if origT then
t,b = low,high;
elseif origB then
t,b = 1-high,1-low;
end
elseif setR == true then
if origT then
t,b = low,high;
elseif origB then
t,b = low, high;
end
end
bar:SetTexCoord(l,r,t,b);
--bar:SetTexCoord(1,r,t,b);
bar:SetWidth(w*(r-l));
bar:SetHeight(h*(b-t));
end