Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.84 KB | None | 0 0
  1. --[[
  2.     Work in progress
  3.        
  4.     Thanks to
  5.         p3lim
  6.         haste
  7.         zork
  8.         Phanx
  9.        
  10.     To do:
  11.         Make status text into icons
  12.             ex: Offline into thunderbolt slashed in 2
  13. ]]--
  14.  
  15. -- Variables
  16. local addon, ns = ...
  17. local oUF = ns.oUF or oUF
  18. --local playerClass = select(3, UnitClass('player'))   
  19.  
  20. -- Closest thing to a config
  21. local FONT = 'Interface\\AddOns\\oUF_Opie\\HOOG0557.ttf'
  22. local FONTSIZE = 8
  23. local FONTSTYLE = 'OUTLINE|MONOCHROME'
  24. local TEXTURE = 'Interface\\ChatFrame\\ChatFrameBackground'
  25. local BACKDROP = {
  26.     bgFile = TEXTURE, insets = {top = -1, bottom = -1, left = -1, right = -1}
  27. }
  28. local BARTEXTURE = 'Interface\\AddOns\\oUF_Opie\\tap2.tga'
  29. -- End of closest thing to a config
  30.  
  31. --[[
  32.     Makes the background of the healthbar classcolored, or falls back to bright red
  33. --]]
  34. local function Health_PostUpdate(bar, unit, health, maxHealth)
  35.    local _, class = UnitClass(unit)
  36.    local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class or ""]
  37.    if color then
  38.       bar.bg:SetVertexColor(color.r, color.g, color.b)
  39.    else
  40.       -- Fall back to red
  41.       bar.bg:SetVertexColor(1, 0, 0)
  42.    end
  43. end
  44.  
  45. --[[
  46.     This entire block is taken from p3lim, with slight modifications where necessary to fit my needs
  47. --]]
  48. local function UpdateAura(self, elapsed)
  49.     if(self.expiration) then
  50.         if(self.expiration < 60) then
  51.             self.remaining:SetFormattedText('%d', self.expiration)
  52.         else
  53.             self.remaining:SetText()
  54.         end
  55.  
  56.         self.expiration = self.expiration - elapsed
  57.     end
  58. end
  59.  
  60. local function PostCreateAura(element, button)
  61.     button:SetBackdrop(BACKDROP)
  62.     button:SetBackdropColor(0, 0, 0)
  63.     button.cd:SetReverse()
  64.     button.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
  65.     button.icon:SetDrawLayer('ARTWORK')
  66.  
  67.     button.count:SetPoint('BOTTOMRIGHT', 2, 1)
  68.     button.count:SetFont(FONT, 8, 'OUTLINEMONOCHROME')
  69.  
  70.     local remaining = button:CreateFontString(nil, 'OVERLAY')
  71.     remaining:SetPoint('TOPLEFT', 0, -1)
  72.     remaining:SetFont(FONT, 8, 'OUTLINEMONOCROME')
  73.     remaining:SetAlpha(0)
  74.     button.remaining = remaining
  75.  
  76.     button:HookScript('OnUpdate', UpdateAura)
  77. end
  78.  
  79. local function PostUpdateBuff(element, unit, button, index)
  80.     local _, _, _, _, _, duration, expiration = UnitAura(unit, index, button.filter)
  81.  
  82.     if(duration and duration > 0) then
  83.         button.expiration = expiration - GetTime()
  84.     else
  85.         button.expiration = math.huge
  86.     end
  87. end
  88.  
  89. local function PostUpdateDebuff(element, unit, button, index)
  90.     local _, _, _, _, type, _, _, owner = UnitAura(unit, index, button.filter)
  91.  
  92.     if(owner == 'player') then
  93.         local color = DebuffTypeColor[type or 'none']
  94.         button:SetBackdropColor(color.r * 3/5, color.g * 3/5, color.b * 3/5)
  95.         button.icon:SetDesaturated(false)
  96.     else
  97.         button:SetBackdropColor(0, 0, 0)
  98.         button.icon:SetDesaturated(true)
  99.     end
  100.  
  101.     PostUpdateBuff(element, unit, button, index)
  102. end
  103.  
  104. local FilterPlayerBuffs
  105. do
  106.     local spells = {
  107.         -- Druid
  108.         [5217] = true, -- Tiger's Fury
  109.         [52610] = true, -- Savage Roar
  110.         [106951] = true, -- Berserk
  111.         [127538] = true, -- Savage Roar (glyphed)
  112.         [124974] = true, -- Nature's Vigil
  113.         [132158] = true, -- Nature's Swiftness
  114.         [132402] = true, -- Savage Defense
  115.  
  116.         -- Rogue
  117.         [5171] = true, -- Slice and Dice
  118.         [31224] = true, -- Cloak of Shadows
  119.         [32645] = true, -- Envenom
  120.         [73651] = true, -- Recuperate
  121.         [121471] = true, -- Shadow Blades
  122.         [115189] = true, -- Anticipation
  123.  
  124.         -- Death Knight
  125.         [48707] = true, -- Anti-Magic Shell
  126.         [51271] = true, -- Pillar of Frost
  127.         [53365] = true, -- Rune of the Fallen Crusader
  128.  
  129.         -- Shared
  130.         [32182] = true, -- Heroism
  131.         [57933] = true, -- Tricks of the Trade
  132.         [80353] = true, -- Time Warp
  133.     }
  134.  
  135.     if(select(2, UnitClass('player')) == 'DEATHKNIGHT') then
  136.         spells[57330] = true -- Horn of Winter
  137.     end
  138.  
  139.     function FilterPlayerBuffs(...)
  140.         local _, _, _, _, _, _, _, _, _, _, _, _, _, id = ...
  141.         return spells[id]
  142.     end
  143. end
  144.  
  145. local FilterTargetDebuffs
  146. do
  147.     local show = {
  148.         [1490] = true, -- Curse of Elements (Magic Vulnerability)
  149.         [58410] = true, -- Master Poisoner (Magic Vulnerability)
  150.         [81326] = true, -- Physical Vulnerability (Shared)
  151.         [113746] = true, -- Weakened Armor (Shared)
  152.     }
  153.  
  154.     local hide = {
  155.         [770] = true, -- Faerie Fire
  156.         [58180] = true, -- Infected Wounds
  157.         [115798] = true, -- Weakened Blows
  158.     }
  159.  
  160.     function FilterTargetDebuffs(...)
  161.         local _, unit, _, _, _, _, _, _, _, _, owner, _, _, id = ...
  162.  
  163.         if(owner == 'player' and hide[id]) then
  164.             return false
  165.         elseif(owner == 'player' or owner == 'vehicle' or UnitIsFriend('player', unit) or show[id] or not owner) then
  166.             return true
  167.         end
  168.     end
  169. end
  170.  
  171. -- Have to define UnitSpecific variable here so Shared has access to it or all things break
  172. local UnitSpecific
  173. -- Engine!
  174. local function Shared(self, unit)
  175.     unit = unit:match('(boss)%d?$') or unit
  176.  
  177.     self.colors.power.MANA = {1, 1, 1}
  178.  
  179.     self:RegisterForClicks('AnyUp')
  180.     self:SetScript('OnEnter', UnitFrame_OnEnter)
  181.     self:SetScript('OnLeave', UnitFrame_OnLeave)
  182.  
  183.     self:SetBackdrop(BACKDROP)
  184.     self:SetBackdropColor(0, 0, 0)
  185.    
  186.     local Buffs = CreateFrame('Frame', nil, self)
  187.     self.Buffs = Buffs
  188.    
  189.     local Debuffs = CreateFrame('Frame', nil, self)
  190.     self.Debuffs = Debuffs
  191.  
  192.     local Health = CreateFrame('StatusBar', nil, self)
  193.     Health:SetStatusBarTexture(BARTEXTURE)
  194.     Health:SetStatusBarColor(53/255, 53/255, 53/255)
  195.     Health.frequentUpdates      = true
  196.     self.Health = Health
  197.  
  198.     local HealthBG = Health:CreateTexture(nil, 'BORDER')
  199.     HealthBG:SetAllPoints()
  200.     HealthBG:SetTexture(BARTEXTURE)
  201.     Health.bg = HealthBG
  202.     Health.PostUpdate = Health_PostUpdate
  203.  
  204.     local HealthValue = Health:CreateFontString(nil, 'OVERLAY')
  205.     HealthValue:SetPoint('RIGHT', -7, -1)
  206.     HealthValue:SetFont(FONT, FONTSIZE, FONTSTYLE)
  207.     HealthValue:SetJustifyH('RIGHT')
  208.     HealthValue.frequentUpdates = 1/4
  209.     self.HealthValue = HealthValue
  210.    
  211.     local PowerValue = self.Health:CreateFontString(nil, 'OVERLAY')
  212.    
  213.     if(unit=='player' or unit=='party') then               
  214.         PowerValue:SetFont(FONT, FONTSIZE, FONTSTYLE)
  215.         PowerValue:SetJustifyH('LEFT')
  216.         PowerValue.frequentUpdates = 0.1
  217.         if(unit=='player') then
  218.             self:Tag(PowerValue, '[oppower]')
  219.             PowerValue:SetPoint('LEFT', 7, -1)
  220.             PowerValue:SetPoint('RIGHT', self.HealthValue, 'LEFT', -3)
  221.         else
  222.             self:Tag(PowerValue, '[oppartypp]')
  223.             PowerValue:SetPoint('LEFT', 7, 0)
  224.             PowerValue:SetPoint('RIGHT', self.HealthValue, 'LEFT', -3)
  225.             HealthValue:SetPoint('RIGHT', -7, 0)
  226.         end
  227.     end
  228.  
  229.     if(unit == 'player' or unit == 'target' or 'targettarget') then
  230.         local Power = CreateFrame('StatusBar', nil, self)
  231.         if(unit == 'player') then      
  232.             Power:SetPoint('TOPRIGHT')
  233.             Power:SetPoint('TOPLEFT')
  234.             Power:SetPoint('BOTTOM', Health, 'TOP', 0, 1)
  235.             Health:SetPoint('BOTTOMRIGHT')
  236.             Health:SetPoint('BOTTOMLEFT')
  237.            
  238.             Buffs:SetPoint('RIGHT', self, 'LEFT', -5, -2)
  239.             Buffs:SetSize(236, 44)
  240.             Buffs.num = 20
  241.             Buffs.size = 20
  242.             Buffs.spacing = 5
  243.             Buffs.initialAnchor = 'RIGHT'
  244.             Buffs['growth-y'] = 'DOWN'
  245.             Buffs['growth-x'] = 'LEFT'
  246.             Buffs.PostCreateIcon = PostCreateAura
  247.             self.Buffs.CustomFilter = FilterPlayerBuffs
  248.             self.Buffs = Buffs
  249.            
  250.             self.Debuffs.size = 20
  251.             self.Debuffs:SetSize(230, 22)
  252.             self.Debuffs.PostUpdateIcon = PostUpdateBuff
  253.             self.Buffs.PostUpdateIcon = PostUpdateBuff
  254.         else
  255.             Power:SetPoint('BOTTOMRIGHT')
  256.             Power:SetPoint('BOTTOMLEFT')
  257.             Power:SetPoint('TOP', Health, 'BOTTOM', 0, -1)
  258.             Health:SetPoint('TOPRIGHT')
  259.             Health:SetPoint('TOPLEFT')
  260.            
  261.             self.Debuffs.size = 22
  262.             self.Debuffs['growth-y'] = 'UP'
  263.             self.Debuffs['growth-x'] = 'LEFT'
  264.             self.Debuffs:SetPoint('BOTTOMLEFT', self, 'TOPRIGHT', -22, 3)
  265.             self.Debuffs:SetSize(159, 22)
  266.             self.Debuffs.PostUpdateIcon = PostUpdateDebuff
  267.             self.Debuffs.CustomFilter = FilterTargetDebuffs
  268.         end
  269.         Power:SetStatusBarTexture(BARTEXTURE)
  270.         Power:SetStatusBarColor(188/255, 188/255, 188/255)
  271.         Power.frequentUpdates = true
  272.         self.Power = Power
  273.  
  274.         local PowerBG = Power:CreateTexture(nil, 'BORDER')
  275.         PowerBG:SetAllPoints()
  276.         PowerBG:SetTexture(BARTEXTURE)
  277.         PowerBG:SetVertexColor(75/255, 75/255, 75/255)
  278.         Power.bg = PowerBG
  279.        
  280.         local RaidIcon = Health:CreateTexture(nil, 'OVERLAY')
  281.         RaidIcon:SetPoint('TOP', self, 0, 8)
  282.         RaidIcon:SetSize(16, 16)
  283.         self.RaidIcon = RaidIcon
  284.        
  285.         Health:SetHeight(20)
  286.  
  287.         self:SetHeight(24)
  288.     end
  289.  
  290.     if(unit ~= 'player' and unit ~= 'party' and unit ~= 'raid') then
  291.         local Name = Health:CreateFontString(nil, 'OVERLAY')
  292.         if(unit=='pet') then
  293.             Name:SetPoint('LEFT', 7, 0)
  294.             Name:SetPoint('RIGHT', HealthValue, 'LEFT')
  295.         else
  296.             Name:SetPoint('LEFT', 7, -1)
  297.             Name:SetPoint('RIGHT', HealthValue, 'LEFT')
  298.         end
  299.         Name:SetFont(FONT, FONTSIZE, FONTSTYLE)
  300.         Name:SetJustifyH('LEFT')
  301.         self:Tag(Name, '[opname]')
  302.        
  303.         Debuffs.spacing = 4
  304.         Debuffs.initialAnchor = 'TOPLEFT'
  305.         Debuffs.PostCreateIcon = PostCreateAura
  306.     end
  307.  
  308.     if(unit ~= 'party' and unit ~= 'raid' and unit ~= 'boss') then
  309.         if(unit == 'focus') then       
  310.             Health:SetAllPoints()
  311.            
  312.             self.Tag(HealthValue, '[ophealth]')
  313.             HealthValue:SetPoint('RIGHT', -7, 0)
  314.         elseif(unit == 'pet') then
  315.             Health:SetAllPoints()
  316.             self:SetSize(120, 18)
  317.         end
  318.     end
  319.     if(unit == 'targettarget') then
  320.         self:SetBackdrop(BACKDROP)
  321.         self:SetBackdropColor(0, 0, 0)
  322.     end
  323.  
  324.     if(UnitSpecific[unit]) then
  325.         return UnitSpecific[unit](self)
  326.     end
  327. end
  328.  
  329. UnitSpecific = {
  330.     player = function(self)    
  331.         local AltPower = CreateFrame('StatusBar', nil, self)
  332.         AltPower:SetPoint('TOPLEFT', 6, 7)
  333.         AltPower:SetSize(170, 6)
  334.         AltPower:SetStatusBarTexture(BARTEXTURE)
  335.         AltPower:SetStatusBarColor(0.15, 0.7, 0.1)
  336.         AltPower:SetBackdrop(BACKDROP)
  337.         AltPower:SetBackdropColor(0, 0, 0)
  338.         AltPower:EnableMouse(true)
  339.         AltPower.colorTexture = true
  340.         self.AltPowerBar = AltPower
  341.  
  342.         local AltPowerBG = AltPower:CreateTexture(nil, 'BORDER')
  343.         AltPowerBG:SetAllPoints()
  344.         AltPowerBG:SetTexture(1/3, 1/3, 1/3)
  345.  
  346.         self:Tag(self.HealthValue, '[opstatus][opphealth]')
  347.         self:SetWidth(159)
  348.     end,
  349.     target = function(self)    
  350.         self:Tag(self.HealthValue, '[ophealth]')
  351.         self:SetWidth(159)
  352.     end,
  353.     targettarget = function(self)
  354.         self:Tag(self.HealthValue, '[ophealth]')
  355.         self:SetWidth(100)
  356.         self.Debuffs.onlyShowPlayer = true
  357.     end,
  358.     party = function(self)
  359.         local Name = self.Health:CreateFontString(nil, 'OVERLAY')
  360.         Name:SetPoint('CENTER', 0, 0)
  361.         Name:SetPoint('CENTER', self, 'CENTER')
  362.         Name:SetFont(FONT, FONTSIZE, FONTSTYLE)
  363.         Name:SetJustifyH('CENTER')
  364.         self:Tag(Name, '[opname]')
  365.  
  366.         local RoleIcon = self:CreateTexture(nil, 'ARTWORK')
  367.         RoleIcon:SetPoint('LEFT', self, 'RIGHT', 3, 0)
  368.         RoleIcon:SetSize(14, 14)
  369.         RoleIcon:SetAlpha(1)
  370.         self.LFDRole = RoleIcon
  371.  
  372.         local ReadyCheck = self:CreateTexture(nil, 'OVERLAY')
  373.         ReadyCheck:SetPoint('LEFT', self, 'RIGHT', 3, 0)
  374.         ReadyCheck:SetSize(14, 14)
  375.         self.ReadyCheck = ReadyCheck
  376.  
  377.         self:HookScript('OnEnter', function() RoleIcon:SetAlpha(1) end)
  378.         self:HookScript('OnLeave', function() RoleIcon:SetAlpha(0) end)
  379.         self.Tag(HealthValue, '[ophealth]')
  380.  
  381.         self.Health:SetAllPoints()
  382.     end,
  383.     boss = function(self)
  384.         self:SetSize(126, 19)
  385.         self.Health:SetAllPoints()
  386.         self:Tag(self.HealthValue, '[perhp]')
  387.     end,
  388.     focus = function(self)     
  389.         self:SetSize(150, 24)
  390.     end
  391. }
  392. --UnitSpecific.raid = UnitSpecific.party
  393.  
  394. oUF:RegisterStyle('opUnitFrames', Shared)
  395. oUF:Factory(function(self)
  396.     -- Single Frames
  397.     self:SetActiveStyle('opUnitFrames')
  398.  
  399.     self:Spawn('player'):SetPoint("BOTTOM",UIParent,"BOTTOM", 0, 279)
  400.     self:Spawn('target'):SetPoint("BOTTOM",UIParent,"BOTTOM", 0, 279+70)
  401.  
  402.     self:Spawn('targettarget'):SetPoint("RIGHT", oUF_opUnitFramesTarget,"LEFT", -7, 0)
  403.     self:Spawn('pet'):SetPoint("TOPLEFT",UIParent,"TOPLEFT", 5, -5)
  404.     self:Spawn('focus'):SetPoint("RIGHT",UIParent,"CENTER", -150, 0)
  405.    
  406.     self:SpawnHeader(nil, nil, 'custom [group:party] show; [@raid3,exists] hide; [@raid26,exists] hide; hide',
  407.         'showParty', true, 'showRaid', false, 'showPlayer', false, 'yOffset', -4,
  408.         'oUF-initialConfigFunction', [[
  409.             self:SetHeight(24)
  410.             self:SetWidth(159)
  411.         ]]
  412.     ):SetPoint('TOP', oUF_opUnitFramesPlayer, 'BOTTOM', 0, -10)
  413. end)
  414.  
  415. -- Most important line in here
  416. oUF:DisableBlizzard('party')
  417.  
  418. local testui = TestUI or function() end
  419. TestUI = function( msg )
  420.     if( msg == "uf" or msg == "unitframes" ) then
  421.         oUF_opUnitFramesTarget:Show(); oUF_opUnitFramesTarget.Hide = function() end; oUF_opUnitFramesTarget.unit = "player"
  422.         oUF_opUnitFramesTargetTarget:Show(); oUF_opUnitFramesTargetTarget.Hide = function() end; oUF_opUnitFramesTargetTarget.unit = "player"
  423.         oUF_opUnitFramesFocus:Show(); oUF_opUnitFramesFocus.Hide = function() end; oUF_opUnitFramesFocus.unit = "player"
  424.         oUF_opUnitFramesPet:Show(); oUF_opUnitFramesPet.Hide = function() end; oUF_opUnitFramesPet.unit = "player"
  425.     elseif( msg == "a" or msg == "arena" ) then
  426.         oUF_opUnitFramesArena1:Show(); oUF_opUnitFramesArena1.Hide = function() end; oUF_opUnitFramesArena1.unit = "player"
  427.         oUF_opUnitFramesArena2:Show(); oUF_opUnitFramesArena2.Hide = function() end; oUF_opUnitFramesArena2.unit = "player"
  428.         oUF_opUnitFramesArena3:Show(); oUF_opUnitFramesArena3.Hide = function() end; oUF_opUnitFramesArena3.unit = "player"
  429.     elseif( msg == "boss" or msg == "b" ) then
  430.         oUF_opUnitFramesBoss1:Show(); oUF_opUnitFramesBoss1.Hide = function() end; oUF_opUnitFramesBoss1.unit = "player"
  431.         oUF_opUnitFramesBoss2:Show(); oUF_opUnitFramesBoss2.Hide = function() end; oUF_opUnitFramesBoss2.unit = "player"
  432.         oUF_opUnitFramesBoss3:Show(); oUF_opUnitFramesBoss3.Hide = function() end; oUF_opUnitFramesBoss3.unit = "player"
  433.     elseif( msg == "buffs" ) then
  434.         UnitAura = function()
  435.             return 139, "Rank 1", "Interface\\Icons\\Spell_Holy_Penance", 1, "Magic", 0, 0, "player"
  436.         end
  437.  
  438.         if( oUF ) then
  439.             for i, v in pairs( oUF.units ) do
  440.                 if( v.UNIT_AURA ) then
  441.                     v:UNIT_AURA( "UNIT_AURA", v.unit )
  442.                 end
  443.             end
  444.         end
  445.     end
  446. end
  447. SlashCmdList.TestUI = TestUI
  448. SLASH_TestUI1 = "/testui"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement