Files

63 lines
3.3 KiB
Lua

-- OctoTextSize: addon-local factory; Blizzard CreateFrame is unchanged.
local CreateFrame = OctoTextSize and OctoTextSize.WrapFactory(CreateFrame) or CreateFrame
-- Original circular profession-output controls require circular quality frames.
-- Some same-build Classic atlas-set overrides instead supply a panel sprite.
-- Rebind only exact reviewed overrides after the original output formatter.
local data = GWNativeProfessionBorders;
if not data or data.build ~= 70334 then return; end
WoWHybridUI = WoWHybridUI or {};
local state = WoWHybridUI;
local function Public(value) return not issecretvalue or not issecretvalue(value); end
local function Matches(info, sprite)
return Public(info) and type(info) == 'table' and Public(info.file) and info.file == sprite.file
and Public(info.leftTexCoord) and info.leftTexCoord == sprite.rect[1]
and Public(info.rightTexCoord) and info.rightTexCoord == sprite.rect[2]
and Public(info.topTexCoord) and info.topTexCoord == sprite.rect[3]
and Public(info.bottomTexCoord) and info.bottomTexCoord == sprite.rect[4];
end
-- Classic SetItemButtonQuality gives every coloured quality the square Interface\Common\WhiteIconFrame, which shows
-- as a square behind the circular output icon. The native circular border atlases exist for every quality colour.
local QUALITY_BORDER = {[0]='gray',[1]='white',[2]='green',[3]='blue',[4]='purple',[5]='orange',[6]='artifact',[7]='account',[8]='account'};
local function Circular(button, item, quality)
local border = button.IconBorder; if not border or not border.SetAtlas then return; end
if not Public(quality) or type(quality) ~= 'number' then
quality = item and C_Item and C_Item.GetItemQualityByID and C_Item.GetItemQualityByID(item);
end
local name = Public(quality) and QUALITY_BORDER[quality];
if not name then return; end
border:SetAtlas('auctionhouse-itemicon-border-'..name, false);
border:SetVertexColor(1, 1, 1);
border:Show();
end
local function Output(button, _, _, _, item, quality)
if not button or not button.CircleMask or not C_Texture or not C_Texture.GetAtlasInfo then return; end
Circular(button, item, quality);
for _, region in ipairs({button:GetRegions()}) do
if region.GetAtlas and region.SetTexture and region.SetTexCoord then
local name = region:GetAtlas();
local row = Public(name) and data.atlases[name];
if row then
local current = C_Texture.GetAtlasInfo(name);
for _, override in ipairs(row.overrides) do
if Matches(current, override) then
region:SetTexture(row.base.file);
region:SetTexCoord(unpack(row.base.rect));
break;
end
end
end
end
end
end
local function Install()
if state.professionIconsInstalled then return true; end
if not Professions or type(Professions.SetupOutputIconCommon) ~= 'function' then return false; end
hooksecurefunc(Professions, 'SetupOutputIconCommon', Output);
state.professionIconsInstalled = true;
return true;
end
local events = CreateFrame('Frame');
events:RegisterEvent('ADDON_LOADED');
events:SetScript('OnEvent', function() if Install() then events:UnregisterEvent('ADDON_LOADED'); end end);
Install();