Advertisement
Guest User

Headline Nameplates

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