diff --git a/WeakAuras/BuffTrigger2.lua b/WeakAuras/BuffTrigger2.lua index 9cae769..82b5338 100644 --- a/WeakAuras/BuffTrigger2.lua +++ b/WeakAuras/BuffTrigger2.lua @@ -2686,10 +2686,22 @@ function BuffTrigger.GetTriggerConditions(data, triggernum) } result["unitCaster"] = { - display = L["Caster"], + display = L["Caster Unit"], type = "string" } + result["nameCaster"] = { + display = L["Casters Name/Realm"], + type = "string", + preamble = function(input) + return Private.ExecEnv.ParseNameCheck(input) + end, + test = function(state, needle, op, preamble) + return state.unitCaster and preamble:Check(WeakAuras.UnitNameWithRealm(state.unitCaster)) + end, + operator_types = "none", + } + result["expirationTime"] = { display = L["Remaining Duration"], type = "timer" diff --git a/WeakAuras/Init.lua b/WeakAuras/Init.lua index 6a46ecd..52a84c3 100644 --- a/WeakAuras/Init.lua +++ b/WeakAuras/Init.lua @@ -21,10 +21,6 @@ function WeakAuras.isAwesomeEnabled() return isAwesomeEnabled end -function WeakAuras.IsClassic() - return false -end - function WeakAuras.IsCorrectVersion() return true end diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 7ee6a88..9df6346 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -1050,6 +1050,7 @@ Private.load_prototype = { operator = "and", limit = 2 }, + optional = true, }, { name = "group_leader", @@ -2191,7 +2192,7 @@ Private.event_prototypes = { display = L["Power Type"], type = "select", values = "power_types", - init = "unitPowerType", + init = "powerTypeToCheck", test = "true", store = true, conditionType = "select", @@ -4892,7 +4893,11 @@ Private.event_prototypes = { }, ["Chat Message"] = { type = "event", - events = { + events = function(trigger) + if trigger.use_messageType and trigger.messageType and Private.chat_message_types[trigger.messageType] then + return { ["events"] = {trigger.messageType} } + end + return { ["events"] = { "CHAT_MSG_BATTLEGROUND", "CHAT_MSG_BATTLEGROUND_LEADER", @@ -4920,9 +4925,11 @@ Private.event_prototypes = { "CHAT_MSG_WHISPER", "CHAT_MSG_YELL", "CHAT_MSG_SYSTEM", - "CHAT_MSG_TEXT_EMOTE" + "CHAT_MSG_TEXT_EMOTE", + "CHAT_MSG_LOOT", } - }, + } + end, name = L["Chat Message"], init = function(trigger) local ret = [[ @@ -7025,6 +7032,138 @@ Private.event_prototypes = { }, automaticrequired = true }, + --[[ Some day i will finish this, soonTM + ["Currency"] = { + type = "unit", + canHaveDuration = false, + events = { + ["events"] = { + "CURRENCY_DISPLAY_UPDATE", + } + }, + force_events = "CURRENCY_DISPLAY_UPDATE", + name = WeakAuras.newFeatureString..L["Currency"], + init = function(trigger) + local ret = [=[ + local currencyInfo = { + name = GetItemInfo(%d), + quantity = GetItemCount(%d), + iconFileID = select(6, GetItemInfo(%d)), + totalEarned = Private.GetTotalCountCurrencies(%d), + discovered = Private.GetDiscoveredCurencies(%d), + } + if not currencyInfo.name then + currencyInfo = { + name = "Unknown Currency", + quantity = 0, + iconFileID = "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) + end, + statesParameter = "one", + args = { + { + name = "currencyId", + type = "currency", + itemControl = "Dropdown-Currency", + values = Private.GetDiscoveredCurencies, + headers = Private.GetDiscoveredCurenciesHeaders, + sorted = true, + sortOrder = function() + local discovered_currencies_sorted = Private.GetDiscoveredCurenciesSorted() + local sortOrder = {} + for key, value in pairs(Private.GetDiscoveredCurencies()) do + tinsert(sortOrder, key) + end + table.sort(sortOrder, function(aKey, bKey) + local aValue = discovered_currencies_sorted[aKey] + local bValue = discovered_currencies_sorted[bKey] + return aValue < bValue + end) + return sortOrder + end, + required = true, + display = L["Currency"], + store = true, + test = "true", + }, + { + name = "name", + init = "currencyInfo.name", + hidden = true, + store = true, + test = "true", + }, + { + name = "value", + init = "currencyInfo.quantity", + type = "number", + display = L["Quantity"], + store = true, + conditionType = "number", + }, + { + name = "total", + init = "currencyInfo.maxQuantity", + type = "number", + hidden = true, + store = true, + test = "true", + }, + { + name = "progressType", + init = "'static'", + hidden = true, + store = true, + test = "true", + }, + { + name = "icon", + init = "currencyInfo.iconFileID", + 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", + type = "string", + display = L["Description"], + store = true, + hidden = true, + test = "true", + }, + { + name = "discovered", + init = "currencyInfo.discovered", + type = "tristate", + display = L["Discovered"], + store = true, + conditionType = "bool", + }, + }, + GetNameAndIcon = function(trigger) + local currencyInfo = Private.GetCurrencyInfoForTrigger(trigger) + return currencyInfo and currencyInfo.name, currencyInfo and currencyInfo.iconFileID + end, + automaticrequired = true + }, + ]] ["Location"] = { type = "unit", events = { diff --git a/WeakAuras/Transmission.lua b/WeakAuras/Transmission.lua index f0ca9b6..b89e9b5 100644 --- a/WeakAuras/Transmission.lua +++ b/WeakAuras/Transmission.lua @@ -439,14 +439,14 @@ end local delayedImport = CreateFrame("FRAME") -local function ImportNow(data, children, target, sender, callbackFunc) +local function ImportNow(data, children, target, linkedAuras, sender, callbackFunc) if InCombatLockdown() then WeakAuras.prettyPrint(L["Importing will start after combat ends."]) delayedImport:RegisterEvent("PLAYER_REGEN_ENABLED") delayedImport:SetScript("OnEvent", function() delayedImport:UnregisterEvent("PLAYER_REGEN_ENABLED") - ImportNow(data, children, target, sender, callbackFunc) + ImportNow(data, children, target, linkedAuras, sender, callbackFunc) end) return end @@ -455,11 +455,11 @@ local function ImportNow(data, children, target, sender, callbackFunc) if not WeakAuras.IsOptionsOpen() then WeakAuras.OpenOptions() end - Private.OpenUpdate(data, children, target, sender, callbackFunc) + Private.OpenUpdate(data, children, target, linkedAuras, sender, callbackFunc) end end -function WeakAuras.Import(inData, target, callbackFunc) +function WeakAuras.Import(inData, target, callbackFunc, linkedAuras) local data, children, version if type(inData) == 'string' then -- encoded data @@ -495,7 +495,7 @@ function WeakAuras.Import(inData, target, callbackFunc) if highestVersion > WeakAuras.InternalVersion() then -- Do not run PreAdd but still show Import Window tooltipLoading = nil; - return ImportNow(data, children, target, nil, callbackFunc) + return ImportNow(data, children, target, linkedAuras, nil, callbackFunc) end ]] @@ -529,7 +529,7 @@ function WeakAuras.Import(inData, target, callbackFunc) end tooltipLoading = nil; - return ImportNow(data, children, target, nil, callbackFunc) + return ImportNow(data, children, target, linkedAuras, nil, callbackFunc) end local function crossRealmSendCommMessage(prefix, text, target, queueName, callbackFn, callbackArg) @@ -659,7 +659,7 @@ Comm:RegisterComm("WeakAuras", function(prefix, message, distribution, sender) end ItemRefTooltip:Hide() - ImportNow(data, children, nil, sender) + ImportNow(data, children, nil, nil, sender) elseif(received.m == "dR") then if(Private.linked and Private.linked[received.d] and Private.linked[received.d] > GetTime() - linkValidityDuration) then TransmitDisplay(received.d, sender); diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index f97a627..ba911b5 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -565,7 +565,7 @@ Private.format_types = { if abbreviateFunc then return function(guid) local ok, _, class, _, _, _, name, realm = pcall(GetPlayerInfoByGUID, guid) - if ok then + if ok and name then local name = abbreviateFunc(nameFunc(name, realm)) return colorFunc(class, name) end @@ -573,7 +573,7 @@ Private.format_types = { else return function(guid) local ok, _, class, _, _, _, name, realm = pcall(GetPlayerInfoByGUID, guid) - if ok then + if ok and name then return colorFunc(class, nameFunc(name, realm)) end end @@ -582,14 +582,14 @@ Private.format_types = { if abbreviateFunc then return function(guid) local ok, _, class, _, _, _, name, realm = pcall(GetPlayerInfoByGUID, guid) - if ok then + if ok and name then return abbreviateFunc(nameFunc(name, realm)) end end else return function(guid) local ok, _, class, _, _, _, name, realm = pcall(GetPlayerInfoByGUID, guid) - if ok then + if ok and name then return nameFunc(name, realm) end end @@ -1158,6 +1158,94 @@ for id, str in pairs(Private.combatlog_spell_school_types) do Private.combatlog_spell_school_types_for_ui[id] = ("%.3d - %s"):format(id, str) end +Private.item_quality_types = { + [0] = ITEM_QUALITY0_DESC, + [1] = ITEM_QUALITY1_DESC, + [2] = ITEM_QUALITY2_DESC, + [3] = ITEM_QUALITY3_DESC, + [4] = ITEM_QUALITY4_DESC, + [5] = ITEM_QUALITY5_DESC, + [6] = ITEM_QUALITY6_DESC, + [7] = ITEM_QUALITY7_DESC, + [8] = ITEM_QUALITY8_DESC, +} + +Private.totalcount_currencies = { + [45624] = 3018, -- Emblems of Conquest + [40753] = 1465, -- Emblems of Valor + [29434] = 1462, -- Badges of Justice + [40752] = 1464, -- Emblems of Heroism + [47241] = 4729, -- Emblems of Triumph + [49426] = 4730, -- Emblems of Frost +} + +function Private.GetTotalCountCurrencies(currencyID) + local achievementID = Private.totalcount_currencies[currencyID] + if achievementID then + local totalEarned = GetStatistic(achievementID) + return tonumber(totalEarned) or 0 + end + return nil +end + +local function InitializeCurrencies() + if Private.discovered_currencies then + return + end + Private.discovered_currencies = {} + Private.discovered_currencies_sorted = {} + Private.discovered_currencies_headers = {} + + local expanded = {} + for index = GetCurrencyListSize(), 1, -1 do + local name, isHeader, isExpanded, _, _, _, _, _, _ = GetCurrencyListInfo(index) + if isHeader and not isExpanded then + ExpandCurrencyList(index, true) + expanded[name] = true + end + end + + for index = 1, GetCurrencyListSize() do + local name, isHeader, _, _, _, _, _, iconFileID, itemID = GetCurrencyListInfo(index) + local currencyLink = tonumber(itemID) and GetItemInfo(itemID) + + if currencyLink then + local icon = iconFileID or "Interface\\Icons\\INV_Misc_QuestionMark" --iconFileID not available on first login + Private.discovered_currencies[itemID] = "|T" .. icon .. ":0|t" .. name + Private.discovered_currencies_sorted[itemID] = index + elseif isHeader then + Private.discovered_currencies[name] = name + Private.discovered_currencies_sorted[name] = index + Private.discovered_currencies_headers[name] = true + end + end + + for index = GetCurrencyListSize(), 1, -1 do + local name, isHeader = GetCurrencyListInfo(index) + if isHeader and expanded[name] then + ExpandCurrencyList(index, false) + end + end + + Private.discovered_currencies["member"] = "|Tinterface\\common\\ui-searchbox-icon:0:0:0:-2|t"..L["Specific Currency"]; + Private.discovered_currencies_sorted["member"] = -1; +end + +Private.GetDiscoveredCurencies = function() + InitializeCurrencies() + return Private.discovered_currencies +end + +Private.GetDiscoveredCurenciesSorted = function() + InitializeCurrencies() + return Private.discovered_currencies_sorted +end + +Private.GetDiscoveredCurenciesHeaders = function() + InitializeCurrencies() + return Private.discovered_currencies_headers +end + Private.combatlog_raid_mark_check_type = { [0] = RAID_TARGET_NONE, "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcon_1:14|t " .. RAID_TARGET_1, -- Star @@ -2071,7 +2159,8 @@ Private.chat_message_types = { CHAT_MSG_SAY = L["Say"], CHAT_MSG_WHISPER = L["Whisper"], CHAT_MSG_YELL = L["Yell"], - CHAT_MSG_SYSTEM = L["System"] + CHAT_MSG_SYSTEM = L["System"], + CHAT_MSG_LOOT = L["Loot"], } Private.send_chat_message_types = { @@ -2474,6 +2563,7 @@ Private.update_categories = { "url", "desc", "version", + "semver" }, default = true, label = L["Meta Data"], diff --git a/WeakAuras/WeakAuras.lua b/WeakAuras/WeakAuras.lua index 412b0bf..5a28e13 100644 --- a/WeakAuras/WeakAuras.lua +++ b/WeakAuras/WeakAuras.lua @@ -329,13 +329,6 @@ Private.ExecEnv.conditionHelpers = {} local load_prototype = Private.load_prototype; -local levelColors = { - [0] = "|cFFFFFFFF", - [1] = "|cFF40FF40", - [2] = "|cFF6060FF", - [3] = "|cFFFF4040" -}; - function Private.validate(input, default) for field, defaultValue in pairs(default) do if(type(defaultValue) == "table" and type(input[field]) ~= "table") then @@ -2209,11 +2202,16 @@ function Private.AddMany(tbl, takeSnapshots) coroutine.yield() local groups = {} for _, data in ipairs(order) do - WeakAuras.Add(data, takeSnapshots); - coroutine.yield() + WeakAuras.PreAdd(data) if data.regionType == "dynamicgroup" or data.regionType == "group" then groups[data] = true end + coroutine.yield() + end + + for _, data in ipairs(order) do + WeakAuras.Add(data, takeSnapshots); + coroutine.yield() end for id in pairs(anchorTargets) do @@ -2388,29 +2386,6 @@ local function validateUserConfig(data, options, config) end end -local function removeSpellNames(data) - local trigger - for i = 1, #data.triggers do - trigger = data.triggers[i].trigger - if trigger and trigger.type == "aura" then - if type(trigger.spellName) == "number" then - trigger.realSpellName = GetSpellInfo(trigger.spellName) or trigger.realSpellName - end - if (trigger.spellId) then - trigger.name = GetSpellInfo(trigger.spellId) or trigger.name; - end - if (trigger.spellIds) then - for i = 1, 10 do - if (trigger.spellIds[i]) then - trigger.names = trigger.names or {}; - trigger.names[i] = GetSpellInfo(trigger.spellIds[i]) or trigger.names[i]; - end - end - end - end - end -end - local function removeNameplateUnits(data) for _, triggerData in ipairs(data.triggers) do local trigger = triggerData.trigger @@ -2618,7 +2593,6 @@ function WeakAuras.PreAdd(data) end end validateUserConfig(data, data.authorOptions, data.config) - removeSpellNames(data) if not(WeakAuras.isAwesomeEnabled()) then removeNameplateUnits(data) end @@ -2811,11 +2785,11 @@ end function Private.SetRegion(data, cloneId) local regionType = data.regionType; if not(regionType) then - error("Improper arguments to Private.SetRegion - regionType not defined"); + error("Improper arguments to Private.SetRegion - regionType not defined in ".. data.id) else if(not regionTypes[regionType]) then regionType = "fallback"; - print("Improper arguments to WeakAuras.CreateRegion - regionType \""..data.regionType.."\" is not supported"); + print("Improper arguments to WeakAuras.CreateRegion - regionType \""..data.regionType.."\" is not supported in ".. data.id) end local id = data.id; @@ -3661,15 +3635,19 @@ local function SetFrameLevel(id, frameLevel) end function Private.FixGroupChildrenOrderForGroup(data) + SetFrameLevel(data.id, 0) local frameLevel, offset if data.regionType == "dynamicgroup" then frameLevel, offset = 5, 0 else - frameLevel, offset = 1, 4 + frameLevel, offset = 2, 4 end - for child in Private.TraverseLeafs(data) do - SetFrameLevel(child.id, frameLevel); - frameLevel = frameLevel + offset; + for _, childId in ipairs(data.controlledChildren) do + local data = WeakAuras.GetData(childId) + if data.regionType ~= "group" and data.regionType ~= "dynamicgroup" then + SetFrameLevel(childId, frameLevel); + frameLevel = frameLevel + offset; + end end end @@ -3679,18 +3657,27 @@ end function Private.ApplyFrameLevel(region, frameLevel) frameLevel = frameLevel or GetFrameLevelFor(region.id) + + local setBackgroundFrameLevel = false if region.subRegions then for index, subRegion in pairs(region.subRegions) do if subRegion.type == "subbackground" then subRegion:SetFrameLevel(frameLevel + index) + setBackgroundFrameLevel = true end end + if not setBackgroundFrameLevel then + region:SetFrameLevel(frameLevel) + end + for index, subRegion in pairs(region.subRegions) do if subRegion.type ~= "subbackground" then subRegion:SetFrameLevel(frameLevel + index) end end + else + region:SetFrameLevel(frameLevel) end end diff --git a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDropDownItemCurrency.lua b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDropDownItemCurrency.lua new file mode 100644 index 0000000..6eced1a --- /dev/null +++ b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDropDownItemCurrency.lua @@ -0,0 +1,115 @@ +-- Item: Toggle +-- Some sort of checkbox for dropdown menus. +-- Does not close the pullout on click. +-- Based on the AceGUI Toggle Item. Extracts the icon from the text + +local AceGUI = LibStub and LibStub("AceGUI-3.0", true) +local ItemBase = LibStub("AceGUI-3.0-DropDown-ItemBase"):GetItemBase() + +local widgetType = "Dropdown-Currency" +local widgetVersion = 1 + +local function UpdateToggle(self) + if self.value and not self.isHeader then + self.check:Show() + else + self.check:Hide() + end +end + +local function OnRelease(self) + ItemBase.OnRelease(self) + self:SetValue(nil) +end + +local function Frame_OnClick(this, button) + local self = this.obj + if self.disabled then return end + self.value = not self.value + if self.value then + PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON + else + PlaySound(857) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF + end + UpdateToggle(self) + self:Fire("OnValueChanged", self.value) +end + +local function Frame_OnShow(self) + local userdata = self.obj.userdata + local key = userdata and userdata.value + local dropDownUserData = userdata and userdata.obj and userdata.obj.userdata + local headers = dropDownUserData and dropDownUserData.option and dropDownUserData.option.headers + if type(headers) == "function" then + headers = headers() + end + + local isHeader = headers and key and headers[key] + self.obj.isHeader = isHeader + + if isHeader then + self:SetScript("OnClick", nil) + self.obj.text:SetTextColor(1, 1, 0) + self.obj.text:SetPoint("TOPLEFT", self, "TOPLEFT", 7, 0) + self.obj.icon:Hide() + self.obj.useHighlight = false + else + self:SetScript("OnClick", Frame_OnClick) + self.obj.text:SetTextColor(1, 1, 1) + self.obj.text:SetPoint("TOPLEFT", self, "TOPLEFT", 34, 0) + self.obj.icon:Show() + self.obj.useHighlight = true + end + UpdateToggle(self.obj) +end + +-- exported +local function SetValue(self, value) + self.value = value + UpdateToggle(self) +end + +-- exported +local function GetValue(self) + return self.value +end + +local function SetText(self, text) + text = text or "" + local pos = text:find("|t", 1, true) + if pos then + ItemBase.SetText(self, text:sub(pos + 2)) + + local firstColon = text:find(":", 1, true) + local icon = text:sub(3, firstColon - 1) + self.icon:SetTexture(icon) + else + ItemBase.SetText(self, text) + end + self.fullText = text +end + + +local function Constructor() + local self = ItemBase.Create(widgetType) + + self.text:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 34) + + self.icon = self.frame:CreateTexture(nil, "OVERLAY") + self.icon:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 18, -2) + self.icon:SetWidth(12) + self.icon:SetHeight(12) + + self.frame:SetScript("OnClick", Frame_OnClick) + self.frame:SetScript("OnShow", Frame_OnShow) + + self.SetValue = SetValue + self.GetValue = GetValue + self.OnRelease = OnRelease + self.SetText = SetText + + AceGUI:RegisterAsWidget(self) + return self +end + +AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version) diff --git a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasPendingUpdateButton.lua b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasPendingUpdateButton.lua index 9e2a95e..703194d 100644 --- a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasPendingUpdateButton.lua +++ b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasPendingUpdateButton.lua @@ -5,7 +5,7 @@ local L = WeakAuras.L local pairs, next, type, unpack = pairs, next, type, unpack -local Type, Version = "WeakAurasPendingUpdateButton", 5 +local Type, Version = "WeakAurasPendingUpdateButton", 6 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then @@ -57,7 +57,14 @@ local methods = { self.linkedChildren = {} function self.callbacks.OnUpdateClick() - WeakAuras.Import(self.companionData.encoded) + local linkedAuras = {} + for auraId in pairs(self.linkedAuras) do + if not self.linkedChildren[auraId] then + tinsert(linkedAuras, auraId) + end + end + + WeakAuras.Import(self.companionData.encoded, nil, nil, linkedAuras) end self:SetTitle(self.companionData.name) diff --git a/WeakAurasOptions/ActionOptions.lua b/WeakAurasOptions/ActionOptions.lua index eb9082c..6de47c1 100644 --- a/WeakAurasOptions/ActionOptions.lua +++ b/WeakAurasOptions/ActionOptions.lua @@ -12,15 +12,8 @@ local hiddenAll = OptionsPrivate.commonOptions.CreateHiddenAll("action") local getAll = OptionsPrivate.commonOptions.CreateGetAll("action") local setAll = OptionsPrivate.commonOptions.CreateSetAll("action", getAll) -local RestrictedChannelCheck -if WeakAuras.IsClassic() then - RestrictedChannelCheck = function() - return false - end -else - RestrictedChannelCheck = function(data) - return data.message_type == "SAY" or data.message_type == "YELL" or data.message_type == "SMARTRAID" - end +local RestrictedChannelCheck = function(data) + return data.message_type == "SAY" or data.message_type == "YELL" or data.message_type == "SMARTRAID" end --- a sound from each setter diff --git a/WeakAurasOptions/AuthorOptions.lua b/WeakAurasOptions/AuthorOptions.lua index 0619249..ac61d93 100644 --- a/WeakAurasOptions/AuthorOptions.lua +++ b/WeakAurasOptions/AuthorOptions.lua @@ -1253,10 +1253,21 @@ typeControlAdders = { name = WeakAuras.newFeatureString .. name(option, "noMerge", L["Prevent Merging"]), desc = desc(option, "noMerge", L["If checked, then this group will not merge with other group when selecting multiple auras."]), order = order(), - width = WeakAuras.doubleWidth, + width = option.groupType == "simple" and WeakAuras.doubleWidth or WeakAuras.normalWidth, get = get(option, "noMerge"), set = set(data, option, "noMerge"), } + if option.groupType ~="simple" then + args[prefix .. "sortAlphabetically"] = { + type = "toggle", + name = WeakAuras.newFeatureString .. name(option, "sortAlphabetically", L["Sort"]), + desc = desc(option, "sortAlphabetically", L["If checked, then the combo box in the User settings will be sorted."]), + order = order(), + width = WeakAuras.normalWidth, + get = get(option, "sortAlphabetically"), + set = set(data, option, "sortAlphabetically"), + } + end if option.groupType ~="simple" then args[prefix .. "limitType"] = { type = "select", @@ -2121,6 +2132,7 @@ local function addUserModeOption(options, args, data, order, prefix, i) end WeakAuras.ClearAndUpdateOptions(data.id, true) end, + sorting = option.sortAlphabetically and OptionsPrivate.Private.SortOrderForValues(values) or nil } args[prefix .. "resetEntry"] = { type = "execute", @@ -2355,6 +2367,15 @@ local function addUserModeOption(options, args, data, order, prefix, i) return AceGUIWidgetLSMlists[option.mediaType] end end + + userOption.sorting = function() + if option.mediaType == "sound" then + return OptionsPrivate.Private.SortOrderForValues(OptionsPrivate.Private.sound_file_types) + else + return nil + end + end + userOption.set = function(_, value) if option.mediaType == "sound" then PlaySoundFile(value, "Master") diff --git a/WeakAurasOptions/OptionsFrames/Update.lua b/WeakAurasOptions/OptionsFrames/Update.lua index e47fba1..19e78e9 100644 --- a/WeakAurasOptions/OptionsFrames/Update.lua +++ b/WeakAurasOptions/OptionsFrames/Update.lua @@ -991,7 +991,17 @@ local function SetCategories(globalCategories, categories) end end - +local function OnlyMetaDataCategory(categories) + local metaData = false + for category in pairs(categories) do + if category == "metadata" then + metaData = true + else + return false + end + end + return metaData +end local function GetCategories(diff, isRoot) local categories = {} @@ -1001,6 +1011,7 @@ local function GetCategories(diff, isRoot) categories[category] = true end end + return categories end @@ -1042,11 +1053,22 @@ local function BuildDiffsHelper(uid, newUidMap, oldUidMap, matchInfo) oldUidMap:SetDiff(matchedUid, diff, categories) SetCategories(matchInfo.activeCategories, categories) - matchInfo.diffs[uid] = true - if isGroup then - matchInfo.modifiedGroupCount = matchInfo.modifiedGroupCount + 1 + matchInfo.categories[uid] = categories + + if OnlyMetaDataCategory(categories) then + matchInfo.onlyMetaDataModified[uid] = true + if isGroup then + matchInfo.modifiedMetaDataGroupCount = matchInfo.modifiedMetaDataGroupCount + 1 + else + matchInfo.modifiedMetaDataCount = matchInfo.modifiedMetaDataCount + 1 + end else - matchInfo.modifiedCount = matchInfo.modifiedCount + 1 + matchInfo.modified[uid] = true + if isGroup then + matchInfo.modifiedGroupCount = matchInfo.modifiedGroupCount + 1 + else + matchInfo.modifiedCount = matchInfo.modifiedCount + 1 + end end else matchInfo.unmodified[uid] = true @@ -1140,6 +1162,8 @@ end local function hasChanges(matchInfo) return matchInfo.modifiedCount > 0 or matchInfo.modifiedGroupCount > 0 + or matchInfo.modifiedMetaDataCount > 0 + or matchInfo.modifiedMetaDataGroupCount > 0 or matchInfo.addedCount > 0 or matchInfo.addedGroupCount > 0 or matchInfo.deletedCount > 0 @@ -1151,13 +1175,17 @@ local function BuildDiffs(newUidMap, oldUidMap) local matchInfo = { modifiedCount = 0, modifiedGroupCount = 0, + modifiedMetaDataCount = 0, + modifiedMetaDataGroupCount = 0, unmodifiedCount = 0, unmodifiedGroupCount = 0, addedCount = 0, addedGroupCount = 0, deletedCount = 0, deletedGroupCount = 0, - diffs = {}, -- Contains diffs for new uids + modified = {}, -- Contains uids that were modified + onlyMetaDataModified = {}, -- Contains uids that are only metadata modified + categories = {}, -- Contains categories for uids unmodified = {}, -- Contains new uids that had a empty diff added = {}, -- Contains new uids that were added deleted = {}, -- Contains old uids that were removed @@ -1228,7 +1256,21 @@ local function MatchInfo(data, children, target) return matchInfo end -local function AddAuraList(container, uidMap, list, expandText) +local function CategoriesToDisplayText(categories) + local categoriesDisplayTexts = {} + for _, category in ipairs(OptionsPrivate.Private.update_categories) do + if categories[category.name] then + tinsert(categoriesDisplayTexts, category.label) + end + end + if #categoriesDisplayTexts > 0 then + return table.concat(categoriesDisplayTexts, ", ") + else + return nil + end +end + +local function AddAuraList(container, uidMap, list, categories, expandText) local expand = AceGUI:Create("WeakAurasExpand") local collapsed = true local image = collapsed and "Interface\\AddOns\\WeakAuras\\Media\\Textures\\expand" @@ -1247,7 +1289,16 @@ local function AddAuraList(container, uidMap, list, expandText) local sortedNames = {} for uid in pairs(list) do - tinsert(sortedNames, uidMap:GetIdFor(uid)) + if categories[uid] then + local categoriesText = CategoriesToDisplayText(categories[uid]) + if categoriesText then + tinsert(sortedNames, L["%s (%s)"]:format(uidMap:GetIdFor(uid), categoriesText)) + else + tinsert(sortedNames, uidMap:GetIdFor(uid)) + end + else + tinsert(sortedNames, uidMap:GetIdFor(uid)) + end end table.sort(sortedNames) @@ -1277,7 +1328,7 @@ local function AddAuraList(container, uidMap, list, expandText) end local methods = { - Open = function(self, data, children, target, sender, callbackFunc) + Open = function(self, data, children, target, linkedAuras, sender, callbackFunc) if(self.optionsWindow.window == "importexport") then self.optionsWindow.importexport:Close(); elseif(self.optionsWindow.window == "texture") then @@ -1294,6 +1345,7 @@ local methods = { data = data, children = children or {}, target = target, + linkedAuras = linkedAuras, sender = sender } self.userChoices = { @@ -1355,13 +1407,22 @@ local methods = { local matchInfoText = L["This is a modified version of your group: |cff9900FF%s|r"]:format(oldRootId) matchInfoResult:SetText(matchInfoText) if matchInfo.addedCount ~= 0 then - AddAuraList(self, matchInfo.newUidMap, matchInfo.added, L["%d |4aura:auras; added"]:format(matchInfo.addedCount)) + AddAuraList(self, matchInfo.newUidMap, matchInfo.added, {}, + L["%d |4aura:auras; added"]:format(matchInfo.addedCount)) end - if matchInfo.modifiedCount ~= 0 then - AddAuraList(self, matchInfo.oldUidMap, matchInfo.diffs, L["%d |4aura:auras; modified"]:format(matchInfo.modifiedCount)) + local modifiedCount = matchInfo.modifiedCount + matchInfo.modifiedGroupCount + if modifiedCount ~= 0 then + AddAuraList(self, matchInfo.oldUidMap, matchInfo.modified, matchInfo.categories, + L["%d |4aura:auras; modified"]:format(modifiedCount)) + end + local onlyMetaDataModifiedCount = matchInfo.modifiedMetaDataCount + matchInfo.modifiedMetaDataGroupCount + if onlyMetaDataModifiedCount ~= 0 then + AddAuraList(self, matchInfo.oldUidMap, matchInfo.onlyMetaDataModified, {}, + L["%d |4aura:auras; with meta data modified"]:format(onlyMetaDataModifiedCount)) end if matchInfo.deletedCount ~= 0 then - AddAuraList(self, matchInfo.oldUidMap, matchInfo.deleted, L["%d |4aura:auras; deleted"]:format(matchInfo.deletedCount)) + AddAuraList(self, matchInfo.oldUidMap, matchInfo.deleted, {}, + L["%d |4aura:auras; deleted"]:format(matchInfo.deletedCount)) end else matchInfoResult:SetText(L["This is a modified version of your aura, |cff9900FF%s.|r"]:format(oldRootId)) @@ -1444,6 +1505,23 @@ local methods = { self:AddChild(scamCheckText) end + if linkedAuras and next(linkedAuras) then + self:AddChild(AceGUI:Create("WeakAurasSpacer")) + + local linkedAurasText = AceGUI:Create("Label") + linkedAurasText:SetFontObject(GameFontHighlight) + linkedAurasText:SetFullWidth(true) + + local auraIdText = table.concat(self.pendingData.linkedAuras, ", ") + if #self.pendingData.linkedAuras == 1 then + linkedAurasText:SetText(L["This aura is marked as an update to an aura '%s', but cannot be used to update that aura. This usually happens if an aura is moved out of a group."]:format(auraIdText)) + else + linkedAurasText:SetText(L["This aura is marked as an update to auras '%s', but cannot be used to update them. This usually happens if an aura is moved out of a group."]:format(auraIdText)) + end + linkedAurasText:SetColor(1, 0, 0) + self:AddChild(linkedAurasText) + end + -- Let people install auras that are newer than their version of WeakAuras local highestVersion = data.internalVersion or 0 if children then diff --git a/WeakAurasOptions/WeakAurasOptions.lua b/WeakAurasOptions/WeakAurasOptions.lua index aac6bd8..ece4963 100644 --- a/WeakAurasOptions/WeakAurasOptions.lua +++ b/WeakAurasOptions/WeakAurasOptions.lua @@ -647,7 +647,7 @@ local function GetSortedOptionsLists() tinsert(to_sort, id); end end - table.sort(to_sort, function(a, b) return a < b end); + table.sort(to_sort, function(a, b) return a:lower() < b:lower() end) for _, id in ipairs(to_sort) do local data = WeakAuras.GetData(id); for child in OptionsPrivate.Private.TraverseAll(data) do @@ -663,7 +663,7 @@ local function GetSortedOptionsLists() tinsert(to_sort, id); end end - table.sort(to_sort, function(a, b) return a < b end); + table.sort(to_sort, function(a, b) return a:lower() < b:lower() end) for _, id in ipairs(to_sort) do local data = WeakAuras.GetData(id); for child in OptionsPrivate.Private.TraverseAll(data) do @@ -927,8 +927,8 @@ function OptionsPrivate.OpenDebugLog(text) frame.debugLog:Open(text) end -function OptionsPrivate.OpenUpdate(data, children, target, sender, callbackFunc) - return frame.update:Open(data, children, target, sender, callbackFunc) +function OptionsPrivate.OpenUpdate(data, children, target, linkedAuras, sender, callbackFunc) + return frame.update:Open(data, children, target, linkedAuras, sender, callbackFunc) end function OptionsPrivate.ConvertDisplay(data, newType) @@ -1196,7 +1196,7 @@ function OptionsPrivate.SortDisplayButtons(filter, overrideReset, id) wipe(frame.loadedButton.childButtons) if frame.loadedButton:GetExpanded() then - table.sort(topLevelLoadedAuras) + table.sort(topLevelLoadedAuras, function(a, b) return a:lower() < b:lower() end) for _, id in ipairs(topLevelLoadedAuras) do if aurasMatchingFilter[id] then addButton(displayButtons[id], aurasMatchingFilter, visible) @@ -1214,7 +1214,7 @@ function OptionsPrivate.SortDisplayButtons(filter, overrideReset, id) wipe(frame.unloadedButton.childButtons) if frame.unloadedButton:GetExpanded() then - table.sort(topLevelUnloadedAuras) + table.sort(topLevelUnloadedAuras, function(a, b) return a:lower() < b:lower() end) for _, id in ipairs(topLevelUnloadedAuras) do if aurasMatchingFilter[id] then addButton(displayButtons[id], aurasMatchingFilter, visible) diff --git a/WeakAurasOptions/WeakAurasOptions.toc b/WeakAurasOptions/WeakAurasOptions.toc index f88f087..3dd6e91 100644 --- a/WeakAurasOptions/WeakAurasOptions.toc +++ b/WeakAurasOptions/WeakAurasOptions.toc @@ -76,6 +76,7 @@ AceGUI-Widgets\AceGUIWidget-WeakAurasIcon.lua AceGUI-Widgets\AceGUIWidget-WeakAurasNewHeaderButton.lua AceGUI-Widgets\AceGUIWidget-WeakAurasLoadedHeaderButton.lua AceGUI-Widgets\AceGUIWidget-WeakAurasDisplayButton.lua +AceGUI-Widgets\AceGUIWidget-WeakAurasDropDownItemCurrency.lua AceGUI-Widgets\AceGUIWidget-WeakAurasPendingInstallButton.lua AceGUI-Widgets\AceGUIWidget-WeakAurasPendingUpdateButton.lua AceGUI-Widgets\AceGUIWidget-WeakAurasTextureButton.lua