Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.50 KB | None | 0 0
  1. local FONT = [=[Interface\Addons\SharedMedia\fonts\HOOG0557.TTF]=]
  2. local TEXTURE = [=[Interface\AddOns\SharedMedia\statusbar\Tap2]=]
  3. local OVERLAY = [=[Interface\TargetingFrame\UI-TargetingFrame-Flash]=]
  4.  
  5. local combat = false
  6.  
  7. local numChildren = -1
  8. local frames = {}
  9.  
  10. local function QueueObject(parent, object)
  11.     parent.queue = parent.queue or {}
  12.     parent.queue[object] = true
  13. end
  14.  
  15. local function HideObjects(parent)
  16.     for object in pairs(parent.queue) do
  17.         if(object:GetObjectType() == 'Texture') then
  18.             object:SetTexture(nil)
  19.         else
  20.             object:Hide()
  21.         end
  22.     end
  23. end
  24.  
  25. local function UpdatePlates(frame)
  26.     if(HeadlineGlobalSettings.target) then
  27.         if(UnitName('target') and frame:GetAlpha() == 1) then
  28.             frame.bg:SetTexture(0, 0, 0)
  29.         else
  30.             frame.bg:SetTexture(0, 0, 0)
  31.         end
  32.     end
  33.     if(frame.hostile) then
  34.         if(combat) then
  35.             if(frame.region:IsShown()) then
  36.                 local r, g, b = frame.region:GetVertexColor()
  37.                 if(g + b == 0) then
  38.                     frame.hp:SetStatusBarColor(1, 0, 0)
  39.                 else
  40.                     frame.hp:SetStatusBarColor(1, 1, 0.3)
  41.                 end
  42.             else
  43.                 frame.hp:SetStatusBarColor(0.3, 1, 0.3)
  44.             end
  45.         else
  46.             frame.hp:SetStatusBarColor(1, 0, 0)
  47.         end
  48.     end
  49. end
  50.  
  51. local function UpdateObjects(frame)
  52.     frame = frame:GetParent()
  53.  
  54.     local r, g, b = frame.hp:GetStatusBarColor()
  55.     frame.hostile = g + b == 0
  56.  
  57.     frame.hp:SetHeight(HeadlineGlobalSettings.height)
  58.     frame.hp:SetWidth(HeadlineGlobalSettings.width)
  59.     frame.hp:ClearAllPoints()
  60.     frame.hp:SetPoint('CENTER', frame)
  61.  
  62.     if(HeadlineGlobalSettings.level) then
  63.         local r, g, b = frame.level:GetTextColor()
  64.         if(frame.bossicon:IsShown()) then
  65.             frame.name:SetText('|cffff0000??|r ' .. frame.oldname:GetText())
  66.         else
  67.             frame.name:SetText(format('|cff%02x%02x%02x', r*255, g*255, b*255) .. (frame.elite:IsShown() and '+' or '') .. tonumber(frame.level:GetText()) .. '|r ' .. frame.oldname:GetText())
  68.         end
  69.     else
  70.         frame.name:SetText(frame.oldname:GetText())
  71.     end
  72.  
  73.     HideObjects(frame)
  74. end
  75.  
  76. local function UpdateCastbar(frame)
  77.     frame:SetHeight(HeadlineGlobalSettings.height)
  78.     frame:SetWidth(HeadlineGlobalSettings.width)
  79.     frame:ClearAllPoints()
  80.     frame:SetPoint('TOP', frame:GetParent().hp, 'BOTTOM', 0, -5)
  81.  
  82.     frame.icon:SetHeight(0.01)
  83.     frame.icon:SetWidth(0.01)
  84.  
  85.     if(not frame.shield:IsShown()) then
  86.         frame:SetStatusBarColor(1, 0.35, 0.2)
  87.     end
  88. end
  89.  
  90. local function SkinObjects(frame)
  91.     local hp, cb = frame:GetChildren()
  92.     local threat, hpborder, cbshield, cbborder, cbicon, overlay, oldname, level, bossicon, raidicon, elite = frame:GetRegions()
  93.  
  94.     local bg = CreateFrame("Frame", nil, hp)
  95.         bg:SetBackdrop({
  96.             bgFile = 'Interface\\AddOns\\TinyDPS\\Textures\\blank.tga',
  97.             edgeFile = 'Interface\\AddOns\\TinyDPS\\Textures\\blank.tga',
  98.             edgeSize = 1,
  99.         })
  100.         bg:SetBackdropColor(0, 0, 0, .4)
  101.         bg:SetBackdropBorderColor(0, 0, 0)
  102.         bg:SetFrameStrata("BACKGROUND")
  103.         bg:SetPoint("TOPLEFT", hp, -1, 1)
  104.         bg:SetPoint("BOTTOMRIGHT", hp, 1, -1)
  105.  
  106.  
  107.  
  108.     local offset = UIParent:GetScale() / hp:GetEffectiveScale()
  109.     local hpbg = hp:CreateTexture(nil, 'OVERLAY')
  110.     hpbg:SetPoint('BOTTOMRIGHT', offset, -offset)
  111.     hpbg:SetPoint('TOPLEFT', -offset, offset)
  112.     hpbg:SetTexture(0, 0, 0)
  113.     hpbg:SetAlpha(0)
  114.     frame.bg = hpbg
  115.  
  116.     local hpbg2 = hp:CreateTexture(nil, 'OVERLAY')
  117.     hpbg2:SetAllPoints(hp)
  118.     hpbg2:SetTexture(0, 0, 0)
  119.     hpbg2:SetAlpha(0)
  120.  
  121.     hp:HookScript('OnShow', UpdateObjects)
  122.     hp:SetStatusBarTexture(TEXTURE)
  123.     frame.hp = hp
  124.    
  125.     local offset = UIParent:GetScale() / cb:GetEffectiveScale()
  126.     local cbbg = cb:CreateTexture(nil, 'OVERLAY')
  127.     cbbg:SetPoint('BOTTOMRIGHT', offset, -offset)
  128.     cbbg:SetPoint('TOPLEFT', -offset, offset)
  129.     cbbg:SetTexture(0, 0, 0)
  130.     cbbg:SetAlpha(0)
  131.  
  132.     local cbbg2 = cb:CreateTexture(nil, 'OVERLAY')
  133.     cbbg2:SetAllPoints(cb)
  134.     cbbg2:SetTexture(0, 0, 0)
  135.     cbbg2:SetAlpha(0)
  136.  
  137.     cb.icon = cbicon
  138.     cb.shield = cbshield
  139.     cb:HookScript('OnShow', UpdateCastbar)
  140.     cb:HookScript('OnSizeChanged', UpdateCastbar)
  141.  
  142.     cb:SetStatusBarTexture(TEXTURE)
  143.     frame.cb = cb
  144.  
  145.     local name = hp:CreateFontString(nil, 'OVERLAY')
  146.     name:SetPoint('BOTTOMLEFT', hp, 'TOPLEFT', 0, 2)
  147.     name:SetPoint('BOTTOMRIGHT', hp, 'TOPRIGHT', 0, 2)
  148.     name:SetFont(FONT, HeadlineGlobalSettings.fsize, 'MONOCHROMEOUTLINE')
  149.     frame.oldname = oldname
  150.     frame.name = name
  151.    
  152.     raidicon:ClearAllPoints()
  153.     raidicon:SetPoint('CENTER', hp, 'CENTER', 0, 5)
  154.     raidicon:SetSize(20, 20)
  155.    
  156.     if(HeadlineGlobalSettings.level) then
  157.         frame.bossicon = bossicon
  158.         frame.elite = elite
  159.         frame.level = level
  160.     end
  161.    
  162.     QueueObject(frame, threat)
  163.     QueueObject(frame, hpborder)
  164.     QueueObject(frame, cbshield)
  165.     QueueObject(frame, cbborder)
  166.     QueueObject(frame, overlay)
  167.     QueueObject(frame, oldname)
  168.     QueueObject(frame, level)
  169.     QueueObject(frame, bossicon)
  170.     QueueObject(frame, elite)
  171.  
  172.     UpdateObjects(hp)
  173.     UpdateCastbar(cb)
  174.  
  175.     frames[frame] = true
  176. end
  177.  
  178. local select = select
  179. local function HookFrames(...)
  180.     for index = 1, select('#', ...) do
  181.         local frame = select(index, ...)
  182.         local region = frame:GetRegions()
  183.         if(not frames[frame] and not frame:GetName() and region and region:GetObjectType() == 'Texture' and region:GetTexture() == OVERLAY) then
  184.             SkinObjects(frame)
  185.             frame.region = region
  186.         end
  187.     end
  188. end
  189.  
  190. local f = CreateFrame'Frame'
  191. f:RegisterEvent('ADDON_LOADED')
  192. f:RegisterEvent('PLAYER_REGEN_ENABLED')
  193. f:RegisterEvent('PLAYER_REGEN_DISABLED')
  194.  
  195.  
  196. f:SetScript('OnUpdate', function(self, elapsed)
  197.     if(WorldFrame:GetNumChildren() ~= numChildren) then
  198.         numChildren = WorldFrame:GetNumChildren()
  199.         HookFrames(WorldFrame:GetChildren())
  200.     end
  201.     if(self.elapsed and self.elapsed > 0.1) then
  202.         for frame in pairs(frames) do
  203.             UpdatePlates(frame)
  204.         end
  205.         self.elapsed = 0
  206.     else
  207.         self.elapsed = (self.elapsed or 0) + elapsed
  208.     end
  209. end)
  210.  
  211. f:SetScript('OnEvent', function(self, e, name)
  212.     if(e == 'PLAYER_REGEN_DISABLED') then
  213.         combat = true
  214.     elseif(e == 'PLAYER_REGEN_ENABLED') then
  215.         combat = false
  216.     elseif(name == 'Headline' and e == 'ADDON_LOADED') then
  217.         if not HeadlineGlobalSettings then HeadlineGlobalSettings = { width = 110, height = 5, fsize = 9, level = true, target = true } end
  218.         SetCVar('ShowClassColorInNameplate', 1)
  219.         SetCVar('bloattest', 0)
  220.         SetCVar('spreadnameplates', 0)
  221.         SetCVar('bloatnameplates', 0)
  222.         SetCVar('bloatthreat', 0)
  223.     end
  224. end)
  225.  
  226. SLASH_HEADLINE1 = '/headline';
  227. function SlashCmdList.HEADLINE(args)
  228.     local arg = string.split(' ', args):lower() or args:lower()
  229.     if(arg == 'width') then
  230.         arg = tonumber(select(2, string.split(' ', args)))
  231.         if(arg and arg > 49 and arg < 301) then
  232.             HeadlineGlobalSettings.width = arg
  233.             ReloadUI()
  234.         end
  235.     elseif(arg == 'height') then
  236.         arg = tonumber(select(2, string.split(' ', args)))
  237.         if(arg and arg > 1 and arg < 51) then
  238.             HeadlineGlobalSettings.height = arg
  239.             ReloadUI()
  240.         end
  241.     elseif(arg == 'fontsize') then
  242.         arg = tonumber(select(2, string.split(' ', args)))
  243.         if(arg and arg > 4 and arg < 31) then
  244.             HeadlineGlobalSettings.fsize = arg
  245.             ReloadUI()
  246.         end
  247.     elseif(arg == 'level') then
  248.         HeadlineGlobalSettings.level = not HeadlineGlobalSettings.level
  249.         ReloadUI()
  250.     elseif(arg == 'target') then
  251.         HeadlineGlobalSettings.target = not HeadlineGlobalSettings.target
  252.         ReloadUI()
  253.     else
  254.         print('Headline')
  255.         print(' - |cFF33FF99width <num>|r: current width is '..HeadlineGlobalSettings.width)
  256.         print(' - |cFF33FF99height <num>|r: current height is '..HeadlineGlobalSettings.height)
  257.         print(' - |cFF33FF99fontsize <num>|r: current font size is '..HeadlineGlobalSettings.fsize)
  258.         print(' - |cFF33FF99level|r: toggles the level display')
  259.         print(' - |cFF33FF99target|r: amplify target display')
  260.     end
  261. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement