📄 tcc_center.lua
字号:
if IsAddOnLoaded("tCT") then
return
end
local cdover
if GetLocale() == "zhCN" then
cdover = "技能 %s 冷却完成了!"
elseif GetLocale() == "zhTW" then
cdover = "技能 %s 冷卻完成了!"
else
cdover = "%s Cooldown Completed!"
end
local centerData = {}
local text, color, center
local function Center_OnUpdate()
this.finish = this.finish + arg1
local alpha = tCC:get(this.type, "calpha")
if this.finish > tCC:get(this.type, "ctime") / 2 then
alpha = (1 - this.finish / tCC:get(this.type, "ctime")) * 2 * alpha
end
this:SetAlpha(alpha)
if this.finish >= tCC:get(this.type, "ctime") then
this.finish = 0
this:Hide()
end
end
tCC:SetScript("OnUpdate", Center_OnUpdate)
tCC:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
function tCC.UNIT_SPELLCAST_SUCCEEDED(self)
if arg1 ~= "player" then return end
local icon = self:GetIcon(arg2)
if icon then
centerData[icon] = arg2
end
end
function tCC:GetIcon(name)
if ( not name ) then return end
local booktype = {"spell", "pet"}
local i, spell, j, _ = 1
for _, book in pairs(booktype) do
while name do
spell, _ = GetSpellName(i,book)
if ( not spell ) then
i = 1
break
end
if ( string.lower(name) == string.lower(spell)) then
return GetSpellTexture(i, book)
end
i=i+1;
end
end
end
function tCC:CreateCenter()
center = CreateFrame("frame", nil, UIParent)
center:Hide()
center:SetAllPoints(UIParent)
center:SetFrameStrata("HIGH")
center:SetScript("OnUpdate", Center_OnUpdate)
center.icon = center:CreateTexture(nil, "OVERLAY")
center.icon:Show()
center.text = center:CreateFontString(nil, "ARTWORK", "SystemFont")
center.text:SetPoint("TOP", center.icon, "BOTTOM")
self.center = center
return center
end
function tCC:StartCenter(timer)
center = self.center or self:CreateCenter()
text = centerData[timer.icon:GetTexture()]
center.text:SetText("")
if text and self:get("Other", "text") then
color = self:get("Color", "TextColor")
center.text:SetFont(self:get("Other", "font"), self:get("Other", "size"), "OUTLINE")
center.text:SetText(format(cdover, "|cff"..format("%2x%2x%2x",color.r*255,color.g*255,color.b*255)..text.."|r"))
end
if center:IsVisible() and center.start and center.start == timer.start then
if text then
centerData[timer.icon:GetTexture()] = nil
else
return
end
end
center:ClearAllPoints()
if self:get(timer.type, "p") then
center.icon:SetPoint(self:get(timer.type, "p"),
UIParent,
self:get(timer.type, "s"),
self:get(timer.type, "x"),
self:get(timer.type, "y"))
else
center.icon:SetPoint("CENTER",UIParent,"CENTER",0,0)
end
center.icon:SetWidth(self:get(timer.type, "cscale"))
center.icon:SetHeight(self:get(timer.type, "cscale"))
center.icon:SetBlendMode(self:get(timer.type, "cmode") and "ADD" or "BLEND")
center.icon:SetTexture(timer.icon:GetTexture())
center.finish = 0
center.start = timer.start
center.type = timer.type
center:Show()
end
function tCC:CenterSound(timer)
if self:get(timer.type, "sound") and timer.icon and centerData[timer.icon:GetTexture()] then
PlaySoundFile("Interface\\AddOns\\tdCoolDownCount\\sound.wav")
end
if self:get(timer.type, "center") then
self:StartCenter(timer)
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -