pcall instead xpcall
This commit is contained in:
@@ -214,7 +214,10 @@ function WeakAuras.ActivateAuraEnvironment(id, cloneId, state, states, onlyConfi
|
|||||||
if(actions and actions.do_custom and actions.custom) then
|
if(actions and actions.do_custom and actions.custom) then
|
||||||
local func = WeakAuras.customActionsFunctions[id]["init"]
|
local func = WeakAuras.customActionsFunctions[id]["init"]
|
||||||
if func then
|
if func then
|
||||||
xpcall(func, geterrorhandler())
|
local ok, ret = xpcall(func)
|
||||||
|
if not ok then
|
||||||
|
geterrorhandler()(ret)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -339,8 +339,9 @@ local function RunOverlayFuncs(event, state)
|
|||||||
for i, overlayFunc in ipairs(event.overlayFuncs) do
|
for i, overlayFunc in ipairs(event.overlayFuncs) do
|
||||||
state.additionalProgress[i] = state.additionalProgress[i] or {};
|
state.additionalProgress[i] = state.additionalProgress[i] or {};
|
||||||
local additionalProgress = state.additionalProgress[i];
|
local additionalProgress = state.additionalProgress[i];
|
||||||
local a, b, c = overlayFunc(event.trigger, state);
|
local ok, a, b, c = pcall(overlayFunc, event.trigger, state);
|
||||||
if (not a) then
|
if (not ok) then
|
||||||
|
geterrorhandler()(a)
|
||||||
additionalProgress.min = nil;
|
additionalProgress.min = nil;
|
||||||
additionalProgress.max = nil;
|
additionalProgress.max = nil;
|
||||||
additionalProgress.direction = nil;
|
additionalProgress.direction = nil;
|
||||||
@@ -386,8 +387,13 @@ local function callFunctionForActivateEvent(func, trigger, fallback, errorHandle
|
|||||||
if not func then
|
if not func then
|
||||||
return fallback
|
return fallback
|
||||||
end
|
end
|
||||||
local value = func(trigger)
|
local ok, value = pcall(func, trigger)
|
||||||
return value or fallback
|
if not ok then
|
||||||
|
errorHandler(value)
|
||||||
|
return fallback
|
||||||
|
else
|
||||||
|
return value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)
|
function WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)
|
||||||
@@ -419,8 +425,13 @@ function WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)
|
|||||||
state.inverse = nil;
|
state.inverse = nil;
|
||||||
state.autoHide = autoHide;
|
state.autoHide = autoHide;
|
||||||
elseif (data.durationFunc) then
|
elseif (data.durationFunc) then
|
||||||
local arg1, arg2, arg3, inverse = data.durationFunc(data.trigger);
|
local ok, arg1, arg2, arg3, inverse = pcall(data.durationFunc, data.trigger);
|
||||||
arg1 = type(arg1) == "number" and arg1 or 0;
|
if not ok then
|
||||||
|
errorHandler(arg1);
|
||||||
|
arg1 = 0;
|
||||||
|
arg2 = 0;
|
||||||
|
end
|
||||||
|
arg1 = type(arg1) == "number" and arg2 or 0;
|
||||||
arg2 = type(arg2) == "number" and arg2 or 0;
|
arg2 = type(arg2) == "number" and arg2 or 0;
|
||||||
|
|
||||||
if (state.inverse ~= inverse) then
|
if (state.inverse ~= inverse) then
|
||||||
@@ -525,13 +536,17 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
|
|||||||
if(data.triggerFunc) then
|
if(data.triggerFunc) then
|
||||||
local untriggerCheck = false;
|
local untriggerCheck = false;
|
||||||
if (data.statesParameter == "full") then
|
if (data.statesParameter == "full") then
|
||||||
local returnValue = data.triggerFunc(allStates, event, arg1, arg2, ...);
|
local ok, returnValue = pcall(data.triggerFunc, allStates, event, arg1, arg2, ...);
|
||||||
if (returnValue) then
|
if not ok then
|
||||||
|
errorHandler(returnValue)
|
||||||
|
elseif ok and returnValue then
|
||||||
updateTriggerState = true;
|
updateTriggerState = true;
|
||||||
end
|
end
|
||||||
elseif (data.statesParameter == "all") then
|
elseif (data.statesParameter == "all") then
|
||||||
local returnValue = data.triggerFunc(allStates, event, arg1, arg2, ...);
|
local ok, returnValue = pcall(data.triggerFunc, allStates, event, arg1, arg2, ...);
|
||||||
if( (returnValue) or optionsEvent) then
|
if not ok then
|
||||||
|
errorHandler(returnValue)
|
||||||
|
elseif (ok and returnValue) or optionsEvent then
|
||||||
for id, state in pairs(allStates) do
|
for id, state in pairs(allStates) do
|
||||||
if (state.changed) then
|
if (state.changed) then
|
||||||
if (WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)) then
|
if (WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)) then
|
||||||
@@ -554,8 +569,10 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
|
|||||||
end
|
end
|
||||||
allStates[cloneId] = allStates[cloneId] or {};
|
allStates[cloneId] = allStates[cloneId] or {};
|
||||||
local state = allStates[cloneId];
|
local state = allStates[cloneId];
|
||||||
local returnValue = data.triggerFunc(state, event, unit, arg1, arg2, ...);
|
local ok, returnValue = pcall(data.triggerFunc, state, event, unit, arg1, arg2, ...);
|
||||||
if returnValue or optionsEvent then
|
if not ok then
|
||||||
|
errorHandler(returnValue)
|
||||||
|
elseif (ok and returnValue) or optionsEvent then
|
||||||
if(WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)) then
|
if(WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)) then
|
||||||
updateTriggerState = true;
|
updateTriggerState = true;
|
||||||
end
|
end
|
||||||
@@ -566,8 +583,10 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
|
|||||||
elseif (data.statesParameter == "one") then
|
elseif (data.statesParameter == "one") then
|
||||||
allStates[""] = allStates[""] or {};
|
allStates[""] = allStates[""] or {};
|
||||||
local state = allStates[""];
|
local state = allStates[""];
|
||||||
local returnValue = data.triggerFunc(state, event, arg1, arg2, ...);
|
local ok, returnValue = pcall(data.triggerFunc, state, event, arg1, arg2, ...);
|
||||||
if returnValue or optionsEvent then
|
if not ok then
|
||||||
|
errorHandler(returnValue)
|
||||||
|
elseif (ok and returnValue) or optionsEvent then
|
||||||
if(WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)) then
|
if(WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)) then
|
||||||
updateTriggerState = true;
|
updateTriggerState = true;
|
||||||
end
|
end
|
||||||
@@ -575,8 +594,10 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
|
|||||||
untriggerCheck = true;
|
untriggerCheck = true;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local returnValue = data.triggerFunc(event, arg1, arg2, ...);
|
local ok, returnValue = pcall(data.triggerFunc, event, arg1, arg2, ...);
|
||||||
if returnValue or optionsEvent then
|
if not ok then
|
||||||
|
errorHandler(returnValue)
|
||||||
|
elseif (ok and returnValue) or optionsEvent then
|
||||||
allStates[""] = allStates[""] or {};
|
allStates[""] = allStates[""] or {};
|
||||||
local state = allStates[""];
|
local state = allStates[""];
|
||||||
if(WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)) then
|
if(WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)) then
|
||||||
@@ -589,8 +610,10 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
|
|||||||
if (untriggerCheck and not optionsEvent) then
|
if (untriggerCheck and not optionsEvent) then
|
||||||
if (data.statesParameter == "all") then
|
if (data.statesParameter == "all") then
|
||||||
if data.untriggerFunc then
|
if data.untriggerFunc then
|
||||||
local returnValue = data.untriggerFunc(allStates, event, arg1, arg2, ...);
|
local ok, returnValue = pcall(data.untriggerFunc, allStates, event, arg1, arg2, ...);
|
||||||
if returnValue then
|
if not ok then
|
||||||
|
errorHandler(returnValue)
|
||||||
|
elseif (ok and returnValue) or optionsEvent then
|
||||||
for id, state in pairs(allStates) do
|
for id, state in pairs(allStates) do
|
||||||
if (state.changed) then
|
if (state.changed) then
|
||||||
if (WeakAuras.EndEvent(id, triggernum, nil, state)) then
|
if (WeakAuras.EndEvent(id, triggernum, nil, state)) then
|
||||||
@@ -606,8 +629,10 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
|
|||||||
local cloneId = WeakAuras.multiUnitUnits[data.trigger.unit] and arg1 or ""
|
local cloneId = WeakAuras.multiUnitUnits[data.trigger.unit] and arg1 or ""
|
||||||
local state = allStates[cloneId]
|
local state = allStates[cloneId]
|
||||||
if state then
|
if state then
|
||||||
local returnValue = data.untriggerFunc(state, event, arg1, arg2, ...);
|
local ok, returnValue = pcall(data.untriggerFunc, state, event, arg1, arg2, ...);
|
||||||
if returnValue then
|
if not ok then
|
||||||
|
errorHandler(returnValue)
|
||||||
|
elseif ok and returnValue then
|
||||||
if (WeakAuras.EndEvent(id, triggernum, nil, state)) then
|
if (WeakAuras.EndEvent(id, triggernum, nil, state)) then
|
||||||
updateTriggerState = true;
|
updateTriggerState = true;
|
||||||
end
|
end
|
||||||
@@ -619,8 +644,10 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
|
|||||||
allStates[""] = allStates[""] or {};
|
allStates[""] = allStates[""] or {};
|
||||||
local state = allStates[""];
|
local state = allStates[""];
|
||||||
if data.untriggerFunc then
|
if data.untriggerFunc then
|
||||||
local returnValue = data.untriggerFunc(state, event, arg1, arg2, ...);
|
local ok, returnValue = pcall(data.untriggerFunc, state, event, arg1, arg2, ...);
|
||||||
if returnValue then
|
if not ok then
|
||||||
|
errorHandler(returnValue)
|
||||||
|
elseif (ok and returnValue) then
|
||||||
if (WeakAuras.EndEvent(id, triggernum, nil, state)) then
|
if (WeakAuras.EndEvent(id, triggernum, nil, state)) then
|
||||||
updateTriggerState = true;
|
updateTriggerState = true;
|
||||||
end
|
end
|
||||||
@@ -628,8 +655,10 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
if data.untriggerFunc then
|
if data.untriggerFunc then
|
||||||
local returnValue = data.untriggerFunc(event, arg1, arg2, ...);
|
local ok, returnValue = pcall(data.untriggerFunc, event, arg1, arg2, ...);
|
||||||
if returnValue then
|
if not ok then
|
||||||
|
errorHandler(returnValue)
|
||||||
|
elseif (ok and returnValue) then
|
||||||
allStates[""] = allStates[""] or {};
|
allStates[""] = allStates[""] or {};
|
||||||
local state = allStates[""];
|
local state = allStates[""];
|
||||||
if(WeakAuras.EndEvent(id, triggernum, nil, state)) then
|
if(WeakAuras.EndEvent(id, triggernum, nil, state)) then
|
||||||
@@ -1026,7 +1055,7 @@ function GenericTrigger.LoadDisplays(toLoad, loadEvent, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for event in pairs(eventsToRegister) do
|
for event in pairs(eventsToRegister) do
|
||||||
frame:RegisterEvent(event)
|
pcall(frame.RegisterEvent, frame, event)
|
||||||
genericTriggerRegisteredEvents[event] = true;
|
genericTriggerRegisteredEvents[event] = true;
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1037,7 +1066,7 @@ function GenericTrigger.LoadDisplays(toLoad, loadEvent, ...)
|
|||||||
frame.unitFrames[unit].unit = unit
|
frame.unitFrames[unit].unit = unit
|
||||||
frame.unitFrames[unit]:SetScript("OnEvent", HandleUnitEvent);
|
frame.unitFrames[unit]:SetScript("OnEvent", HandleUnitEvent);
|
||||||
end
|
end
|
||||||
frame.unitFrames[unit]:RegisterEvent(event)
|
pcall(frame.unitFrames[unit].RegisterEvent, frame.unitFrames[unit], event, unit)
|
||||||
genericTriggerRegisteredUnitEvents[unit] = genericTriggerRegisteredUnitEvents[unit] or {};
|
genericTriggerRegisteredUnitEvents[unit] = genericTriggerRegisteredUnitEvents[unit] or {};
|
||||||
genericTriggerRegisteredUnitEvents[unit][event] = true;
|
genericTriggerRegisteredUnitEvents[unit][event] = true;
|
||||||
end
|
end
|
||||||
@@ -3646,26 +3675,56 @@ function GenericTrigger.CreateFallbackState(data, triggernum, state)
|
|||||||
WeakAuras.ActivateAuraEnvironment(data.id, "", state);
|
WeakAuras.ActivateAuraEnvironment(data.id, "", state);
|
||||||
local firstTrigger = data.triggers[1].trigger
|
local firstTrigger = data.triggers[1].trigger
|
||||||
if (event.nameFunc) then
|
if (event.nameFunc) then
|
||||||
local name = event.nameFunc(firstTrigger);
|
local success, res = pcall(event.nameFunc, firstTrigger);
|
||||||
state.name = name or nil;
|
if not success then
|
||||||
|
geterrorhandler()(res)
|
||||||
|
state.name = nil
|
||||||
|
else
|
||||||
|
state.name = res or nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if (event.iconFunc) then
|
if (event.iconFunc) then
|
||||||
local icon = event.iconFunc(firstTrigger);
|
local success, res = pcall(event.iconFunc, firstTrigger);
|
||||||
state.icon = icon or nil;
|
if not success then
|
||||||
|
geterrorhandler()(res)
|
||||||
|
state.icon = nil
|
||||||
|
else
|
||||||
|
state.icon = res or nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (event.textureFunc ) then
|
if (event.textureFunc ) then
|
||||||
local texture = event.textureFunc(firstTrigger);
|
local success, res = pcall(event.textureFunc, firstTrigger);
|
||||||
state.texture = texture or nil;
|
if not success then
|
||||||
|
geterrorhandler()(res)
|
||||||
|
state.texture = nil
|
||||||
|
else
|
||||||
|
state.texture = res or nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (event.stacksFunc) then
|
if (event.stacksFunc) then
|
||||||
local stacks = event.stacksFunc(firstTrigger);
|
local success, res = pcall(event.stacksFunc, firstTrigger);
|
||||||
state.stacks = stacks or nil;
|
if not success then
|
||||||
|
geterrorhandler()(res)
|
||||||
|
state.stacks = nil
|
||||||
|
else
|
||||||
|
state.stacks = res or nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (event.durationFunc) then
|
if (event.durationFunc) then
|
||||||
local arg1, arg2, arg3, inverse = event.durationFunc(firstTrigger);
|
local arg1, arg2, arg3, inverse = event.durationFunc(firstTrigger);
|
||||||
|
local success, arg1, arg2, arg3, inverse = pcall(event.durationFunc, firstTrigger);
|
||||||
|
if not success then
|
||||||
|
geterrorhandler()(arg1)
|
||||||
|
state.progressType = "timed";
|
||||||
|
state.duration = 0;
|
||||||
|
state.expirationTime = math.huge;
|
||||||
|
state.value = nil;
|
||||||
|
state.total = nil;
|
||||||
|
return;
|
||||||
|
end
|
||||||
arg1 = type(arg1) == "number" and arg1 or 0;
|
arg1 = type(arg1) == "number" and arg1 or 0;
|
||||||
arg2 = type(arg2) == "number" and arg2 or 0;
|
arg2 = type(arg2) == "number" and arg2 or 0;
|
||||||
|
|
||||||
|
|||||||
@@ -310,9 +310,11 @@ local sorters = {
|
|||||||
local sortFunc = WeakAuras.LoadFunction("return " .. sortStr, data.id, "custom sort") or noop
|
local sortFunc = WeakAuras.LoadFunction("return " .. sortStr, data.id, "custom sort") or noop
|
||||||
return function(a, b)
|
return function(a, b)
|
||||||
WeakAuras.ActivateAuraEnvironment(data.id)
|
WeakAuras.ActivateAuraEnvironment(data.id)
|
||||||
local result = sortFunc(a, b)
|
local ok, result = pcall(sortFunc, a, b)
|
||||||
WeakAuras.ActivateAuraEnvironment()
|
WeakAuras.ActivateAuraEnvironment()
|
||||||
if result then
|
if not ok then
|
||||||
|
geterrorhandler()(result)
|
||||||
|
else
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -367,7 +369,10 @@ local anchorers = {
|
|||||||
local anchorFunc = WeakAuras.LoadFunction("return " .. anchorStr, data.id, "custom frame anchor") or noop
|
local anchorFunc = WeakAuras.LoadFunction("return " .. anchorStr, data.id, "custom frame anchor") or noop
|
||||||
return function(frames, activeRegions)
|
return function(frames, activeRegions)
|
||||||
WeakAuras.ActivateAuraEnvironment(data.id)
|
WeakAuras.ActivateAuraEnvironment(data.id)
|
||||||
anchorFunc(frames, activeRegions)
|
local ok, ret = pcall(anchorFunc, frames, activeRegions)
|
||||||
|
if not ok then
|
||||||
|
geterrorhandler()(ret)
|
||||||
|
end
|
||||||
WeakAuras.ActivateAuraEnvironment()
|
WeakAuras.ActivateAuraEnvironment()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -715,11 +720,12 @@ local growers = {
|
|||||||
local growFunc = WeakAuras.LoadFunction("return " .. growStr, data.id, "custom grow") or noop
|
local growFunc = WeakAuras.LoadFunction("return " .. growStr, data.id, "custom grow") or noop
|
||||||
return function(newPositions, activeRegions)
|
return function(newPositions, activeRegions)
|
||||||
WeakAuras.ActivateAuraEnvironment(data.id)
|
WeakAuras.ActivateAuraEnvironment(data.id)
|
||||||
growFunc(newPositions, activeRegions)
|
local ok, ret = pcall(growFunc, newPositions, activeRegions)
|
||||||
WeakAuras.ActivateAuraEnvironment()
|
WeakAuras.ActivateAuraEnvironment()
|
||||||
--if not ok then
|
if not ok then
|
||||||
-- wipe(newPositions)
|
geterrorhandler()(ret)
|
||||||
--end
|
wipe(newPositions)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -731,7 +737,10 @@ local function createGrowFunc(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function SafeGetPos(region, func)
|
local function SafeGetPos(region, func)
|
||||||
return func(region)
|
local ok, value1, value2 = pcall(func, region)
|
||||||
|
if ok then
|
||||||
|
return value1, value2
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function modify(parent, region, data)
|
local function modify(parent, region, data)
|
||||||
|
|||||||
@@ -283,7 +283,10 @@ end
|
|||||||
local function RunCode(self, func)
|
local function RunCode(self, func)
|
||||||
if func and not WeakAuras.IsOptionsOpen() then
|
if func and not WeakAuras.IsOptionsOpen() then
|
||||||
WeakAuras.ActivateAuraEnvironment(self.id, self.cloneId, self.state, self.states);
|
WeakAuras.ActivateAuraEnvironment(self.id, self.cloneId, self.state, self.states);
|
||||||
xpcall(func, geterrorhandler());
|
local ok, ret = pcall(func);
|
||||||
|
if not ok then
|
||||||
|
geterrorhandler()(ret)
|
||||||
|
end
|
||||||
WeakAuras.ActivateAuraEnvironment(nil);
|
WeakAuras.ActivateAuraEnvironment(nil);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -304,7 +307,10 @@ local function UpdatePosition(self)
|
|||||||
local yOffset = self.yOffset + (self.yOffsetAnim or 0) + (self.yOffsetRelative or 0)
|
local yOffset = self.yOffset + (self.yOffsetAnim or 0) + (self.yOffsetRelative or 0)
|
||||||
self:RealClearAllPoints();
|
self:RealClearAllPoints();
|
||||||
|
|
||||||
self:SetPoint(self.anchorPoint, self.relativeTo, self.relativePoint, xOffset, yOffset);
|
local ok, ret = pcall(self.SetPoint, self, self.anchorPoint, self.relativeTo, self.relativePoint, xOffset, yOffset);
|
||||||
|
if not ok then
|
||||||
|
geterrorhandler()(ret)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ResetPosition(self)
|
local function ResetPosition(self)
|
||||||
|
|||||||
+81
-27
@@ -831,8 +831,12 @@ end
|
|||||||
local customConditionTestFunctions = {};
|
local customConditionTestFunctions = {};
|
||||||
|
|
||||||
function WeakAuras.CallCustomConditionTest(testFunctionNumber, ...)
|
function WeakAuras.CallCustomConditionTest(testFunctionNumber, ...)
|
||||||
local result = customConditionTestFunctions[testFunctionNumber](...)
|
local ok, result = pcall(customConditionTestFunctions[testFunctionNumber], ...)
|
||||||
return result
|
if not ok then
|
||||||
|
geterrorhandler()(result)
|
||||||
|
elseif (ok) then
|
||||||
|
return result
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function CreateTestForCondition(input, allConditionsTemplate, usedStates)
|
local function CreateTestForCondition(input, allConditionsTemplate, usedStates)
|
||||||
@@ -4276,8 +4280,12 @@ function WeakAuras.Add(data, takeSnapshot, simpleChange)
|
|||||||
if takeSnapshot then
|
if takeSnapshot then
|
||||||
WeakAuras.SetMigrationSnapshot(data.uid, snapshot)
|
WeakAuras.SetMigrationSnapshot(data.uid, snapshot)
|
||||||
end
|
end
|
||||||
WeakAuras.PreAdd(data)
|
local ok, ret = pcall(WeakAuras.PreAdd, data)
|
||||||
pAdd(data, simpleChange)
|
if not ok then
|
||||||
|
geterrorhandler()(ret)
|
||||||
|
elseif ok then
|
||||||
|
pAdd(data, simpleChange)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function WeakAuras.SetRegion(data, cloneId)
|
function WeakAuras.SetRegion(data, cloneId)
|
||||||
@@ -4697,7 +4705,10 @@ function WeakAuras.PerformActions(data, when, region)
|
|||||||
local func = WeakAuras.customActionsFunctions[data.id][when]
|
local func = WeakAuras.customActionsFunctions[data.id][when]
|
||||||
if func then
|
if func then
|
||||||
WeakAuras.ActivateAuraEnvironment(region.id, region.cloneId, region.state, region.states);
|
WeakAuras.ActivateAuraEnvironment(region.id, region.cloneId, region.state, region.states);
|
||||||
xpcall(func, geterrorhandler());
|
local ok, ret = pcall(func);
|
||||||
|
if not ok then
|
||||||
|
geterrorhandler()(ret)
|
||||||
|
end
|
||||||
WeakAuras.ActivateAuraEnvironment(nil);
|
WeakAuras.ActivateAuraEnvironment(nil);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -4783,40 +4794,64 @@ function WeakAuras.UpdateAnimations()
|
|||||||
WeakAuras.ActivateAuraEnvironment(anim.name, anim.cloneId, anim.region.state, anim.region.states);
|
WeakAuras.ActivateAuraEnvironment(anim.name, anim.cloneId, anim.region.state, anim.region.states);
|
||||||
if(anim.translateFunc) then
|
if(anim.translateFunc) then
|
||||||
if (anim.region.SetOffsetAnim) then
|
if (anim.region.SetOffsetAnim) then
|
||||||
local x, y = anim.translateFunc(progress, 0, 0, anim.dX, anim.dY);
|
local ok, x, y = pcall(anim.translateFunc, progress, 0, 0, anim.dX, anim.dY);
|
||||||
anim.region:SetOffsetAnim(x, y);
|
if not ok then
|
||||||
|
errorHandler(x)
|
||||||
|
else
|
||||||
|
anim.region:SetOffsetAnim(x, y);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
anim.region:ClearAllPoints();
|
anim.region:ClearAllPoints();
|
||||||
local x, y = anim.translateFunc(progress, anim.startX, anim.startY, anim.dX, anim.dY);
|
local ok, x, y = xpcall(anim.translateFunc, progress, anim.startX, anim.startY, anim.dX, anim.dY);
|
||||||
anim.region:SetPoint(anim.selfPoint, anim.anchor, anim.anchorPoint, x, y);
|
if not ok then
|
||||||
|
errorHandler(x)
|
||||||
|
else
|
||||||
|
anim.region:SetPoint(anim.selfPoint, anim.anchor, anim.anchorPoint, x, y);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if(anim.alphaFunc) then
|
if(anim.alphaFunc) then
|
||||||
local alpha = anim.alphaFunc(progress, anim.startAlpha, anim.dAlpha);
|
local ok, alpha = pcall(anim.alphaFunc, progress, anim.startAlpha, anim.dAlpha);
|
||||||
if (anim.region.SetAnimAlpha) then
|
if not ok then
|
||||||
anim.region:SetAnimAlpha(alpha);
|
errorHandler(alpha)
|
||||||
else
|
else
|
||||||
anim.region:SetAlpha(alpha);
|
if (anim.region.SetAnimAlpha) then
|
||||||
|
anim.region:SetAnimAlpha(alpha);
|
||||||
|
else
|
||||||
|
anim.region:SetAlpha(alpha);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if(anim.scaleFunc) then
|
if(anim.scaleFunc) then
|
||||||
local scaleX, scaleY = anim.scaleFunc(progress, 1, 1, anim.scaleX, anim.scaleY);
|
local ok, scaleX, scaleY = pcall(anim.scaleFunc, progress, 1, 1, anim.scaleX, anim.scaleY);
|
||||||
if(anim.region.Scale) then
|
if (ok) then
|
||||||
anim.region:Scale(scaleX, scaleY);
|
errorHandler(scaleX)
|
||||||
else
|
else
|
||||||
anim.region:SetWidth(anim.startWidth * scaleX);
|
if(anim.region.Scale) then
|
||||||
anim.region:SetHeight(anim.startHeight * scaleY);
|
anim.region:Scale(scaleX, scaleY);
|
||||||
|
else
|
||||||
|
anim.region:SetWidth(anim.startWidth * scaleX);
|
||||||
|
anim.region:SetHeight(anim.startHeight * scaleY);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if(anim.rotateFunc and anim.region.Rotate) then
|
if(anim.rotateFunc and anim.region.Rotate) then
|
||||||
local rotate = anim.rotateFunc(progress, anim.startRotation, anim.rotate);
|
local ok, rotate = pcall(anim.rotateFunc, progress, anim.startRotation, anim.rotate);
|
||||||
anim.region:Rotate(rotate);
|
if not ok then
|
||||||
|
errorHandler(rotate)
|
||||||
|
else
|
||||||
|
anim.region:Rotate(rotate);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if(anim.colorFunc and anim.region.ColorAnim) then
|
if(anim.colorFunc and anim.region.ColorAnim) then
|
||||||
local startR, startG, startB, startA = anim.region:GetColor();
|
local startR, startG, startB, startA = anim.region:GetColor();
|
||||||
startR, startG, startB, startA = startR or 1, startG or 1, startB or 1, startA or 1;
|
startR, startG, startB, startA = startR or 1, startG or 1, startB or 1, startA or 1;
|
||||||
local r, g, b, a = anim.colorFunc(progress, startR, startG, startB, startA, anim.colorR, anim.colorG, anim.colorB, anim.colorA);
|
local ok, r, g, b, a = pcall(anim.colorFunc, progress, startR, startG, startB, startA, anim.colorR, anim.colorG, anim.colorB, anim.colorA);
|
||||||
anim.region:ColorAnim(r, g, b, a);
|
if not ok then
|
||||||
|
errorHandler(r)
|
||||||
|
else
|
||||||
|
anim.region:ColorAnim(r, g, b, a);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
WeakAuras.ActivateAuraEnvironment(nil);
|
WeakAuras.ActivateAuraEnvironment(nil);
|
||||||
if(finished) then
|
if(finished) then
|
||||||
@@ -5855,7 +5890,12 @@ local function evaluateTriggerStateTriggers(id)
|
|||||||
result = true;
|
result = true;
|
||||||
else
|
else
|
||||||
if (triggerState[id].disjunctive == "custom" and triggerState[id].triggerLogicFunc) then
|
if (triggerState[id].disjunctive == "custom" and triggerState[id].triggerLogicFunc) then
|
||||||
result = triggerState[id].triggerLogicFunc(triggerState[id].triggers);
|
local ok
|
||||||
|
ok, result = pcall(triggerState[id].triggerLogicFunc, triggerState[id].triggers);
|
||||||
|
if not ok then
|
||||||
|
geterrorhandler()(result)
|
||||||
|
result = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -6035,7 +6075,13 @@ function WeakAuras.RunCustomTextFunc(region, customFunc)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local custom = {customFunc(expirationTime or math.huge, duration or 0, progress, dur, name, icon, stacks)}
|
local custom = {pcall(customFunc, expirationTime or math.huge, duration or 0, progress, dur, name, icon, stacks)}
|
||||||
|
if not custom[1] then
|
||||||
|
geterrorhandler()(custom[2])
|
||||||
|
else
|
||||||
|
table.remove(custom, 1)
|
||||||
|
end
|
||||||
|
|
||||||
WeakAuras.ActivateAuraEnvironment(nil)
|
WeakAuras.ActivateAuraEnvironment(nil)
|
||||||
return custom
|
return custom
|
||||||
end
|
end
|
||||||
@@ -6560,11 +6606,13 @@ local function GetAnchorFrame(data, region, parent)
|
|||||||
WeakAuras.StartProfileSystem("custom region anchor")
|
WeakAuras.StartProfileSystem("custom region anchor")
|
||||||
WeakAuras.StartProfileAura(region.id)
|
WeakAuras.StartProfileAura(region.id)
|
||||||
WeakAuras.ActivateAuraEnvironment(region.id, region.cloneId, region.state)
|
WeakAuras.ActivateAuraEnvironment(region.id, region.cloneId, region.state)
|
||||||
local ok, frame = xpcall(region.customAnchorFunc, geterrorhandler())
|
local ok, frame = pcall(region.customAnchorFunc)
|
||||||
WeakAuras.ActivateAuraEnvironment()
|
WeakAuras.ActivateAuraEnvironment()
|
||||||
WeakAuras.StopProfileSystem("custom region anchor")
|
WeakAuras.StopProfileSystem("custom region anchor")
|
||||||
WeakAuras.StopProfileAura(region.id)
|
WeakAuras.StopProfileAura(region.id)
|
||||||
if ok and frame then
|
if not ok then
|
||||||
|
geterrorhandler()(frame)
|
||||||
|
elseif ok and frame then
|
||||||
return frame
|
return frame
|
||||||
elseif WeakAuras.IsOptionsOpen() then
|
elseif WeakAuras.IsOptionsOpen() then
|
||||||
return parent
|
return parent
|
||||||
@@ -6591,7 +6639,13 @@ function WeakAuras.AnchorFrame(data, region, parent)
|
|||||||
if not anchorParent then return end
|
if not anchorParent then return end
|
||||||
if (data.anchorFrameParent or data.anchorFrameParent == nil
|
if (data.anchorFrameParent or data.anchorFrameParent == nil
|
||||||
or data.anchorFrameType == "SCREEN" or data.anchorFrameType == "MOUSE") then
|
or data.anchorFrameType == "SCREEN" or data.anchorFrameType == "MOUSE") then
|
||||||
region:SetParent(anchorParent);
|
local errorhandler = function(text)
|
||||||
|
geterrorhandler()(L["'ERROR: Anchoring %s': \n"]:format(data.id) .. text)
|
||||||
|
end
|
||||||
|
local ok, ret = pcall(region.SetParent, region, anchorParent);
|
||||||
|
if not ok then
|
||||||
|
errorhandler(ret)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
region:SetParent(frame);
|
region:SetParent(frame);
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user