idUnitframes = AceLibrary('AceAddon-2.0'):new('AceDB-2.0', 'AceEvent-2.0', 'AceHook-2.0') idUnitframes.Frames = {} function idUnitframes:OnEnable() -- Some vars self.Globalscale = 1 self.Globalalpha = 1 self.Backgroundpadding = 5 self.Backgroundposition = { x = 100, y = 100 } self.Healthbarwidth = 150 self.Healthbarheight = 15 self.Healthbartexture = 'Interface\\AddOns\\idUnitframes\\textures\\bar' self.Healthbarcolor = { r1 = 49/255, g1 = 227/255, b1 = 37/255 } self.Powerbarwidth = 150 self.Powerbarheight = 15 self.Powerbartexture = 'Interface\\AddOns\\idUnitframes\\textures\\bar' self.Powerbarcolor = { r1 = 49/255, g1 = 37/255, b1 = 227/255 } self.Classnames = { Druid = 'Dru', Hunter = 'Hun', Mage = 'Mag', Paladin = 'Pal', Priest = 'Pri', Rogue = 'Rog', Shaman = 'Shm', Warlock = 'Wlk', Warrior = 'War' } self:createPlayerframe() --self:createPetframe() --self:createTargetframe() --self:createTargettargetframe() self.Frames.Player:Show() --self.Frames.Pet:Show() --self.Frames.Target:Show() --self.Frames.Targettarget:Show() end function idUnitframes:OnDisable() end function idUnitframes:createPlayerframe() self.Frames.Player = self:newFrame() self.Frames.Player:ClearAllPoints() self.Frames.Player:SetPoint('CENTER', UIParent, 'CENTER') self:RegisterEvent('UNIT_HEALTH', function() if arg1 == 'player' then self:updateHealth('player') end end) self:RegisterEvent('UNIT_MAX_HEALTH', function() if arg1 == 'player' then self:updateHealth('player') end end) end function idUnitframes:createPetframe() end function idUnitframes:createTargetframe() end function idUnitframes:createTargettargetframe() end function idUnitframes:newFrame() local Font, _, _ = GameFontHighlightSmall:GetFont() local Background = CreateFrame('Frame', name, UIParent) local Healthbar = CreateFrame('StatusBar', nil, Background) local Powerbar = CreateFrame('StatusBar', nil, Background) local Name = Background:CreateFontString(nil, 'OVERLAY') Healthbar:SetWidth(self.Healthbarwidth) Healthbar:SetHeight(self.Healthbarheight) Healthbar:SetScale(self.Globalscale) Healthbar:SetAlpha(self.Globalalpha) Healthbar:SetStatusBarTexture(self.Healthbartexture) Healthbar:SetStatusBarColor(self.Healthbarcolor.r1, self.Healthbarcolor.g1, self.Healthbarcolor.b1) Powerbar:SetWidth(self.Powerbarwidth) Powerbar:SetHeight(self.Powerbarheight) Powerbar:SetScale(self.Globalscale) Powerbar:SetAlpha(self.Globalalpha) Powerbar:SetStatusBarTexture(self.Powerbartexture) Powerbar:SetStatusBarColor(self.Powerbarcolor.r1, self.Powerbarcolor.g1, self.Powerbarcolor.b1) Background:SetWidth(self.Backgroundpadding*3 + self.Healthbarwidth + self.Powerbarwidth) Background:SetHeight(self.Backgroundpadding*2 + self.Healthbarheight) Background:SetScale(self.Globalscale) Background:SetAlpha(self.Globalalpha) Background:SetBackdrop({ bgFile = 'Interface\\Tooltips\\UI-Tooltip-Background', edgeFile = '', edgeSize = 0, tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0} }) Background:SetBackdropColor(0,0,0,0.6) Name:SetFontObject(GameFontNormal) Name:SetFont(Font, 11) Name:SetHeight(Background:GetHeight()) Name:SetWidth(Healthbar:GetWidth()) Name:SetTextColor(1, 1, 1) Name:SetJustifyH('RIGHT') Name:SetJustifyV('CENTER') Name:SetText(string.format('%s %s %s', UnitName('player'), UnitLevel('player'), self.Classnames[UnitClass('player')])) Healthbar:SetPoint('TOPLEFT', Background, 'TOPLEFT', self.Backgroundpadding, -self.Backgroundpadding) Powerbar:SetPoint('LEFT', Healthbar, 'RIGHT', self.Backgroundpadding, 0) Name:SetPoint('RIGHT', Background, 'LEFT', -self.Backgroundpadding, 0) return Background end function idUnitframes:updateHealth(Unit) local Health = UnitHealth(Unit) local Maxhealth = UnitHealthMax(Unit) local r1,g1,b1 = self.Healthbarcolor.r1, self.Healthbarcolor.g1, self.Healthbarcolor.b1 self.Frames[Unit].Healthbar:SetStatusBarColor(r1, g1, b1, 1) self.Frames[Unit].Healthbar:SetMinMaxValues(0, Maxhealth) self.Frames[Unit].Healthbar:SetValue(Health) end