From c080aa96d5ef349a2c820b2b361d7d361112df57 Mon Sep 17 00:00:00 2001 From: NoM0Re Date: Thu, 16 Jan 2025 16:10:02 +0100 Subject: [PATCH] from retail --- WeakAuras/Conditions.lua | 4 +- .../AceGUIWidget-WeakAurasExpand.lua | 12 +++- WeakAurasOptions/ConditionOptions.lua | 66 +++++++++++++++---- WeakAurasOptions/TriggerOptions.lua | 22 ++++++- 4 files changed, 88 insertions(+), 16 deletions(-) diff --git a/WeakAuras/Conditions.lua b/WeakAuras/Conditions.lua index e7ebee1..60044ee 100644 --- a/WeakAuras/Conditions.lua +++ b/WeakAuras/Conditions.lua @@ -484,7 +484,9 @@ function Private.GetSubRegionProperties(data, properties) if subProperties then for key, property in pairs(subProperties) do subIndex[key] = subIndex[key] and subIndex[key] + 1 or 1 - property.display = { subIndex[key] .. ". " .. subRegionTypeData.displayName, property.display, property.defaultProperty } + property.display = { subRegionTypeData.displayName .. " " .. subIndex[key], + property.display, + property.defaultProperty } properties["sub." .. index .. "." .. key ] = property; end end diff --git a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpand.lua b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpand.lua index 1732ec0..cc3c0af 100644 --- a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpand.lua +++ b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpand.lua @@ -3,7 +3,7 @@ Button Widget for our Expand button -------------------------------------------------------------------------------]] if not WeakAuras.IsLibsOK() then return end -local Type, Version = "WeakAurasExpand", 5 +local Type, Version = "WeakAurasExpand", 6 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end @@ -30,6 +30,12 @@ local function Button_OnClick(frame, button) AceGUI:ClearFocus() end +local function OnFrameShow(frame) + local self = frame.obj + local fontObject = self.userdata and self.userdata.option and self.userdata.option.fontObject + self:SetFontObject(fontObject or GameFontHighlightLarge) +end + --[[----------------------------------------------------------------------------- Methods -------------------------------------------------------------------------------]] @@ -38,7 +44,6 @@ local methods = { self:SetHeight(110) self:SetWidth(110) self:SetLabel() - self:SetFontObject(GameFontHighlightLarge) self:SetImage(nil) self:SetImageSize(64, 64) self:SetDisabled(false) @@ -111,6 +116,7 @@ local function Constructor() frame:SetScript("OnEnter", Control_OnEnter) frame:SetScript("OnLeave", Control_OnLeave) frame:SetScript("OnClick", Button_OnClick) + frame:SetScript("OnShow", OnFrameShow) local image = frame:CreateTexture(nil, "BACKGROUND") image:SetWidth(64) @@ -119,7 +125,7 @@ local function Constructor() local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlightLarge") label:SetJustifyH("LEFT") - label:SetJustifyV("TOP") + label:SetJustifyV("MIDDLE") label:SetPoint("LEFT", image, "RIGHT", 5, 0) label:SetPoint("TOP") label:SetPoint("BOTTOM") diff --git a/WeakAurasOptions/ConditionOptions.lua b/WeakAurasOptions/ConditionOptions.lua index 6f8bb54..a8380f9 100644 --- a/WeakAurasOptions/ConditionOptions.lua +++ b/WeakAurasOptions/ConditionOptions.lua @@ -1378,14 +1378,14 @@ local function addControlsForIfLine(args, order, data, conditionVariable, totalA local isFirst = path[#path] == 1; if (isFirst) then if (needsTriggerName) then - optionsName = optionsName .. string.format(L["Trigger %s"], check.trigger); + optionsName = optionsName .. OptionsPrivate.GetTriggerTitle(data, check.trigger) end else if (needsTriggerName) then if (parentType == "AND") then - optionsName = optionsName .. string.format(L["and Trigger %s"], check.trigger); + optionsName = optionsName .. string.format(L["and %s"], OptionsPrivate.GetTriggerTitle(data, check.trigger)); else - optionsName = optionsName .. string.format(L["or Trigger %s"], check.trigger); + optionsName = optionsName .. string.format(L["or %s"], OptionsPrivate.GetTriggerTitle(data, check.trigger)); end end end @@ -1393,9 +1393,9 @@ local function addControlsForIfLine(args, order, data, conditionVariable, totalA local isLinked = conditions[i].linked and i > 1 if (needsTriggerName) then if isLinked then - optionsName = optionsName .. string.format(L["Else If Trigger %s"], check.trigger); + optionsName = optionsName .. string.format(L["Else If %s"], OptionsPrivate.GetTriggerTitle(data, check.trigger)); else - optionsName = optionsName .. string.format(L["If Trigger %s"], check.trigger); + optionsName = optionsName .. string.format(L["If %s"], OptionsPrivate.GetTriggerTitle(data, check.trigger)); end else optionsName = optionsName .. (isLinked and L["Else If"] or L["If"]) @@ -1954,6 +1954,49 @@ local function fixUpLinkedInFirstCondition(conditions) end end +local function formatConditionTitle(text, propertyType, value) + if propertyType == "color" and type(value) == "table" then + local r, g, b = unpack(value) + r, g, b = r or 1, g or 1, b or 1 + return ("|cFF%2x%2x%2x%s|r"):format(r * 220 + 35, g * 220 + 35, b * 220 + 35, text) + elseif propertyType == "bool" then + return ("%s: %s"):format(text, value and L["ON"] or L["OFF"]) + elseif propertyType == "sound" and type(value) == "table" and type(value.sound) == "string" and value.sound ~= "" then + if OptionsPrivate.Private.sound_types[value.sound] then + return ("%s: %s"):format(text, OptionsPrivate.Private.sound_types[value.sound]) + end + elseif value ~= nil and type(value) ~= "table" then + return ("%s: %s"):format(text, value) + end + return text +end + +local function GetConditionTitle(changes, conditionnum, allProperties) + if type(changes) == "table" and #changes > 0 then + local outs = {} + for i, change in ipairs(changes) do + local property = change.property + if property and allProperties.propertyMap[property] then + local display = allProperties.propertyMap[property].display + local propertyType = allProperties.propertyMap[property].type + local title + if type(display) == "string" then + title = display + elseif type(display) == "table" then + title = ("%s %s"):format(display[1], display[2]) + end + if title then + tinsert(outs, formatConditionTitle(title, propertyType, change.value)) + end + end + end + if #outs > 0 then + return L["%i. %s"]:format(conditionnum, table.concat(outs, ", ")) + end + end + return L["%i."]:format(conditionnum) +end + local function addControlsForCondition(args, order, data, conditionVariable, totalAuraCount, conditions, i, conditionTemplates, conditionTemplateWithoutCombinations, allProperties) if (not conditions[i].check) then return order; @@ -1975,7 +2018,7 @@ local function addControlsForCondition(args, order, data, conditionVariable, tot args["condition" .. i .. "header"] = { type = "execute", - name = L["Condition %i"]:format(i), + name = GetConditionTitle(conditions[i].changes, i, allProperties), order = order, width = WeakAuras.doubleWidth - 0.6, func = function() @@ -1993,7 +2036,8 @@ local function addControlsForCondition(args, order, data, conditionVariable, tot image = collapsed and "Interface\\AddOns\\WeakAuras\\Media\\Textures\\expand" or "Interface\\AddOns\\WeakAuras\\Media\\Textures\\collapse" , imageWidth = 18, imageHeight = 18, - control = "WeakAurasExpand" + control = "WeakAurasExpand", + fontObject = GameFontHighlight }; order = order + 1; @@ -2292,7 +2336,7 @@ local function mergeConditionTemplates(allConditionTemplates, auraConditionsTemp end end -local function createConditionTemplatesValueList(allConditionTemplates, numTriggers, excludeCombinations) +local function createConditionTemplatesValueList(allConditionTemplates, numTriggers, excludeCombinations, data) local conditionTemplates = {}; conditionTemplates.all = allConditionTemplates; conditionTemplates.indexToTrigger = {}; @@ -2322,7 +2366,7 @@ local function createConditionTemplatesValueList(allConditionTemplates, numTrigg elseif (triggernum == -1) then conditionTemplates.display[index] = string.format(L["Global Conditions"]); else - conditionTemplates.display[index] = string.format(L["Trigger %d"], triggernum); + conditionTemplates.display[index] = OptionsPrivate.GetTriggerTitle(data, triggernum) end index = index + 1; @@ -2381,7 +2425,7 @@ local function createConditionTemplates(data) } allConditionTemplates[-1] = OptionsPrivate.Private.GetGlobalConditions(); - local conditionTemplates = createConditionTemplatesValueList(allConditionTemplates, numTriggers); + local conditionTemplates = createConditionTemplatesValueList(allConditionTemplates, numTriggers, nil, data); if (data.controlledChildren) then conditionTemplates.displayWithCopy = CopyTable(conditionTemplates.display); @@ -2391,7 +2435,7 @@ local function createConditionTemplates(data) conditionTemplates.indexToVariable[9998] = "COPY"; end - local conditionTemplateWithoutCombinations = createConditionTemplatesValueList(allConditionTemplates, numTriggers, true); + local conditionTemplateWithoutCombinations = createConditionTemplatesValueList(allConditionTemplates, numTriggers, true, data); return conditionTemplates, conditionTemplateWithoutCombinations; end diff --git a/WeakAurasOptions/TriggerOptions.lua b/WeakAurasOptions/TriggerOptions.lua index 0f27297..369f6c5 100644 --- a/WeakAurasOptions/TriggerOptions.lua +++ b/WeakAurasOptions/TriggerOptions.lua @@ -253,10 +253,30 @@ function OptionsPrivate.ClearTriggerExpandState() maxTriggerNumForExpand = 0 end +function OptionsPrivate.GetTriggerTitle(data, triggernum) + if data.triggers[triggernum] then + local trigger = data.triggers[triggernum].trigger + if trigger then + local event_prototype = OptionsPrivate.Private.event_prototypes[trigger.event] + local triggerType = trigger.type + local name + if triggerType == "aura2" then + name = L["Aura"] + elseif triggerType == "custom" then + name = L["Custom"] + else + name = event_prototype.name + end + return L["Trigger %i: %s"]:format(triggernum, name) + end + end + return L["Trigger %i"]:format(triggernum) +end + local triggerDeleteDialogOpen = false function OptionsPrivate.AddTriggerMetaFunctions(options, data, triggernum) - options.__title = L["Trigger %s"]:format(triggernum) + options.__title = OptionsPrivate.GetTriggerTitle(data, triggernum) options.__order = triggernum * 10 options.__collapsed = #data.triggers > 1 options.__isCollapsed = function()