From f72e96ae6ed5250a2df11ff50ec2cba33a26000e Mon Sep 17 00:00:00 2001 From: NoM0Re Date: Sat, 18 Jan 2025 17:23:16 +0100 Subject: [PATCH] from retail --- WeakAuras/Profiling.lua | 38 +++++++- WeakAuras/Prototypes.lua | 91 +++++++++++++++---- WeakAuras/RegionTypes/DynamicGroup.lua | 18 ++-- WeakAuras/RegionTypes/Text.lua | 2 +- WeakAuras/SubRegionTypes/SubText.lua | 2 +- WeakAuras/WeakAuras.lua | 15 +-- WeakAurasOptions/OptionsFrames/IconPicker.lua | 31 ++++--- 7 files changed, 149 insertions(+), 48 deletions(-) diff --git a/WeakAuras/Profiling.lua b/WeakAuras/Profiling.lua index 361b06e..150588f 100644 --- a/WeakAuras/Profiling.lua +++ b/WeakAuras/Profiling.lua @@ -341,6 +341,24 @@ local function TotalProfileTime(map) return total end +local function unitEventToMultiUnit(event) + local count + event, count = event:gsub("nameplate%d+$", "nameplate") + if count == 1 then return event end + event, count = event:gsub("boss%d$", "boss") + if count == 1 then return event end + event, count = event:gsub("arena%d$", "arena") + if count == 1 then return event end + event, count = event:gsub("raid%d+$", "group") + if count == 1 then return event end + event, count = event:gsub("raidpet%d+$", "group") + if count == 1 then return event end + event, count = event:gsub("party%d$", "party") + if count == 1 then return event end + event, count = event:gsub("partypet%d$", "party") + return event +end + function WeakAuras.PrintProfile() local popup = ProfilePopup() if not profileData.systems.time then @@ -387,9 +405,25 @@ function WeakAuras.PrintProfile() popup:AddText("") popup:AddText("|cff9900ffSystems:|r") - for i, k in ipairs(SortProfileMap(profileData.systems)) do + -- make a new table for system data with multiUnits grouped + local systemRegrouped = {} + for k, v in pairs(profileData.systems) do + local event = unitEventToMultiUnit(k) + if systemRegrouped[event] == nil then + systemRegrouped[event] = CopyTable(v) + else + if v.elapsed then + systemRegrouped[event].elapsed = (systemRegrouped[event].elapsed or 0) + v.elapsed + end + if v.spike then + systemRegrouped[event].spike = (systemRegrouped[event].spike or 0) + v.spike + end + end + end + + for i, k in ipairs(SortProfileMap(systemRegrouped)) do if (k ~= "time" and k ~= "wa") then - PrintOneProfile(popup, k, profileData.systems[k], profileData.systems.wa.elapsed) + PrintOneProfile(popup, k, systemRegrouped[k], profileData.systems.wa.elapsed) end end diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 13d7972..7ee6a88 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -2542,8 +2542,10 @@ Private.event_prototypes = { store = true, test = "Private.ExecEnv.CheckCombatLogFlags(sourceFlags, %q)", conditionType = "select", - conditionTest = function(state, needle) - return state and state.show and Private.ExecEnv.CheckCombatLogFlags(state.sourceFlags, needle); + conditionTest = function(state, needle, op) + if state and state.show then + return Private.ExecEnv.CheckCombatLogFlags(state.sourceFlags, needle) == (op == "==") + end end }, { @@ -2553,8 +2555,10 @@ Private.event_prototypes = { values = "combatlog_flags_check_reaction", test = "Private.ExecEnv.CheckCombatLogFlagsReaction(sourceFlags, %q)", conditionType = "select", - conditionTest = function(state, needle) - return state and state.show and Private.ExecEnv.CheckCombatLogFlagsReaction(state.sourceFlags, needle); + conditionTest = function(state, needle, op) + if state and state.show then + return Private.ExecEnv.CheckCombatLogFlagsReaction(state.sourceFlags, needle) == (op == "==") + end end }, { @@ -2564,8 +2568,10 @@ Private.event_prototypes = { values = "combatlog_flags_check_object_type", test = "Private.ExecEnv.CheckCombatLogFlagsObjectType(sourceFlags, %q)", conditionType = "select", - conditionTest = function(state, needle) - return state and state.show and Private.ExecEnv.CheckCombatLogFlagsObjectType(state.sourceFlags, needle); + conditionTest = function(state, needle, op) + if state and state.show then + return Private.ExecEnv.CheckCombatLogFlagsObjectType(state.sourceFlags, needle) == (op == "==") + end end }, { @@ -2577,8 +2583,10 @@ Private.event_prototypes = { store = true, test = "Private.ExecEnv.CheckRaidFlags(sourceRaidFlags, %q)", conditionType = "select", - conditionTest = function(state, needle) - return state and state.show and Private.ExecEnv.CheckRaidFlags(state.sourceRaidFlags, needle); + conditionTest = function(state, needle, op) + if state and state.show then + return Private.ExecEnv.CheckRaidFlags(state.sourceRaidFlags, needle) == (op == "==") + end end }, { @@ -2679,8 +2687,10 @@ Private.event_prototypes = { store = true, test = "Private.ExecEnv.CheckCombatLogFlags(destFlags, %q)", conditionType = "select", - conditionTest = function(state, needle) - return state and state.show and Private.ExecEnv.CheckCombatLogFlags(state.destFlags, needle); + conditionTest = function(state, needle, op) + if state and state.show then + return Private.ExecEnv.CheckCombatLogFlags(state.destFlags, needle) == (op == "==") + end end, enable = function(trigger) return not (trigger.subeventPrefix == "SPELL" and trigger.subeventSuffix == "_CAST_START"); @@ -2693,8 +2703,10 @@ Private.event_prototypes = { values = "combatlog_flags_check_reaction", test = "Private.ExecEnv.CheckCombatLogFlagsReaction(destFlags, %q)", conditionType = "select", - conditionTest = function(state, needle) - return state and state.show and Private.ExecEnv.CheckCombatLogFlagsReaction(state.destFlags, needle); + conditionTest = function(state, needle, op) + if state and state.show then + return Private.ExecEnv.CheckCombatLogFlagsReaction(state.destFlags, needle) == (op == "==") + end end, enable = function(trigger) return not (trigger.subeventPrefix == "SPELL" and trigger.subeventSuffix == "_CAST_START"); @@ -2707,8 +2719,10 @@ Private.event_prototypes = { values = "combatlog_flags_check_object_type", test = "Private.ExecEnv.CheckCombatLogFlagsObjectType(destFlags, %q)", conditionType = "select", - conditionTest = function(state, needle) - return state and state.show and Private.ExecEnv.CheckCombatLogFlagsObjectType(state.destFlags, needle); + conditionTest = function(state, needle, op) + if state and state.show then + return Private.ExecEnv.CheckCombatLogFlagsObjectType(state.destFlags, needle) == (op == "==") + end end, enable = function(trigger) return not (trigger.subeventPrefix == "SPELL" and trigger.subeventSuffix == "_CAST_START"); @@ -2728,8 +2742,10 @@ Private.event_prototypes = { store = true, test = "Private.ExecEnv.CheckRaidFlags(destRaidFlags, %q)", conditionType = "select", - conditionTest = function(state, needle) - return state and state.show and Private.ExecEnv.CheckRaidFlags(state.destRaidFlags, needle); + conditionTest = function(state, needle, op) + if state and state.show then + return Private.ExecEnv.CheckRaidFlags(state.destRaidFlags, needle) == (op == "==") + end end, enable = function(trigger) return not (trigger.subeventPrefix == "SPELL" and trigger.subeventSuffix == "_CAST_START"); @@ -4479,7 +4495,8 @@ Private.event_prototypes = { display = L["Totem Name"], type = "string", conditionType = "string", - store = true + store = true, + desc = L["Enter a name or a spellId"] }, { name = "totemNamePattern", @@ -5429,6 +5446,7 @@ Private.event_prototypes = { trigger.unit = trigger.unit or "target"; local ret = [[ unit = string.lower(unit) + local name = UnitName(unit, false) local ok = true local aggro, status, threatpct, rawthreatpct, threatvalue, threattotal if unit and unit ~= "none" then @@ -5510,6 +5528,43 @@ Private.event_prototypes = { limit = 2 }, }, + { + name = "name", + display = L["Unit Name"], + type = "string", + store = true, + multiline = true, + preamble = "local nameChecker = Private.ExecEnv.ParseStringCheck(%q)", + test = "nameChecker:Check(name)", + conditionType = "string", + conditionPreamble = function(input) + return Private.ExecEnv.ParseStringCheck(input) + end, + conditionTest = function(state, needle, op, preamble) + return preamble:Check(state.name) + end, + operator_types = "none", + desc = L["Supports multiple entries, separated by commas"] + }, + { + name = "npcId", + display = L["Npc ID"], + type = "string", + multiline = true, + store = true, + init = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '')", + conditionType = "string", + preamble = "local npcIdChecker = Private.ExecEnv.ParseStringCheck(%q)", + test = "npcIdChecker:Check(npcId)", + conditionPreamble = function(input) + return Private.ExecEnv.ParseStringCheck(input) + end, + conditionTest = function(state, needle, op, preamble) + return preamble:Check(state.npcId) + end, + operator_types = "none", + desc = L["Supports multiple entries, separated by commas"] + }, { name = "value", hidden = true, @@ -5537,7 +5592,7 @@ Private.event_prototypes = { }, { hidden = true, - test = "WeakAuras.UnitExistsFixed(unit, smart) and specificUnitCheck" + test = "WeakAuras.UnitExistsFixed(unit, false) and specificUnitCheck" } }, automaticrequired = true diff --git a/WeakAuras/RegionTypes/DynamicGroup.lua b/WeakAuras/RegionTypes/DynamicGroup.lua index cec8b5a..961752b 100644 --- a/WeakAuras/RegionTypes/DynamicGroup.lua +++ b/WeakAuras/RegionTypes/DynamicGroup.lua @@ -1139,13 +1139,6 @@ local function modify(parent, region, data) region.controlledChildren[childID] = region.controlledChildren[childID] or {} region.controlledChildren[childID][cloneID] = controlPoint childRegion:SetAnchor(data.selfPoint, controlPoint, data.selfPoint) - if(childData.frameStrata == 1) then - local frameStrata = region:GetFrameStrata() - childRegion:SetFrameStrata(frameStrata ~= "UNKNOWN" and frameStrata or "BACKGROUND"); - else - childRegion:SetFrameStrata(Private.frame_strata_types[childData.frameStrata]); - end - Private.ApplyFrameLevel(childRegion) return regionData end @@ -1397,6 +1390,17 @@ local function modify(parent, region, data) else controlPoint:SetParent(self) end + + local childData = controlPoint.regionData.data + local childRegion = controlPoint.regionData.region + if(childData.frameStrata == 1) then + local frameStrata = region:GetFrameStrata() + childRegion:SetFrameStrata(frameStrata ~= "UNKNOWN" and frameStrata or "BACKGROUND"); + else + childRegion:SetFrameStrata(Private.frame_strata_types[childData.frameStrata]); + end + Private.ApplyFrameLevel(childRegion) + if self.anchorPerUnit == "UNITFRAME" then Private.dyngroup_unitframe_monitor[regionData] = frame end diff --git a/WeakAuras/RegionTypes/Text.lua b/WeakAuras/RegionTypes/Text.lua index f0ed0db..2b92c01 100644 --- a/WeakAuras/RegionTypes/Text.lua +++ b/WeakAuras/RegionTypes/Text.lua @@ -84,7 +84,7 @@ local function modify(parent, region, data) if not text:GetFont() and fontPath then -- workaround font not loading correctly local objectName = "WeakAuras-Font-" .. data.font local fontObject = _G[objectName] or CreateFont(objectName) - fontObject:SetFont(fontPath, data.fontSize < 33 and data.fontSize or 33, data.outline) + fontObject:SetFont(fontPath, data.fontSize < 33 and data.fontSize or 33, data.outline == "None" and "" or data.outline) text:SetFontObject(fontObject) end text:SetFont(fontPath, data.fontSize < 33 and data.fontSize or 33, data.outline); diff --git a/WeakAuras/SubRegionTypes/SubText.lua b/WeakAuras/SubRegionTypes/SubText.lua index f15ac2a..1f41614 100644 --- a/WeakAuras/SubRegionTypes/SubText.lua +++ b/WeakAuras/SubRegionTypes/SubText.lua @@ -142,7 +142,7 @@ local function modify(parent, region, parentData, data, first) if not text:GetFont() and fontPath then -- workaround font not loading correctly local objectName = "WeakAuras-Font-" .. data.text_font local fontObject = _G[objectName] or CreateFont(objectName) - fontObject:SetFont(fontPath, data.text_fontSize < 33 and data.text_fontSize or 33, data.text_fontType) + fontObject:SetFont(fontPath, data.text_fontSize < 33 and data.text_fontSize or 33, data.text_fontType == "None" and "" or data.text_fontType) text:SetFontObject(fontObject) end if not text:GetFont() then -- Font invalid, set the font but keep the setting diff --git a/WeakAuras/WeakAuras.lua b/WeakAuras/WeakAuras.lua index 5ab2ced..412b0bf 100644 --- a/WeakAuras/WeakAuras.lua +++ b/WeakAuras/WeakAuras.lua @@ -3661,12 +3661,15 @@ local function SetFrameLevel(id, frameLevel) end function Private.FixGroupChildrenOrderForGroup(data) - local frameLevel = 1; - if data.parent == nil then - for child in Private.TraverseAll(data) do - SetFrameLevel(child.id, frameLevel); - frameLevel = frameLevel + 4; - end + local frameLevel, offset + if data.regionType == "dynamicgroup" then + frameLevel, offset = 5, 0 + else + frameLevel, offset = 1, 4 + end + for child in Private.TraverseLeafs(data) do + SetFrameLevel(child.id, frameLevel); + frameLevel = frameLevel + offset; end end diff --git a/WeakAurasOptions/OptionsFrames/IconPicker.lua b/WeakAurasOptions/OptionsFrames/IconPicker.lua index ca243f3..982de59 100644 --- a/WeakAurasOptions/OptionsFrames/IconPicker.lua +++ b/WeakAurasOptions/OptionsFrames/IconPicker.lua @@ -31,19 +31,6 @@ local function ConstructIconPicker(frame) local function iconPickerFill(subname, doSort) scroll:ReleaseChildren(); - - -- Work around special numbers such as inf and nan - if (tonumber(subname)) then - local spellId = tonumber(subname); - if (abs(spellId) < math.huge and tostring(spellId) ~= "nan") then - subname = GetSpellInfo(spellId or 0) - end - end - - if subname then - subname = subname:lower(); - end - local usedIcons = {}; local AddButton = function(name, icon) local button = AceGUI:Create("WeakAurasIconButton"); @@ -57,6 +44,24 @@ local function ConstructIconPicker(frame) usedIcons[icon] = true; end + -- Work around special numbers such as inf and nan + if (tonumber(subname)) then + local spellId = tonumber(subname); + if (abs(spellId) < math.huge and tostring(spellId) ~= "nan") then + local name, _, icon = GetSpellInfo(spellId) + if name and icon then + AddButton(name, icon) + end + return; + end + end + if subname then + subname = subname:lower(); + end + + + + local num = 0; if(subname and subname ~= "") then for name, icons in pairs(spellCache.Get()) do