<!-- Slider Template -->
<Slider name = "PowaBarSliderTemplate" orientation = "HORIZONTAL" virtual = "true" enableMouse = "true">
<Size>
<AbsDimension x = "144" y = "17"/>
</Size>
<HitRectInsets>
<AbsInset left = "0" right = "0" top = "-2" bottom = "1"/>
</HitRectInsets>
<Backdrop bgFile = "Interface\Buttons\UI-SliderBar-Background" edgeFile = "Interface\Buttons\UI-SliderBar-Border" tile = "true">
<EdgeSize>
<AbsValue val = "8"/>
</EdgeSize>
<TileSize>
<AbsValue val = "8"/>
</TileSize>
<BackgroundInsets>
<AbsInset left = "3" right = "3" top = "6" bottom = "6"/>
</BackgroundInsets>
</Backdrop>
<Layers>
<Layer level = "ARTWORK">
<FontString name = "$parentText" inherits = "GameFontNormalSmall">
<Anchors>
<Anchor point = "BOTTOM" relativePoint = "TOP"/>
</Anchors>
</FontString>
<FontString name = "$parentLow" inherits = "GameFontHighlightSmall">
<Anchors>
<Anchor point = "TOPLEFT" relativePoint = "BOTTOMLEFT">
<Offset>
<AbsDimension x = "0" y = "-2"/>
</Offset>
</Anchor>
</Anchors>
</FontString>
<FontString name = "$parentHigh" inherits = "GameFontHighlightSmall">
<Anchors>
<Anchor point = "TOPRIGHT" relativePoint = "BOTTOMRIGHT">
<Offset>
<AbsDimension x = "0" y = "-2"/>
</Offset>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Frames>
<EditBox name = "$parentEditBox" autoFocus = "false">
<Size>
<AbsDimension x = "50" y = "14"/>
</Size>
<Anchors>
<Anchor point = "TOP" relativePoint = "BOTTOM"/>
</Anchors>
<FontString inherits = "GameFontHighlightSmall"/>
<Backdrop bgFile = "Interface\ChatFrame\ChatFrameBackground" edgeFile = "Interface\ChatFrame\ChatFrameBackground" tile = "true">
<EdgeSize>
<AbsValue val = "1"/>
</EdgeSize>
<TileSize>
<AbsValue val = "5"/>
</TileSize>
</Backdrop>
<Scripts>
<OnLoad>
self:EnableMouseWheel(true)
self:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
self:SetBackdropColor(0, 0, 0, 0.5)
self:SetJustifyH("CENTER")
self:SetMaxLetters(6)
</OnLoad>
<OnEnter>
self:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
</OnEnter>
<OnLeave>
self:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
</OnLeave>
<OnEnterPressed>
PowaAuras.SliderEditBoxChanged(self)
self:ClearFocus()
</OnEnterPressed>
<OnEditFocusLost>
PowaAuras.SliderEditBoxChanged(self)
</OnEditFocusLost>
<OnEscapePressed>
PowaAuras.SliderEditBoxChanged(self)
self:ClearFocus()
</OnEscapePressed>
<OnMouseWheel>
local slider = _G[string.sub(self:GetName(), 1, - 1 * (string.len("EditBox") + 1))]
PowaAuras.SliderSetValues(slider, delta)
</OnMouseWheel>
</Scripts>
</EditBox>
<Button name = "$parentPlus">
<Size>
<AbsDimension x = "18" y = "18"/>
</Size>
<Anchors>
<Anchor point = "LEFT" relativeTo = "$parentEditBox" relativePoint = "RIGHT">
<Offset>
<AbsDimension x = "0" y = "0"/>
</Offset>
</Anchor>
</Anchors>
<NormalTexture file = "Interface\Buttons\UI-SpellbookIcon-NextPage-Up"/>
<PushedTexture file = "Interface\Buttons\UI-SpellbookIcon-NextPage-Down"/>
<HighlightTexture file = "Interface\Buttons\UI-Panel-MinimizeButton-Highlight" alphaMode = "ADD"/>
<Scripts>
<OnLoad>
self:RegisterForClicks("AnyUp")
</OnLoad>
<OnClick>
PowaAuras.SliderSetValues(self:GetParent(), 1)
</OnClick>
</Scripts>
</Button>
<Button name = "$parentMinus">
<Size>
<AbsDimension x = "18" y = "18"/>
</Size>
<Anchors>
<Anchor point = "RIGHT" relativeTo = "$parentEditBox" relativePoint = "LEFT">
<Offset>
<AbsDimension x = "0" y = "0"/>
</Offset>
</Anchor>
</Anchors>
<NormalTexture file = "Interface\Buttons\UI-SpellbookIcon-PrevPage-Up"/>
<PushedTexture file = "Interface\Buttons\UI-SpellbookIcon-PrevPage-Down"/>
<HighlightTexture file = "Interface\Buttons\UI-Panel-MinimizeButton-Highlight" alphaMode = "ADD"/>
<Scripts>
<OnLoad>
self:RegisterForClicks("AnyUp")
</OnLoad>
<OnClick>
PowaAuras.SliderSetValues(self:GetParent(), 0)
</OnClick>
</Scripts>
</Button>
</Frames>
<ThumbTexture name = "$parentThumb" file = "Interface\Buttons\UI-SliderBar-Button-Horizontal">
<Size>
<AbsDimension x = "32" y = "32"/>
</Size>
</ThumbTexture>
<Scripts>
<OnLoad>
self:EnableMouseWheel(true)
</OnLoad>
<OnEnter>
if (self:IsEnabled()) then
if (self.aide) then
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(self.aide, nil, nil, nil, nil, 1)
end
end
</OnEnter>
<OnLeave>
GameTooltip:Hide()
</OnLeave>
<OnMouseWheel>
PowaAuras.SliderSetValues(self, delta)
</OnMouseWheel>
</Scripts>
</Slider>
function PowaAuras.SliderSetValues(slider, delta)
if (delta > 0) then
slider:SetValue(slider:GetValue() + slider:GetValueStep())
else
slider:SetValue(slider:GetValue() - slider:GetValueStep())
end
end
function PowaAuras.SliderOnMouseUp(self, x, y, decimals, postfix)
local frame = self:GetName()
local min
local max
if (x ~= 0) then
min = format("%."..decimals.."f", (self:GetValue() - x))
else
local sliderMin = self:GetMinMaxValues()
min = sliderMin
end
if (y ~= 0) then
max = format("%."..decimals.."f", (self:GetValue() + y))
else
local _, sliderMax = self:GetMinMaxValues()
max = sliderMax
end
self:SetMinMaxValues(min, max)
if postfix == nil then
_G[frame.."Low"]:SetText(min)
_G[frame.."High"]:SetText(max)
else
_G[frame.."Low"]:SetText(min..postfix)
_G[frame.."High"]:SetText(max..postfix)
end
PowaAuras:RedisplayAura(PowaAuras.CurrentAuraId)
end
function PowaAuras.SliderEditBoxSetValues(slider, editbox, x, y, decimals, endmark)
local frame = slider:GetName()
local slidervalue = slider:GetValue()
local postfix = tostring(string.sub(editbox:GetText(), - 1))
local value
if (postfix == "%") then
value = tonumber(string.sub(editbox:GetText(), 1, - 2))
else
value = tonumber(editbox:GetText())
end
if (value ~= nil) then
value = format("%."..decimals.."f", value)
local min
local max
if (x ~= 0) then
min = format("%."..decimals.."f", (value - x))
else
local sliderMin = slider:GetMinMaxValues()
min = sliderMin
end
if (y ~= 0) then
max = format("%."..decimals.."f", (value + y))
else
local _, sliderMax = slider:GetMinMaxValues()
max = sliderMax
end
slider:SetMinMaxValues(min, max)
slider:SetValue(value)
if (endmark == nil) then
editbox:SetText(format("%."..decimals.."f", value))
elseif (endmark == "%") then
editbox:SetText(format("%."..decimals.."f", value)..endmark)
else
if (postfix == "%") then
editbox:SetText(format("%."..decimals.."f", slider:GetValue()).."%")
else
editbox:SetText(format("%."..decimals.."f", slider:GetValue()))
end
end
if (endmark == "%") then
_G[frame.."Low"]:SetText(min..endmark)
_G[frame.."High"]:SetText(max..endmark)
else
_G[frame.."Low"]:SetText(min)
_G[frame.."High"]:SetText(max)
end
else
if (x == 0 and y == 0) then
local sliderMin, sliderMax = slider:GetMinMaxValues()
slider:SetMinMaxValues(sliderMin, sliderMax)
elseif (x == 0) then
local sliderMin = slider:GetMinMaxValues()
slider:SetMinMaxValues(sliderMin, slidervalue + y)
elseif (y == 0) then
local _, sliderMax = slider:GetMinMaxValues()
slider:SetMinMaxValues(slidervalue - x, sliderMax)
else
slider:SetMinMaxValues(slidervalue - x, slidervalue + y)
end
slider:SetValue(slidervalue)
if (endmark == "%") then
editbox:SetText(format("%."..decimals.."f", slidervalue)..endmark)
else
editbox:SetText(format("%."..decimals.."f", slidervalue))
end
if (endmark == "%") then
_G[frame.."Low"]:SetText((slidervalue - x)..endmark)
_G[frame.."High"]:SetText((slidervalue + y)..endmark)
else
_G[frame.."Low"]:SetText(slidervalue - x)
_G[frame.."High"]:SetText(slidervalue + y)
end
end
PowaAuras:RedisplayAura(PowaAuras.CurrentAuraId)
end
function PowaAuras.SliderEditBoxChanged(self)
local frame = self:GetName()
local slider = _G[string.sub(frame, 1, - 1 * (string.len("EditBox") + 1))]
local postfix = tostring(string.sub(self:GetText(), - 1))
if (slider == PowaBarAuraSizeSlider) then
PowaAuras.SliderEditBoxSetValues(slider, self, 0, 100, 0, "%")
elseif (slider == PowaBarAuraCoordXSlider or slider == PowaTimerCoordXSlider or slider == PowaStacksCoordXSlider) then
PowaAuras.SliderEditBoxSetValues(slider, self, 700, 700, 0)
elseif (slider == PowaBarAuraCoordYSlider or slider == PowaTimerCoordYSlider or slider == PowaStacksCoordYSlider) then
PowaAuras.SliderEditBoxSetValues(slider, self, 400, 400, 0)
elseif (slider == PowaModelPositionZSlider) then
PowaAuras.SliderEditBoxSetValues(slider, self, 100, 100, 0)
elseif (slider == PowaModelPositionXSlider or slider == PowaModelPositionYSlider) then
PowaAuras.SliderEditBoxSetValues(slider, self, 50, 50, 0)
end
if ((postfix == "%") and (slider == PowaBarAuraAlphaSlider or slider == PowaTimerSizeSlider or slider == PowaTimerAlphaSlider or slider == PowaStacksSizeSlider or slider == PowaStacksAlphaSlider)) then
local text = tonumber(string.sub(self:GetText(), 1, - 2))
if (text ~= nil) then
text = text / 100
slider:SetValue(text)
self:SetText(format("%.0f", (slider:GetValue() * 100)).."%")
local sliderlow, sliderhigh = slider:GetMinMaxValues()
if (text <= sliderlow or text >= sliderhigh) then
self:SetText(format("%.0f", (slider:GetValue() * 100)).."%")
end
else
self:SetText(format("%.0f", (slider:GetValue() * 100)).."%")
end
elseif (postfix == "%" and (slider == PowaBarAuraSizeSlider or slider == PowaBarAuraAnimSpeedSlider)) then
local text = tonumber(string.sub(self:GetText(), 1, - 2))
if (text ~= nil) then
slider:SetValue(text)
self:SetText(format("%.0f", (slider:GetValue())).."%")
local sliderlow, sliderhigh = slider:GetMinMaxValues()
if (text <= sliderlow or text >= sliderhigh) then
self:SetText(format("%.0f", slider:GetValue()).."%")
end
else
self:SetText(format("%.0f", slider:GetValue()).."%")
end
elseif (postfix == "%" and (slider == PowaBarThresholdSlider)) then
local text = tonumber(string.sub(self:GetText(), 1, - 2))
local aura = PowaAuras.Auras[PowaAuras.CurrentAuraId]
if (text ~= nil and aura.RangeType == "%") then
slider:SetValue(text)
self:SetText(format("%.0f", (slider:GetValue()))..aura.RangeType)
local sliderlow, sliderhigh = slider:GetMinMaxValues()
if (text <= sliderlow or text >= sliderhigh) then
self:SetText(format("%.0f", slider:GetValue())..aura.RangeType)
end
else
self:SetText(format("%.0f", slider:GetValue())..aura.RangeType)
end
elseif (slider == PowaBarAuraAlphaSlider or slider == PowaTimerSizeSlider or slider == PowaTimerAlphaSlider or slider == PowaStacksSizeSlider or slider == PowaStacksAlphaSlider) then
local text = tonumber(self:GetText())
if (text ~= nil) then
text = text / 100
slider:SetValue(text)
self:SetText(format("%.0f", (slider:GetValue() * 100)).."%")
local sliderlow, sliderhigh = slider:GetMinMaxValues()
if (text < sliderlow or text > sliderhigh) then
self:SetText(format("%.0f", (slider:GetValue() * 100)).."%")
end
else
self:SetText(format("%.0f", (slider:GetValue() * 100)).."%")
end
elseif (slider == PowaBarAuraSizeSlider or slider == PowaBarAuraAnimSpeedSlider) then
local text = tonumber(self:GetText())
if (text ~= nil) then
slider:SetValue(text)
self:SetText(format("%.0f", (slider:GetValue())).."%")
local sliderlow, sliderhigh = slider:GetMinMaxValues()
if (text <= sliderlow or text >= sliderhigh) then
self:SetText(format("%.0f", slider:GetValue()).."%")
end
else
self:SetText(format("%.0f", slider:GetValue()).."%")
end
elseif (slider == PowaBarThresholdSlider) then
local text = tonumber(self:GetText())
local aura = PowaAuras.Auras[PowaAuras.CurrentAuraId]
if (text ~= nil) then
slider:SetValue(text)
self:SetText(format("%.0f", (slider:GetValue()))..aura.RangeType)
local sliderlow, sliderhigh = slider:GetMinMaxValues()
if (text <= sliderlow or text >= sliderhigh) then
self:SetText(format("%.0f", slider:GetValue())..aura.RangeType)
end
else
self:SetText(format("%.0f", slider:GetValue())..aura.RangeType)
end
elseif (tonumber(postfix) == nil and slider == PowaBarAuraRotateSlider) then
local text = tonumber(string.sub(self:GetText(), 1, - 2))
if text == nil then
text = tonumber(string.sub(self:GetText(), 1, - 3))
end
if (text ~= nil) then
slider:SetValue(text)
self:SetText(format("%.0f", slider:GetValue()).."°")
local sliderlow, sliderhigh = slider:GetMinMaxValues()
if (text < sliderlow or text > sliderhigh) then
self:SetText(format("%.0f", slider:GetValue()).."°")
end
else
self:SetText(format("%.0f", slider:GetValue()).."°")
end
elseif (slider == PowaBarAuraRotateSlider) then
local text = tonumber(self:GetText())
if (text ~= nil) then
slider:SetValue(text)
self:SetText(format("%.0f", slider:GetValue()).."°")
local sliderlow, sliderhigh = slider:GetMinMaxValues()
if (text < sliderlow or text > sliderhigh) then
self:SetText(format("%.0f", slider:GetValue()).."°")
end
else
self:SetText(format("%.0f", slider:GetValue()).."°")
end
elseif (slider == PowaBarAuraDeformSlider or slider == PowaBarAuraDurationSlider or slider == PowaTimerDurationSlider or slider == PowaTimerInvertAuraSlider) then
if (tonumber(self:GetText()) ~= nil) then
slider:SetValue(tonumber(self:GetText()))
self:SetText(format("%.2f", slider:GetValue()))
local sliderlow, sliderhigh = slider:GetMinMaxValues()
if (tonumber(self:GetText()) < sliderlow or tonumber(self:GetText()) > sliderhigh) then
self:SetText(slider:GetValue())
end
else
self:SetText(slider:GetValue())
end
else
if (tonumber(self:GetText()) ~= nil) then
slider:SetValue(tonumber(self:GetText()))
self:SetText(format("%.0f", slider:GetValue()))
local sliderlow, sliderhigh = slider:GetMinMaxValues()
if (tonumber(self:GetText()) < sliderlow) or (tonumber(self:GetText()) > sliderhigh) then
self:SetText(slider:GetValue())
end
else
self:SetText(slider:GetValue())
end
end
end