PHP код:
local FONT = [=[Fonts\FRIZQT__.TTF]=]
local TEXTURE = [=[Interface\AddOns\Headline\minimalist]=]
local OVERLAY = [=[Interface\TargetingFrame\UI-TargetingFrame-Flash]=]
local combat = false
local numChildren = -1
local frames = {}
local GetTotemInfo
do
local tbl = {"", " II", " III", " IV", " V", " VI", " VII", " VIII", " IX", " X"}
GetTotemInfo = function(id)
local name, rank, texture = GetSpellInfo(id)
rank = tbl[tonumber(string.match(rank, ("%d+")))]
if rank ~= nil then
return format("%s%s", name, rank), texture
else
return name, texture
end
end
end
-- список сформирован скриптой , может выебнуться
local totemList = {
--Air Totems
8177, -- Grounding Totem
10595, -- Nature Resistance Totem I
10600, -- Nature Resistance Totem II
10601, -- Nature Resistance Totem III
25574, -- Nature Resistance Totem IV
58746, -- Nature Resistance Totem V
58749, -- Nature Resistance Totem VI
6495, -- Sentry Totem
8512, -- Windfury Totem
3738, -- Wrath of Air Totem
--Earth Totems
2062, -- Earth Elemental Totem
2484, -- Earthbind Totem
5730, -- Stoneclaw Totem I
6390, -- Stoneclaw Totem II
6391, -- Stoneclaw Totem III
6392, -- Stoneclaw Totem IV
10427, -- Stoneclaw Totem V
10428, -- Stoneclaw Totem VI
25525, -- Stoneclaw Totem VII
58580, -- Stoneclaw Totem VIII
58581, -- Stoneclaw Totem IX
58582, -- Stoneclaw Totem X
8071, -- Stoneskin Totem I -- Faction Champs
8154, -- Stoneskin Totem II
8155, -- Stoneskin Totem III
10406, -- Stoneskin Totem IV
10407, -- Stoneskin Totem V
10408, -- Stoneskin Totem VI
25508, -- Stoneskin Totem VII
25509, -- Stoneskin Totem VIII
58751, -- Stoneskin Totem IX
58753, -- Stoneskin Totem X
8075, -- Strength of Earth Totem I -- Faction Champs
8160, -- Strength of Earth Totem II
8161, -- Strength of Earth Totem III
10442, -- Strength of Earth Totem IV
25361, -- Strength of Earth Totem V
25528, -- Strength of Earth Totem VI
57622, -- Strength of Earth Totem VII
58643, -- Strength of Earth Totem VIII
8143, -- Tremor Totem
--Fire Totems
2894, -- Fire Elemental Totem
8227, -- Flametongue Totem I -- Faction Champs
8249, -- Flametongue Totem II
10526, -- Flametongue Totem III
16387, -- Flametongue Totem IV
25557, -- Flametongue Totem V
58649, -- Flametongue Totem VI
58652, -- Flametongue Totem VII
58656, -- Flametongue Totem VIII
8181, -- Frost Resistance Totem I
10478, -- Frost Resistance Totem II
10479, -- Frost Resistance Totem III
25560, -- Frost Resistance Totem IV
58741, -- Frost Resistance Totem V
58745, -- Frost Resistance Totem VI
8190, -- Magma Totem I
10585, -- Magma Totem II
10586, -- Magma Totem III
10587, -- Magma Totem IV
25552, -- Magma Totem V
58731, -- Magma Totem VI
58734, -- Magma Totem VII
3599, -- Searing Totem I -- Faction Champs
6363, -- Searing Totem II
6364, -- Searing Totem III
6365, -- Searing Totem IV
10437, -- Searing Totem V
10438, -- Searing Totem VI
25533, -- Searing Totem VII
58699, -- Searing Totem VIII
58703, -- Searing Totem IX
58704, -- Searing Totem X
30706, -- Totem of Wrath I
57720, -- Totem of Wrath II
57721, -- Totem of Wrath III
57722, -- Totem of Wrath IV
--Water Totems
8170, -- Cleansing Totem
8184, -- Fire Resistance Totem I
10537, -- Fire Resistance Totem II
10538, -- Fire Resistance Totem III
25563, -- Fire Resistance Totem IV
58737, -- Fire Resistance Totem V
58739, -- Fire Resistance Totem VI
5394, -- Healing Stream Totem I -- Faction Champs
6375, -- Healing Stream Totem II
6377, -- Healing Stream Totem III
10462, -- Healing Stream Totem IV
10463, -- Healing Stream Totem V
25567, -- Healing Stream Totem VI
58755, -- Healing Stream Totem VII
58756, -- Healing Stream Totem VIII
58757, -- Healing Stream Totem IX
5675, -- Mana Spring Totem I
10495, -- Mana Spring Totem II
10496, -- Mana Spring Totem III
10497, -- Mana Spring Totem IV
25570, -- Mana Spring Totem V
58771, -- Mana Spring Totem VI
58773, -- Mana Spring Totem VII
58774, -- Mana Spring Totem VIII
16190 -- Mana Tide Totem
}
do -- конвертируем помойку из айди в имя = текстура
local name, texture
for i = 1, #totemList do
name, texture = GetTotemInfo(totemList[i])
totemList[name] = texture
totemList[i] = nil -- мусор в виде айди более не нужен
end
end
local function QueueObject(parent, object)
parent.queue = parent.queue or {}
parent.queue[object] = true
end
local function HideObjects(parent)
for object in pairs(parent.queue) do
if(object:GetObjectType() == 'Texture') then
object:SetTexture(nil)
else
object:Hide()
end
end
end
local function UpdateObjects(frame)
frame = frame:GetParent()
local r, g, b = frame.hp:GetStatusBarColor()
frame.hostile = g + b == 0
frame.hp:SetHeight(HeadlineGlobalSettings.height)
frame.hp:SetWidth(HeadlineGlobalSettings.width)
frame.hp:ClearAllPoints()
frame.hp:SetPoint('CENTER', frame)
local curName = frame.oldname:GetText()
if(HeadlineGlobalSettings.level) then
local r, g, b = frame.level:GetTextColor()
if(frame.bossicon:IsShown()) then
frame.name:SetText('|cffff0000??|r ' .. curName)
else
frame.name:SetText(format('|cff%02x%02x%02x', r*255, g*255, b*255) .. (frame.elite:IsShown() and '+' or '') .. tonumber(frame.level:GetText()) .. '|r ' .. curName)
end
else
frame.name:SetText(curName)
end
if totemList[curName] then
frame.totem:SetTexture(totemList[curName])
frame.totem:Show()
else
frame.totem:Hide()
end
HideObjects(frame)
end
local function UpdateCastbar(frame)
frame:SetHeight(HeadlineGlobalSettings.height)
frame:SetWidth(HeadlineGlobalSettings.width)
frame:ClearAllPoints()
frame:SetPoint('TOP', frame:GetParent().hp, 'BOTTOM', 0, -5)
frame.icon:SetHeight(0.01)
frame.icon:SetWidth(0.01)
if(not frame.shield:IsShown()) then
frame:SetStatusBarColor(1, 0.35, 0.2)
end
end
local function HealthBar_OnValueChanged(self,value)
self.hpVal:SetText((value > 1e6 and ("%.1f"):format(value/1e6).."m") or (value > 1e3 and ("%.1f"):format(value/1e3).."k") or value)
end
local function HealthBar_OnShow(self)
HealthBar_OnValueChanged(self,self:GetValue())
UpdateObjects(self)
end
local function SkinObjects(frame)
local hp, cb = frame:GetChildren()
local threat, hpborder, cbshield, cbborder, cbicon, overlay, oldname, level, bossicon, raidicon, elite = frame:GetRegions()
local offset = UIParent:GetScale() / hp:GetEffectiveScale()
local hpbg = hp:CreateTexture(nil, 'BACKGROUND')
hpbg:SetPoint('BOTTOMRIGHT', offset, -offset)
hpbg:SetPoint('TOPLEFT', -offset, offset)
hpbg:SetTexture(0, 0, 0)
frame.bg = hpbg
local hpbg2 = hp:CreateTexture(nil, 'BORDER')
hpbg2:SetAllPoints(hp)
hpbg2:SetTexture(1/3, 1/3, 1/3)
hp:HookScript('OnShow', HealthBar_OnShow)
hp:HookScript('OnValueChanged', HealthBar_OnValueChanged)
hp:HookScript('OnSizeChanged', UpdateObjects)
frame.totem = frame:CreateTexture(nil,"BORDER")
frame.totem:SetSize(30,30)
frame.totem:SetPoint("BOTTOM",frame,"TOP")
frame.totem:Hide()
hp.hpVal = hp:CreateFontString(nil,"ARTWORK")
hp.hpVal:SetFont([[Fonts\FRIZQT__.ttf]],9)
hp.hpVal:SetShadowOffset(1,-1)
hp.hpVal:SetShadowColor(0.2,0.2,0.2)
hp.hpVal:SetPoint("CENTER")
hp:SetStatusBarTexture(TEXTURE)
frame.hp = hp
local offset = UIParent:GetScale() / cb:GetEffectiveScale()
local cbbg = cb:CreateTexture(nil, 'BACKGROUND')
cbbg:SetPoint('BOTTOMRIGHT', offset, -offset)
cbbg:SetPoint('TOPLEFT', -offset, offset)
cbbg:SetTexture(0, 0, 0)
local cbbg2 = cb:CreateTexture(nil, 'BORDER')
cbbg2:SetAllPoints(cb)
cbbg2:SetTexture(1/3, 1/3, 1/3)
cb.icon = cbicon
cb.shield = cbshield
cb:HookScript('OnShow', UpdateCastbar)
cb:HookScript('OnSizeChanged', UpdateCastbar)
cb:SetStatusBarTexture(TEXTURE)
frame.cb = cb
local name = hp:CreateFontString(nil, 'OVERLAY')
name:SetPoint('BOTTOMLEFT', hp, 'TOPLEFT', 0, 2)
name:SetPoint('BOTTOMRIGHT', hp, 'TOPRIGHT', 0, 2)
name:SetFont(FONT, HeadlineGlobalSettings.fsize, 'OUTLINE')
frame.oldname = oldname
frame.name = name
raidicon:ClearAllPoints()
raidicon:SetPoint('CENTER', hp, 'CENTER', 0, 5)
raidicon:SetSize(20, 20)
if(HeadlineGlobalSettings.level) then
frame.bossicon = bossicon
frame.elite = elite
frame.level = level
end
QueueObject(frame, threat)
QueueObject(frame, hpborder)
QueueObject(frame, cbshield)
QueueObject(frame, cbborder)
QueueObject(frame, overlay)
QueueObject(frame, oldname)
QueueObject(frame, level)
QueueObject(frame, bossicon)
QueueObject(frame, elite)
HealthBar_OnShow(hp)
UpdateCastbar(cb)
frames[frame] = true
end
local select = select
local function HookFrames(...)
for index = 1, select('#', ...) do
local frame = select(index, ...)
local region = frame:GetRegions()
if(not frames[frame] and not frame:GetName() and region and region:GetObjectType() == 'Texture' and region:GetTexture() == OVERLAY) then
SkinObjects(frame)
frame.region = region
end
end
end
local f = CreateFrame'Frame'
f:RegisterEvent('ADDON_LOADED')
f:RegisterEvent('PLAYER_REGEN_ENABLED')
f:RegisterEvent('PLAYER_REGEN_DISABLED')
f:SetScript('OnUpdate', function(self, elapsed)
if(WorldFrame:GetNumChildren() ~= numChildren) then
numChildren = WorldFrame:GetNumChildren()
HookFrames(WorldFrame:GetChildren())
end
end)
f:SetScript('OnEvent', function(self, e, name)
if(e == 'PLAYER_REGEN_DISABLED') then
combat = true
elseif(e == 'PLAYER_REGEN_ENABLED') then
combat = false
elseif(name == 'Headline' and e == 'ADDON_LOADED') then
if not HeadlineGlobalSettings then HeadlineGlobalSettings = { width = 110, height = 5, fsize = 9, level = true} end
SetCVar('ShowClassColorInNameplate', 1)
--SetCVar('bloattest', 1)
--SetCVar('spreadnameplates', 0)
--SetCVar('bloatnameplates', 0)
--SetCVar('bloatthreat', 1)
end
end)
SLASH_HEADLINE1 = '/headline';
function SlashCmdList.HEADLINE(args)
local arg = string.split(' ', args):lower() or args:lower()
if(arg == 'width') then
arg = tonumber(select(2, string.split(' ', args)))
if(arg and arg > 49 and arg < 301) then
HeadlineGlobalSettings.width = arg
ReloadUI()
end
elseif(arg == 'height') then
arg = tonumber(select(2, string.split(' ', args)))
if(arg and arg > 1 and arg < 51) then
HeadlineGlobalSettings.height = arg
ReloadUI()
end
elseif(arg == 'fontsize') then
arg = tonumber(select(2, string.split(' ', args)))
if(arg and arg > 4 and arg < 31) then
HeadlineGlobalSettings.fsize = arg
ReloadUI()
end
elseif(arg == 'level') then
HeadlineGlobalSettings.level = not HeadlineGlobalSettings.level
ReloadUI()
else
print('Headline')
print(' - |cFF33FF99width <num>|r: current width is '..HeadlineGlobalSettings.width)
print(' - |cFF33FF99height <num>|r: current height is '..HeadlineGlobalSettings.height)
print(' - |cFF33FF99fontsize <num>|r: current font size is '..HeadlineGlobalSettings.fsize)
print(' - |cFF33FF99level|r: toggles the level display')
end
end