from retail
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user