from retail
This commit is contained in:
@@ -35,12 +35,7 @@ local default = {
|
||||
icon_side = "RIGHT",
|
||||
icon_color = {1.0, 1.0, 1.0, 1.0},
|
||||
frameStrata = 1,
|
||||
zoom = 0,
|
||||
subRegions = {
|
||||
[1] = {
|
||||
["type"] = "aurabar_bar"
|
||||
}
|
||||
}
|
||||
zoom = 0
|
||||
};
|
||||
|
||||
WeakAuras.regionPrototype.AddAdjustedDurationToDefault(default);
|
||||
@@ -223,8 +218,6 @@ local anchorAlignment = {
|
||||
["VERTICAL_INVERSE"] = { "BOTTOMLEFT", "BOTTOMRIGHT", "TOP" }
|
||||
}
|
||||
|
||||
local extraTextureWrapMode = "REPEAT";
|
||||
|
||||
-- Emulate blizzard statusbar with advanced features (more grow directions)
|
||||
local barPrototype = {
|
||||
["UpdateAnchors"] = function(self)
|
||||
@@ -314,7 +307,6 @@ local barPrototype = {
|
||||
for index, additionalBar in ipairs(self.additionalBars) do
|
||||
if (not self.extraTextures[index]) then
|
||||
local extraTexture = self:CreateTexture(nil, "ARTWORK");
|
||||
extraTexture:SetTexture(self:GetStatusBarTexture(), extraTextureWrapMode, extraTextureWrapMode);
|
||||
extraTexture:SetDrawLayer("ARTWORK", min(index, 7));
|
||||
self.extraTextures[index] = extraTexture;
|
||||
end
|
||||
@@ -379,6 +371,14 @@ local barPrototype = {
|
||||
extraTexture:SetVertexColor(1, 1, 1, 1);
|
||||
end
|
||||
|
||||
local texture = self.additionalBarsTextures and self.additionalBarsTextures[index];
|
||||
if texture then
|
||||
local texturePath = SharedMedia:Fetch("statusbar", texture) or ""
|
||||
extraTexture:SetTexture(texturePath)
|
||||
else
|
||||
extraTexture:SetTexture(self:GetStatusBarTexture());
|
||||
end
|
||||
|
||||
local xOffset = 0;
|
||||
local yOffset = 0;
|
||||
local width, height = self:GetRealSize()
|
||||
@@ -461,9 +461,10 @@ local barPrototype = {
|
||||
end
|
||||
end,
|
||||
|
||||
["SetAdditionalBars"] = function(self, additionalBars, colors, min, max, inverse, overlayclip)
|
||||
["SetAdditionalBars"] = function(self, additionalBars, colors, textures, min, max, inverse, overlayclip)
|
||||
self.additionalBars = additionalBars;
|
||||
self.additionalBarsColors = colors;
|
||||
self.additionalBarsTextures = textures;
|
||||
self.additionalBarsMin = min or 0;
|
||||
self.additionalBarsMax = max or 0;
|
||||
self.additionalBarsInverse = inverse;
|
||||
@@ -471,6 +472,15 @@ local barPrototype = {
|
||||
self:UpdateAdditionalBars();
|
||||
end,
|
||||
|
||||
["GetAdditionalBarsInverse"] = function(self)
|
||||
return self.additionalBarsInverse
|
||||
end,
|
||||
|
||||
["SetAdditionalBarsInverse"] = function(self, value)
|
||||
self.additionalBarsInverse = value;
|
||||
self:UpdateAdditionalBars();
|
||||
end,
|
||||
|
||||
["SetAdditionalBarColor"] = function(self, id, color)
|
||||
self.additionalBarsColors[id] = color;
|
||||
if self.extraTextures[id] then
|
||||
@@ -515,7 +525,7 @@ local barPrototype = {
|
||||
self.fg:SetTexture(texture);
|
||||
self.bg:SetTexture(texture);
|
||||
for index, extraTexture in ipairs(self.extraTextures) do
|
||||
extraTexture:SetTexture(texture, extraTextureWrapMode, extraTextureWrapMode);
|
||||
extraTexture:SetTexture(texture);
|
||||
end
|
||||
end,
|
||||
|
||||
@@ -854,6 +864,7 @@ local funcs = {
|
||||
else
|
||||
self.bar:SetValue(1 - self.bar:GetValue());
|
||||
end
|
||||
self.bar:SetAdditionalBarsInverse(not self.bar:GetAdditionalBarsInverse())
|
||||
self.subRegionEvents:Notify("InverseChanged")
|
||||
end,
|
||||
SetOrientation = function(self, orientation)
|
||||
@@ -994,6 +1005,7 @@ end
|
||||
local function create(parent)
|
||||
-- Create overall region (containing everything else)
|
||||
local region = CreateFrame("FRAME", nil, parent);
|
||||
region.regionType = "aurabar"
|
||||
region:SetMovable(true);
|
||||
region:SetResizable(true);
|
||||
region:SetMinResize(1, 1);
|
||||
@@ -1030,9 +1042,6 @@ local function create(parent)
|
||||
icon._SetTexture = icon.SetTexture
|
||||
icon.SetTexture = setTexture
|
||||
|
||||
-- Region variables
|
||||
region.values = {};
|
||||
|
||||
local oldSetFrameLevel = region.SetFrameLevel;
|
||||
function region.SetFrameLevel(self, frameLevel)
|
||||
oldSetFrameLevel(self, frameLevel);
|
||||
@@ -1100,6 +1109,11 @@ local function modify(parent, region, data)
|
||||
else
|
||||
region.overlays = {}
|
||||
end
|
||||
if data.overlaysTexture then
|
||||
region.overlaysTexture = CopyTable(data.overlaysTexture)
|
||||
else
|
||||
region.overlaysTexture = {}
|
||||
end
|
||||
|
||||
-- Update texture settings
|
||||
local texturePath = SharedMedia:Fetch("statusbar", data.texture) or "";
|
||||
@@ -1236,15 +1250,33 @@ local function modify(parent, region, data)
|
||||
local state = region.state
|
||||
region:UpdateMinMax()
|
||||
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
|
||||
if region.TimerTick then
|
||||
region.TimerTick = nil
|
||||
region:UpdateRegionHasTimerTick()
|
||||
end
|
||||
expirationTime = GetTime() + (state.remaining or 0)
|
||||
else
|
||||
if region.paused then
|
||||
region:Resume()
|
||||
end
|
||||
if not region.TimerTick then
|
||||
region.TimerTick = TimerTick
|
||||
region:UpdateRegionHasTimerTick()
|
||||
end
|
||||
expirationTime = state.expirationTime and state.expirationTime > 0 and state.expirationTime or math.huge;
|
||||
end
|
||||
local duration = state.duration or 0
|
||||
|
||||
region:SetTime(region.currentMax - region.currentMin, expirationTime - region.currentMin, state.inverse);
|
||||
if not region.TimerTick then
|
||||
region.TimerTick = TimerTick
|
||||
region:UpdateRegionHasTimerTick()
|
||||
end
|
||||
elseif state.progressType == "static" then
|
||||
if region.paused then
|
||||
region:Resume()
|
||||
end
|
||||
local value = state.value or 0;
|
||||
local total = state.total or 0;
|
||||
|
||||
@@ -1254,6 +1286,9 @@ local function modify(parent, region, data)
|
||||
region:UpdateRegionHasTimerTick()
|
||||
end
|
||||
else
|
||||
if region.paused then
|
||||
region:Resume()
|
||||
end
|
||||
region:SetTime(0, math.huge)
|
||||
if region.TimerTick then
|
||||
region.TimerTick = nil
|
||||
@@ -1265,7 +1300,7 @@ local function modify(parent, region, data)
|
||||
|
||||
local duration = state.duration or 0
|
||||
local effectiveInverse = (state.inverse and not region.inverseDirection) or (not state.inverse and region.inverseDirection);
|
||||
region.bar:SetAdditionalBars(state.additionalProgress, region.overlays, region.currentMin, region.currentMax, effectiveInverse, region.overlayclip);
|
||||
region.bar:SetAdditionalBars(state.additionalProgress, region.overlays, region.overlaysTexture, region.currentMin, region.currentMax, effectiveInverse, region.overlayclip);
|
||||
end
|
||||
|
||||
-- Scale update function
|
||||
@@ -1322,42 +1357,18 @@ local function modify(parent, region, data)
|
||||
WeakAuras.regionPrototype.modifyFinish(parent, region, data);
|
||||
end
|
||||
|
||||
local function ValidateRegion(data)
|
||||
data.subRegions = data.subRegions or {}
|
||||
for index, subRegionData in ipairs(data.subRegions) do
|
||||
if subRegionData.type == "aurabar_bar" then
|
||||
return
|
||||
local function validate(data)
|
||||
-- pre-migration
|
||||
if data.subRegions then
|
||||
for _, subRegionData in ipairs(data.subRegions) do
|
||||
if subRegionData.type == "aurabar_bar" then
|
||||
subRegionData.type = "subforeground"
|
||||
end
|
||||
end
|
||||
end
|
||||
tinsert(data.subRegions, 1, {
|
||||
["type"] = "aurabar_bar"
|
||||
})
|
||||
Private.EnforceSubregionExists(data, "subforeground")
|
||||
Private.EnforceSubregionExists(data, "subbackground")
|
||||
end
|
||||
|
||||
-- Register new region type with WeakAuras
|
||||
WeakAuras.RegisterRegionType("aurabar", create, modify, default, GetProperties, ValidateRegion);
|
||||
|
||||
local function subSupports(regionType)
|
||||
return regionType == "aurabar"
|
||||
end
|
||||
|
||||
local function noop()
|
||||
end
|
||||
|
||||
local function SetFrameLevel(self, level)
|
||||
self.parent.bar:SetFrameLevel(level)
|
||||
self.parent.iconFrame:SetFrameLevel(level)
|
||||
end
|
||||
|
||||
local function subCreate()
|
||||
local result = {}
|
||||
result.Update = noop
|
||||
result.SetFrameLevel = SetFrameLevel
|
||||
return result
|
||||
end
|
||||
|
||||
local function subModify(parent, region)
|
||||
region.parent = parent
|
||||
end
|
||||
|
||||
WeakAuras.RegisterSubRegionType("aurabar_bar", L["Foreground"], subSupports, subCreate, subModify, noop, noop, {}, nil, {}, false);
|
||||
WeakAuras.RegisterRegionType("aurabar", create, modify, default, GetProperties, validate);
|
||||
|
||||
@@ -104,6 +104,7 @@ end
|
||||
|
||||
local function create(parent)
|
||||
local region = CreateFrame("FRAME", nil, parent)
|
||||
region.regionType = "dynamicgroup"
|
||||
region:SetSize(16, 16)
|
||||
region:SetMovable(true)
|
||||
region.sortedChildren = {}
|
||||
@@ -116,6 +117,13 @@ local function create(parent)
|
||||
region.controlPoints.parent = region
|
||||
WeakAuras.regionPrototype.create(region)
|
||||
region.suspended = 0
|
||||
|
||||
local oldSetFrameLevel = region.SetFrameLevel
|
||||
region.SetFrameLevel = function(self, level)
|
||||
oldSetFrameLevel(self, level)
|
||||
self.background:SetFrameLevel(level)
|
||||
end
|
||||
|
||||
return region
|
||||
end
|
||||
|
||||
@@ -855,6 +863,7 @@ local function modify(parent, region, data)
|
||||
else
|
||||
childRegion:SetFrameStrata(Private.frame_strata_types[childData.frameStrata]);
|
||||
end
|
||||
Private.ApplyFrameLevel(childRegion)
|
||||
return regionData
|
||||
end
|
||||
|
||||
@@ -1191,7 +1200,7 @@ local function modify(parent, region, data)
|
||||
-- if self.dynamicAnchor then self:UpdateBorder(); return end
|
||||
Private.StartProfileSystem("dynamicgroup")
|
||||
Private.StartProfileAura(data.id)
|
||||
local numVisible, minX, maxX, maxY, minY, minLevel = 0
|
||||
local numVisible, minX, maxX, maxY, minY = 0
|
||||
for active, regionData in ipairs(self.sortedChildren) do
|
||||
if regionData.shown then
|
||||
numVisible = numVisible + 1
|
||||
@@ -1199,14 +1208,12 @@ local function modify(parent, region, data)
|
||||
local regionLeft, regionRight, regionTop, regionBottom
|
||||
= SafeGetPos(childRegion, childRegion.GetLeft), SafeGetPos(childRegion, childRegion.GetRight),
|
||||
SafeGetPos(childRegion, childRegion.GetTop), SafeGetPos(childRegion, childRegion.GetBottom)
|
||||
local frameLevel = childRegion:GetFrameLevel()
|
||||
|
||||
if(regionLeft and regionRight and regionTop and regionBottom and frameLevel) then
|
||||
if(regionLeft and regionRight and regionTop and regionBottom) then
|
||||
minX = minX and min(regionLeft, minX) or regionLeft
|
||||
maxX = maxX and max(regionRight, maxX) or regionRight
|
||||
minY = minY and min(regionBottom, minY) or regionBottom
|
||||
maxY = maxY and max(regionTop, maxY) or regionTop
|
||||
minLevel = minLevel and min(frameLevel, minLevel) or frameLevel
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1223,7 +1230,6 @@ local function modify(parent, region, data)
|
||||
self:SetHeight(height)
|
||||
self.currentWidth = width
|
||||
self.currentHeight = height
|
||||
self.background:SetFrameLevel(minLevel and minLevel - 1 or 0)
|
||||
else
|
||||
self:Hide()
|
||||
end
|
||||
|
||||
@@ -26,6 +26,7 @@ local default = {
|
||||
local function create(parent)
|
||||
-- Main region
|
||||
local region = CreateFrame("FRAME", nil, parent);
|
||||
region.regionType = "group"
|
||||
region:SetMovable(true);
|
||||
region:SetWidth(2);
|
||||
region:SetHeight(2);
|
||||
@@ -36,6 +37,12 @@ local function create(parent)
|
||||
|
||||
WeakAuras.regionPrototype.create(region);
|
||||
|
||||
local oldSetFrameLevel = region.SetFrameLevel
|
||||
region.SetFrameLevel = function(self, level)
|
||||
oldSetFrameLevel(self, level)
|
||||
self.border:SetFrameLevel(level)
|
||||
end
|
||||
|
||||
return region;
|
||||
end
|
||||
|
||||
@@ -92,20 +99,14 @@ local function modify(parent, region, data)
|
||||
|
||||
-- Get overall bounding box
|
||||
local leftest, rightest, lowest, highest = 0, 0, 0, 0;
|
||||
local minLevel
|
||||
for index, childId in ipairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
local childRegion = WeakAuras.GetRegion(childId)
|
||||
if(childData) then
|
||||
local blx, bly, trx, try = getRect(childData, childRegion);
|
||||
for child in Private.TraverseLeafs(data) do
|
||||
local childRegion = WeakAuras.GetRegion(child.id)
|
||||
if(child) then
|
||||
local blx, bly, trx, try = getRect(child, childRegion);
|
||||
leftest = math.min(leftest, blx);
|
||||
rightest = math.max(rightest, trx);
|
||||
lowest = math.min(lowest, bly);
|
||||
highest = math.max(highest, try);
|
||||
local frameLevel = childRegion and childRegion:GetFrameLevel()
|
||||
if frameLevel then
|
||||
minLevel = minLevel and math.min(minLevel, frameLevel) or frameLevel
|
||||
end
|
||||
end
|
||||
end
|
||||
region.blx = leftest;
|
||||
@@ -116,56 +117,67 @@ local function modify(parent, region, data)
|
||||
-- Adjust frame-level sorting
|
||||
Private.FixGroupChildrenOrderForGroup(data);
|
||||
|
||||
-- Control children (does not happen with "group")
|
||||
function region:UpdateBorder(childRegion)
|
||||
local border = region.border;
|
||||
-- Apply border settings
|
||||
if data.border then
|
||||
-- Initial visibility (of child that originated UpdateBorder(...))
|
||||
local childVisible = childRegion and childRegion.toShow or false;
|
||||
local hasDynamicSubGroups = false
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
if childData.regionType == "dynamicgroup" then
|
||||
hasDynamicSubGroups = true
|
||||
break;
|
||||
end
|
||||
end
|
||||
|
||||
-- Scan children for visibility
|
||||
if not childVisible then
|
||||
for index, childId in ipairs(data.controlledChildren) do
|
||||
local childRegion = WeakAuras.regions[childId] and WeakAuras.regions[childId].region;
|
||||
if childRegion and childRegion.toShow then
|
||||
childVisible = true;
|
||||
break;
|
||||
if not hasDynamicSubGroups then
|
||||
-- Control children (does not happen with "group")
|
||||
function region:UpdateBorder(childRegion)
|
||||
local border = region.border;
|
||||
-- Apply border settings
|
||||
if data.border then
|
||||
-- Initial visibility (of child that originated UpdateBorder(...))
|
||||
local childVisible = childRegion and childRegion.toShow or false;
|
||||
|
||||
-- Scan children for visibility
|
||||
if not childVisible then
|
||||
for child in Private.TraverseLeafs(data) do
|
||||
local childRegion = WeakAuras.regions[child.id] and WeakAuras.regions[child.id].region;
|
||||
if childRegion and childRegion.toShow then
|
||||
childVisible = true;
|
||||
break;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Show border if child is visible
|
||||
if childVisible then
|
||||
border:SetBackdrop({
|
||||
edgeFile = data.borderEdge ~= "None" and SharedMedia:Fetch("border", data.borderEdge) or "",
|
||||
edgeSize = data.borderSize,
|
||||
bgFile = data.borderBackdrop ~= "None" and SharedMedia:Fetch("background", data.borderBackdrop) or "",
|
||||
insets = {
|
||||
left = data.borderInset,
|
||||
right = data.borderInset,
|
||||
top = data.borderInset,
|
||||
bottom = data.borderInset,
|
||||
},
|
||||
});
|
||||
border:SetBackdropBorderColor(data.borderColor[1], data.borderColor[2], data.borderColor[3], data.borderColor[4]);
|
||||
border:SetBackdropColor(data.backdropColor[1], data.backdropColor[2], data.backdropColor[3], data.backdropColor[4]);
|
||||
-- Show border if child is visible
|
||||
if childVisible then
|
||||
border:SetBackdrop({
|
||||
edgeFile = data.borderEdge ~= "None" and SharedMedia:Fetch("border", data.borderEdge) or "",
|
||||
edgeSize = data.borderSize,
|
||||
bgFile = data.borderBackdrop ~= "None" and SharedMedia:Fetch("background", data.borderBackdrop) or "",
|
||||
insets = {
|
||||
left = data.borderInset,
|
||||
right = data.borderInset,
|
||||
top = data.borderInset,
|
||||
bottom = data.borderInset,
|
||||
},
|
||||
});
|
||||
border:SetBackdropBorderColor(data.borderColor[1], data.borderColor[2], data.borderColor[3], data.borderColor[4]);
|
||||
border:SetBackdropColor(data.backdropColor[1], data.backdropColor[2], data.backdropColor[3], data.backdropColor[4]);
|
||||
|
||||
border:ClearAllPoints();
|
||||
border:SetPoint("bottomleft", region, "bottomleft", leftest-data.borderOffset, lowest-data.borderOffset);
|
||||
border:SetPoint("topright", region, "topright", rightest+data.borderOffset, highest+data.borderOffset);
|
||||
if minLevel then
|
||||
border:SetFrameLevel(minLevel - 1)
|
||||
border:ClearAllPoints();
|
||||
border:SetPoint("bottomleft", region, "bottomleft", leftest-data.borderOffset, lowest-data.borderOffset);
|
||||
border:SetPoint("topright", region, "topright", rightest+data.borderOffset, highest+data.borderOffset);
|
||||
border:Show();
|
||||
else
|
||||
border:Hide();
|
||||
end
|
||||
border:Show();
|
||||
else
|
||||
border:Hide();
|
||||
end
|
||||
else
|
||||
border:Hide();
|
||||
end
|
||||
region:UpdateBorder()
|
||||
else
|
||||
region.UpdateBorder = function() end
|
||||
region.border:Hide()
|
||||
end
|
||||
region:UpdateBorder()
|
||||
|
||||
WeakAuras.regionPrototype.modifyFinish(parent, region, data);
|
||||
end
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -30,7 +30,7 @@ local default = {
|
||||
borderOffset = 5,
|
||||
borderInset = 11,
|
||||
borderSize = 16,
|
||||
borderBackdrop = "Blizzard Tooltip",
|
||||
borderBackdrop = "Blizzard Tooltip"
|
||||
};
|
||||
|
||||
local screenWidth, screenHeight = math.ceil(GetScreenWidth() / 20) * 20, math.ceil(GetScreenHeight() / 20) * 20;
|
||||
@@ -70,6 +70,7 @@ local regionFunctions = {
|
||||
local function create(parent)
|
||||
-- Main region
|
||||
local region = CreateFrame("FRAME", nil, UIParent);
|
||||
region.regionType = "model"
|
||||
region:SetMovable(true);
|
||||
region:SetResizable(true);
|
||||
region:SetMinResize(1, 1);
|
||||
@@ -84,6 +85,8 @@ local function create(parent)
|
||||
region[k] = v
|
||||
end
|
||||
|
||||
region.AnchorSubRegion = WeakAuras.regionPrototype.AnchorSubRegion
|
||||
|
||||
-- Return complete region
|
||||
return region;
|
||||
end
|
||||
@@ -293,5 +296,9 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
local function validate(data)
|
||||
Private.EnforceSubregionExists(data, "subbackground")
|
||||
end
|
||||
|
||||
-- Register new region type with WeakAuras
|
||||
WeakAuras.RegisterRegionType("model", create, modify, default, GetProperties);
|
||||
WeakAuras.RegisterRegionType("model", create, modify, default, GetProperties, validate);
|
||||
|
||||
@@ -92,7 +92,6 @@ local default = {
|
||||
height = 200,
|
||||
orientation = "VERTICAL",
|
||||
inverse = false,
|
||||
alpha = 1.0,
|
||||
foregroundColor = {1, 1, 1, 1},
|
||||
backgroundColor = {0.5, 0.5, 0.5, 0.5},
|
||||
startAngle = 0,
|
||||
@@ -101,7 +100,6 @@ local default = {
|
||||
user_y = 0,
|
||||
crop_x = 0.41,
|
||||
crop_y = 0.41,
|
||||
crop = 0.41,
|
||||
rotation = 0,
|
||||
selfPoint = "CENTER",
|
||||
anchorPoint = "CENTER",
|
||||
@@ -110,9 +108,9 @@ local default = {
|
||||
yOffset = 0,
|
||||
font = defaultFont,
|
||||
fontSize = defaultFontSize,
|
||||
stickyDuration = false,
|
||||
mirror = false,
|
||||
frameStrata = 1
|
||||
frameStrata = 1,
|
||||
slantMode = "INSIDE"
|
||||
};
|
||||
|
||||
WeakAuras.regionPrototype.AddAlphaToDefault(default);
|
||||
@@ -160,10 +158,46 @@ local properties = {
|
||||
bigStep = 1,
|
||||
default = 32
|
||||
},
|
||||
orientation = {
|
||||
display = L["Orientation"],
|
||||
setter = "SetOrientation",
|
||||
type = "list",
|
||||
values = Private.orientation_with_circle_types
|
||||
},
|
||||
inverse = {
|
||||
display = L["Inverse"],
|
||||
setter = "SetInverse",
|
||||
type = "bool"
|
||||
},
|
||||
mirror = {
|
||||
display = L["Mirror"],
|
||||
setter = "SetMirror",
|
||||
type = "bool"
|
||||
}
|
||||
}
|
||||
|
||||
WeakAuras.regionPrototype.AddProperties(properties, default);
|
||||
|
||||
local function GetProperties(data)
|
||||
local overlayInfo = Private.GetOverlayInfo(data);
|
||||
if (overlayInfo and next(overlayInfo)) then
|
||||
local auraProperties = CopyTable(properties);
|
||||
|
||||
for id, display in ipairs(overlayInfo) do
|
||||
auraProperties["overlays." .. id] = {
|
||||
display = string.format(L["%s Overlay Color"], display),
|
||||
setter = "SetOverlayColor",
|
||||
arg1 = id,
|
||||
type = "color",
|
||||
}
|
||||
end
|
||||
|
||||
return auraProperties;
|
||||
else
|
||||
return CopyTable(properties);
|
||||
end
|
||||
end
|
||||
|
||||
local spinnerFunctions = {};
|
||||
|
||||
function spinnerFunctions.SetTexture(self, texture)
|
||||
@@ -391,6 +425,7 @@ local function create(parent)
|
||||
local font = "GameFontHighlight";
|
||||
|
||||
local region = CreateFrame("FRAME", nil, parent);
|
||||
region.regionType = "progresstexture"
|
||||
region:SetMovable(true);
|
||||
region:SetResizable(true);
|
||||
region:SetMinResize(1, 1);
|
||||
@@ -405,15 +440,30 @@ local function create(parent)
|
||||
region.foregroundSpinner = createSpinner(region, "ARTWORK", parent:GetFrameLevel() + 2);
|
||||
region.backgroundSpinner = createSpinner(region, "BACKGROUND", parent:GetFrameLevel() + 1);
|
||||
|
||||
region.values = {};
|
||||
region.extraTextures = {};
|
||||
region.extraSpinners = {};
|
||||
|
||||
-- Use a dummy object for the SmoothStatusBarMixin, because our SetValue
|
||||
-- is used for a different purpose
|
||||
region.smoothProgress = {};
|
||||
WeakAuras.Mixin(region.smoothProgress, SmoothStatusBarMixin);
|
||||
region.smoothProgress.SetValue = function(self, progress)
|
||||
region:SetValueOnTexture(progress);
|
||||
end
|
||||
|
||||
region.smoothProgress.GetValue = function(self)
|
||||
return region.progress;
|
||||
end
|
||||
|
||||
region.smoothProgress.GetMinMaxValues = function(self)
|
||||
return 0, 1;
|
||||
end
|
||||
|
||||
region.duration = 0;
|
||||
region.expirationTime = math.huge;
|
||||
|
||||
WeakAuras.regionPrototype.create(region);
|
||||
|
||||
region.AnchorSubRegion = WeakAuras.regionPrototype.AnchorSubRegion
|
||||
|
||||
return region;
|
||||
end
|
||||
|
||||
@@ -805,7 +855,11 @@ local function modify(parent, region, data)
|
||||
end
|
||||
|
||||
progress = progress > 0.0001 and progress or 0.0001;
|
||||
region:SetValueOnTexture(progress);
|
||||
if (data.smoothProgress) then
|
||||
region.smoothProgress:SetSmoothedValue(progress);
|
||||
else
|
||||
region:SetValueOnTexture(progress);
|
||||
end
|
||||
end
|
||||
|
||||
function region:SetValue(value, total)
|
||||
@@ -817,7 +871,11 @@ local function modify(parent, region, data)
|
||||
end
|
||||
end
|
||||
progress = progress > 0.0001 and progress or 0.0001;
|
||||
region:SetValueOnTexture(progress);
|
||||
if (data.smoothProgress) then
|
||||
region.smoothProgress:SetSmoothedValue(progress);
|
||||
else
|
||||
region:SetValueOnTexture(progress);
|
||||
end
|
||||
end
|
||||
|
||||
function region:Update()
|
||||
@@ -825,7 +883,27 @@ local function modify(parent, region, data)
|
||||
|
||||
local max
|
||||
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
|
||||
if region.TimerTick then
|
||||
region.TimerTick = nil
|
||||
region:UpdateRegionHasTimerTick()
|
||||
end
|
||||
expirationTime = GetTime() + (state.remaining or 0)
|
||||
else
|
||||
if region.paused then
|
||||
region:Resume()
|
||||
end
|
||||
if not region.TimerTick then
|
||||
region.TimerTick = TimerTick
|
||||
region:UpdateRegionHasTimerTick()
|
||||
end
|
||||
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
|
||||
@@ -843,11 +921,11 @@ local function modify(parent, region, data)
|
||||
end
|
||||
|
||||
region:SetTime(max - adjustMin, expirationTime - adjustMin, state.inverse);
|
||||
if not region.TimerTick then
|
||||
region.TimerTick = TimerTick
|
||||
region:UpdateRegionHasTimerTick()
|
||||
end
|
||||
elseif state.progressType == "static" then
|
||||
if region.paused then
|
||||
region:Resume()
|
||||
end
|
||||
|
||||
local value = state.value or 0;
|
||||
local total = state.total or 0;
|
||||
if region.adjustedMinRelPercent then
|
||||
@@ -870,6 +948,9 @@ local function modify(parent, region, data)
|
||||
region:UpdateRegionHasTimerTick()
|
||||
end
|
||||
else
|
||||
if region.paused then
|
||||
region:Resume()
|
||||
end
|
||||
region:SetTime(0, math.huge)
|
||||
if region.TimerTick then
|
||||
region.TimerTick = nil
|
||||
@@ -892,6 +973,14 @@ local function modify(parent, region, data)
|
||||
background:SetTexture(texture);
|
||||
backgroundSpinner:SetTexture(texture);
|
||||
end
|
||||
|
||||
for _, extraTexture in ipairs(region.extraTextures) do
|
||||
extraTexture:SetTexture(texture);
|
||||
end
|
||||
|
||||
for _, extraSpinner in ipairs(region.extraSpinners) do
|
||||
extraSpinner:SetTexture(texture);
|
||||
end
|
||||
end
|
||||
|
||||
function region:SetForegroundDesaturated(b)
|
||||
@@ -929,7 +1018,21 @@ local function modify(parent, region, data)
|
||||
region:SetValueOnTexture(progress);
|
||||
end
|
||||
|
||||
function region:SetOverlayColor(id, r, g, b, a)
|
||||
self.overlays[id] = { r, g, b, a};
|
||||
if (self.extraTextures[id]) then
|
||||
self.extraTextures[id]:SetVertexColor(r, g, b, a);
|
||||
end
|
||||
if (self.extraSpinners[id]) then
|
||||
self.extraSpinners[id]:Color(r, g, b, a);
|
||||
end
|
||||
end
|
||||
|
||||
WeakAuras.regionPrototype.modifyFinish(parent, region, data);
|
||||
end
|
||||
|
||||
WeakAuras.RegisterRegionType("progresstexture", create, modify, default, properties);
|
||||
local function validate(data)
|
||||
Private.EnforceSubregionExists(data, "subbackground")
|
||||
end
|
||||
|
||||
WeakAuras.RegisterRegionType("progresstexture", create, modify, default, GetProperties, validate);
|
||||
|
||||
@@ -118,11 +118,16 @@ local screenWidth, screenHeight = math.ceil(GetScreenWidth() / 20) * 20, math.ce
|
||||
function Private.GetAnchorsForData(parentData, type)
|
||||
local result
|
||||
if not parentData.controlledChildren then
|
||||
if not WeakAuras.regionOptions[parentData.regionType] or not WeakAuras.regionOptions[parentData.regionType].getAnchors then
|
||||
if not WeakAuras.regionOptions[parentData.regionType] then
|
||||
return
|
||||
end
|
||||
|
||||
local anchors = WeakAuras.regionOptions[parentData.regionType].getAnchors(parentData)
|
||||
local anchors
|
||||
if WeakAuras.regionOptions[parentData.regionType].getAnchors then
|
||||
anchors = WeakAuras.regionOptions[parentData.regionType].getAnchors(parentData)
|
||||
else
|
||||
anchors = Private.default_types_for_anchor
|
||||
end
|
||||
for anchorId, anchorData in pairs(anchors) do
|
||||
if anchorData.type == type then
|
||||
result = result or {}
|
||||
@@ -133,23 +138,6 @@ function Private.GetAnchorsForData(parentData, type)
|
||||
return result
|
||||
end
|
||||
|
||||
function WeakAuras.regionPrototype:AnchorSubRegion(subRegion, anchorType, selfPoint, anchorPoint, anchorXOffset, anchorYOffset)
|
||||
subRegion:ClearAllPoints()
|
||||
|
||||
if anchorType == "point" then
|
||||
local xOffset = anchorXOffset or 0
|
||||
local yOffset = anchorYOffset or 0
|
||||
subRegion:SetPoint(Private.point_types[selfPoint] and selfPoint or "CENTER",
|
||||
self, Private.point_types[anchorPoint] and anchorPoint or "CENTER",
|
||||
xOffset, yOffset)
|
||||
else
|
||||
anchorXOffset = anchorXOffset or 0
|
||||
anchorYOffset = anchorYOffset or 0
|
||||
subRegion:SetPoint("bottomleft", self, "bottomleft", -anchorXOffset, -anchorYOffset)
|
||||
subRegion:SetPoint("topright", self, "topright", anchorXOffset, anchorYOffset)
|
||||
end
|
||||
end
|
||||
|
||||
-- Sound / Chat Message / Custom Code
|
||||
function WeakAuras.regionPrototype.AddProperties(properties, defaultsForRegion)
|
||||
properties["sound"] = {
|
||||
@@ -259,8 +247,7 @@ local function SendChat(self, options)
|
||||
if (not options or WeakAuras.IsOptionsOpen()) then
|
||||
return
|
||||
end
|
||||
|
||||
Private.HandleChatAction(options.message_type, options.message, options.message_dest, options.message_channel, options.r, options.g, options.b, self, options.message_custom, nil, options.message_formaters);
|
||||
Private.HandleChatAction(options.message_type, options.message, options.message_dest, options.message_dest_isunit, options.message_channel, options.r, options.g, options.b, self, options.message_custom, nil, options.message_formaters);
|
||||
end
|
||||
|
||||
local function RunCode(self, func)
|
||||
@@ -432,7 +419,7 @@ local function TimerTickForRegion(region)
|
||||
end
|
||||
|
||||
local function UpdateTimerTick(self)
|
||||
if self.triggerProvidesTimer and self.regionHasTimer then
|
||||
if self.triggerProvidesTimer and self.regionHasTimer and self.toShow then
|
||||
if not self:GetScript("OnUpdate") then
|
||||
self:SetScript("OnUpdate", function()
|
||||
TimerTickForRegion(self)
|
||||
@@ -445,7 +432,27 @@ local function UpdateTimerTick(self)
|
||||
end
|
||||
end
|
||||
|
||||
local function AnchorSubRegion(self, subRegion, anchorType, selfPoint, anchorPoint, anchorXOffset, anchorYOffset)
|
||||
subRegion:ClearAllPoints()
|
||||
|
||||
if anchorType == "point" then
|
||||
local xOffset = anchorXOffset or 0
|
||||
local yOffset = anchorYOffset or 0
|
||||
subRegion:SetPoint(Private.point_types[selfPoint] and selfPoint or "CENTER",
|
||||
self, Private.point_types[anchorPoint] and anchorPoint or "CENTER",
|
||||
xOffset, yOffset)
|
||||
else
|
||||
anchorXOffset = anchorXOffset or 0
|
||||
anchorYOffset = anchorYOffset or 0
|
||||
subRegion:SetPoint("bottomleft", self, "bottomleft", -anchorXOffset, -anchorYOffset)
|
||||
subRegion:SetPoint("topright", self, "topright", anchorXOffset, anchorYOffset)
|
||||
end
|
||||
end
|
||||
|
||||
WeakAuras.regionPrototype.AnchorSubRegion = AnchorSubRegion
|
||||
|
||||
function WeakAuras.regionPrototype.create(region)
|
||||
local defaultsForRegion = WeakAuras.regionTypes[region.regionType] and WeakAuras.regionTypes[region.regionType].default;
|
||||
region.SoundPlay = SoundPlay;
|
||||
region.SoundRepeatStop = SoundRepeatStop;
|
||||
region.SendChat = SendChat;
|
||||
@@ -470,8 +477,10 @@ function WeakAuras.regionPrototype.create(region)
|
||||
region:RealClearAllPoints();
|
||||
region:ResetPosition();
|
||||
end
|
||||
region.SetRegionAlpha = SetRegionAlpha;
|
||||
region.GetRegionAlpha = GetRegionAlpha;
|
||||
if (defaultsForRegion and defaultsForRegion.alpha) then
|
||||
region.SetRegionAlpha = SetRegionAlpha;
|
||||
region.GetRegionAlpha = GetRegionAlpha;
|
||||
end
|
||||
region.SetAnimAlpha = SetAnimAlpha;
|
||||
|
||||
region.SetTriggerProvidesTimer = SetTriggerProvidesTimer
|
||||
@@ -479,6 +488,8 @@ function WeakAuras.regionPrototype.create(region)
|
||||
region.UpdateTimerTick = UpdateTimerTick
|
||||
|
||||
region.subRegionEvents = CreateSubRegionEventSystem()
|
||||
region.AnchorSubRegion = AnchorSubRegion
|
||||
region.values = {} -- For SubText
|
||||
|
||||
region:SetPoint("CENTER", UIParent, "CENTER")
|
||||
end
|
||||
@@ -486,12 +497,12 @@ end
|
||||
-- SetDurationInfo
|
||||
|
||||
function WeakAuras.regionPrototype.modify(parent, region, data)
|
||||
region.state = nil
|
||||
region.states = nil
|
||||
region.subRegionEvents:ClearSubscribers()
|
||||
|
||||
local defaultsForRegion = WeakAuras.regionTypes[data.regionType] and WeakAuras.regionTypes[data.regionType].default;
|
||||
if (defaultsForRegion and defaultsForRegion.alpha) then
|
||||
region:SetRegionAlpha(data.alpha);
|
||||
end
|
||||
|
||||
if region.SetRegionAlpha then
|
||||
region:SetRegionAlpha(data.alpha)
|
||||
end
|
||||
@@ -558,7 +569,7 @@ function WeakAuras.regionPrototype.modify(parent, region, data)
|
||||
data.actions.start[fullKey] = default
|
||||
end
|
||||
return data.actions.start[fullKey]
|
||||
end)
|
||||
end, true)
|
||||
|
||||
region.finishFormatters = Private.CreateFormatters(data.actions.finish.message, function(key, default)
|
||||
local fullKey = "message_format_" .. key
|
||||
@@ -566,7 +577,8 @@ function WeakAuras.regionPrototype.modify(parent, region, data)
|
||||
data.actions.finish[fullKey] = default
|
||||
end
|
||||
return data.actions.finish[fullKey]
|
||||
end)
|
||||
end, true)
|
||||
|
||||
end
|
||||
|
||||
function WeakAuras.regionPrototype.modifyFinish(parent, region, data)
|
||||
@@ -742,7 +754,20 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare
|
||||
|
||||
Private.RunConditions(region, uid, true)
|
||||
region.subRegionEvents:Notify("PreHide")
|
||||
region:Hide();
|
||||
if region:IsProtected() then
|
||||
if InCombatLockdown() then
|
||||
Private.AuraWarnings.UpdateWarning(uid, "protected_frame", "error",
|
||||
L["Cannot hide secure frame in combat lockdown. Find more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Protected-Frames"],
|
||||
true)
|
||||
else
|
||||
Private.AuraWarnings.UpdateWarning(uid, "protected_frame", "warning",
|
||||
L["Secure frame detected. Find more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Protected-Frames"])
|
||||
region:Hide()
|
||||
end
|
||||
else
|
||||
Private.AuraWarnings.UpdateWarning(uid, "protected_frame")
|
||||
region:Hide()
|
||||
end
|
||||
region.states = nil
|
||||
region.state = nil
|
||||
if (cloneId) then
|
||||
@@ -759,7 +784,22 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare
|
||||
end
|
||||
Private.RunConditions(region, uid, true)
|
||||
region.subRegionEvents:Notify("PreHide")
|
||||
region:Hide();
|
||||
|
||||
if region:IsProtected() then
|
||||
if InCombatLockdown() then
|
||||
Private.AuraWarnings.UpdateWarning(uid, "protected_frame", "error",
|
||||
L["Cannot hide secure frame in combat lockdown. Find more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Protected-Frames"],
|
||||
true)
|
||||
else
|
||||
Private.AuraWarnings.UpdateWarning(uid, "protected_frame", "warning",
|
||||
L["Secure frame detected. Find more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Protected-Frames"])
|
||||
region:Hide()
|
||||
end
|
||||
else
|
||||
Private.AuraWarnings.UpdateWarning(uid, "protected_frame")
|
||||
region:Hide()
|
||||
end
|
||||
|
||||
region.states = nil
|
||||
region.state = nil
|
||||
if (cloneId) then
|
||||
@@ -786,6 +826,7 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare
|
||||
end
|
||||
|
||||
UnRegisterForFrameTick(region)
|
||||
region:UpdateTimerTick()
|
||||
end
|
||||
function region:Expand()
|
||||
if (region.toShow) then
|
||||
@@ -799,7 +840,21 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare
|
||||
region.subRegionEvents:Notify("PreShow")
|
||||
|
||||
Private.ApplyFrameLevel(region)
|
||||
region:Show();
|
||||
if region:IsProtected() then
|
||||
if InCombatLockdown() then
|
||||
Private.AuraWarnings.UpdateWarning(uid, "protected_frame", "error",
|
||||
L["Cannot show secure frame in combat lockdown. Find more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Protected-Frames"],
|
||||
true)
|
||||
else
|
||||
Private.AuraWarnings.UpdateWarning(uid, "protected_frame", "warning",
|
||||
L["Secure frame detected. Find more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Protected-Frames"])
|
||||
region:Show()
|
||||
end
|
||||
else
|
||||
Private.AuraWarnings.UpdateWarning(uid, "protected_frame")
|
||||
region:Show()
|
||||
end
|
||||
|
||||
Private.PerformActions(data, "start", region);
|
||||
if not(Private.Animate("display", data.uid, "start", data.animation.start, region, true, startMainAnimation, nil, cloneId)) then
|
||||
startMainAnimation();
|
||||
@@ -831,6 +886,7 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare
|
||||
end
|
||||
|
||||
UnRegisterForFrameTick(region)
|
||||
region:UpdateTimerTick()
|
||||
end
|
||||
function region:Expand()
|
||||
if data.anchorFrameType == "SELECTFRAME"
|
||||
@@ -843,16 +899,30 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare
|
||||
if (region.toShow) then
|
||||
return;
|
||||
end
|
||||
region.toShow = true;
|
||||
region.toShow = true
|
||||
|
||||
if(region.PreShow) then
|
||||
region:PreShow();
|
||||
end
|
||||
|
||||
region.subRegionEvents:Notify("PreShow")
|
||||
|
||||
Private.ApplyFrameLevel(region)
|
||||
region:Show();
|
||||
|
||||
if region:IsProtected() then
|
||||
if InCombatLockdown() then
|
||||
Private.AuraWarnings.UpdateWarning(uid, "protected_frame", "error",
|
||||
L["Cannot show secure frame in combat lockdown. Find more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Protected-Frames"],
|
||||
true)
|
||||
else
|
||||
Private.AuraWarnings.UpdateWarning(uid, "protected_frame", "warning",
|
||||
L["Secure frame detected. Find more information:\nhttps://github.com/WeakAuras/WeakAuras2/wiki/Protected-Frames"])
|
||||
region:Show()
|
||||
end
|
||||
else
|
||||
Private.AuraWarnings.UpdateWarning(uid, "protected_frame")
|
||||
region:Show()
|
||||
end
|
||||
|
||||
Private.PerformActions(data, "start", region);
|
||||
if not(Private.Animate("display", data.uid, "start", data.animation.start, region, true, startMainAnimation, nil, cloneId)) then
|
||||
startMainAnimation();
|
||||
@@ -873,4 +943,60 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare
|
||||
if not region.Expand then
|
||||
function region:Expand() end
|
||||
end
|
||||
if not region.Pause then
|
||||
function region:Pause()
|
||||
self.paused = true
|
||||
end
|
||||
end
|
||||
if not region.Resume then
|
||||
function region:Resume()
|
||||
self.paused = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local function move_condition_subregions(data, offset, afterPos)
|
||||
if data.conditions then
|
||||
for conditionIndex, condition in ipairs(data.conditions) do
|
||||
if type(condition.changes) == "table" then
|
||||
for changeIndex, change in ipairs(condition.changes) do
|
||||
if change.property then
|
||||
local subRegionIndex, property = change.property:match("^sub%.(%d+)%.(.*)")
|
||||
subRegionIndex = tonumber(subRegionIndex)
|
||||
if subRegionIndex and property then
|
||||
if (subRegionIndex >= afterPos) then
|
||||
change.property = "sub." .. subRegionIndex + offset .. "." .. property
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Private.EnforceSubregionExists(data, subregionType)
|
||||
data.subRegions = data.subRegions or {}
|
||||
-- search and save indexes of matching subregions
|
||||
local indexes = {}
|
||||
for index, subRegionData in ipairs(data.subRegions) do
|
||||
if subRegionData.type == subregionType then
|
||||
table.insert(indexes, index)
|
||||
end
|
||||
end
|
||||
-- add if missing
|
||||
if #indexes == 0 then
|
||||
tinsert(data.subRegions, 1, {
|
||||
["type"] = subregionType
|
||||
})
|
||||
move_condition_subregions(data, 1, 1)
|
||||
-- delete duplicate
|
||||
elseif #indexes > 1 then
|
||||
for i = #indexes, 2, -1 do
|
||||
table.remove(data.subRegions, indexes[i])
|
||||
move_condition_subregions(data, -1, indexes[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,6 +37,10 @@ local default = {
|
||||
customForegroundRows = 16,
|
||||
customForegroundColumns = 16,
|
||||
customBackgroundFrames = 0,
|
||||
customForegroundFileWidth = 0,
|
||||
customForegroundFileHeight = 0,
|
||||
customForegroundFrameWidth = 0,
|
||||
customForegroundFrameHeight = 0,
|
||||
customBackgroundRows = 16,
|
||||
customBackgroundColumns = 16,
|
||||
hideBackground = true
|
||||
@@ -87,6 +91,7 @@ WeakAuras.regionPrototype.AddProperties(properties, default);
|
||||
|
||||
local function create(parent)
|
||||
local frame = CreateFrame("FRAME", nil, UIParent);
|
||||
frame.regionType = "stopmotion"
|
||||
frame:SetMovable(true);
|
||||
frame:SetResizable(true);
|
||||
frame:SetMinResize(1, 1);
|
||||
@@ -108,27 +113,34 @@ local function SetTextureViaAtlas(self, texture)
|
||||
self:SetTexture(texture);
|
||||
end
|
||||
|
||||
local function setTile(texture, frame, rows, columns )
|
||||
local function setTile(texture, frame, rows, columns, frameScaleW, frameScaleH)
|
||||
frame = frame - 1;
|
||||
local row = floor(frame / columns);
|
||||
local column = frame % columns;
|
||||
|
||||
local deltaX = 1 / columns;
|
||||
local deltaY = 1 / rows;
|
||||
local deltaX = frameScaleW / columns
|
||||
local deltaY = frameScaleH / rows
|
||||
|
||||
local left = deltaX * column;
|
||||
local right = left + deltaX;
|
||||
|
||||
local top = deltaY * row;
|
||||
local bottom = top + deltaY;
|
||||
|
||||
texture:SetTexCoord(left, right, top, bottom);
|
||||
pcall(function() texture:SetTexCoord(left, right, top, bottom) end)
|
||||
end
|
||||
|
||||
WeakAuras.setTile = setTile;
|
||||
|
||||
local function SetFrameViaAtlas(self, texture, frame)
|
||||
setTile(self, frame, self.rows, self.columns);
|
||||
local frameScaleW = 1
|
||||
local frameScaleH = 1
|
||||
if self.fileWidth and self.frameWidth and self.fileWidth > 0 and self.frameWidth > 0 then
|
||||
frameScaleW = (self.frameWidth * self.columns) / self.fileWidth
|
||||
end
|
||||
if self.fileHeight and self.frameHeight and self.fileHeight > 0 and self.frameHeight > 0 then
|
||||
frameScaleH = (self.frameHeight * self.rows) / self.fileHeight
|
||||
end
|
||||
setTile(self, frame, self.rows, self.columns, frameScaleW, frameScaleH);
|
||||
end
|
||||
|
||||
local function SetTextureViaFrames(self, texture)
|
||||
@@ -142,29 +154,63 @@ end
|
||||
|
||||
local function modify(parent, region, data)
|
||||
WeakAuras.regionPrototype.modify(parent, region, data);
|
||||
|
||||
region.foreground = region.foreground or {}
|
||||
region.background = region.background or {}
|
||||
local pattern = "%.x(%d+)y(%d+)f(%d+)%.[tb][gl][ap]"
|
||||
local tdata = texture_data[data.foregroundTexture];
|
||||
if (tdata) then
|
||||
local lastFrame = tdata.count - 1;
|
||||
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
|
||||
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
|
||||
region.foreground.rows = tdata.rows;
|
||||
region.foreground.columns = tdata.columns;
|
||||
else
|
||||
local rows, columns, frames = data.foregroundTexture:lower():match(pattern)
|
||||
if rows and columns and frames then
|
||||
local lastFrame = frames - 1;
|
||||
local pattern2 = "%.x(%d+)y(%d+)f(%d+)w(%d+)h(%d+)W(%d+)H(%d+)%.[tb][gl][ap]"
|
||||
|
||||
do
|
||||
local tdata = texture_data[data.foregroundTexture];
|
||||
if (tdata) then
|
||||
local lastFrame = tdata.count - 1;
|
||||
region.foreground.lastFrame = lastFrame
|
||||
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
|
||||
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
|
||||
region.foreground.rows = rows;
|
||||
region.foreground.columns = columns;
|
||||
region.foreground.rows = tdata.rows;
|
||||
region.foreground.columns = tdata.columns;
|
||||
region.foreground.fileWidth = 0
|
||||
region.foreground.fileHeight = 0
|
||||
region.foreground.frameWidth = 0
|
||||
region.foreground.frameHeight = 0
|
||||
else
|
||||
local lastFrame = (data.customForegroundFrames or 256) - 1;
|
||||
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
|
||||
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
|
||||
region.foreground.rows = data.customForegroundRows;
|
||||
region.foreground.columns = data.customForegroundColumns;
|
||||
local rows, columns, frames = data.foregroundTexture:lower():match(pattern)
|
||||
if rows then
|
||||
local lastFrame = tonumber(frames) - 1;
|
||||
region.foreground.lastFrame = lastFrame
|
||||
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
|
||||
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
|
||||
region.foreground.rows = tonumber(rows)
|
||||
region.foreground.columns = tonumber(columns)
|
||||
region.foreground.fileWidth = 0
|
||||
region.foreground.fileHeight = 0
|
||||
region.foreground.frameWidth = 0
|
||||
region.foreground.frameHeight = 0
|
||||
else
|
||||
local rows, columns, frames, frameWidth, frameHeight, fileWidth, fileHeight = data.foregroundTexture:match(pattern2)
|
||||
if rows then
|
||||
local lastFrame = tonumber(frames) - 1;
|
||||
region.foreground.lastFrame = lastFrame
|
||||
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
|
||||
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
|
||||
region.foreground.rows = tonumber(rows)
|
||||
region.foreground.columns = tonumber(columns)
|
||||
region.foreground.fileWidth = tonumber(fileWidth)
|
||||
region.foreground.fileHeight = tonumber(fileHeight)
|
||||
region.foreground.frameWidth = tonumber(frameWidth)
|
||||
region.foreground.frameHeight = tonumber(frameHeight)
|
||||
else
|
||||
local lastFrame = (data.customForegroundFrames or 256) - 1;
|
||||
region.foreground.lastFrame = lastFrame
|
||||
region.startFrame = floor( (data.startPercent or 0) * lastFrame) + 1;
|
||||
region.endFrame = floor( (data.endPercent or 1) * lastFrame) + 1;
|
||||
region.foreground.rows = data.customForegroundRows;
|
||||
region.foreground.columns = data.customForegroundColumns;
|
||||
region.foreground.fileWidth = data.customForegroundFileWidth
|
||||
region.foreground.fileHeight = data.customForegroundFileHeight
|
||||
region.foreground.frameWidth = data.customForegroundFrameWidth
|
||||
region.foreground.frameHeight = data.customForegroundFrameHeight
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -172,27 +218,60 @@ local function modify(parent, region, data)
|
||||
and data.foregroundTexture
|
||||
or data.backgroundTexture;
|
||||
|
||||
local tbdata = texture_data[backgroundTexture];
|
||||
if (tbdata) then
|
||||
local lastFrame = tbdata.count - 1;
|
||||
region.backgroundFrame = floor( (data.backgroundPercent or 1) * lastFrame + 1);
|
||||
region.background.rows = tbdata.rows;
|
||||
region.background.columns = tbdata.columns;
|
||||
else
|
||||
local rows, columns, frames = backgroundTexture:lower():match(pattern)
|
||||
if rows and columns and frames then
|
||||
local lastFrame = frames - 1;
|
||||
region.backgroundFrame = floor( (data.backgroundPercent or 1) * lastFrame + 1);
|
||||
region.background.rows = rows;
|
||||
region.background.columns = columns;
|
||||
do
|
||||
if data.sameTexture then
|
||||
region.backgroundFrame = floor( (data.backgroundPercent or 1) * region.foreground.lastFrame + 1);
|
||||
region.background.rows = region.foreground.rows
|
||||
region.background.columns = region.foreground.columns
|
||||
region.background.fileWidth = region.foreground.fileWidth
|
||||
region.background.fileHeight = region.foreground.fileHeight
|
||||
region.background.frameWidth = region.foreground.frameWidth
|
||||
region.background.frameHeight = region.foreground.frameHeight
|
||||
else
|
||||
local lastFrame = (data.sameTexture and data.customForegroundFrames
|
||||
or data.customBackgroundFrames or 256) - 1;
|
||||
region.backgroundFrame = floor( (data.backgroundPercent or 1) * lastFrame + 1);
|
||||
region.background.rows = data.sameTexture and data.customForegroundRows
|
||||
or data.customBackgroundRows;
|
||||
region.background.columns = data.sameTexture and data.customForegroundColumns
|
||||
or data.customBackgroundColumns;
|
||||
local tdata = texture_data[data.backgroundTexture];
|
||||
if (tdata) then
|
||||
local lastFrame = tdata.count - 1;
|
||||
region.backgroundFrame = floor( (data.backgroundPercent or 1) * lastFrame + 1);
|
||||
region.background.rows = tdata.rows;
|
||||
region.background.columns = tdata.columns;
|
||||
region.background.fileWidth = 0
|
||||
region.background.fileHeight = 0
|
||||
region.background.frameWidth = 0
|
||||
region.background.frameHeight = 0
|
||||
else
|
||||
local rows, columns, frames = data.backgroundTexture:lower():match(pattern)
|
||||
if rows then
|
||||
local lastFrame = frames - 1;
|
||||
region.backgroundFrame = floor( (data.backgroundPercent or 1) * lastFrame + 1);
|
||||
region.background.rows = tonumber(rows)
|
||||
region.background.columns = tonumber(columns)
|
||||
region.background.fileWidth = 0
|
||||
region.background.fileHeight = 0
|
||||
region.background.frameWidth = 0
|
||||
region.background.frameHeight = 0
|
||||
else
|
||||
local rows, columns, frames, frameWidth, frameHeight, fileWidth, fileHeight = data.backgroundTexture:match(pattern2)
|
||||
if rows then
|
||||
local lastFrame = frames - 1;
|
||||
region.backgroundFrame = floor( (data.backgroundPercent or 1) * lastFrame + 1);
|
||||
region.background.rows = tonumber(rows)
|
||||
region.background.columns = tonumber(columns)
|
||||
region.background.fileWidth = tonumber(fileWidth)
|
||||
region.background.fileHeight = tonumber(fileHeight)
|
||||
region.background.frameWidth = tonumber(frameWidth)
|
||||
region.background.frameHeight = tonumber(frameHeight)
|
||||
else
|
||||
local lastFrame = (data.customBackgroundFrames or 256) - 1;
|
||||
region.backgroundFrame = floor( (data.backgroundPercent or 1) * lastFrame + 1);
|
||||
region.background.rows = data.customBackgroundRows;
|
||||
region.background.columns = data.customBackgroundColumns;
|
||||
region.background.fileWidth = data.customBackgroundFileWidth
|
||||
region.background.fileHeight = data.customBackgroundFileHeight
|
||||
region.background.frameWidth = data.customBackgroundFrameWidth
|
||||
region.background.frameHeight = data.customBackgroundFrameHeight
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -339,7 +418,12 @@ local function modify(parent, region, data)
|
||||
local total = region.state.total ~= 0 and region.state.total or 1
|
||||
frame = floor((frames - 1) * value / total) + startFrame;
|
||||
else
|
||||
local remaining = region.state.expirationTime and (region.state.expirationTime - GetTime()) or 0;
|
||||
local remaining
|
||||
if region.state.paused then
|
||||
remaining = region.state.remaining or 0;
|
||||
else
|
||||
remaining = region.state.expirationTime and (region.state.expirationTime - GetTime()) or 0;
|
||||
end
|
||||
local progress = region.state.duration and region.state.duration > 0 and (1 - (remaining / region.state.duration)) or 0;
|
||||
frame = floor( (frames - 1) * progress) + startFrame;
|
||||
end
|
||||
@@ -364,6 +448,15 @@ local function modify(parent, region, data)
|
||||
region.FrameTick = onUpdate;
|
||||
|
||||
function region:Update()
|
||||
if region.state.paused then
|
||||
if not region.paused then
|
||||
region:Pause()
|
||||
end
|
||||
else
|
||||
if region.paused then
|
||||
region:Resume()
|
||||
end
|
||||
end
|
||||
onUpdate();
|
||||
end
|
||||
|
||||
@@ -390,4 +483,8 @@ local function modify(parent, region, data)
|
||||
end
|
||||
end
|
||||
|
||||
WeakAuras.RegisterRegionType("stopmotion", create, modify, default, properties);
|
||||
local function validate(data)
|
||||
Private.EnforceSubregionExists(data, "subbackground")
|
||||
end
|
||||
|
||||
WeakAuras.RegisterRegionType("stopmotion", create, modify, default, properties, validate);
|
||||
|
||||
@@ -27,7 +27,7 @@ local default = {
|
||||
|
||||
shadowColor = { 0, 0, 0, 1},
|
||||
shadowXOffset = 1,
|
||||
shadowYOffset = -1,
|
||||
shadowYOffset = -1
|
||||
};
|
||||
|
||||
local properties = {
|
||||
@@ -55,6 +55,7 @@ end
|
||||
|
||||
local function create(parent)
|
||||
local region = CreateFrame("FRAME", nil, parent);
|
||||
region.regionType = "text"
|
||||
region:SetMovable(true);
|
||||
|
||||
local text = region:CreateFontString(nil, "OVERLAY");
|
||||
@@ -62,7 +63,6 @@ local function create(parent)
|
||||
text:SetWordWrap(true);
|
||||
text:SetNonSpaceWrap(true);
|
||||
|
||||
region.values = {};
|
||||
region.duration = 0;
|
||||
region.expirationTime = math.huge;
|
||||
|
||||
@@ -268,7 +268,11 @@ local function modify(parent, region, data)
|
||||
WeakAuras.regionPrototype.modifyFinish(parent, region, data);
|
||||
end
|
||||
|
||||
WeakAuras.RegisterRegionType("text", create, modify, default, GetProperties);
|
||||
local function validate(data)
|
||||
Private.EnforceSubregionExists(data, "subbackground")
|
||||
end
|
||||
|
||||
WeakAuras.RegisterRegionType("text", create, modify, default, GetProperties, validate);
|
||||
|
||||
-- Fallback region type
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ WeakAuras.regionPrototype.AddProperties(properties, default);
|
||||
|
||||
local function create(parent)
|
||||
local region = CreateFrame("FRAME", nil, UIParent);
|
||||
region.regionType = "texture"
|
||||
region:SetMovable(true);
|
||||
region:SetResizable(true);
|
||||
region:SetMinResize(1, 1);
|
||||
@@ -78,9 +79,6 @@ local function create(parent)
|
||||
texture:SetAllPoints(region);
|
||||
|
||||
WeakAuras.regionPrototype.create(region);
|
||||
region.values = {};
|
||||
|
||||
region.AnchorSubRegion = WeakAuras.regionPrototype.AnchorSubRegion
|
||||
|
||||
return region;
|
||||
end
|
||||
@@ -237,4 +235,8 @@ local function modify(parent, region, data)
|
||||
WeakAuras.regionPrototype.modifyFinish(parent, region, data);
|
||||
end
|
||||
|
||||
WeakAuras.RegisterRegionType("texture", create, modify, default, properties);
|
||||
local function validate(data)
|
||||
Private.EnforceSubregionExists(data, "subbackground")
|
||||
end
|
||||
|
||||
WeakAuras.RegisterRegionType("texture", create, modify, default, properties, validate);
|
||||
|
||||
Reference in New Issue
Block a user