This was in response to
http://www.wowinterface.com/forums/s...ad.php?t=53787, but it had little to do with it
I've been sorting the visuals alphabetically in
WardrobeSort but
GetAppearanceSources would not include the
name and
quality half of the time
So I first had to cache them all
There is
TRANSMOG_COLLECTION_ITEM_UPDATE but it doesn't have any return values for the respective item, instead it uses WardrobeCollectionFrame.tooltipAppearanceID or something
Is there a better way to go about this?
Lua Code:
local f = CreateFrame("Frame")
local visualAppearance, visualIllusion = {}, {}
local cacheAppearance, cacheIllusion = {}, {}
local completed = {}
local function IsAppearance()
return (WardrobeCollectionFrame.transmogType == LE_TRANSMOG_TYPE_APPEARANCE)
end
-- appearances/transmogs get the name via visualID
-- illusions/enchants get the name via sourceID
local function CheckVisuals()
-- grab all our data first
if not completed[WardrobeCollectionFrame.activeSlot] then
local isApp = IsAppearance()
local cache = isApp and cacheAppearance or cacheIllusion
local idType = isApp and "visualID" or "sourceID"
for k, v in pairs(WardrobeCollectionFrame.filteredVisualsList) do
cache[v[idType]] = true -- queue data to be cached
end
f:SetScript("OnUpdate", f.GetVisuals)
else -- go ahead and sort
f:SortVisuals()
end
end
-- takes around 30 onupdates
function f:GetVisuals()
local isApp = IsAppearance()
if isApp then
-- need to use WardrobeCollectionFrame_GetSortedAppearanceSources
-- otherwise cant get the used header name consistently
for k in pairs(cacheAppearance) do
local t = WardrobeCollectionFrame_GetSortedAppearanceSources(k)
if t[1].name then
visualAppearance[k] = t[1].name
cacheAppearance[k] = nil -- remove
end
end
else
for k in pairs(cacheIllusion) do
local _, name = C_TransmogCollection.GetIllusionSourceInfo(k)
visualIllusion[k] = name
cacheIllusion[k] = nil
end
end
-- got all visuals for the wardrobe slot
if not next(isApp and cacheAppearance or cacheIllusion) then
completed[WardrobeCollectionFrame.activeSlot] = true -- remember
self:SetScript("OnUpdate", nil)
self:SortVisuals()
end
end
function f:SortVisuals() -- finally we can sort
local isApp = IsAppearance()
local visual = isApp and visualAppearance or visualIllusion
local idType = isApp and "visualID" or "sourceID"
sort(WardrobeCollectionFrame.filteredVisualsList, function(source1, source2)
if source1.isCollected ~= source2.isCollected then
return source1.isCollected
end
if source1.isUsable ~= source2.isUsable then
return source1.isUsable
end
if source1.isFavorite ~= source2.isFavorite then
return source1.isFavorite
end
if source1.isHideVisual ~= source2.isHideVisual then
return source1.isHideVisual
end
local name1 = visual[source1[idType]]
local name2 = visual[source2[idType]]
if name1 ~= name2 then
return name1 < name2 -- alphabetic
end
if source1.uiOrder and source2.uiOrder then
return source1.uiOrder > source2.uiOrder
end
return source1.sourceID > source2.sourceID
end)
WardrobeCollectionFrame_Update() -- update
end
hooksecurefunc("WardrobeCollectionFrame_SortVisuals", CheckVisuals)