Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Work in progress
- Thanks to
- p3lim
- haste
- zork
- Phanx
- To do:
- Make status text into icons
- ex: Offline into thunderbolt slashed in 2
- ]]--
- -- Variables
- local addon, ns = ...
- local oUF = ns.oUF or oUF
- --local playerClass = select(3, UnitClass('player'))
- -- Closest thing to a config
- local FONT = 'Interface\\AddOns\\oUF_Opie\\HOOG0557.ttf'
- local FONTSIZE = 8
- local FONTSTYLE = 'OUTLINE|MONOCHROME'
- local TEXTURE = 'Interface\\ChatFrame\\ChatFrameBackground'
- local BACKDROP = {
- bgFile = TEXTURE, insets = {top = -1, bottom = -1, left = -1, right = -1}
- }
- local BARTEXTURE = 'Interface\\AddOns\\oUF_Opie\\tap2.tga'
- -- End of closest thing to a config
- --[[
- Makes the background of the healthbar classcolored, or falls back to bright red
- --]]
- local function Health_PostUpdate(bar, unit, health, maxHealth)
- local _, class = UnitClass(unit)
- local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class or ""]
- if color then
- bar.bg:SetVertexColor(color.r, color.g, color.b)
- else
- -- Fall back to red
- bar.bg:SetVertexColor(1, 0, 0)
- end
- end
- --[[
- This entire block is taken from p3lim, with slight modifications where necessary to fit my needs
- --]]
- local function UpdateAura(self, elapsed)
- if(self.expiration) then
- if(self.expiration < 60) then
- self.remaining:SetFormattedText('%d', self.expiration)
- else
- self.remaining:SetText()
- end
- self.expiration = self.expiration - elapsed
- end
- end
- local function PostCreateAura(element, button)
- button:SetBackdrop(BACKDROP)
- button:SetBackdropColor(0, 0, 0)
- button.cd:SetReverse()
- button.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
- button.icon:SetDrawLayer('ARTWORK')
- button.count:SetPoint('BOTTOMRIGHT', 2, 1)
- button.count:SetFont(FONT, 8, 'OUTLINEMONOCHROME')
- local remaining = button:CreateFontString(nil, 'OVERLAY')
- remaining:SetPoint('TOPLEFT', 0, -1)
- remaining:SetFont(FONT, 8, 'OUTLINEMONOCROME')
- remaining:SetAlpha(0)
- button.remaining = remaining
- button:HookScript('OnUpdate', UpdateAura)
- end
- local function PostUpdateBuff(element, unit, button, index)
- local _, _, _, _, _, duration, expiration = UnitAura(unit, index, button.filter)
- if(duration and duration > 0) then
- button.expiration = expiration - GetTime()
- else
- button.expiration = math.huge
- end
- end
- local function PostUpdateDebuff(element, unit, button, index)
- local _, _, _, _, type, _, _, owner = UnitAura(unit, index, button.filter)
- if(owner == 'player') then
- local color = DebuffTypeColor[type or 'none']
- button:SetBackdropColor(color.r * 3/5, color.g * 3/5, color.b * 3/5)
- button.icon:SetDesaturated(false)
- else
- button:SetBackdropColor(0, 0, 0)
- button.icon:SetDesaturated(true)
- end
- PostUpdateBuff(element, unit, button, index)
- end
- local FilterPlayerBuffs
- do
- local spells = {
- -- Druid
- [5217] = true, -- Tiger's Fury
- [52610] = true, -- Savage Roar
- [106951] = true, -- Berserk
- [127538] = true, -- Savage Roar (glyphed)
- [124974] = true, -- Nature's Vigil
- [132158] = true, -- Nature's Swiftness
- [132402] = true, -- Savage Defense
- -- Rogue
- [5171] = true, -- Slice and Dice
- [31224] = true, -- Cloak of Shadows
- [32645] = true, -- Envenom
- [73651] = true, -- Recuperate
- [121471] = true, -- Shadow Blades
- [115189] = true, -- Anticipation
- -- Death Knight
- [48707] = true, -- Anti-Magic Shell
- [51271] = true, -- Pillar of Frost
- [53365] = true, -- Rune of the Fallen Crusader
- -- Shared
- [32182] = true, -- Heroism
- [57933] = true, -- Tricks of the Trade
- [80353] = true, -- Time Warp
- }
- if(select(2, UnitClass('player')) == 'DEATHKNIGHT') then
- spells[57330] = true -- Horn of Winter
- end
- function FilterPlayerBuffs(...)
- local _, _, _, _, _, _, _, _, _, _, _, _, _, id = ...
- return spells[id]
- end
- end
- local FilterTargetDebuffs
- do
- local show = {
- [1490] = true, -- Curse of Elements (Magic Vulnerability)
- [58410] = true, -- Master Poisoner (Magic Vulnerability)
- [81326] = true, -- Physical Vulnerability (Shared)
- [113746] = true, -- Weakened Armor (Shared)
- }
- local hide = {
- [770] = true, -- Faerie Fire
- [58180] = true, -- Infected Wounds
- [115798] = true, -- Weakened Blows
- }
- function FilterTargetDebuffs(...)
- local _, unit, _, _, _, _, _, _, _, _, owner, _, _, id = ...
- if(owner == 'player' and hide[id]) then
- return false
- elseif(owner == 'player' or owner == 'vehicle' or UnitIsFriend('player', unit) or show[id] or not owner) then
- return true
- end
- end
- end
- -- Have to define UnitSpecific variable here so Shared has access to it or all things break
- local UnitSpecific
- -- Engine!
- local function Shared(self, unit)
- unit = unit:match('(boss)%d?$') or unit
- self.colors.power.MANA = {1, 1, 1}
- self:RegisterForClicks('AnyUp')
- self:SetScript('OnEnter', UnitFrame_OnEnter)
- self:SetScript('OnLeave', UnitFrame_OnLeave)
- self:SetBackdrop(BACKDROP)
- self:SetBackdropColor(0, 0, 0)
- local Buffs = CreateFrame('Frame', nil, self)
- self.Buffs = Buffs
- local Debuffs = CreateFrame('Frame', nil, self)
- self.Debuffs = Debuffs
- local Health = CreateFrame('StatusBar', nil, self)
- Health:SetStatusBarTexture(BARTEXTURE)
- Health:SetStatusBarColor(53/255, 53/255, 53/255)
- Health.frequentUpdates = true
- self.Health = Health
- local HealthBG = Health:CreateTexture(nil, 'BORDER')
- HealthBG:SetAllPoints()
- HealthBG:SetTexture(BARTEXTURE)
- Health.bg = HealthBG
- Health.PostUpdate = Health_PostUpdate
- local HealthValue = Health:CreateFontString(nil, 'OVERLAY')
- HealthValue:SetPoint('RIGHT', -7, -1)
- HealthValue:SetFont(FONT, FONTSIZE, FONTSTYLE)
- HealthValue:SetJustifyH('RIGHT')
- HealthValue.frequentUpdates = 1/4
- self.HealthValue = HealthValue
- local PowerValue = self.Health:CreateFontString(nil, 'OVERLAY')
- if(unit=='player' or unit=='party') then
- PowerValue:SetFont(FONT, FONTSIZE, FONTSTYLE)
- PowerValue:SetJustifyH('LEFT')
- PowerValue.frequentUpdates = 0.1
- if(unit=='player') then
- self:Tag(PowerValue, '[oppower]')
- PowerValue:SetPoint('LEFT', 7, -1)
- PowerValue:SetPoint('RIGHT', self.HealthValue, 'LEFT', -3)
- else
- self:Tag(PowerValue, '[oppartypp]')
- PowerValue:SetPoint('LEFT', 7, 0)
- PowerValue:SetPoint('RIGHT', self.HealthValue, 'LEFT', -3)
- HealthValue:SetPoint('RIGHT', -7, 0)
- end
- end
- if(unit == 'player' or unit == 'target' or 'targettarget') then
- local Power = CreateFrame('StatusBar', nil, self)
- if(unit == 'player') then
- Power:SetPoint('TOPRIGHT')
- Power:SetPoint('TOPLEFT')
- Power:SetPoint('BOTTOM', Health, 'TOP', 0, 1)
- Health:SetPoint('BOTTOMRIGHT')
- Health:SetPoint('BOTTOMLEFT')
- Buffs:SetPoint('RIGHT', self, 'LEFT', -5, -2)
- Buffs:SetSize(236, 44)
- Buffs.num = 20
- Buffs.size = 20
- Buffs.spacing = 5
- Buffs.initialAnchor = 'RIGHT'
- Buffs['growth-y'] = 'DOWN'
- Buffs['growth-x'] = 'LEFT'
- Buffs.PostCreateIcon = PostCreateAura
- self.Buffs.CustomFilter = FilterPlayerBuffs
- self.Buffs = Buffs
- self.Debuffs.size = 20
- self.Debuffs:SetSize(230, 22)
- self.Debuffs.PostUpdateIcon = PostUpdateBuff
- self.Buffs.PostUpdateIcon = PostUpdateBuff
- else
- Power:SetPoint('BOTTOMRIGHT')
- Power:SetPoint('BOTTOMLEFT')
- Power:SetPoint('TOP', Health, 'BOTTOM', 0, -1)
- Health:SetPoint('TOPRIGHT')
- Health:SetPoint('TOPLEFT')
- self.Debuffs.size = 22
- self.Debuffs['growth-y'] = 'UP'
- self.Debuffs['growth-x'] = 'LEFT'
- self.Debuffs:SetPoint('BOTTOMLEFT', self, 'TOPRIGHT', -22, 3)
- self.Debuffs:SetSize(159, 22)
- self.Debuffs.PostUpdateIcon = PostUpdateDebuff
- self.Debuffs.CustomFilter = FilterTargetDebuffs
- end
- Power:SetStatusBarTexture(BARTEXTURE)
- Power:SetStatusBarColor(188/255, 188/255, 188/255)
- Power.frequentUpdates = true
- self.Power = Power
- local PowerBG = Power:CreateTexture(nil, 'BORDER')
- PowerBG:SetAllPoints()
- PowerBG:SetTexture(BARTEXTURE)
- PowerBG:SetVertexColor(75/255, 75/255, 75/255)
- Power.bg = PowerBG
- local RaidIcon = Health:CreateTexture(nil, 'OVERLAY')
- RaidIcon:SetPoint('TOP', self, 0, 8)
- RaidIcon:SetSize(16, 16)
- self.RaidIcon = RaidIcon
- Health:SetHeight(20)
- self:SetHeight(24)
- end
- if(unit ~= 'player' and unit ~= 'party' and unit ~= 'raid') then
- local Name = Health:CreateFontString(nil, 'OVERLAY')
- if(unit=='pet') then
- Name:SetPoint('LEFT', 7, 0)
- Name:SetPoint('RIGHT', HealthValue, 'LEFT')
- else
- Name:SetPoint('LEFT', 7, -1)
- Name:SetPoint('RIGHT', HealthValue, 'LEFT')
- end
- Name:SetFont(FONT, FONTSIZE, FONTSTYLE)
- Name:SetJustifyH('LEFT')
- self:Tag(Name, '[opname]')
- Debuffs.spacing = 4
- Debuffs.initialAnchor = 'TOPLEFT'
- Debuffs.PostCreateIcon = PostCreateAura
- end
- if(unit ~= 'party' and unit ~= 'raid' and unit ~= 'boss') then
- if(unit == 'focus') then
- Health:SetAllPoints()
- self.Tag(HealthValue, '[ophealth]')
- HealthValue:SetPoint('RIGHT', -7, 0)
- elseif(unit == 'pet') then
- Health:SetAllPoints()
- self:SetSize(120, 18)
- end
- end
- if(unit == 'targettarget') then
- self:SetBackdrop(BACKDROP)
- self:SetBackdropColor(0, 0, 0)
- end
- if(UnitSpecific[unit]) then
- return UnitSpecific[unit](self)
- end
- end
- UnitSpecific = {
- player = function(self)
- local AltPower = CreateFrame('StatusBar', nil, self)
- AltPower:SetPoint('TOPLEFT', 6, 7)
- AltPower:SetSize(170, 6)
- AltPower:SetStatusBarTexture(BARTEXTURE)
- AltPower:SetStatusBarColor(0.15, 0.7, 0.1)
- AltPower:SetBackdrop(BACKDROP)
- AltPower:SetBackdropColor(0, 0, 0)
- AltPower:EnableMouse(true)
- AltPower.colorTexture = true
- self.AltPowerBar = AltPower
- local AltPowerBG = AltPower:CreateTexture(nil, 'BORDER')
- AltPowerBG:SetAllPoints()
- AltPowerBG:SetTexture(1/3, 1/3, 1/3)
- self:Tag(self.HealthValue, '[opstatus][opphealth]')
- self:SetWidth(159)
- end,
- target = function(self)
- self:Tag(self.HealthValue, '[ophealth]')
- self:SetWidth(159)
- end,
- targettarget = function(self)
- self:Tag(self.HealthValue, '[ophealth]')
- self:SetWidth(100)
- self.Debuffs.onlyShowPlayer = true
- end,
- party = function(self)
- local Name = self.Health:CreateFontString(nil, 'OVERLAY')
- Name:SetPoint('CENTER', 0, 0)
- Name:SetPoint('CENTER', self, 'CENTER')
- Name:SetFont(FONT, FONTSIZE, FONTSTYLE)
- Name:SetJustifyH('CENTER')
- self:Tag(Name, '[opname]')
- local RoleIcon = self:CreateTexture(nil, 'ARTWORK')
- RoleIcon:SetPoint('LEFT', self, 'RIGHT', 3, 0)
- RoleIcon:SetSize(14, 14)
- RoleIcon:SetAlpha(1)
- self.LFDRole = RoleIcon
- local ReadyCheck = self:CreateTexture(nil, 'OVERLAY')
- ReadyCheck:SetPoint('LEFT', self, 'RIGHT', 3, 0)
- ReadyCheck:SetSize(14, 14)
- self.ReadyCheck = ReadyCheck
- self:HookScript('OnEnter', function() RoleIcon:SetAlpha(1) end)
- self:HookScript('OnLeave', function() RoleIcon:SetAlpha(0) end)
- self.Tag(HealthValue, '[ophealth]')
- self.Health:SetAllPoints()
- end,
- boss = function(self)
- self:SetSize(126, 19)
- self.Health:SetAllPoints()
- self:Tag(self.HealthValue, '[perhp]')
- end,
- focus = function(self)
- self:SetSize(150, 24)
- end
- }
- --UnitSpecific.raid = UnitSpecific.party
- oUF:RegisterStyle('opUnitFrames', Shared)
- oUF:Factory(function(self)
- -- Single Frames
- self:SetActiveStyle('opUnitFrames')
- self:Spawn('player'):SetPoint("BOTTOM",UIParent,"BOTTOM", 0, 279)
- self:Spawn('target'):SetPoint("BOTTOM",UIParent,"BOTTOM", 0, 279+70)
- self:Spawn('targettarget'):SetPoint("RIGHT", oUF_opUnitFramesTarget,"LEFT", -7, 0)
- self:Spawn('pet'):SetPoint("TOPLEFT",UIParent,"TOPLEFT", 5, -5)
- self:Spawn('focus'):SetPoint("RIGHT",UIParent,"CENTER", -150, 0)
- self:SpawnHeader(nil, nil, 'custom [group:party] show; [@raid3,exists] hide; [@raid26,exists] hide; hide',
- 'showParty', true, 'showRaid', false, 'showPlayer', false, 'yOffset', -4,
- 'oUF-initialConfigFunction', [[
- self:SetHeight(24)
- self:SetWidth(159)
- ]]
- ):SetPoint('TOP', oUF_opUnitFramesPlayer, 'BOTTOM', 0, -10)
- end)
- -- Most important line in here
- oUF:DisableBlizzard('party')
- local testui = TestUI or function() end
- TestUI = function( msg )
- if( msg == "uf" or msg == "unitframes" ) then
- oUF_opUnitFramesTarget:Show(); oUF_opUnitFramesTarget.Hide = function() end; oUF_opUnitFramesTarget.unit = "player"
- oUF_opUnitFramesTargetTarget:Show(); oUF_opUnitFramesTargetTarget.Hide = function() end; oUF_opUnitFramesTargetTarget.unit = "player"
- oUF_opUnitFramesFocus:Show(); oUF_opUnitFramesFocus.Hide = function() end; oUF_opUnitFramesFocus.unit = "player"
- oUF_opUnitFramesPet:Show(); oUF_opUnitFramesPet.Hide = function() end; oUF_opUnitFramesPet.unit = "player"
- elseif( msg == "a" or msg == "arena" ) then
- oUF_opUnitFramesArena1:Show(); oUF_opUnitFramesArena1.Hide = function() end; oUF_opUnitFramesArena1.unit = "player"
- oUF_opUnitFramesArena2:Show(); oUF_opUnitFramesArena2.Hide = function() end; oUF_opUnitFramesArena2.unit = "player"
- oUF_opUnitFramesArena3:Show(); oUF_opUnitFramesArena3.Hide = function() end; oUF_opUnitFramesArena3.unit = "player"
- elseif( msg == "boss" or msg == "b" ) then
- oUF_opUnitFramesBoss1:Show(); oUF_opUnitFramesBoss1.Hide = function() end; oUF_opUnitFramesBoss1.unit = "player"
- oUF_opUnitFramesBoss2:Show(); oUF_opUnitFramesBoss2.Hide = function() end; oUF_opUnitFramesBoss2.unit = "player"
- oUF_opUnitFramesBoss3:Show(); oUF_opUnitFramesBoss3.Hide = function() end; oUF_opUnitFramesBoss3.unit = "player"
- elseif( msg == "buffs" ) then
- UnitAura = function()
- return 139, "Rank 1", "Interface\\Icons\\Spell_Holy_Penance", 1, "Magic", 0, 0, "player"
- end
- if( oUF ) then
- for i, v in pairs( oUF.units ) do
- if( v.UNIT_AURA ) then
- v:UNIT_AURA( "UNIT_AURA", v.unit )
- end
- end
- end
- end
- end
- SlashCmdList.TestUI = TestUI
- SLASH_TestUI1 = "/testui"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement