PHP код:
local Conf = {
Point = {x = 0, y = -150}, -- Позиция ЕнержиБара относително центра;
Width = 150, -- Ширина;
Height = 20, -- Высота;
Font = "Fonts\\FRIZQT__.TTF", -- Шрифт;
FontSize = 12, -- Размер шрифта;
Delay = 0.1, -- Задержка;
}
local PowerBarColor = PowerBarColor;
local select = select;
local UnitPowerType = UnitPowerType;
local UnitClass = UnitClass;
local UnitPower = UnitPower;
local Core = CreateFrame("StatusBar", nil, UIParent);
Core:RegisterEvent("PLAYER_LOGIN");
Core:SetScript("OnEvent", function(self, event, ...) return self[event](self, ...) end);
function Core:CreateEnergyBar()
self:SetPoint("CENTER", UIParent, "CENTER", Conf.Point.x, Conf.Point.y);
self:SetSize(Conf.Width, Conf.Height);
self:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar");
local PB_Color = PowerBarColor[select(2, UnitPowerType("player"))];
self:SetStatusBarColor(PB_Color.r, PB_Color.g, PB_Color.b);
self.bg = self:CreateTexture(nil, "BACKGROUND");
self.bg:SetTexture("Interface\\TARGETINGFRAME\\UI-StatusBar");
self.bg:SetAllPoints();
self.bg:SetVertexColor(0, 0, 0, 1);
self.Text = self:CreateFontString(nil, "OVERLAY");
self.Text:SetPoint("LEFT",self,"LEFT", 2, 0);
self.Text:SetFont(Conf.Font, Conf.FontSize, "OUTLINE");
self.Text:SetShadowOffset(1, -1);
self.Text:SetTextColor(1, 1, 1);
end;
function Core:PLAYER_LOGIN()
if select(2, UnitClass("player")) ~= "ROGUE" then self:UnregisterEvent("PLAYER_LOGIN"); return; end;
self:RegisterEvent("UNIT_MAXENERGY");
self:CreateEnergyBar();
self:SetMinMaxValues(0, UnitPowerMax("player"));
self:SetScript("OnUpdate", self.OnUpdate)
end;
local Update = 0;
function Core:OnUpdate(elapsed)
Update = Update + elapsed;
if Update > Conf.Delay then
self:SetValue(UnitPower("player"));
self.Text:SetText(UnitPower("player"));
Update = 0;
end;
end;
function Core:UNIT_MAXENERGY(UnitID)
if UnitID ~= "player" then return; end;
self:SetMinMaxValues(0, UnitPowerMax("player"));
end;