from retail

This commit is contained in:
NoM0Re
2025-01-07 15:03:14 +01:00
parent 7a185106f2
commit 74a1a856ac
9 changed files with 115 additions and 72 deletions
+30 -30
View File
@@ -457,7 +457,7 @@ function Private.EndEvent(id, triggernum, force, state)
end
end
local function RunOverlayFuncs(event, state)
local function RunOverlayFuncs(event, state, id)
state.additionalProgress = state.additionalProgress or {};
local changed = false;
for i, overlayFunc in ipairs(event.overlayFuncs) do
@@ -465,7 +465,7 @@ local function RunOverlayFuncs(event, state)
local additionalProgress = state.additionalProgress[i];
local ok, a, b, c = pcall(overlayFunc, event.trigger, state);
if (not ok) then
geterrorhandler()(a)
Private.GetErrorHandlerId(id, L["Overlay %s"]:format(i))
additionalProgress.min = nil;
additionalProgress.max = nil;
additionalProgress.direction = nil;
@@ -522,7 +522,7 @@ local function callFunctionForActivateEvent(func, trigger, fallback, errorHandle
end
end
function Private.ActivateEvent(id, triggernum, data, state, errorHandler)
function Private.ActivateEvent(id, triggernum, data, state)
local changed = state.changed or false;
if (state.show ~= true) then
state.show = true;
@@ -553,7 +553,7 @@ function Private.ActivateEvent(id, triggernum, data, state, errorHandler)
elseif (data.durationFunc) then
local ok, arg1, arg2, arg3, inverse = pcall(data.durationFunc, data.trigger);
if not ok then
errorHandler(arg1);
Private.GetErrorHandlerId(id, L["Duration Function"])
arg1 = 0;
arg2 = 0;
else
@@ -619,10 +619,10 @@ function Private.ActivateEvent(id, triggernum, data, state, errorHandler)
end
end
local name = callFunctionForActivateEvent(data.nameFunc, data.trigger, state.name, errorHandler)
local icon = callFunctionForActivateEvent(data.iconFunc, data.trigger, state.icon, errorHandler)
local texture = callFunctionForActivateEvent(data.textureFunc, data.trigger, state.texture, errorHandler)
local stacks = callFunctionForActivateEvent(data.stacksFunc, data.trigger, state.stacks, errorHandler)
local name = callFunctionForActivateEvent(data.nameFunc, data.trigger, state.name, Private.GetErrorHandlerId(id, L["Name Function"]))
local icon = callFunctionForActivateEvent(data.iconFunc, data.trigger, state.icon, Private.GetErrorHandlerId(id, L["Icon Function"]))
local texture = callFunctionForActivateEvent(data.textureFunc, data.trigger, state.texture, Private.GetErrorHandlerId(id, L["Texture Function"]))
local stacks = callFunctionForActivateEvent(data.stacksFunc, data.trigger, state.stacks, Private.GetErrorHandlerId(id, L["Stacks Function"]))
if (state.name ~= name) then
state.name = name;
@@ -642,7 +642,7 @@ function Private.ActivateEvent(id, triggernum, data, state, errorHandler)
end
if (data.overlayFuncs) then
RunOverlayFuncs(data, state);
RunOverlayFuncs(data, state, id);
else
state.additionalProgress = nil;
end
@@ -658,7 +658,7 @@ end
local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2, ...)
local optionsEvent = event == "OPTIONS";
local errorHandler = (optionsEvent and data.ignoreOptionsEventErrors) and ignoreErrorHandler or geterrorhandler()
local errorHandler = (optionsEvent and data.ignoreOptionsEventErrors) and ignoreErrorHandler or Private.GetErrorHandlerId(id, L["Trigger %s"]:format(triggernum))
local updateTriggerState = false;
local unitForUnitTrigger
@@ -675,7 +675,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
end
for key, state in pairs(allStates) do
if (type(state) ~= "table") then
errorHandler(string.format(L["Error in aura '%s' in %s. trigger. All States table contains a non table at key: '%s'."], id, triggernum, key))
errorHandler(string.format(L["All States table contains a non table at key: '%s'."], key))
wipe(allStates)
return
end
@@ -687,7 +687,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
elseif (ok and returnValue) or optionsEvent then
for id, state in pairs(allStates) do
if (state.changed) then
if (Private.ActivateEvent(id, triggernum, data, state, errorHandler)) then
if (Private.ActivateEvent(id, triggernum, data, state)) then
updateTriggerState = true;
end
end
@@ -721,7 +721,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
if not ok then
errorHandler(returnValue)
elseif (ok and returnValue) or optionsEvent then
if(Private.ActivateEvent(id, triggernum, data, state, errorHandler)) then
if(Private.ActivateEvent(id, triggernum, data, state)) then
updateTriggerState = true;
end
else
@@ -735,7 +735,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
if not ok then
errorHandler(returnValue)
elseif (ok and returnValue) or optionsEvent then
if(Private.ActivateEvent(id, triggernum, data, state, errorHandler)) then
if(Private.ActivateEvent(id, triggernum, data, state)) then
updateTriggerState = true;
end
else
@@ -748,7 +748,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2
elseif (ok and returnValue) or optionsEvent then
allStates[""] = allStates[""] or {};
local state = allStates[""];
if(Private.ActivateEvent(id, triggernum, data, state, errorHandler)) then
if(Private.ActivateEvent(id, triggernum, data, state)) then
updateTriggerState = true;
end
else
@@ -1391,7 +1391,7 @@ function GenericTrigger.Add(data, region)
triggerFuncStr = ConstructFunction(prototype, trigger);
statesParameter = prototype.statesParameter;
triggerFunc = WeakAuras.LoadFunction(triggerFuncStr, id);
triggerFunc = WeakAuras.LoadFunction(triggerFuncStr);
durationFunc = prototype.durationFunc;
nameFunc = prototype.nameFunc;
@@ -1455,7 +1455,7 @@ function GenericTrigger.Add(data, region)
end
end
else -- CUSTOM
triggerFunc = WeakAuras.LoadFunction("return "..(trigger.custom or ""), id);
triggerFunc = WeakAuras.LoadFunction("return "..(trigger.custom or ""));
if (trigger.custom_type == "stateupdate") then
tsuConditionVariables = WeakAuras.LoadFunction("return function() return \n" .. (trigger.customVariables or "") .. "\n end");
if not tsuConditionVariables then
@@ -1464,35 +1464,35 @@ function GenericTrigger.Add(data, region)
end
if(trigger.custom_type == "status" or trigger.custom_type == "event" and trigger.custom_hide == "custom") then
untriggerFunc = WeakAuras.LoadFunction("return "..(untrigger.custom or ""), id);
untriggerFunc = WeakAuras.LoadFunction("return "..(untrigger.custom or ""));
if (not untriggerFunc) then
untriggerFunc = trueFunction;
end
end
if(trigger.custom_type ~= "stateupdate" and trigger.customDuration and trigger.customDuration ~= "") then
durationFunc = WeakAuras.LoadFunction("return "..trigger.customDuration, id);
durationFunc = WeakAuras.LoadFunction("return "..trigger.customDuration);
end
if(trigger.custom_type ~= "stateupdate") then
overlayFuncs = {};
for i = 1, 7 do
local property = "customOverlay" .. i;
if (trigger[property] and trigger[property] ~= "") then
overlayFuncs[i] = WeakAuras.LoadFunction("return ".. trigger[property], id);
overlayFuncs[i] = WeakAuras.LoadFunction("return ".. trigger[property]);
end
end
end
if(trigger.custom_type ~= "stateupdate" and trigger.customName and trigger.customName ~= "") then
nameFunc = WeakAuras.LoadFunction("return "..trigger.customName, id);
nameFunc = WeakAuras.LoadFunction("return "..trigger.customName);
end
if(trigger.custom_type ~= "stateupdate" and trigger.customIcon and trigger.customIcon ~= "") then
iconFunc = WeakAuras.LoadFunction("return "..trigger.customIcon, id);
iconFunc = WeakAuras.LoadFunction("return "..trigger.customIcon);
end
if(trigger.custom_type ~= "stateupdate" and trigger.customTexture and trigger.customTexture ~= "") then
textureFunc = WeakAuras.LoadFunction("return "..trigger.customTexture, id);
textureFunc = WeakAuras.LoadFunction("return "..trigger.customTexture);
end
if(trigger.custom_type ~= "stateupdate" and trigger.customStacks and trigger.customStacks ~= "") then
stacksFunc = WeakAuras.LoadFunction("return "..trigger.customStacks, id);
stacksFunc = WeakAuras.LoadFunction("return "..trigger.customStacks);
end
if((trigger.custom_type == "status" or trigger.custom_type == "stateupdate") and trigger.check == "update") then
@@ -4098,7 +4098,7 @@ function GenericTrigger.CreateFallbackState(data, triggernum, state)
if (event.nameFunc) then
local ok, name = pcall(event.nameFunc, firstTrigger);
if not ok then
geterrorhandler()(name)
Private.GetErrorHandlerUid(data.uid, L["Name Function (fallback state)"])
state.name = nil
else
state.name = name or nil
@@ -4107,7 +4107,7 @@ function GenericTrigger.CreateFallbackState(data, triggernum, state)
if (event.iconFunc) then
local ok, icon = pcall(event.iconFunc, firstTrigger);
if not ok then
geterrorhandler()(icon)
Private.GetErrorHandlerUid(data.uid, L["Icon Function (fallback state)"])
state.icon = nil
else
state.icon = icon or nil
@@ -4117,7 +4117,7 @@ function GenericTrigger.CreateFallbackState(data, triggernum, state)
if (event.textureFunc ) then
local ok, texture = pcall(event.textureFunc, firstTrigger);
if not ok then
geterrorhandler()(texture)
Private.GetErrorHandlerUid(data.uid, L["Texture Function (fallback state)"])
state.texture = nil
else
state.texture = texture or nil
@@ -4127,7 +4127,7 @@ function GenericTrigger.CreateFallbackState(data, triggernum, state)
if (event.stacksFunc) then
local ok, stacks = pcall(event.stacksFunc, firstTrigger);
if not ok then
geterrorhandler()(stacks)
Private.GetErrorHandlerUid(data.uid, L["Stacks Function (fallback state)"])
state.stacks = nil
else
state.stacks = stacks or nil
@@ -4137,7 +4137,7 @@ function GenericTrigger.CreateFallbackState(data, triggernum, state)
if (event.durationFunc) then
local ok, arg1, arg2, arg3, inverse = pcall(event.durationFunc, firstTrigger);
if not ok then
geterrorhandler()(arg1)
Private.GetErrorHandlerUid(data.uid, L["Duration Function (fallback state)"])
state.progressType = "timed";
state.duration = 0;
state.expirationTime = math.huge;
@@ -4180,7 +4180,7 @@ function GenericTrigger.CreateFallbackState(data, triggernum, state)
state.total = nil;
end
if (event.overlayFuncs) then
RunOverlayFuncs(event, state);
RunOverlayFuncs(event, state, data.id);
end
Private.ActivateAuraEnvironment(nil);
end