from retail
This commit is contained in:
+51
-57
@@ -722,38 +722,38 @@ function WeakAuras.GetActiveConditions(id, cloneId)
|
||||
return triggerState[id].activatedConditions[cloneId];
|
||||
end
|
||||
|
||||
local function formatValueForAssignment(vtype, value, pathToCustomFunction)
|
||||
local function formatValueForAssignment(vType, value, pathToCustomFunction)
|
||||
if (value == nil) then
|
||||
value = false;
|
||||
end
|
||||
if (vtype == "bool") then
|
||||
if (vType == "bool") then
|
||||
return value and tostring(value) or "false";
|
||||
elseif(vtype == "number") then
|
||||
elseif(vType == "number") then
|
||||
return value and tostring(value) or "0";
|
||||
elseif (vtype == "list") then
|
||||
elseif (vType == "list") then
|
||||
return type(value) == "string" and string.format("%q", value) or "nil";
|
||||
elseif(vtype == "color") then
|
||||
elseif(vType == "color") then
|
||||
if (value and type(value) == "table") then
|
||||
return string.format("{%s, %s, %s, %s}", tostring(value[1]), tostring(value[2]), tostring(value[3]), tostring(value[4]));
|
||||
end
|
||||
return "{1, 1, 1, 1}";
|
||||
elseif(vtype == "chat") then
|
||||
elseif(vType == "chat") then
|
||||
if (value and type(value) == "table") then
|
||||
return string.format("{message_type = %q, message = %q, message_dest = %q, message_channel = %q, message_custom = %s}",
|
||||
tostring(value.message_type), tostring(value.message or ""),
|
||||
tostring(value.message_dest), tostring(value.message_channel),
|
||||
pathToCustomFunction);
|
||||
end
|
||||
elseif(vtype == "sound") then
|
||||
elseif(vType == "sound") then
|
||||
if (value and type(value) == "table") then
|
||||
return string.format("{ sound = %q, sound_channel = %q, sound_path = %q, sound_kit_id = %q, sound_type = %q, %s}",
|
||||
tostring(value.sound or ""), tostring(value.sound_channel or ""), tostring(value.sound_path or ""),
|
||||
tostring(value.sound_kit_id or ""), tostring(value.sound_type or ""),
|
||||
value.sound_repeat and "sound_repeat = " .. tostring(value.sound_repeat) or "nil");
|
||||
end
|
||||
elseif(vtype == "customcode") then
|
||||
elseif(vType == "customcode") then
|
||||
return string.format("%s", pathToCustomFunction);
|
||||
elseif vtype == "glowexternal" then
|
||||
elseif vType == "glowexternal" then
|
||||
if (value and type(value) == "table") then
|
||||
return ([[{ glow_action = %q, glow_frame_type = %q, glow_type = %q,
|
||||
glow_frame = %q, use_glow_color = %s, glow_color = {%s, %s, %s, %s},
|
||||
@@ -869,7 +869,7 @@ local function CreateTestForCondition(input, allConditionsTemplate, usedStates)
|
||||
usedStates[trigger] = true;
|
||||
|
||||
local conditionTemplate = allConditionsTemplate[trigger] and allConditionsTemplate[trigger][variable];
|
||||
local ctype = conditionTemplate and conditionTemplate.type;
|
||||
local cType = conditionTemplate and conditionTemplate.type;
|
||||
local test = conditionTemplate and conditionTemplate.test;
|
||||
|
||||
local stateCheck = "state[" .. trigger .. "] and state[" .. trigger .. "].show and ";
|
||||
@@ -882,27 +882,27 @@ local function CreateTestForCondition(input, allConditionsTemplate, usedStates)
|
||||
local opString = type(op) == "string" and "[[" .. op .. "]]" or op;
|
||||
check = "state and WeakAuras.CallCustomConditionTest(" .. testFunctionNumber .. ", state[" .. trigger .. "], " .. valueString .. ", " .. (opString or "nil") .. ")";
|
||||
end
|
||||
elseif (ctype == "number" and op) then
|
||||
elseif (cType == "number" and op) then
|
||||
local v = tonumber(value)
|
||||
if (v) then
|
||||
check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]." .. variable .. op .. v;
|
||||
end
|
||||
elseif (ctype == "timer" and op) then
|
||||
elseif (cType == "timer" and op) then
|
||||
if (op == "==") then
|
||||
check = stateCheck .. stateVariableCheck .. "abs(state[" .. trigger .. "]." ..variable .. "- now -" .. value .. ") < 0.05";
|
||||
else
|
||||
check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]." .. variable .. "- now" .. op .. value;
|
||||
end
|
||||
elseif (ctype == "select" and op) then
|
||||
elseif (cType == "select" and op) then
|
||||
if (tonumber(value)) then
|
||||
check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]." .. variable .. op .. tonumber(value);
|
||||
else
|
||||
check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]." .. variable .. op .. "'" .. value .. "'";
|
||||
end
|
||||
elseif (ctype == "bool") then
|
||||
elseif (cType == "bool") then
|
||||
local rightSide = value == 0 and "false" or "true";
|
||||
check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]." .. variable .. "==" .. rightSide
|
||||
elseif (ctype == "string") then
|
||||
elseif (cType == "string") then
|
||||
if(op == "==") then
|
||||
check = stateCheck .. stateVariableCheck .. "state[" .. trigger .. "]." .. variable .. " == [[" .. value .. "]]";
|
||||
elseif (op == "find('%s')") then
|
||||
@@ -912,7 +912,7 @@ local function CreateTestForCondition(input, allConditionsTemplate, usedStates)
|
||||
end
|
||||
end
|
||||
|
||||
if (ctype == "timer" and value) then
|
||||
if (cType == "timer" and value) then
|
||||
recheckCode = " nextTime = state[" .. trigger .. "] and state[" .. trigger .. "]." .. variable .. " and (state[" .. trigger .. "]." .. variable .. " -" .. value .. ")\n";
|
||||
recheckCode = recheckCode .. " if (nextTime and (not recheckTime or nextTime < recheckTime) and nextTime >= now) then\n"
|
||||
recheckCode = recheckCode .. " recheckTime = nextTime\n";
|
||||
@@ -1339,8 +1339,8 @@ end
|
||||
|
||||
function WeakAuras.RegisterForGlobalConditions(id)
|
||||
local data = WeakAuras.GetData(id);
|
||||
for event, conditonFunctions in pairs(dynamicConditions) do
|
||||
conditonFunctions.id = nil;
|
||||
for event, conditionFunctions in pairs(dynamicConditions) do
|
||||
conditionFunctions.id = nil;
|
||||
end
|
||||
|
||||
local register = {};
|
||||
@@ -1462,9 +1462,9 @@ WeakAuras.frames["LDB Tooltip Updater"] = tooltip_update_frame;
|
||||
local function getAnchors(frame)
|
||||
local x, y = frame:GetCenter()
|
||||
if not x or not y then return "CENTER" end
|
||||
local hhalf = (x > UIParent:GetWidth()*2/3) and "RIGHT" or (x < UIParent:GetWidth()/3) and "LEFT" or ""
|
||||
local vhalf = (y > UIParent:GetHeight()/2) and "TOP" or "BOTTOM"
|
||||
return vhalf..hhalf, frame, (vhalf == "TOP" and "BOTTOM" or "TOP")..hhalf
|
||||
local hHalf = (x > UIParent:GetWidth()*2/3) and "RIGHT" or (x < UIParent:GetWidth()/3) and "LEFT" or ""
|
||||
local vHalf = (y > UIParent:GetHeight()/2) and "TOP" or "BOTTOM"
|
||||
return vHalf..hHalf, frame, (vHalf == "TOP" and "BOTTOM" or "TOP")..hHalf
|
||||
end
|
||||
|
||||
local Broker_WeakAuras;
|
||||
@@ -3709,7 +3709,7 @@ function WeakAuras.SyncParentChildRelationships(silent)
|
||||
-- 1. Find all auras where data.parent ~= nil or data.controlledChildren ~= nil
|
||||
-- If an aura has both, then remove data.parent
|
||||
-- If an aura has data.parent which doesn't exist, then remove data.parent
|
||||
-- If an aura has data.parent which doesn't have data.controledChildren, then remove data.parent
|
||||
-- If an aura has data.parent which doesn't have data.controlledChildren, then remove data.parent
|
||||
-- 2. For each aura with data.controlledChildren, iterate through the list of children and remove entries where:
|
||||
-- The child doesn't exist in the database
|
||||
-- The child ID is duplicated in data.controlledChildren (only the first will be kept)
|
||||
@@ -4448,9 +4448,10 @@ function WeakAuras.ReleaseClone(id, cloneId, regionType)
|
||||
clonePool[regionType][#clonePool[regionType] + 1] = region;
|
||||
end
|
||||
|
||||
function WeakAuras.HandleChatAction(message_type, message, message_dest, message_channel, r, g, b, region, customFunc)
|
||||
function WeakAuras.HandleChatAction(message_type, message, message_dest, message_channel, r, g, b, region, customFunc, when)
|
||||
local useHiddenStates = when == "finish"
|
||||
if (message:find('%%')) then
|
||||
message = WeakAuras.ReplacePlaceHolders(message, region, customFunc);
|
||||
message = WeakAuras.ReplacePlaceHolders(message, region, customFunc, useHiddenStates);
|
||||
end
|
||||
if(message_type == "PRINT") then
|
||||
DEFAULT_CHAT_FRAME:AddMessage(message, r or 1, g or 1, b or 1);
|
||||
@@ -4466,23 +4467,13 @@ function WeakAuras.HandleChatAction(message_type, message, message_dest, message
|
||||
pcall(function() SendChatMessage(message, "WHISPER", nil, message_dest) end);
|
||||
end
|
||||
end
|
||||
elseif(message_type == "CHANNEL") then
|
||||
local channel = message_channel and tonumber(message_channel);
|
||||
if(GetChannelName(channel)) then
|
||||
pcall(function() SendChatMessage(message, "CHANNEL", nil, channel) end);
|
||||
end
|
||||
elseif(message_type == "SMARTRAID") then
|
||||
local isInstanceGroup = IsInGroup(LE_PARTY_CATEGORY_INSTANCE)
|
||||
if UnitInBattleground("player") then
|
||||
pcall(function() SendChatMessage(message, "CHAT_MSG_BATTLEGROUND") end)
|
||||
elseif UnitInRaid("player") then
|
||||
pcall(function() SendChatMessage(message, "RAID") end)
|
||||
elseif UnitInParty("player") then
|
||||
if isInstanceGroup then
|
||||
pcall(function() SendChatMessage(message, "CHAT_MSG_BATTLEGROUND") end)
|
||||
else
|
||||
pcall(function() SendChatMessage(message, "PARTY") end)
|
||||
end
|
||||
pcall(function() SendChatMessage(message, "PARTY") end)
|
||||
else
|
||||
if IsInInstance() then
|
||||
pcall(function() SendChatMessage(message, "SAY") end)
|
||||
@@ -4695,7 +4686,7 @@ function WeakAuras.PerformActions(data, when, region)
|
||||
|
||||
if(actions.do_message and actions.message_type and actions.message) then
|
||||
local customFunc = WeakAuras.customActionsFunctions[data.id][when .. "_message"];
|
||||
WeakAuras.HandleChatAction(actions.message_type, actions.message, actions.message_dest, actions.message_channel, actions.r, actions.g, actions.b, region, customFunc);
|
||||
WeakAuras.HandleChatAction(actions.message_type, actions.message, actions.message_dest, actions.message_channel, actions.r, actions.g, actions.b, region, customFunc, when);
|
||||
end
|
||||
|
||||
if (actions.stop_sound) then
|
||||
@@ -5899,11 +5890,12 @@ local function evaluateTriggerStateTriggers(id)
|
||||
result = true;
|
||||
else
|
||||
if (triggerState[id].disjunctive == "custom" and triggerState[id].triggerLogicFunc) then
|
||||
local ok
|
||||
ok, result = pcall(triggerState[id].triggerLogicFunc, triggerState[id].triggers);
|
||||
local ok, returnValue = pcall(triggerState[id].triggerLogicFunc, triggerState[id].triggers);
|
||||
if not ok then
|
||||
geterrorhandler()(result)
|
||||
geterrorhandler()(returnValue)
|
||||
result = false
|
||||
else
|
||||
result = returnValue
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -6121,7 +6113,7 @@ local function ReplaceValuePlaceHolders(textStr, region, customFunc, state)
|
||||
end
|
||||
|
||||
-- States:
|
||||
-- 0 Normal state, text is just appened to result. Can transition to percent start state 1 via %
|
||||
-- 0 Normal state, text is just appended to result. Can transition to percent start state 1 via %
|
||||
-- 1 Percent start state, entered via %. Can transition to via { to braced, via % to normal, AZaz09 to percent rest state
|
||||
-- 2 Percent rest state, stay in it via AZaz09, transition to normal on anything else
|
||||
-- 3 Braced state, } transitions to normal, everything else stay in braced state
|
||||
@@ -6233,31 +6225,33 @@ function WeakAuras.ContainsAnyPlaceHolders(textStr)
|
||||
return ContainsPlaceHolders(textStr, function(symbol) return true end)
|
||||
end
|
||||
|
||||
local function ValueForSymbol(symbol, region, customFunc, regionState, regionStates)
|
||||
local function ValueForSymbol(symbol, region, customFunc, regionState, regionStates, useHiddenStates)
|
||||
local triggerNum, sym = string.match(symbol, "(.+)%.(.+)")
|
||||
triggerNum = triggerNum and tonumber(triggerNum)
|
||||
if triggerNum and sym then
|
||||
if regionStates and regionStates[triggerNum] then
|
||||
if regionStates[triggerNum][sym] then
|
||||
return tostring(regionStates[triggerNum][sym]) or ""
|
||||
else
|
||||
local value = ReplaceValuePlaceHolders(sym, region, customFunc, regionStates[triggerNum]);
|
||||
return value or ""
|
||||
if regionStates[triggerNum] then
|
||||
if (useHiddenStates or regionStates[triggerNum].show) then
|
||||
if regionStates[triggerNum][sym] then
|
||||
return tostring(regionStates[triggerNum][sym]) or ""
|
||||
else
|
||||
local value = ReplaceValuePlaceHolders(sym, region, customFunc, regionStates[triggerNum]);
|
||||
return value or ""
|
||||
end
|
||||
end
|
||||
end
|
||||
return ""
|
||||
elseif regionState and regionState[symbol] then
|
||||
return regionState.show and tostring(regionState[symbol]) or ""
|
||||
elseif regionState[symbol] then
|
||||
return (useHiddenStates or regionState.show) and tostring(regionState[symbol]) or ""
|
||||
else
|
||||
local value = regionState and ReplaceValuePlaceHolders(symbol, region, customFunc, regionState);
|
||||
local value = (useHiddenStates or regionState.show) and ReplaceValuePlaceHolders(symbol, region, customFunc, regionState);
|
||||
return value or ""
|
||||
end
|
||||
end
|
||||
|
||||
function WeakAuras.ReplacePlaceHolders(textStr, region, customFunc)
|
||||
function WeakAuras.ReplacePlaceHolders(textStr, region, customFunc, useHiddenStates)
|
||||
local regionValues = region.values;
|
||||
local regionState = region.state;
|
||||
local regionStates = region.states;
|
||||
local regionState = region.state or {};
|
||||
local regionStates = region.states or {};
|
||||
if (not regionState and not regionValues) then
|
||||
return;
|
||||
end
|
||||
@@ -6269,7 +6263,7 @@ function WeakAuras.ReplacePlaceHolders(textStr, region, customFunc)
|
||||
|
||||
if (endPos == 2) then
|
||||
if string.byte(textStr, 1) == 37 then
|
||||
local value = ReplaceValuePlaceHolders(string.sub(textStr, 2), region, customFunc, regionState);
|
||||
local value = (regionState.show or useHiddenStates) and ReplaceValuePlaceHolders(string.sub(textStr, 2), region, customFunc, regionState);
|
||||
if (value) then
|
||||
textStr = tostring(value);
|
||||
end
|
||||
@@ -6307,7 +6301,7 @@ function WeakAuras.ReplacePlaceHolders(textStr, region, customFunc)
|
||||
-- 0-9a-zA-Z or dot character
|
||||
else -- End of variable
|
||||
local symbol = string.sub(textStr, start, currentPos - 1)
|
||||
result = result .. ValueForSymbol(symbol, region, customFunc, regionState, regionStates)
|
||||
result = result .. ValueForSymbol(symbol, region, customFunc, regionState, regionStates, useHiddenStates)
|
||||
|
||||
if char == 37 then
|
||||
else
|
||||
@@ -6317,7 +6311,7 @@ function WeakAuras.ReplacePlaceHolders(textStr, region, customFunc)
|
||||
elseif state == 3 then
|
||||
if char == 125 then -- } closing brace
|
||||
local symbol = string.sub(textStr, start, currentPos - 1)
|
||||
result = result .. ValueForSymbol(symbol, region, customFunc, regionState, regionStates)
|
||||
result = result .. ValueForSymbol(symbol, region, customFunc, regionState, regionStates, useHiddenStates)
|
||||
start = currentPos + 1
|
||||
end
|
||||
end
|
||||
@@ -6446,7 +6440,7 @@ local function ensureMouseFrame()
|
||||
local optionsFrame = WeakAuras.OptionsFrame();
|
||||
local yOffset = (optionsFrame:GetTop() + optionsFrame:GetBottom()) / 2;
|
||||
local xOffset = xPositionNextToOptions();
|
||||
-- We use the top right, because the main frame usees the top right as the reference too
|
||||
-- We use the top right, because the main frame uses the top right as the reference too
|
||||
mouseFrame:ClearAllPoints();
|
||||
mouseFrame:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", xOffset - GetScreenWidth(), yOffset - GetScreenHeight());
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user