Skip to content

Commit

Permalink
CircularProgressTexture: Add inverse option
Browse files Browse the repository at this point in the history
  • Loading branch information
InfusOnWoW committed Jan 28, 2025
1 parent 55a3be7 commit c7c8267
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
20 changes: 20 additions & 0 deletions WeakAuras/SubRegionTypes/CircularProgressTexture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ local properties = {
setter = "SetDesaturated",
type = "bool",
},
circularTextureInverse = {
display = L["Inverse"],
setter = "SetInverse",
type = "bool",
},
circularTextureColor = {
display = L["Color"],
setter = "SetColor",
Expand Down Expand Up @@ -195,15 +200,24 @@ local funcs = {
if progressData.total ~= 0 then
progress = progressData.value / progressData.total
end
if self.inverse then
progress = 1 - progress
end
self.circularTexture:SetProgress(self:ProgressToAngles(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.circularTexture:SetProgress(self:ProgressToAngles(progress))
else
local remaining = self.progressData.expirationTime - GetTime()
local progress = remaining / self.progressData.duration
if self.inverse then
progress = 1 - progress
end
self.circularTexture:SetProgress(self:ProgressToAngles(progress))
end
end
Expand All @@ -220,6 +234,10 @@ local funcs = {
self.circularTexture:SetHeight(h)
self.circularTexture:UpdateTextures()
end,
SetInverse = function(self, inverse)
self.inverse = inverse
self:UpdateFrame()
end
}

local function create()
Expand Down Expand Up @@ -265,6 +283,8 @@ local function modify(parent, region, parentData, data, first)
region:OnSizeChanged()
end

region.inverse = data.circularTextureInverse

Private.CircularProgressTextureBase.modify(region.circularTexture, {
crop_x = 1 + data.circularTextureCrop_x,
crop_y = 1 + data.circularTextureCrop_y,
Expand Down
8 changes: 4 additions & 4 deletions WeakAurasOptions/SubRegionOptions/CircularProgressTexture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ local function createOptions(parentData, data, index, subIndex)
order = 8,
values = OptionsPrivate.Private.blend_types
},
space = {
type = "description",
name = "",
order = 8.5,
circularTextureInverse = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Inverse"],
order = 8.5,
},
circularTextureStartAngle = {
type = "range",
Expand Down

0 comments on commit c7c8267

Please sign in to comment.