/trunk/Libs
-- luacheck: globals CreateFromMixins ObjectPoolMixin CreateTexturePool CreateFramePool |
local MAJOR_VERSION = "LibCustomGlow-1.0" |
local MINOR_VERSION = 15 |
local MINOR_VERSION = 16 |
if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end |
local lib, oldversion = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION) |
if not lib then return end |
local Masque = LibStub("Masque", true) |
local isRetail = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE |
local textureList = { |
["empty"] = [[Interface\AdventureMap\BrokenIsles\AM_29]], |
["white"] = [[Interface\BUTTONS\WHITE8X8]], |
["shine"] = [[Interface\Artifacts\Artifacts]] |
empty = [[Interface\AdventureMap\BrokenIsles\AM_29]], |
white = [[Interface\BUTTONS\WHITE8X8]], |
shine = [[Interface\ItemSocketingFrame\UI-ItemSockets]] |
} |
local shineCoords = {0.3984375, 0.4453125, 0.40234375, 0.44921875} |
if isRetail then |
textureList.shine = [[Interface\Artifacts\Artifacts]] |
shineCoords = {0.8115234375,0.9169921875,0.8798828125,0.9853515625} |
end |
function lib.RegisterTextures(texture,id) |
textureList[id] = texture |
end |
local TexPoolResetter = function(pool,tex) |
local maskNum = tex:GetNumMaskTextures() |
for i = maskNum,1 do |
local curMask = tex:GetMaskTexture(i) |
if curMask then |
tex:RemoveMaskTexture(curMask) |
end |
for i = maskNum, 1, -1 do |
tex:RemoveMaskTexture(tex:GetMaskTexture(i)) |
end |
tex:Hide() |
tex:ClearAllPoints() |
local function addFrameAndTex(r,color,name,key,N,xOffset,yOffset,texture,texCoord,desaturated,frameLevel) |
key = key or "" |
frameLevel = frameLevel or 8 |
frameLevel = frameLevel or 8 |
if not r[name..key] then |
r[name..key] = GlowFramePool:Acquire() |
r[name..key]:SetParent(r) |
r[name..key].name = name..key |
end |
local f = r[name..key] |
f:SetFrameLevel(r:GetFrameLevel()+frameLevel) |
f:SetFrameLevel(r:GetFrameLevel()+frameLevel) |
f:SetPoint("TOPLEFT",r,"TOPLEFT",-xOffset+0.05,yOffset+0.05) |
f:SetPoint("BOTTOMRIGHT",r,"BOTTOMRIGHT",xOffset,-yOffset+0.05) |
f:Show() |
for i=1,N do |
if not f.textures[i] then |
f.textures[i] = GlowTexPool:Acquire() |
f.textures[i]: SetTexture(texture) |
f.textures[i]: SetTexCoord(texCoord[1],texCoord[2],texCoord[3],texCoord[4]) |
f.textures[i]: SetDesaturated(desaturated) |
f.textures[i]: SetParent(f) |
f.textures[i]: SetDrawLayer("ARTWORK",7) |
f.textures[i]:SetTexture(texture) |
f.textures[i]:SetTexCoord(texCoord[1],texCoord[2],texCoord[3],texCoord[4]) |
f.textures[i]:SetDesaturated(desaturated) |
f.textures[i]:SetParent(f) |
f.textures[i]:SetDrawLayer("ARTWORK",7) |
if not isRetail and name == "_AutoCastGlow" then |
f.textures[i]:SetBlendMode("ADD") |
end |
end |
f.textures[i]:SetVertexColor(color[1],color[2],color[3],color[4]) |
f.textures[i]:Show() |
local function acUpdate(self,elapsed) |
local width,height = self:GetSize() |
if width ~= self.info.width or height ~= self.info.height then |
if width*height == 0 then return end -- Avoid division by zero |
self.info.width = width |
self.info.height = height |
self.info.perimeter = 2*(width+height) |
yOffset = yOffset or 0 |
key = key or "" |
addFrameAndTex(r,color,"_AutoCastGlow",key,N*4,xOffset,yOffset,textureList.shine,{0.8115234375,0.9169921875,0.8798828125,0.9853515625},true, frameLevel) |
addFrameAndTex(r,color,"_AutoCastGlow",key,N*4,xOffset,yOffset,textureList.shine,shineCoords, true, frameLevel) |
local f = r["_AutoCastGlow"..key] |
local sizes = {7,6,5,4} |
for k,size in pairs(sizes) do |
end |
local function configureButtonGlow(f,alpha) |
f.spark = f:CreateTexture(nil, "BACKGROUND", nil, 1) |
f.spark = f:CreateTexture(nil, "BACKGROUND") |
f.spark:SetPoint("CENTER") |
f.spark:SetAlpha(0) |
f.spark:SetTexture([[Interface\SpellActivationOverlay\IconAlert]]) |
f.spark:SetTexCoord(0.00781250, 0.61718750, 0.00390625, 0.26953125) |
-- inner glow |
f.innerGlow = f:CreateTexture(nil, "ARTWORK", nil, 1) |
f.innerGlow = f:CreateTexture(nil, "ARTWORK") |
f.innerGlow:SetPoint("CENTER") |
f.innerGlow:SetAlpha(0) |
f.innerGlow:SetTexture([[Interface\SpellActivationOverlay\IconAlert]]) |
f.innerGlow:SetTexCoord(0.00781250, 0.50781250, 0.27734375, 0.52734375) |
-- inner glow over |
f.innerGlowOver = f:CreateTexture(nil, "ARTWORK", nil, 1) |
f.innerGlowOver = f:CreateTexture(nil, "ARTWORK") |
f.innerGlowOver:SetPoint("TOPLEFT", f.innerGlow, "TOPLEFT") |
f.innerGlowOver:SetPoint("BOTTOMRIGHT", f.innerGlow, "BOTTOMRIGHT") |
f.innerGlowOver:SetAlpha(0) |
f.innerGlowOver:SetTexCoord(0.00781250, 0.50781250, 0.53515625, 0.78515625) |
-- outer glow |
f.outerGlow = f:CreateTexture(nil, "ARTWORK", nil, 1) |
f.outerGlow = f:CreateTexture(nil, "ARTWORK") |
f.outerGlow:SetPoint("CENTER") |
f.outerGlow:SetAlpha(0) |
f.outerGlow:SetTexture([[Interface\SpellActivationOverlay\IconAlert]]) |
f.outerGlow:SetTexCoord(0.00781250, 0.50781250, 0.27734375, 0.52734375) |
-- outer glow over |
f.outerGlowOver = f:CreateTexture(nil, "ARTWORK", nil, 1) |
f.outerGlowOver = f:CreateTexture(nil, "ARTWORK") |
f.outerGlowOver:SetPoint("TOPLEFT", f.outerGlow, "TOPLEFT") |
f.outerGlowOver:SetPoint("BOTTOMRIGHT", f.outerGlow, "BOTTOMRIGHT") |
f.outerGlowOver:SetAlpha(0) |
f.outerGlowOver:SetTexCoord(0.00781250, 0.50781250, 0.53515625, 0.78515625) |
-- ants |
f.ants = f:CreateTexture(nil, "OVERLAY", nil, 1) |
f.ants = f:CreateTexture(nil, "OVERLAY") |
f.ants:SetPoint("CENTER") |
f.ants:SetAlpha(0) |
f.ants:SetTexture([[Interface\SpellActivationOverlay\IconAlertAnts]]) |
if not r then |
return |
end |
frameLevel = frameLevel or 8; |
frameLevel = frameLevel or 8; |
local throttle |
if frequency and frequency > 0 then |
throttle = 0.25/frequency*0.01 |
f:SetPoint("TOPLEFT", r, "TOPLEFT", -width * 0.2, height * 0.2) |
f:SetPoint("BOTTOMRIGHT", r, "BOTTOMRIGHT", width * 0.2, -height * 0.2) |
f.ants:SetSize(width*1.4*0.85, height*1.4*0.85) |
AnimIn_OnFinished(f.animIn) |
if f.animOut:IsPlaying() then |
AnimIn_OnFinished(f.animIn) |
if f.animOut:IsPlaying() then |
f.animOut:Stop() |
f.animIn:Play() |
end |