Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 20th, 2010 | Syntax: None | Size: 8.16 KB | Hits: 71 | Expires: Never
Copy text to clipboard
  1. local bartexture = 'Interface\\AddOns\\oUF_zp\\texture\\statusbar'
  2. local bufftexture = 'Interface\\AddOns\\oUF_zp\\texture\\buff'
  3. oUF.colors.power['MANA'] = {26/255, 139/255, 255/255}
  4.  
  5. local menu = function(self)
  6.         local unit = self.unit:sub(1, -2)
  7.         local cunit = self.unit:gsub('(.)', string.upper, 1)
  8.  
  9.         if(unit == 'party' or unit == 'partypet') then
  10.                 ToggleDropDownMenu(1, nil, _G['PartyMemberFrame'..self.id..'DropDown'], 'cursor', 0, 0)
  11.         elseif(_G[cunit..'FrameDropDown']) then
  12.                 ToggleDropDownMenu(1, nil, _G[cunit..'FrameDropDown'], 'cursor', 0, 0)
  13.         end
  14. end
  15.  
  16. local function updateCombo(self, event, unit)
  17.         if(unit == PlayerFrame.unit and unit ~= self.CPoints.unit) then
  18.                 self.CPoints.unit = unit
  19.         end
  20. end
  21.  
  22. local function shorthpval(value)
  23.         if(value >= 1e6) then
  24.                 return string.format('%.1fm', value / 1e6)
  25.         elseif(value >= 1e4) then
  26.                 return string.format('%.1fk', value / 1e3)
  27.         elseif value >= 1e3 then
  28.                 return string.format('%.1fk', value / 1e3)
  29.         else
  30.                 return value
  31.         end
  32. end
  33.  
  34. oUF.Tags['[shortcurhp]'] = function(u) return shorthpval(UnitHealth(u)) end
  35. oUF.TagEvents['[shortcurhp]'] = 'UNIT_HEALTH'
  36.  
  37. oUF.Tags['[shortcurpp]'] = function(u) return shorthpval(UnitPower(u)) end
  38. oUF.TagEvents['[shortcurpp]'] = 'UNIT_ENERGY UNIT_FOCUS UNIT_MANA UNIT_RAGE'
  39.  
  40. local auraIcon = function(self, button, icons)
  41.         icons.showDebuffType = true
  42.        
  43.         button.icon:SetTexCoord(.07, .93, .07, .93)
  44.         button.icon:SetPoint('TOPLEFT', button, 'TOPLEFT', 1, -1)
  45.         button.icon:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', -1, 1)
  46.        
  47.         button.overlay:SetTexture(bufftexture)
  48.         button.overlay:SetTexCoord(0,1,0,1)
  49.         button.overlay.Hide = function(self) self:SetVertexColor(0.3, 0.3, 0.3) end
  50.        
  51.         button.cd:SetReverse()
  52.         button.cd:SetPoint('TOPLEFT', button, 'TOPLEFT', 2, -2)
  53.         button.cd:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', -2, 2)
  54.         button.cd.noCooldownCount = true    
  55. end
  56.  
  57. local function layout(self, unit)
  58.  
  59.         self.menu = menu
  60.         self:RegisterForClicks('AnyUp')
  61.         self:SetScript('OnEnter', UnitFrame_OnEnter)
  62.         self:SetScript('OnLeave', UnitFrame_OnLeave)
  63.         self:SetAttribute('*type2', 'menu')
  64.        
  65.         if unit=='focus' then
  66.                 self:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], insets = {top = -2, left = -2, bottom = -5, right = -2}})
  67.         else
  68.                 self:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], insets = {top = -2, left = -2, bottom = -5, right = -3}})
  69.         end
  70.        
  71.         self:SetBackdropColor(0, 0, 0, 0.5)
  72.  
  73.         self.Health = CreateFrame('StatusBar', nil, self)
  74.         self.Health:SetStatusBarTexture(bartexture)
  75.         self.Health:SetHeight(15)
  76.  
  77.         self.Health:SetParent(self)
  78.         self.Health:SetPoint'TOP'
  79.         self.Health:SetPoint'LEFT'
  80.         self.Health:SetPoint'RIGHT'
  81.  
  82.         self.Health.colorClass = true
  83.         self.Health.colorTapping = true
  84.         self.Health.colorReaction = true
  85.         self.Health.frequentUpdates = true
  86.  
  87.         self.Health.bg = self.Health:CreateTexture(nil, 'BORDER')
  88.         self.Health.bg:SetAllPoints(self.Health)
  89.         self.Health.bg:SetTexture(bartexture)
  90.         self.Health.bg:SetAlpha(0.3)
  91.  
  92.         if unit~='player' then
  93.                 self.disallowVehicleSwap = true
  94.         end
  95.  
  96.         if unit=='player' or unit=='target' then
  97.                 self:SetAttribute('initial-height', 20)
  98.                 self:SetAttribute('initial-width', 250)
  99.  
  100.                 self.Power = CreateFrame('StatusBar', nil, self)
  101.                 self.Power:SetStatusBarTexture(bartexture)
  102.                 self.Power:SetHeight(5)
  103.                 self.Power:SetPoint('TOP', self.Health, 'BOTTOM', 0, -1.45)
  104.  
  105.                 self.Power:SetParent(self)
  106.                 self.Power:SetPoint'LEFT'
  107.                 self.Power:SetPoint'RIGHT'
  108.  
  109.                 self.Power.colorPower = true
  110.                 self.Power.frequentUpdates = true
  111.  
  112.                 self.Power.bg = self.Power:CreateTexture(nil, 'BORDER')
  113.                 self.Power.bg:SetAllPoints(self.Power)
  114.                 self.Power.bg:SetTexture(bartexture)
  115.                 self.Power.bg:SetAlpha(0.3)
  116.        
  117.                 local curhealth = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft')
  118.                 curhealth:SetPoint('BOTTOM', self, 0, -20)
  119.                 self:Tag(curhealth,'[shortcurhp]')
  120.        
  121.                 local perhealth = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft')
  122.                 perhealth:SetPoint('BOTTOMLEFT', self, 0, -20)
  123.                 self:Tag(perhealth,'[perhp]%')
  124.  
  125.                 local healthbg = self.Health:CreateTexture(nil, 'BORDER')
  126.                 healthbg:SetPoint('CENTER', curhealth, 'CENTER', 1, 0)
  127.                 healthbg:SetTexture(bartexture)
  128.                 healthbg:SetWidth(254)
  129.                 healthbg:SetHeight(13)
  130.                 healthbg:SetVertexColor(0, 0, 0, 0.5)
  131.  
  132.                 local curpower = self.Power:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft')
  133.                 curpower:SetPoint('BOTTOMRIGHT', self, 0, -20)
  134.                 curpower.frequentUpdates = 0.1
  135.                 self:Tag(curpower,'[shortcurpp]')
  136.  
  137.                 self.Castbar = CreateFrame('StatusBar', nil, self)
  138.                 self.Castbar:SetBackdrop({bgFile = 'Interface\ChatFrame\ChatFrameBackground', insets = {top = -3, left = -3, bottom = -3, right = -3}})
  139.                 self.Castbar:SetBackdropColor(0, 0, 0)
  140.                 self.Castbar:SetWidth(254)
  141.                 self.Castbar:SetHeight(8)
  142.                 self.Castbar:SetStatusBarTexture(bartexture)
  143.        
  144.                 self.Castbar.bg = self.Castbar:CreateTexture(nil, 'BORDER')
  145.                 self.Castbar.bg:SetAllPoints(self.Castbar)
  146.                 self.Castbar.bg:SetTexture(bartexture)
  147.                 self.Castbar.bg:SetVertexColor(0,0,0,0.5)
  148.                
  149.                 self.Castbar.Text = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft')
  150.                 self.Castbar.Text:SetPoint('LEFT', self.Castbar, 0, 12)
  151.                 self.Castbar.Text:SetTextColor(1, 1, 1)
  152.        
  153.                 self.Castbar.Time = self.Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
  154.                 self.Castbar.Time:SetPoint('RIGHT', self.Castbar, -3, 12)
  155.                 self.Castbar.Time:SetTextColor(1, 1, 1)
  156.         end
  157.  
  158.         if unit=='player' then
  159.                 self.Castbar:SetPoint('CENTER', oUF.units.player, 'CENTER', 0, -80)
  160.                 self.Castbar:SetStatusBarColor(1, 0.50, 0)
  161.         end
  162.        
  163.         if unit=='target' then
  164.                 self.Castbar:SetPoint('CENTER', oUF.units.target, 'CENTER', 0, -80)
  165.                 self.Castbar:SetStatusBarColor(0.80, 0.01, 0)
  166.         end
  167.        
  168.         local unitnames = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft')
  169.         self:Tag(unitnames,'[name]')
  170.  
  171.         if unit=='target' then
  172.                 unitnames:SetPoint('LEFT', self, -1, 20)
  173.  
  174.                 self.RaidIcon = self.Health:CreateTexture(nil, 'OVERLAY')
  175.                 self.RaidIcon:SetHeight(16)
  176.                 self.RaidIcon:SetWidth(16)
  177.                 self.RaidIcon:SetPoint('TOP', self, 0, 9)
  178.                 self.RaidIcon:SetTexture'Interface\\TargetingFrame\\UI-RaidTargetingIcons'
  179.        
  180.                 self.Buffs = CreateFrame('Frame', nil, self)
  181.                 self.Buffs.size = 20
  182.                 self.Buffs:SetHeight(self.Buffs.size)
  183.                 self.Buffs:SetWidth(self.Buffs.size * 5)
  184.                 self.Buffs:SetPoint('BOTTOMLEFT', self, 'TOPLEFT', -2, 20)
  185.                 self.Buffs.initialAnchor = 'BOTTOMLEFT'
  186.                 self.Buffs['growth-y'] = 'TOP'
  187.                 self.Buffs.num = 20
  188.                 self.Buffs.spacing = 2
  189.  
  190.                 self.Debuffs = CreateFrame('Frame', nil, self)
  191.                 self.Debuffs.size = 20
  192.                 self.Debuffs:SetHeight(self.Debuffs.size)
  193.                 self.Debuffs:SetWidth(self.Debuffs.size * 12)
  194.                 self.Debuffs:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -33)
  195.                 self.Debuffs.initialAnchor = 'TOPLEFT'
  196.                 self.Debuffs['growth-y'] = 'DOWN'
  197.                 self.Debuffs.num = 11
  198.                 self.Debuffs.spacing = 2
  199.         end
  200.  
  201.         if unit=='target' then
  202.                 self.CPoints = {}
  203.                 for id = 1, MAX_COMBO_POINTS do
  204.                         self.CPoints[id] = CreateFrame('StatusBar', nil, self)
  205.  
  206.                         if (id > 1) then
  207.                                 self.CPoints[id]:SetPoint('TOPLEFT', self.CPoints[id-1], 'TOPRIGHT', 1, 0)
  208.                         else
  209.                                 self.CPoints[id]:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', -1, -25)
  210.                         end
  211.  
  212.                         self.CPoints[id]:SetStatusBarTexture(bartexture)
  213.                         self.CPoints[id]:SetStatusBarColor(1, 0.8, 0)
  214.                         self.CPoints[id]:SetHeight(6)
  215.                         self.CPoints[id]:SetWidth(250 / MAX_COMBO_POINTS)
  216.                 end
  217.  
  218.                 self.CPoints.unit = PlayerFrame.unit
  219.                 self:RegisterEvent('UNIT_COMBO_POINTS', updateCombo)
  220.         end
  221.        
  222.         if unit=='focus' or unit=='targettarget' or unit=='pet' then
  223.                 self:SetAttribute('initial-height', 12)
  224.                 self:SetAttribute('initial-width', 100)
  225.                 unitnames:SetPoint('LEFT', self, 0, 0)
  226.                 unitnames:SetWidth(90)
  227.                 unitnames:SetHeight(10)
  228.         end
  229.         self.PostCreateAuraIcon = auraIcon
  230. end
  231.  
  232. oUF:RegisterStyle('zp', layout)
  233. oUF:SetActiveStyle('zp')
  234.  
  235. oUF:Spawn('player'):SetPoint('CENTER', -200, -300)
  236. oUF:Spawn('focus'):SetPoint('TOPLEFT', oUF.units.player, 0, 30)
  237. oUF:Spawn('target'):SetPoint('CENTER', 200, -300)
  238. oUF:Spawn('targettarget'):SetPoint('TOPRIGHT', oUF.units.target, 0, 30)
  239. oUF:Spawn('pet'):SetPoint('BOTTOMLEFT', oUF.units.player, 0, -40)