from retail

This commit is contained in:
NoM0Re
2025-02-12 21:32:40 +01:00
parent b7a505f118
commit a9b95ca09d
4 changed files with 127 additions and 115 deletions
+3 -1
View File
@@ -3,7 +3,6 @@ local AddonName, Private = ...
local WeakAuras = WeakAuras
local L = WeakAuras.L
local prettyPrint = WeakAuras.prettyPrint
local LibSerialize = LibStub("LibSerialize")
local LibDeflate = LibStub:GetLibrary("LibDeflate")
@@ -142,6 +141,7 @@ local blockedFunctions = {
EditMacro = true,
DevTools_DumpCommand = true,
hash_SlashCmdList = true,
RegisterNewSlashCommand = true,
CreateMacro = true,
SetBindingMacro = true,
GuildDisband = true,
@@ -194,6 +194,7 @@ local current_aura_env = nil
-- Stack of of aura environments/uids, allows use of recursive aura activations through calls to WeakAuras.ScanEvents().
local aura_env_stack = {}
local function UpdateSavedDataWarning(uid, size)
local savedDataWarning = 16 * 1024 * 1024 -- 16 KB, but it's only a warning
if size > savedDataWarning then
@@ -547,6 +548,7 @@ end
local PrivateForBuiltIn = {
ExecEnv = Private.ExecEnv
}
local env_getglobal_builtin
local exec_env_builtin = setmetatable({},
{
+59 -65
View File
@@ -3037,7 +3037,7 @@ Private.event_prototypes = {
end,
store = true,
preambleGroup = "spell",
preamble = "local spellChecker = WeakAuras.CreateSpellChecker()",
preamble = "local spellChecker = Private.ExecEnv.CreateSpellChecker()",
multiEntry = {
operator = "preamble",
preambleAdd = "spellChecker:AddExact(%q)"
@@ -3059,7 +3059,7 @@ Private.event_prototypes = {
end,
store = true,
preambleGroup = "spell",
preamble = "local spellChecker = WeakAuras.CreateSpellChecker()",
preamble = "local spellChecker = Private.ExecEnv.CreateSpellChecker()",
multiEntry = {
operator = "preamble",
preambleAdd = "spellChecker:AddName(%q)"
@@ -5542,9 +5542,8 @@ Private.event_prototypes = {
timedrequired = true,
progressType = "timed"
},
-- fixing later
--[[
["Spell Cast Succeeded"] = {
["Spell Cast Succeeded"] = {
type = "event",
events = function(trigger)
local result = {}
@@ -5552,6 +5551,13 @@ Private.event_prototypes = {
AddUnitEventForEvents(result, unit, "UNIT_SPELLCAST_SUCCEEDED")
return result
end,
init = function(trigger)
local ret =
local spellRank = %d
local rank = tonumber(spellRank:match("Rank (%d+)")) or nil
;
return ret:format(trigger.spellRank or nil);
end,
name = L["Spell Cast Succeeded"],
statesParameter = "unit",
args = {
@@ -5568,12 +5574,9 @@ Private.event_prototypes = {
return state and state.show and (UnitIsUnit(needle, state.unit or '') == (op == "=="))
end
},
{
},
{ -- castGUID
},
{
name = "spellNames",
init = "arg",
display = L["Name(s)"],
type = "spell",
multiEntry = {
@@ -5582,36 +5585,40 @@ Private.event_prototypes = {
},
preamble = "local spellChecker = Private.ExecEnv.CreateSpellChecker()",
preambleGroup = "spell",
test = "spellChecker:Check(spellId)",
test = "spellChecker:Check(spellNames)",
noValidation = true,
},
{
name = "spellId",
display = L["Exact Spell ID(s)"],
type = "spell",
name = "spellRank",
hidden = true,
init = "arg",
type = "string",
store = true,
test = "true"
},
{
name = "rank",
hidden = true,
init = "rank",
display = L["Rank"],
store = true,
multiEntry = {
operator = "preamble",
preambleAdd = "spellChecker:AddExact(%q)"
},
preamble = "local spellChecker = Private.ExecEnv.CreateSpellChecker()",
preambleGroup = "spell",
test = "spellChecker:Check(spellId)",
conditionType = "number",
noProgressSource = true
multiEntry = {
operator = "or",
limit = 2
},
},
{
name = "icon",
hidden = true,
init = "GetSpellIcon(spellId or 0)",
init = "GetSpellIcon(spellNames or 0)",
store = true,
test = "true"
},
{
name = "name",
hidden = true,
init = "GetSpellInfo(spellId or 0)",
init = "GetSpellInfo(spellNames or 0)",
store = true,
test = "true"
},
@@ -6382,7 +6389,7 @@ Private.event_prototypes = {
type = "spell",
enable = function(trigger) return not trigger.use_inverse end,
preambleGroup = "spell",
preamble = "local spellChecker = WeakAuras.CreateSpellChecker()",
preamble = "local spellChecker = Private.ExecEnv.CreateSpellChecker()",
multiEntry = {
operator = "preamble",
preambleAdd = "spellChecker:AddName(%q)"
@@ -6396,7 +6403,7 @@ Private.event_prototypes = {
type = "spell",
enable = function(trigger) return not trigger.use_inverse end,
preambleGroup = "spell",
preamble = "local spellChecker = WeakAuras.CreateSpellChecker()",
preamble = "local spellChecker = Private.ExecEnv.CreateSpellChecker()",
multiEntry = {
operator = "preamble",
preambleAdd = "spellChecker:AddName(GetSpellInfo(%q))"
@@ -7798,11 +7805,10 @@ Private.event_prototypes = {
test = "true",
},
},
GetNameAndIcon = function(trigger)
GetNameAndIcon = function()
return MONEY, "interface/moneyframe/ui-goldicon"
end,
},
--[[ Some day i will finish this, soonTM
["Currency"] = {
type = "unit",
progressType = "static",
@@ -7815,24 +7821,26 @@ Private.event_prototypes = {
name = WeakAuras.newFeatureString..L["Currency"],
init = function(trigger)
local ret = [=[
local currencyID = %d
local discoveredTbl = Private.ExecEnv.GetDiscoveredCurrencies() or {}
local currencyInfo = {
name = GetItemInfo(%d),
quantity = GetItemCount(%d),
iconFileID = select(6, GetItemInfo(%d)),
totalEarned = Private.GetTotalCountCurrencies(%d),
discovered = Private.GetDiscoveredCurencies(%d),
name = GetItemInfo(currencyID),
quantity = GetItemCount(currencyID),
icon = GetItemIcon(currencyID),
totalEarned = Private.ExecEnv.GetTotalCountCurrencies(currencyID),
discovered = discoveredTbl[currencyID] and true or false,
}
if not currencyInfo.name then
currencyInfo = {
name = "Unknown Currency",
quantity = 0,
iconFileID = "Interface\\Icons\\INV_Misc_QuestionMark",
icon = "Interface\\Icons\\INV_Misc_QuestionMark",
totalEarned = 0,
discovered = false
}
end
]=]
return ret:format(trigger.currencyId or 1, trigger.currencyId or 1, trigger.currencyId or 1, trigger.currencyId or 1, trigger.currencyId or 1)
return ret:format(tonumber(trigger.currencyId) or 1)
end,
statesParameter = "one",
args = {
@@ -7840,13 +7848,13 @@ Private.event_prototypes = {
name = "currencyId",
type = "currency",
itemControl = "Dropdown-Currency",
values = Private.GetDiscoveredCurencies,
headers = Private.GetDiscoveredCurenciesHeaders,
values = Private.ExecEnv.GetDiscoveredCurrencies,
headers = Private.GetDiscoveredCurrenciesHeaders,
sorted = true,
sortOrder = function()
local discovered_currencies_sorted = Private.GetDiscoveredCurenciesSorted()
local discovered_currencies_sorted = Private.GetDiscoveredCurrenciesSorted()
local sortOrder = {}
for key, value in pairs(Private.GetDiscoveredCurencies()) do
for key, value in pairs(Private.ExecEnv.GetDiscoveredCurrencies()) do
tinsert(sortOrder, key)
end
table.sort(sortOrder, function(aKey, bKey)
@@ -7877,12 +7885,12 @@ Private.event_prototypes = {
conditionType = "number",
},
{
name = "total",
init = "currencyInfo.maxQuantity",
name = "totalEarned",
init = "currencyInfo.totalEarned",
type = "number",
hidden = true,
display = L["Total"],
store = true,
test = "true",
conditionType = "number",
},
{
name = "progressType",
@@ -7893,22 +7901,11 @@ Private.event_prototypes = {
},
{
name = "icon",
init = "currencyInfo.iconFileID",
init = "currencyInfo.icon",
store = true,
hidden = true,
test = "true",
},
{
name = "totalEarned",
init = "currencyInfo.totalEarned",
type = "number",
display = L["Total Earned in this Season"],
store = true,
conditionType = "number",
enable = function(trigger)
-- soonTM
end
},
{
name = "description",
init = "currencyInfo.description",
@@ -7928,12 +7925,12 @@ Private.event_prototypes = {
},
},
GetNameAndIcon = function(trigger)
local currencyInfo = Private.GetCurrencyInfoForTrigger(trigger)
return currencyInfo and currencyInfo.name, currencyInfo and currencyInfo.iconFileID
local name = GetItemInfo(trigger.currencyId or 0)
local icon = GetItemIcon(trigger.currencyId or 0)
return name, icon
end,
automaticrequired = true
},
]]
["Location"] = {
type = "unit",
events = {
@@ -8051,15 +8048,12 @@ Private.event_prototypes = {
},
};
if not (DBM and DBM.ReleaseRevision >= 7003) then
Private.event_prototypes["DBM Announce"] = nil
Private.event_prototypes["DBM Timer"] = nil
end
if not (DBM and DBM.ReleaseRevision >= 7005) then
Private.event_prototypes["DBM Stage"] = nil
end
Private.event_prototypes["BigWigs Message"] = nil
Private.event_prototypes["BigWigs Timer"] = nil
--[[
Disable any event here
if () then
Private.event_prototypes[] = nil
end
]]
Private.category_event_prototype = {}
for name, prototype in pairs(Private.event_prototypes) do
+5 -5
View File
@@ -1408,13 +1408,13 @@ Private.totalcount_currencies = {
[49426] = 4730, -- Emblems of Frost
}
function Private.GetTotalCountCurrencies(currencyID)
function Private.ExecEnv.GetTotalCountCurrencies(currencyID)
local achievementID = Private.totalcount_currencies[currencyID]
if achievementID then
local totalEarned = GetStatistic(achievementID)
return tonumber(totalEarned) or 0
end
return nil
return 0
end
local function InitializeCurrencies()
@@ -1460,17 +1460,17 @@ local function InitializeCurrencies()
Private.discovered_currencies_sorted["member"] = -1;
end
Private.GetDiscoveredCurencies = function()
Private.ExecEnv.GetDiscoveredCurrencies = function()
InitializeCurrencies()
return Private.discovered_currencies
end
Private.GetDiscoveredCurenciesSorted = function()
Private.GetDiscoveredCurrenciesSorted = function()
InitializeCurrencies()
return Private.discovered_currencies_sorted
end
Private.GetDiscoveredCurenciesHeaders = function()
Private.GetDiscoveredCurrenciesHeaders = function()
InitializeCurrencies()
return Private.discovered_currencies_headers
end
+60 -44
View File
@@ -1157,7 +1157,7 @@ loadedFrame:SetScript("OnEvent", function(self, event, addon)
if(addon == ADDON_NAME) then
WeakAurasSaved = WeakAurasSaved or {};
db = WeakAurasSaved;
Private.db = db
-- Defines the action squelch period after login
-- Stored in SavedVariables so it can be changed by the user if they find it necessary
db.login_squelch_time = db.login_squelch_time or 10;
@@ -1668,7 +1668,7 @@ function Private.UnloadDisplays(toUnload, ...)
-- Even though auras are collapsed, their finish animation can be running
Private.CancelAnimation(Private.regions[id].region, true, true, true, true, true, true)
if clones[id] then
for cloneId, region in pairs(clones[id]) do
for _, region in pairs(clones[id]) do
Private.CancelAnimation(region, true, true, true, true, true, true)
end
end
@@ -1744,8 +1744,8 @@ function WeakAuras.Delete(data)
if clones[id] then
for _, region in pairs(clones[id]) do
region:Collapse();
Private.CancelAnimation(region, true, true, true, true, true, true)
region:Collapse();
Private.CancelAnimation(region, true, true, true, true, true, true)
end
clones[id] = nil
end
@@ -1756,6 +1756,7 @@ function WeakAuras.Delete(data)
triggerSystem.Delete(id);
end
loaded[id] = nil;
loadFuncs[id] = nil;
loadFuncsForOptions[id] = nil;
@@ -1815,6 +1816,7 @@ function WeakAuras.Rename(data, newid)
if Private.regions[newid] and Private.regions[newid].region then
Private.regions[newid].region.id = newid
end
if(clones[oldid]) then
clones[newid] = clones[oldid]
clones[oldid] = nil
@@ -1850,7 +1852,6 @@ function WeakAuras.Rename(data, newid)
db.displays[newid] = db.displays[oldid];
db.displays[oldid] = nil;
db.displays[newid].id = newid;
if(data.controlledChildren) then
@@ -1892,7 +1893,6 @@ end
function Private.Convert(data, newType)
local id = data.id;
Private.FakeStatesFor(id, false)
if Private.regions[id] then
@@ -2633,9 +2633,7 @@ function WeakAuras.PreAdd(data, snapshot)
Private.GetErrorHandlerId(data.id, L["Modernize"])
end
local default = data.regionType and
Private.regionTypes[data.regionType] and
Private.regionTypes[data.regionType].default
local default = data.regionType and Private.regionTypes[data.regionType] and Private.regionTypes[data.regionType].default
if default then
Private.validate(data, default)
end
@@ -2837,7 +2835,7 @@ function WeakAuras.Add(data, simpleChange)
if (data.internalVersion or 0) < internalVersion then
Private.SetMigrationSnapshot(data.uid, data)
end
local ok, ret = pcall(WeakAuras.PreAdd, data, oldSnapshot)
local ok = pcall(WeakAuras.PreAdd, data, oldSnapshot)
if ok then
pAdd(data, simpleChange)
else
@@ -2978,9 +2976,11 @@ local function EnsureRegion(id)
end
return Private.regions[id] and Private.regions[id].region
end
--- Ensures that a region/clone exists and returns it
-- Even if we are asked to only create a clone, we create the default region too.
function Private.EnsureRegion(id, cloneId)
-- Even if we are asked to only create a clone, we create the default region
-- too.
EnsureRegion(id)
if(cloneId and cloneId ~= "") then
return EnsureClone(id, cloneId);
@@ -3143,35 +3143,40 @@ local glow_frame_monitor
local anchor_unitframe_monitor
Private.dyngroup_unitframe_monitor = {}
do
local function frame_monitor_callback(event, frame, unit)
local function frame_monitor_callback(event, frame, unit, previousUnit)
local new_frame
local update_frame = event == "FRAME_UNIT_UPDATE"
local FRAME_UNIT_UPDATE = event == "FRAME_UNIT_UPDATE"
local FRAME_UNIT_ADDED = event == "FRAME_UNIT_ADDED"
local FRAME_UNIT_REMOVED = event == "FRAME_UNIT_REMOVED"
local dynamicGroupsToUpdate = {}
if type(glow_frame_monitor) == "table" then
for region, data in pairs(glow_frame_monitor) do
if region.state and UnitIsUnit(region.state.unit, unit)
and (data.frame ~= frame) == update_frame
if region.state and type(region.state.unit) == "string" and UnitIsUnit(region.state.unit, unit)
and ((data.frame ~= frame) and (FRAME_UNIT_ADDED or FRAME_UNIT_UPDATE))
or ((data.frame == frame) and FRAME_UNIT_REMOVED)
then
if not new_frame then
new_frame = WeakAuras.GetUnitFrame(unit) or WeakAuras.HiddenFrames
new_frame = WeakAuras.GetUnitFrame(unit)
end
if new_frame and new_frame ~= data.frame then
if new_frame ~= data.frame then
local id = region.id .. (region.cloneId or "")
-- remove previous glow
if data.frame then
actionGlowStop(data.actions, data.frame, id)
end
-- apply the glow to new_frame
data.frame = new_frame
actionGlowStart(data.actions, data.frame, id)
-- update hidefunc
local region = region
region.active_glows_hidefunc = region.active_glows_hidefunc or {}
region.active_glows_hidefunc[data.frame] = function()
actionGlowStop(data.actions, data.frame, id)
glow_frame_monitor[region] = nil
if new_frame then
-- apply the glow to new_frame
actionGlowStart(data.actions, data.frame, id)
-- update hidefunc
local region = region
region.active_glows_hidefunc = region.active_glows_hidefunc or {}
region.active_glows_hidefunc[data.frame] = function()
actionGlowStop(data.actions, data.frame, id)
glow_frame_monitor[region] = nil
end
end
end
end
@@ -3179,21 +3184,23 @@ do
end
if type(anchor_unitframe_monitor) == "table" then
for region, data in pairs(anchor_unitframe_monitor) do
if region.state and region.state.unit == unit
and (data.frame ~= frame) == update_frame
if region.state and type(region.state.unit) == "string" and UnitIsUnit(region.state.unit, unit)
and ((data.frame ~= frame) and (FRAME_UNIT_ADDED or FRAME_UNIT_UPDATE))
or ((data.frame == frame) and FRAME_UNIT_REMOVED)
then
if not new_frame then
new_frame = WeakAuras.GetUnitFrame(unit) or WeakAuras.HiddenFrames
end
if new_frame and new_frame ~= data.frame then
if new_frame ~= data.frame then
Private.AnchorFrame(data.data, region, data.parent)
end
end
end
end
for regionData, data_frame in pairs(Private.dyngroup_unitframe_monitor) do
if regionData.region and regionData.region.state and regionData.region.state.unit == unit
and (data_frame ~= frame) == update_frame
if regionData.region.state and type(regionData.region.state.unit) == "string" and UnitIsUnit(regionData.region.state.unit, unit)
and ((data_frame ~= frame) and (FRAME_UNIT_ADDED or FRAME_UNIT_UPDATE))
or ((data_frame == frame) and FRAME_UNIT_REMOVED)
then
if not new_frame then
new_frame = WeakAuras.GetUnitFrame(unit) or WeakAuras.HiddenFrames
@@ -3207,10 +3214,10 @@ do
for frame in pairs(dynamicGroupsToUpdate) do
frame:DoPositionChildren()
end
end
LGF.RegisterCallback("WeakAuras", "FRAME_UNIT_UPDATE", frame_monitor_callback)
LGF.RegisterCallback("WeakAuras", "FRAME_UNIT_ADDED", frame_monitor_callback)
LGF.RegisterCallback("WeakAuras", "FRAME_UNIT_REMOVED", frame_monitor_callback)
end
@@ -3218,8 +3225,7 @@ function Private.HandleGlowAction(actions, region)
if actions.glow_action
and (
(
(actions.glow_frame_type == "UNITFRAME" or
actions.glow_frame_type == "NAMEPLATE")
(actions.glow_frame_type == "UNITFRAME" or actions.glow_frame_type == "NAMEPLATE")
and region.state.unit
)
or (actions.glow_frame_type == "FRAMESELECTOR" and actions.glow_frame)
@@ -3560,6 +3566,7 @@ function Private.GetProgressSourcesForUi(data, subelement)
return result
end
function Private.GetOverlayInfo(data, triggernum)
local overlayInfo;
if (data.controlledChildren) then
@@ -4175,8 +4182,8 @@ local function startStopTimers(id, cloneId, triggernum, state)
state.changed = true;
-- if the trigger has updated then check to see if it is flagged for WatchedTrigger and send to queue if it is
if Private.watched_trigger_events[id] and Private.watched_trigger_events[id][triggernum] then
Private.AddToWatchedTriggerDelay(id, triggernum)
if Private.watched_trigger_events[id] and Private.watched_trigger_events[id][triggernum] then
Private.AddToWatchedTriggerDelay(id, triggernum)
end
Private.UpdatedTriggerState(id);
end
@@ -4239,11 +4246,11 @@ local function evaluateTriggerStateTriggers(id)
Private.ActivateAuraEnvironment(id)
local ok, returnValue = pcall(triggerState[id].triggerLogicFunc, triggerState[id].triggers);
Private.ActivateAuraEnvironment()
if not ok then
if ok then
result = returnValue
else
Private.GetErrorHandlerId(id, L["Custom Trigger Combination"])
result = false
else
result = returnValue
end
end
end
@@ -4428,7 +4435,6 @@ function Private.UpdatedTriggerState(id)
state.changed = false;
end
end
-- once updatedTriggerStates is complete, and empty states removed, etc., then check for queued watched triggers update
Private.SendDelayedWatchedTriggers()
end
@@ -4484,13 +4490,20 @@ local function ReplaceValuePlaceHolders(textStr, region, customFunc, state, form
end
local index = tonumber(textStr:match("^c(%d+)$") or 1)
if custom then
value = WeakAuras.EnsureString(custom[index])
value = custom[index]
end
if value == nil then value = "" end
if formatter then
value = formatter(value, state)
end
if custom then
value = WeakAuras.EnsureString(value)
end
else
local variable = Private.dynamic_texts[textStr];
if (not variable) then
@@ -5243,7 +5256,6 @@ local function GetAnchorFrame(data, region, parent)
local anchorFrameType = data.anchorFrameType
local anchorFrameFrame = data.anchorFrameFrame
if not id then return end
if (personalRessourceDisplayFrame) then
personalRessourceDisplayFrame:anchorFrame(id, anchorFrameType);
end
@@ -5352,7 +5364,7 @@ function Private.AnchorFrame(data, region, parent, force)
if not anchorParent then return end
if (data.anchorFrameParent or data.anchorFrameParent == nil
or data.anchorFrameType == "SCREEN" or data.anchorFrameType == "UIPARENT" or data.anchorFrameType == "MOUSE") then
local ok, ret = pcall(region.SetParent, region, anchorParent);
local ok = pcall(region.SetParent, region, anchorParent);
if not ok then
Private.GetErrorHandlerId(data.id, L["Anchoring"])
end
@@ -5524,6 +5536,10 @@ do
trackableUnits["raidpet" .. i] = true
end
for i = 1, 100 do
trackableUnits["nameplate" .. i] = true
end
function WeakAuras.UntrackableUnit(unit)
return not trackableUnits[unit]
end
@@ -5639,7 +5655,6 @@ function Private.ExecEnv.ParseZoneCheck(input)
for id in string.gmatch(input, "%d+") do
matcher:AddId(tonumber(id))
end
return matcher
end
@@ -5647,7 +5662,7 @@ function WeakAuras.IsAuraLoaded(id)
return Private.loaded[id]
end
function WeakAuras.CreateSpellChecker()
function Private.ExecEnv.CreateSpellChecker()
local matcher = {
names = {},
spellIds = {},
@@ -5820,3 +5835,4 @@ do
return data.regionType == "group" or data.regionType == "dynamicgroup"
end
end