Skip to content

Commit

Permalink
Linear Progress Texture: Add an inverse setting
Browse files Browse the repository at this point in the history
Fixes: #5632
  • Loading branch information
InfusOnWoW committed Jan 28, 2025
1 parent 567c526 commit 55a3be7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
19 changes: 19 additions & 0 deletions WeakAuras/SubRegionTypes/LinearProgressTexture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ local properties = {
setter = "SetDesaturated",
type = "bool",
},
linearTextureInverse = {
display = L["Inverse"],
setter = "SetInverse",
type = "bool",
},
linearTextureColor = {
display = L["Color"],
setter = "SetColor",
Expand Down Expand Up @@ -160,15 +165,24 @@ local funcs = {
if progressData.total ~= 0 then
progress = progressData.value / progressData.total
end
if self.inverse then
progress = 1 - progress
end
self.linearTexture:SetValue(0, progress)
elseif progressData.progressType == "timed" then
if progressData.paused then
local remaining = self.progressData.remaining
local progress = remaining / self.progressData.duration
if self.inverse then
progress = 1 - progress
end
self.linearTexture:SetValue(0, progress)
else
local remaining = self.progressData.expirationTime - GetTime()
local progress = remaining / self.progressData.duration
if self.inverse then
progress = 1 - progress
end
self.linearTexture:SetValue(0, progress)
end
end
Expand All @@ -185,6 +199,10 @@ local funcs = {
self.linearTexture:SetHeight(h)
self.linearTexture:UpdateTextures()
end,
SetInverse = function(self, inverse)
self.inverse = inverse
self:UpdateFrame()
end
}

local function create()
Expand Down Expand Up @@ -223,6 +241,7 @@ local function modify(parent, region, parentData, data, first)
region:SetSize(data.width or 0, data.height or 0)
end

region.inverse = data.linearTextureInverse

region.Anchor = function()
region:ClearAllPoints()
Expand Down
6 changes: 6 additions & 0 deletions WeakAurasOptions/SubRegionOptions/LinearProgressTexture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ local function createOptions(parentData, data, index, subIndex)
order = 5,
values = OptionsPrivate.Private.texture_wrap_types
},
linearTextureInverse = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Inverse"],
order = 5.5,
},
linearTextureMirror = {
type = "toggle",
width = WeakAuras.normalWidth,
Expand Down

0 comments on commit 55a3be7

Please sign in to comment.