Advertisement
Guest User

Untitled

a guest
Oct 4th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.61 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.         if(unit~='pet' or unit~='focus' or unit~='party') then
  206.             HealthValue:SetPoint('RIGHT', -7, -1)
  207.         end
  208.         HealthValue:SetFont(FONT, FONTSIZE, FONTSTYLE)
  209.         HealthValue:SetJustifyH('RIGHT')
  210.         HealthValue.frequentUpdates = 1/4
  211.         self.HealthValue = HealthValue
  212.        
  213.         if(unit=='party') then
  214.             HealthValue:SetPoint('RIGHT', -7, 0)
  215.             HealthValue:SetAlpha(1)
  216.             --HealthValue:SetFrameStrata('HIGH')
  217.             --HealthValue:SetFrameLevel(10)
  218.             print('healthvalue 1')
  219.         end
  220.        
  221.         local PowerValue = self.Health:CreateFontString(nil, 'OVERLAY')
  222.        
  223.         if(unit=='player' or unit=='party') then                               
  224.                 PowerValue:SetFont(FONT, FONTSIZE, FONTSTYLE)
  225.                 PowerValue:SetJustifyH('LEFT')
  226.                 PowerValue.frequentUpdates = 0.1
  227.                 if(unit=='player') then
  228.                         self:Tag(PowerValue, '[oppower]')
  229.                         PowerValue:SetPoint('LEFT', 7, -1)
  230.                         PowerValue:SetPoint('RIGHT', self.HealthValue, 'LEFT', -3)
  231.                 else
  232.                         self:Tag(PowerValue, '[oppartypp]')
  233.                         PowerValue:SetPoint('LEFT', 7, 0)
  234.                         PowerValue:SetPoint('RIGHT', self.HealthValue, 'LEFT', -3)
  235.                        
  236.                         Buffs:Hide()
  237.                         Debuffs:Hide()
  238.                 end
  239.         end
  240.  
  241.         if(unit == 'player' or unit == 'target' or 'targettarget') then
  242.                 local Power = CreateFrame('StatusBar', nil, self)
  243.                 if(unit == 'player') then            
  244.                         Power:SetPoint('TOPRIGHT')
  245.                         Power:SetPoint('TOPLEFT')
  246.                         Power:SetPoint('BOTTOM', Health, 'TOP', 0, 1)
  247.                         Health:SetPoint('BOTTOMRIGHT')
  248.                         Health:SetPoint('BOTTOMLEFT')
  249.                        
  250.                         Buffs:SetPoint('RIGHT', self, 'LEFT', -5, -2)
  251.                         Buffs:SetSize(236, 44)
  252.                         Buffs.num = 20
  253.                         Buffs.size = 20
  254.                         Buffs.spacing = 5
  255.                         Buffs.initialAnchor = 'RIGHT'
  256.                         Buffs['growth-y'] = 'DOWN'
  257.                         Buffs['growth-x'] = 'LEFT'
  258.                         Buffs.PostCreateIcon = PostCreateAura
  259.                         self.Buffs.CustomFilter = FilterPlayerBuffs
  260.                         self.Buffs = Buffs
  261.                        
  262.                         self.Debuffs.size = 20
  263.                         self.Debuffs:SetSize(230, 22)
  264.                         self.Debuffs.PostUpdateIcon = PostUpdateBuff
  265.                         self.Buffs.PostUpdateIcon = PostUpdateBuff
  266.                 else
  267.                         Power:SetPoint('BOTTOMRIGHT')
  268.                         Power:SetPoint('BOTTOMLEFT')
  269.                         Power:SetPoint('TOP', Health, 'BOTTOM', 0, -1)
  270.                         Health:SetPoint('TOPRIGHT')
  271.                         Health:SetPoint('TOPLEFT')
  272.                        
  273.                         self.Debuffs.size = 22
  274.                         self.Debuffs['growth-y'] = 'UP'
  275.                         self.Debuffs['growth-x'] = 'LEFT'
  276.                         self.Debuffs:SetPoint('BOTTOMLEFT', self, 'TOPRIGHT', -22, 3)
  277.                         self.Debuffs:SetSize(159, 22)
  278.                         self.Debuffs.PostUpdateIcon = PostUpdateDebuff
  279.                         self.Debuffs.CustomFilter = FilterTargetDebuffs
  280.                 end
  281.                 Power:SetStatusBarTexture(BARTEXTURE)
  282.                 Power:SetStatusBarColor(188/255, 188/255, 188/255)
  283.                 Power.frequentUpdates = true
  284.                 self.Power = Power
  285.  
  286.                 local PowerBG = Power:CreateTexture(nil, 'BORDER')
  287.                 PowerBG:SetAllPoints()
  288.                 PowerBG:SetTexture(BARTEXTURE)
  289.                 PowerBG:SetVertexColor(75/255, 75/255, 75/255)
  290.                 Power.bg = PowerBG
  291.                
  292.                 local RaidIcon = Health:CreateTexture(nil, 'OVERLAY')
  293.                 RaidIcon:SetPoint('TOP', self, 0, 8)
  294.                 RaidIcon:SetSize(16, 16)
  295.                 self.RaidIcon = RaidIcon
  296.                
  297.                 Health:SetHeight(20)
  298.  
  299.                 self:SetHeight(24)
  300.         end
  301.  
  302.         if(unit ~= 'player' and unit ~= 'party' and unit ~= 'raid') then
  303.                 local Name = Health:CreateFontString(nil, 'OVERLAY')
  304.                 if(unit=='pet') then
  305.                         Name:SetPoint('LEFT', 7, 0)
  306.                         Name:SetPoint('RIGHT', HealthValue, 'LEFT')
  307.                 else
  308.                         Name:SetPoint('LEFT', 7, -1)
  309.                         Name:SetPoint('RIGHT', HealthValue, 'LEFT')
  310.                 end
  311.                 Name:SetFont(FONT, FONTSIZE, FONTSTYLE)
  312.                 Name:SetJustifyH('LEFT')
  313.                 self:Tag(Name, '[opname]')
  314.                
  315.                 Debuffs.spacing = 4
  316.                 Debuffs.initialAnchor = 'TOPLEFT'
  317.                 Debuffs.PostCreateIcon = PostCreateAura
  318.         end
  319.  
  320.         if(unit ~= 'party' and unit ~= 'raid' and unit ~= 'boss') then
  321.                 if(unit == 'focus') then               
  322.                         Health:SetAllPoints()                      
  323.                         self.Tag(HealthValue, '[ophealth]')
  324.                         print('healthvalue 2')
  325.                 elseif(unit == 'pet') then
  326.                         Health:SetAllPoints()
  327.                         self:SetSize(120, 18)
  328.                 end
  329.         end
  330.         if(unit == 'targettarget') then
  331.                 self:SetBackdrop(BACKDROP)
  332.                 self:SetBackdropColor(0, 0, 0)
  333.         end
  334.  
  335.         if(UnitSpecific[unit]) then
  336.                 return UnitSpecific[unit](self)
  337.         end
  338. end
  339.  
  340. UnitSpecific = {
  341.         player = function(self)    
  342.                 local AltPower = CreateFrame('StatusBar', nil, self)
  343.                 AltPower:SetPoint('TOPLEFT', 6, 7)
  344.                 AltPower:SetSize(170, 6)
  345.                 AltPower:SetStatusBarTexture(BARTEXTURE)
  346.                 AltPower:SetStatusBarColor(0.15, 0.7, 0.1)
  347.                 AltPower:SetBackdrop(BACKDROP)
  348.                 AltPower:SetBackdropColor(0, 0, 0)
  349.                 AltPower:EnableMouse(true)
  350.                 AltPower.colorTexture = true
  351.                 self.AltPowerBar = AltPower
  352.  
  353.                 local AltPowerBG = AltPower:CreateTexture(nil, 'BORDER')
  354.                 AltPowerBG:SetAllPoints()
  355.                 AltPowerBG:SetTexture(1/3, 1/3, 1/3)
  356.  
  357.                 self:Tag(self.HealthValue, '[opstatus][opphealth]')
  358.                 self:SetWidth(159)
  359.         end,
  360.         target = function(self)    
  361.                 self:Tag(self.HealthValue, '[ophealth]')
  362.                 self:SetWidth(159)
  363.         end,
  364.         targettarget = function(self)
  365.                 self:Tag(self.HealthValue, '[ophealth]')
  366.                 self:SetWidth(100)
  367.                 self.Debuffs.onlyShowPlayer = true
  368.         end,
  369.         party = function(self)
  370.                 local Name = self.Health:CreateFontString(nil, 'OVERLAY')
  371.                 Name:SetPoint('CENTER', 0, 0)
  372.                 Name:SetPoint('CENTER', self, 'CENTER')
  373.                 Name:SetFont(FONT, FONTSIZE, FONTSTYLE)
  374.                 Name:SetJustifyH('CENTER')
  375.                 self:Tag(Name, '[opname]')
  376.  
  377.                 local RoleIcon = self:CreateTexture(nil, 'ARTWORK')
  378.                 RoleIcon:SetPoint('LEFT', self, 'RIGHT', 3, 0)
  379.                 RoleIcon:SetSize(14, 14)
  380.                 RoleIcon:SetAlpha(1)
  381.                 self.LFDRole = RoleIcon
  382.  
  383.                 local ReadyCheck = self:CreateTexture(nil, 'OVERLAY')
  384.                 ReadyCheck:SetPoint('LEFT', self, 'RIGHT', 3, 0)
  385.                 ReadyCheck:SetSize(14, 14)
  386.                 self.ReadyCheck = ReadyCheck
  387.  
  388.                 self:HookScript('OnEnter', function() RoleIcon:SetAlpha(1) end)
  389.                 self:HookScript('OnLeave', function() RoleIcon:SetAlpha(0) end)
  390.                 self.Tag(self.HealthValue, '[oppartyhp]')
  391.                 print('healthvalue 3')
  392.  
  393.                 self.Health:SetAllPoints()
  394.         end,
  395.         boss = function(self)
  396.                 self:SetSize(126, 19)
  397.                 self.Health:SetAllPoints()
  398.                 self:Tag(self.HealthValue, '[perhp]')
  399.         end,
  400.         focus = function(self)       
  401.                 self:SetSize(150, 24)
  402.         end
  403. }
  404. --UnitSpecific.raid = UnitSpecific.party
  405.  
  406. oUF:RegisterStyle('opUnitFrames', Shared)
  407. oUF:Factory(function(self)
  408.         -- Single Frames
  409.         self:SetActiveStyle('opUnitFrames')
  410.  
  411.         self:Spawn('player'):SetPoint("BOTTOM",UIParent,"BOTTOM", 0, 279)
  412.         self:Spawn('target'):SetPoint("BOTTOM",UIParent,"BOTTOM", 0, 279+70)
  413.  
  414.         self:Spawn('targettarget'):SetPoint("RIGHT", oUF_opUnitFramesTarget,"LEFT", -7, 0)
  415.         self:Spawn('pet'):SetPoint("TOPLEFT",UIParent,"TOPLEFT", 5, -5)
  416.         self:Spawn('focus'):SetPoint("RIGHT",UIParent,"CENTER", -150, 0)
  417.        
  418.         self:SpawnHeader(nil, nil, 'custom [group:party] show; [@raid3,exists] hide; [@raid26,exists] hide; hide',
  419.                 'showParty', true, 'showRaid', false, 'showPlayer', false, 'yOffset', -4,
  420.                 'oUF-initialConfigFunction', [[
  421.                         self:SetHeight(24)
  422.                         self:SetWidth(159)
  423.                 ]]
  424.         ):SetPoint('TOP', oUF_opUnitFramesPlayer, 'BOTTOM', 0, -10)
  425. end)
  426.  
  427. -- Most important line in here
  428. oUF:DisableBlizzard('party')
  429.  
  430. local testui = TestUI or function() end
  431. TestUI = function( msg )
  432.     if( msg == "uf" or msg == "unitframes" ) then
  433.         oUF_opUnitFramesTarget:Show(); oUF_opUnitFramesTarget.Hide = function() end; oUF_opUnitFramesTarget.unit = "player"
  434.         oUF_opUnitFramesTargetTarget:Show(); oUF_opUnitFramesTargetTarget.Hide = function() end; oUF_opUnitFramesTargetTarget.unit = "player"
  435.         oUF_opUnitFramesFocus:Show(); oUF_opUnitFramesFocus.Hide = function() end; oUF_opUnitFramesFocus.unit = "player"
  436.         oUF_opUnitFramesPet:Show(); oUF_opUnitFramesPet.Hide = function() end; oUF_opUnitFramesPet.unit = "player"
  437.     elseif( msg == "a" or msg == "arena" ) then
  438.         oUF_opUnitFramesArena1:Show(); oUF_opUnitFramesArena1.Hide = function() end; oUF_opUnitFramesArena1.unit = "player"
  439.         oUF_opUnitFramesArena2:Show(); oUF_opUnitFramesArena2.Hide = function() end; oUF_opUnitFramesArena2.unit = "player"
  440.         oUF_opUnitFramesArena3:Show(); oUF_opUnitFramesArena3.Hide = function() end; oUF_opUnitFramesArena3.unit = "player"
  441.     elseif( msg == "boss" or msg == "b" ) then
  442.         oUF_opUnitFramesBoss1:Show(); oUF_opUnitFramesBoss1.Hide = function() end; oUF_opUnitFramesBoss1.unit = "player"
  443.         oUF_opUnitFramesBoss2:Show(); oUF_opUnitFramesBoss2.Hide = function() end; oUF_opUnitFramesBoss2.unit = "player"
  444.         oUF_opUnitFramesBoss3:Show(); oUF_opUnitFramesBoss3.Hide = function() end; oUF_opUnitFramesBoss3.unit = "player"
  445.     elseif( msg == "buffs" ) then
  446.         UnitAura = function()
  447.             return 139, "Rank 1", "Interface\\Icons\\Spell_Holy_Penance", 1, "Magic", 0, 0, "player"
  448.         end
  449.  
  450.         if( oUF ) then
  451.             for i, v in pairs( oUF.units ) do
  452.                 if( v.UNIT_AURA ) then
  453.                     v:UNIT_AURA( "UNIT_AURA", v.unit )
  454.                 end
  455.             end
  456.         end
  457.     end
  458. end
  459. SlashCmdList.TestUI = TestUI
  460. SLASH_TestUI1 = "/testui"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement