Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smallpatches #5640

Merged
merged 5 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion WeakAuras/GenericTrigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,8 @@ local function AddFakeInformation(data, triggernum, state, eventData)
state.progressType = "timed"
end
if state.progressType == "timed" then
if state.expirationTime and state.expirationTime ~= math.huge and state.expirationTime > GetTime() then
local expirationTime = state.expirationTime
if expirationTime and type(expirationTime) == "number" and expirationTime ~= math.huge and expirationTime > GetTime() then
return
end
state.progressType = "timed"
Expand Down
3 changes: 0 additions & 3 deletions WeakAuras/Prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2430,9 +2430,6 @@ Private.event_prototypes = {
values = "role_types",
store = true,
conditionType = "select",
enable = function(trigger)
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
end
},
{
name = "raid_role",
Expand Down
4 changes: 4 additions & 0 deletions WeakAuras/RegionTypes/RegionPrototype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,9 @@ local function UpdateProgressFromState(self, minMaxConfig, state, progressSource
end

local duration = totalProperty and state[totalProperty] or 0
if type(duration) ~= "number" then
duration = 0
end
local modRate = modRateProperty and state[modRateProperty] or nil
local adjustMin
if minMaxConfig.adjustedMin then
Expand Down Expand Up @@ -521,6 +524,7 @@ local function UpdateProgressFromState(self, minMaxConfig, state, progressSource
else
max = duration
end

self.minProgress, self.maxProgress = adjustMin, max
self.progressType = "timed"
self.duration = max - adjustMin
Expand Down
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
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
17 changes: 11 additions & 6 deletions WeakAuras/WeakAuras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4574,10 +4574,16 @@ do
local changed = false
for triggernum, triggerData in ipairs(triggers) do
for id, state in pairs(triggerData) do
if state.progressType == "timed" and state.expirationTime and state.expirationTime < t and state.duration and state.duration > 0 then
state.expirationTime = t + state.duration
state.changed = true
changed = true
if state.progressType == "timed" then
local expirationTime = state.expirationTime
local duration = state.duration
if expirationTime and type(expirationTime) == "number" and expirationTime < t
and duration and type(duration) == "number" and duration > 0
then
state.expirationTime = t + state.duration
state.changed = true
changed = true
end
end
end
end
Expand Down Expand Up @@ -4701,7 +4707,7 @@ local function startStopTimers(id, cloneId, triggernum, state)
timer:CancelTimer(record.handle);
end

if expirationTime then
if expirationTime and type(expirationTime) == "number" then
record.handle = timer:ScheduleTimerFixed(
function()
if (state.show ~= false and state.show ~= nil) then
Expand All @@ -4712,7 +4718,6 @@ local function startStopTimers(id, cloneId, triggernum, state)
if Private.watched_trigger_events[id] and Private.watched_trigger_events[id][triggernum] then
Private.AddToWatchedTriggerDelay(id, triggernum)
end

Private.UpdatedTriggerState(id);
end
end,
Expand Down
1 change: 1 addition & 0 deletions WeakAurasOptions/SubRegionOptions/Border.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ local function createOptions(parentData, data, index, subIndex)
anchor_area = {
type = "select",
width = WeakAuras.normalWidth,
control = "WeakAurasTwoColumnDropdown",
name = L["Border Anchor"],
order = 7,
values = areaAnchors,
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
1 change: 1 addition & 0 deletions WeakAurasOptions/SubRegionOptions/Glow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ local function createOptions(parentData, data, index, subIndex)
anchor_area = {
type = "select",
width = WeakAuras.normalWidth,
control = "WeakAurasTwoColumnDropdown",
name = L["Glow Anchor"],
order = 3,
values = areaAnchors,
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