diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 784b1fc..9e3b572 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -1305,8 +1305,8 @@ Private.event_prototypes = { display = L["Npc ID"], type = "string", store = true, - conditionType = "string", - test = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '') == %q", + conditionType = "init", + init = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '')", }, { name = "attackable", @@ -1587,8 +1587,8 @@ Private.event_prototypes = { display = L["Npc ID"], type = "string", store = true, - conditionType = "string", - test = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '') == %q", + conditionType = "init", + init = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '')", }, { name = "class", @@ -1848,8 +1848,8 @@ Private.event_prototypes = { display = L["Npc ID"], type = "string", store = true, - conditionType = "string", - test = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '') == %q", + conditionType = "init", + init = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '')", }, { name = "class", @@ -1976,7 +1976,7 @@ Private.event_prototypes = { name = "sourceNpcId", display = L["Source NPC Id"], type = "string", - test = "tostring(tonumber(string.sub(sourceGUID or '', 8, 12), 16) or '') == %q", + init = "tostring(tonumber(string.sub(sourceGUID or '', 8, 12), 16) or '')", enable = function(trigger) return not (trigger.subeventPrefix == "ENVIRONMENTAL") end, @@ -2054,7 +2054,7 @@ Private.event_prototypes = { name = "destNpcId", display = L["Destination NPC Id"], type = "string", - test = "tostring(tonumber(string.sub(destGUID or '', 8, 12), 16) or '') == %q", + init = "tostring(tonumber(string.sub(destGUID or '', 8, 12), 16) or '')", enable = function(trigger) return not (trigger.subeventPrefix == "SPELL" and trigger.subeventSuffix == "_CAST_START"); end, @@ -5335,10 +5335,10 @@ Private.event_prototypes = { { name = "npcId", display = L["Npc ID"], - type = "string", + type = "init", store = true, - conditionType = "string", - test = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '') == %q", + conditionType = "init", + init = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '')", enable = function(trigger) return not trigger.use_inverse end @@ -5594,6 +5594,22 @@ Private.event_prototypes = { store = true, conditionType = "number" }, + { + name = "attackpower", + display = L["Attack Power"], + type = "number", + init = "select(1, UnitAttackPower('player')) + select(2, UnitAttackPower('player'))", + store = true, + conditionType = "number" + }, + { + name = "rangedattackpower", + display = L["Ranged Attack Power"], + type = "number", + init = "select(1, UnitRangedAttackPower('player')) + select(2, UnitRangedAttackPower('player'))", + store = true, + conditionType = "number" + }, { name = "meleecriticalrating", display = L["Melee Critical Rating"], @@ -5620,7 +5636,7 @@ Private.event_prototypes = { }, { name = "meleecriticalpercent", - display = L["Mele Critical (%)"], + display = L["Melee Critical (%)"], type = "number", init = "GetCritChance()", store = true, @@ -5665,6 +5681,94 @@ Private.event_prototypes = { init = "GetCombatRating(CR_HASTE_SPELL)", store = true, conditionType = "number" + }, + { + name = "meleehitrating", + display = L["Melee Hit Rating"], + type = "number", + init = "GetCombatRating(CR_HIT_MELEE)", + store = true, + conditionType = "number" + }, + { + name = "meleehitpercent", + display = L["Melee Hit Percent (%)"], + type = "number", + init = "GetCombatRatingBonus(CR_HIT_MELEE)", + store = true, + conditionType = "number" + }, + { + name = "rangedhitrating", + display = L["Ranged Hit Rating"], + type = "number", + init = "GetCombatRating(CR_HIT_RANGED)", + store = true, + conditionType = "number" + }, + { + name = "rangedhitpercent", + display = L["Ranged Hit Percent (%)"], + type = "number", + init = "GetCombatRatingBonus(CR_HIT_RANGED)", + store = true, + conditionType = "number" + }, + { + name = "spellhitrating", + display = L["Spell Hit Rating"], + type = "number", + init = "GetCombatRating(CR_HIT_SPELL)", + store = true, + conditionType = "number" + }, + { + name = "spellhitpercent", + display = L["Spell Hit Percent (%)"], + type = "number", + init = "GetCombatRatingBonus(CR_HIT_SPELL)", + store = true, + conditionType = "number" + }, + { + name = "expertiserating", + display = L["Expertise Rating"], + type = "number", + init = "GetCombatRating(CR_EXPERTISE)", + store = true, + conditionType = "number" + }, + { + name = "expertisebonus", + display = L["Expertise Bonus"], + type = "number", + init = "GetCombatRatingBonus(CR_EXPERTISE)", + store = true, + conditionType = "number" + }, + { + name = "spellpenrating", + display = L["Spell Penetration Rating"], + type = "number", + init = "GetSpellPenetration()", + store = true, + conditionType = "number" + }, + { + name = "armorpenrating", + display = L["Armor Penetration Rating"], + type = "number", + init = "GetCombatRating(CR_ARMOR_PENETRATION)", + store = true, + conditionType = "number" + }, + { + name = "armorpenpercent", + display = L["Armor Penetration Percent (%)"], + type = "number", + init = "GetCombatRatingBonus(CR_ARMOR_PENETRATION)", + store = true, + conditionType = "number" }, { name = "resistancefire", diff --git a/WeakAurasOptions/OptionsFrames/IconPicker.lua b/WeakAurasOptions/OptionsFrames/IconPicker.lua index e428b09..720e823 100644 --- a/WeakAurasOptions/OptionsFrames/IconPicker.lua +++ b/WeakAurasOptions/OptionsFrames/IconPicker.lua @@ -31,69 +31,66 @@ local function ConstructIconPicker(frame) group:AddChild(scroll); local function iconPickerFill(subname, doSort) - scroll:ReleaseChildren(); + scroll:ReleaseChildren(); + + local usedIcons = {}; + local AddButton = function(name, icon) + local button = AceGUI:Create("WeakAurasIconButton"); + button:SetName(name); + button:SetTexture(icon); + button:SetClick(function() + group:Pick(icon); + end); + scroll:AddChild(button); + + usedIcons[icon] = true; + end + + local num = 0; + if subname and subname ~= "" then + subname = subname:lower(); - local distances = {}; - local names = {}; + for name, icons in pairs(spellCache.Get()) do + local nameMatches = name:lower():find(subname, 1, true); - -- 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) + + local allIcons = {}; + if icons.spells then + for spellId, icon in pairs(icons.spells) do + table.insert(allIcons, { spellId = spellId, icon = icon }); + end + end + if icons.achievements then + for _, icon in pairs(icons.achievements) do + table.insert(allIcons, { spellId = nil, icon = icon }); + end end - end - if subname then - subname = subname:lower(); - end + for _, data in ipairs(allIcons) do + local icon = data.icon; + local spellId = data.spellId; - local usedIcons = {}; - local AddButton = function(name, icon) - local button = AceGUI:Create("WeakAurasIconButton"); - button:SetName(name); - button:SetTexture(icon); - button:SetClick(function() - group:Pick(icon); - end); - scroll:AddChild(button); - - usedIcons[icon] = true; - end + local iconMatches = icon:lower():find(subname, 1, true); + + if (nameMatches or iconMatches) and not usedIcons[icon] then + local displayName = iconMatches and icon or name; + AddButton(displayName, icon); + num = num + 1; - local num = 0; - if(subname and subname ~= "") then - for name, icons in pairs(spellCache.Get()) do - if(name:lower():find(subname, 1, true)) then - if icons.spells then - for spellId, icon in pairs(icons.spells) do - if (not usedIcons[icon]) then - AddButton(name, icon) - num = num + 1; - if(num >= 500) then - break; - end - end - end - elseif icons.achievements then - for _, icon in pairs(icons.achievements) do - if (not usedIcons[icon]) then - AddButton(name, icon) - num = num + 1; - if(num >= 500) then - break; - end - end - end + if num >= 500 then + break; end end + end - if(num >= 500) then - break; - end + if num >= 500 then + break; end end end +end + + local input = CreateFrame("EDITBOX", "WeakAurasIconFilterInput", group.frame, "InputBoxTemplate"); input:SetScript("OnTextChanged", function(...) iconPickerFill(input:GetText(), false); end);