diff --git a/WeakAuras/LibGroupTalentsWrapper.lua b/WeakAuras/LibGroupTalentsWrapper.lua index 17c7a92..3a77f8f 100644 --- a/WeakAuras/LibGroupTalentsWrapper.lua +++ b/WeakAuras/LibGroupTalentsWrapper.lua @@ -87,7 +87,6 @@ if LibGroupTalents then -- Notify subscribers for _, f in ipairs(subscribers) do - print(f) f(nameToUnitMap[unitName]) end end diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 2492244..7d67aec 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -1576,9 +1576,6 @@ Private.event_prototypes = { values = "spec_types_all", store = true, conditionType = "select", - enable = function(trigger) - return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party" - end, desc = L["Requires syncing the specialization via LibSpecialization."], }, { diff --git a/WeakAurasOptions/Cache.lua b/WeakAurasOptions/Cache.lua index 8bd4f9a..e6d1fe8 100644 --- a/WeakAurasOptions/Cache.lua +++ b/WeakAurasOptions/Cache.lua @@ -27,6 +27,26 @@ function spellCache.Build() return end + local holes + --[[ + if WeakAuras.IsClassicEra() then + holes = {} + holes[63707] = 81743 + holes[81748] = 219002 + holes[219004] = 285223 + holes[285224] = 301088 + holes[301101] = 324269 + holes[474742] = 1213143 + elseif WeakAuras.IsCataClassic() then + holes = {} + holes[121820] = 158262 + holes[158263] = 186402 + holes[186403] = 219002 + holes[219004] = 243805 + holes[243806] = 261127 + holes[262591] = 281624 + holes[301101] = 324269 + end]] wipe(cache) local co = coroutine.create(function() metaData.rebuilding = true @@ -39,15 +59,21 @@ function spellCache.Build() if(icon == 136243) then -- 136243 is the a gear icon, we can ignore those spells misses = 0; - elseif name and name ~= "" then + elseif name and name ~= "" and icon then cache[name] = cache[name] or {} - cache[name].spells = cache[name].spells or {} - cache[name].spells[id] = icon + + if not cache[name].spells or cache[name].spells == "" then + cache[name].spells = id .. "=" .. icon + else + cache[name].spells = cache[name].spells .. "," .. id .. "=" .. icon + end misses = 0 + if holes and holes[id] then + id = holes[id] + end else misses = misses + 1 end - coroutine.yield(0.01, "spells") end @@ -57,30 +83,48 @@ function spellCache.Build() local id,name,_,_,_,_,_,_,_,iconID = GetAchievementInfo(category, i) if name and iconID then cache[name] = cache[name] or {} - cache[name].achievements = cache[name].achievements or {} - cache[name].achievements[id] = iconID + if not cache[name].achievements or cache[name].achievements == "" then + cache[name].achievements = id .. "=" .. iconID + else + cache[name].achievements = cache[name].achievements .. "," .. id .. "=" .. iconID + end end coroutine.yield(0.1, "achievements") end coroutine.yield(0.1, "categories") end - -- Updates the icon cache with whatever icons WeakAuras core has actually used. - -- This helps keep name<->icon matches relevant. - for name, icons in pairs(WeakAurasSaved.dynamicIconCache) do - if WeakAurasSaved.dynamicIconCache[name] then - for spellId, icon in pairs(WeakAurasSaved.dynamicIconCache[name]) do - spellCache.AddIcon(name, spellId, icon) - end - end - end - metaData.needsRebuild = false metaData.rebuilding = false end) OptionsPrivate.Private.Threads:Add("spellCache", co, 'background') end +--[[ function to help find big holes in spellIds to help speedup Build() + +local id = 0 +local misses = 0 +local lastId +print("####") +while misses < 4000000 do + id = id + 1 + local name = GetSpellInfo(id) + local icon = GetSpellTexture(id) + if icon == 136243 then -- 136243 is the a gear icon, we can ignore those spells + misses = 0 + elseif name and name ~= "" and icon then + if misses > 10000 then + print(("holes[%s] = %s"):format(lastId, id - 1)) + end + lastId = id + misses = 0 + else + misses = misses + 1 + end +end +print("lastId", lastId) +]] + function spellCache.GetIcon(name) if (name == nil) then return nil; @@ -94,9 +138,11 @@ function spellCache.GetIcon(name) local bestMatch = nil if (icons) then if (icons.spells) then - for spellId, icon in pairs(icons.spells) do - if not bestMatch or (type(spellId) == "number" and spellId ~= 0 and IsSpellKnown(spellId)) then - bestMatch = spellId + for spell, icon in icons.spells:gmatch("(%d+)=(%d+)") do + local spellId = tonumber(spell) + + if not bestMatch or (spellId and spellId ~= 0 and IsSpellKnown(spellId)) then + bestMatch = tonumber(icon) end end end @@ -104,8 +150,8 @@ function spellCache.GetIcon(name) OptionsPrivate.Private.Threads:SetPriority('spellCache', 'normal') end - bestIcon[name] = bestMatch and icons.spells[bestMatch]; - return bestIcon[name]; + bestIcon[name] = bestMatch + return bestIcon[name] else error("spellCache has not been loaded. Call WeakAuras.spellCache.Load(...) first.") end @@ -113,23 +159,33 @@ end function spellCache.GetSpellsMatching(name) if cache[name] then - return cache[name].spells + if cache[name].spells then + local result = {} + for spell, icon in cache[name].spells:gmatch("(%d+)=(%d+)") do + local spellId = tonumber(spell) + local iconId = tonumber(icon) + result[spellId] = icon + end + return result + end + elseif metaData.rebuilding then + OptionsPrivate.Private.Threads:SetPriority('spellCache', 'normal') end end function spellCache.AddIcon(name, id, icon) - if cache then - if name then - cache[name] = cache[name] or {} - cache[name].spells = cache[name].spells or {} - if id and icon then - cache[name].spells[id] = icon - end - end - elseif metaData.rebuilding then - OptionsPrivate.Private.Threads:SetPriority('spellCache', 'normal') - else + if not cache then error("spellCache has not been loaded. Call WeakAuras.spellCache.Load(...) first.") + return + end + + if name and id and icon then + cache[name] = cache[name] or {} + if not cache[name].spells or cache[name].spells == "" then + cache[name].spells = id .. "=" .. icon + else + cache[name].spells = cache[name].spells .. "," .. id .. "=" .. icon + end end end @@ -154,11 +210,14 @@ function spellCache.Load(data) num = num + 1; end - if(num < 39000 or metaData.locale ~= locale or metaData.build ~= build or metaData.version ~= version or not metaData.spellCacheAchivements) then + if(num < 39000 or metaData.locale ~= locale or metaData.build ~= build + or metaData.version ~= version or not metaData.spellCacheStrings) + then metaData.build = build; metaData.locale = locale; metaData.version = version; - metaData.spellCacheAchivements = true + metaData.spellCacheAchievements = true + metaData.spellCacheStrings = true metaData.needsRebuild = true wipe(cache) end diff --git a/WeakAurasOptions/OptionsFrames/IconPicker.lua b/WeakAurasOptions/OptionsFrames/IconPicker.lua index a56a0fb..23aeed1 100644 --- a/WeakAurasOptions/OptionsFrames/IconPicker.lua +++ b/WeakAurasOptions/OptionsFrames/IconPicker.lua @@ -31,6 +31,7 @@ local function ConstructIconPicker(frame) local function iconPickerFill(subname, doSort) scroll:ReleaseChildren(); + local usedIcons = {}; local AddButton = function(name, icon) local button = AceGUI:Create("WeakAurasIconButton"); @@ -55,21 +56,20 @@ local function ConstructIconPicker(frame) 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 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) + for spell, icon in icons.spells:gmatch("(%d+)=([%w_\\-]+),?") do + local iconId = icon + if (not usedIcons[iconId]) then + AddButton(name, iconId) num = num + 1; if(num >= 500) then break; @@ -77,9 +77,10 @@ local function ConstructIconPicker(frame) end end elseif icons.achievements then - for _, icon in pairs(icons.achievements) do - if (not usedIcons[icon]) then - AddButton(name, icon) + for spell, icon in icons.achievements:gmatch("(%d+)=([%w_\\-]+),?") do + local iconId = icon + if (not usedIcons[iconId]) then + AddButton(name, iconId) num = num + 1; if(num >= 500) then break;