from retail

This commit is contained in:
Bunny67
2022-05-19 22:04:17 +03:00
parent 9465daedd8
commit e7e789686a
86 changed files with 9118 additions and 5486 deletions
+90 -9
View File
@@ -33,8 +33,7 @@ local default = {
keepAspectRatio = false,
frameStrata = 1,
cooldown = false,
cooldownEdge = false,
subRegions = {}
cooldownEdge = false
};
WeakAuras.regionPrototype.AddAlphaToDefault(default);
@@ -187,10 +186,65 @@ local function setTexture(self, ...)
return apply
end
local function cooldown_onUpdate(self, e)
if self._duration then
if self._delay then
if not self._paused then
self._delay = self._delay - e
end
self:_SetCooldown(GetTime(), self._duration)
if self._delay <= 0 then
self._delay = nil
if not self._paused then
self:SetScript("OnUpdate", nil)
end
end
return
end
if self._paused then
self:_SetCooldown(GetTime() - self._paused, self._duration)
end
end
end
local function cooldown_pause(self)
if not self._paused then
self._paused = GetTime() - (self._start or 0)
self:SetScript("OnUpdate", cooldown_onUpdate)
end
end
local function cooldown_resume(self)
if self._paused then
self._start = GetTime() - self._paused
end
self._paused = nil
self:SetScript("OnUpdate", nil)
end
local function cooldown_setCooldown(self, start, duration, ...)
if self._start == start and self._duration == duration then
return
end
self._start = start
self._duration = duration
local getTime = GetTime()
local delay = start - getTime
if delay > 0 then
self._delay = delay
self:SetScript("OnUpdate", cooldown_onUpdate)
end
if self._paused then
self._paused = getTime - self._start
end
return self._SetCooldown(self, math.min(getTime, start), duration, ...)
end
local function create(parent, data)
local font = "GameFontHighlight";
local region = CreateFrame("FRAME", nil, parent);
region.regionType = "icon"
region:SetMovable(true);
region:SetResizable(true);
region:SetMinResize(1, 1);
@@ -262,8 +316,10 @@ local function create(parent, data)
region.cooldown = cooldown;
cooldown:SetAllPoints(icon);
region.values = {};
cooldown._SetCooldown = cooldown.SetCooldown;
cooldown.SetCooldown = cooldown_setCooldown;
cooldown.Pause = cooldown_pause;
cooldown.Resume = cooldown_resume;
local SetFrameLevel = region.SetFrameLevel;
@@ -504,9 +560,14 @@ local function modify(parent, region, data)
cooldown:Hide()
if(data.cooldown) then
function region:SetValue(value, total)
cooldown.duration = 0
cooldown.expirationTime = math.huge
cooldown:Hide();
cooldown.value = value
cooldown.total = total
if (value >= 0 and value <= total) then
cooldown:Show()
cooldown:SetCooldown(GetTime() - (total - value), total)
else
cooldown:Hide();
end
end
function region:SetTime(duration, expirationTime)
@@ -526,13 +587,28 @@ local function modify(parent, region, data)
if (cooldown.duration and cooldown.duration > 0.01) then
cooldown:Show();
cooldown:SetCooldown(cooldown.expirationTime - cooldown.duration, cooldown.duration);
cooldown:Resume()
end
end
function region:Update()
local state = region.state
if state.progressType == "timed" then
local expirationTime = state.expirationTime and state.expirationTime > 0 and state.expirationTime or math.huge;
local expirationTime
if state.paused == true then
if not region.paused then
region:Pause()
end
cooldown:Pause()
expirationTime = GetTime() + (state.remaining or 0)
else
if region.paused then
region:Resume()
end
cooldown:Resume()
expirationTime = state.expirationTime and state.expirationTime > 0 and state.expirationTime or math.huge;
end
local duration = state.duration or 0
if region.adjustedMinRelPercent then
region.adjustedMinRel = region.adjustedMinRelPercent * duration
@@ -561,6 +637,7 @@ local function modify(parent, region, data)
local adjustMin = region.adjustedMin or region.adjustedMinRel or 0;
local max = region.adjustedMax or region.adjustedMaxRel or total;
region:SetValue(value - adjustMin, max - adjustMin);
cooldown:Pause()
else
region:SetTime(0, math.huge)
end
@@ -595,4 +672,8 @@ local function modify(parent, region, data)
region:SetHeight(region:GetHeight())
end
WeakAuras.RegisterRegionType("icon", create, modify, default, GetProperties)
local function validate(data)
Private.EnforceSubregionExists(data, "subbackground")
end
WeakAuras.RegisterRegionType("icon", create, modify, default, GetProperties, validate)