PHP код:
local CastBar = CreateFrame("StatusBar", nil, UIParent);
CastBar:SetPoint("CENTER", UIParent, 0, -150);
CastBar:SetSize(160, 25);
CastBar:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar");
CastBar:SetStatusBarColor(1, 165/255, 0);
CastBar:Hide();
CastBar.bg = CastBar:CreateTexture(nil, "BACKGROUND");
CastBar.bg:SetTexture("Interface\\TARGETINGFRAME\\UI-StatusBar");
CastBar.bg:SetAllPoints();
CastBar.bg:SetVertexColor(0, 0, 0, 1);
CastBar.Text = CastBar:CreateFontString(nil, "OVERLAY");
CastBar.Text:SetPoint("TOPLEFT",CastBar,"TOPLEFT", 2, -5);
CastBar.Text:SetPoint("BOTTOMRIGHT",CastBar,"BOTTOMRIGHT", 0, 6);
CastBar.Text:SetFont("Fonts\\FRIZQT__.TTF", 9, "OUTLINE");
CastBar.Text:SetJustifyH("LEFT");
CastBar.Text:SetShadowOffset(1, -1);
CastBar.Text:SetTextColor(1, 1, 1);
CastBar.SpellIcon = CreateFrame("Frame", nil, CastBar);
CastBar.SpellIcon:SetPoint("TOPRIGHT", CastBar, "TOPLEFT", 0, 3);
CastBar.SpellIcon:SetSize(CastBar:GetHeight()+6, CastBar:GetHeight()+6);
CastBar.SpellIcon:SetFrameStrata("HIGH");
CastBar.SpellIcon.Texture = CastBar.SpellIcon:CreateTexture(nil, "ARTWORK");
CastBar.SpellIcon.Texture:SetAllPoints();
local SpellList = {
48447, -- Tranquility;
48378, -- Healing Touch;
}
CastBar:RegisterEvent("UNIT_SPELLCAST_START");
CastBar:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START");
CastBar:SetScript("OnEvent", function(self, event, UnitID, Spell)
if UnitID ~= "party1" then return; end;
local Exit = true;
for index, value in ipairs(SpellList) do
if Spell == GetSpellInfo(value) then Exit = false; end;
end;
if Exit == true then return; end;
local CastingInfo;
if event == "UNIT_SPELLCAST_START" then CastingInfo = UnitCastingInfo;
elseif event == "UNIT_SPELLCAST_CHANNEL_START" then CastingInfo = UnitChannelInfo;
end;
self:Show();
self.Text:SetText(Spell);
self.SpellIcon.Texture:SetTexture(select(4, CastingInfo(UnitID)));
local endTime = select(6, CastingInfo(UnitID)) / 1e3;
local startTime = select(5, CastingInfo(UnitID)) / 1e3;
local Max = endTime - startTime;
self:SetMinMaxValues(0, Max);
self:SetValue(0);
self:SetScript('OnUpdate', function(self)
if not CastingInfo(UnitID) then self:SetScript('OnUpdate', nil); self:Hide() return; end;
self:SetValue(GetTime() - startTime);
end)
end);