annotate SkeletonUnit/UnitFrame.lua @ 0:69e828f4238a

Initial Commit
author Nenue
date Mon, 20 Jun 2016 06:35:11 -0400
parents
children cd7d06bcd98d
rev   line source
Nenue@0 1 --------------------------------------------
Nenue@0 2 -- KrakTool
Nenue@0 3 -- Nick
Nenue@0 4 -- @project - r e v i s i o n @ @project-hash@
Nenue@0 5 -- @file - r e v i s i o n @ @file-hash@
Nenue@0 6 -- Created: 6/16/2016 3:46 AM
Nenue@0 7 --------------------------------------------
Nenue@0 8
Nenue@0 9 local KT = select(2,...)
Nenue@0 10 local PLAYER_NAMEPLATE
Nenue@0 11 local PLAYER_WIDTH = 220
Nenue@0 12 local BUFF_SIZE = 24
Nenue@0 13
Nenue@0 14
Nenue@0 15 KT.register(KTplayerFrame)
Nenue@0 16 KTplayerFrame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", "player")
Nenue@0 17 KTplayerFrame:RegisterUnitEvent("UNIT_POWER_FREQUENT", "player")
Nenue@0 18 KTplayerFrame:RegisterUnitEvent("UNIT_AURA", 'player')
Nenue@0 19 KTplayerFrame:RegisterEvent("NAME_PLATE_UNIT_ADDED")
Nenue@0 20 KTplayerFrame:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
Nenue@0 21 KTplayerFrame.event = function(self)
Nenue@0 22 -- print(C_NamePlate.GetNamePlateForUnit('player'))
Nenue@0 23 end
Nenue@0 24
Nenue@0 25 local buttons = {}
Nenue@0 26 local SetupButton = function(self, unit, index)
Nenue@0 27 if not buttons[index] then
Nenue@0 28 buttons[index] = CreateFrame('Frame', 'KT'..unit..'Buff'..index, self, 'KTAuraButton')
Nenue@0 29 buttons[index]:SetSize(BUFF_SIZE, BUFF_SIZE)
Nenue@0 30 buttons[index].cooldown:SetHideCountdownNumbers(true)
Nenue@0 31
Nenue@0 32 end
Nenue@0 33 return buttons[index]
Nenue@0 34 end
Nenue@0 35
Nenue@0 36 KTplayerFrame.UNIT_AURA = function(self, event, unit)
Nenue@0 37 local buffOffset = 0
Nenue@0 38 for i = 1, 16 do
Nenue@0 39 --UnitAura()
Nenue@0 40 local aura, _, texture, count, dispelType, duration, expires, caster = UnitAura(unit, i, nil, 'HELPFUL')
Nenue@0 41 if aura then
Nenue@0 42 local button = SetupButton(self, unit, i)
Nenue@0 43
Nenue@0 44 button.icon:SetTexture(texture)
Nenue@0 45 button.cooldown:SetCooldown(expires - duration, duration)
Nenue@0 46 button.cooldown:Show()
Nenue@0 47 button.count:SetText(count > 0 and count or nil)
Nenue@0 48 button:SetPoint('BOTTOMLEFT', self, 'TOPLEFT', buffOffset* BUFF_SIZE, 2)
Nenue@0 49 button:Show()
Nenue@0 50 buffOffset = buffOffset + 1
Nenue@0 51 else
Nenue@0 52 if buttons[i] then
Nenue@0 53 buttons[i]:Hide()
Nenue@0 54 end
Nenue@0 55 end
Nenue@0 56 end
Nenue@0 57 end
Nenue@0 58
Nenue@0 59 KTplayerFrame.NAME_PLATE_UNIT_ADDED = function(self, event, unit)
Nenue@0 60 print('|cFF008800'..unit)
Nenue@0 61 if UnitIsUnit('player', unit) then
Nenue@0 62 PLAYER_NAMEPLATE = unit
Nenue@0 63 self:ClearAllPoints()
Nenue@0 64 self:SetPoint('TOP', C_NamePlate.GetNamePlateForUnit(unit), 'BOTTOM', 0, 0)
Nenue@0 65 end
Nenue@0 66 end
Nenue@0 67 KTplayerFrame.NAME_PLATE_UNIT_REMOVED = function(self, event, unit)
Nenue@0 68 if unit == PLAYER_NAMEPLATE then
Nenue@0 69 PLAYER_NAMEPLATE = nil
Nenue@0 70 self:ClearAllPoints()
Nenue@0 71 self:SetPoint('LEFT', UIParent, 'LEFT', 25, 0)
Nenue@0 72 end
Nenue@0 73 end
Nenue@0 74
Nenue@0 75 KTplayerFrame.UNIT_HEALTH_FREQUENT = function(self, ...)
Nenue@0 76 --print(UnitHealth('player') / UnitHealthMax('player'))
Nenue@0 77 self.healthbar:SetWidth(PLAYER_WIDTH * UnitHealth('player') / UnitHealthMax('player'))
Nenue@0 78 return true
Nenue@0 79 end
Nenue@0 80
Nenue@0 81 KTplayerFrame.UNIT_POWER_FREQUENT = function(self)
Nenue@0 82 self.powerbar:SetWidth(PLAYER_WIDTH * UnitPower('player') / UnitPowerMax('player'))
Nenue@0 83 return true
Nenue@0 84 end
Nenue@0 85
Nenue@0 86 KTplayerFrame:SetWidth(PLAYER_WIDTH)
Nenue@0 87 KTplayerFrame.variables = function()
Nenue@0 88 KTplayerFrame:UNIT_HEALTH_FREQUENT()
Nenue@0 89 KTplayerFrame:UNIT_POWER_FREQUENT()
Nenue@0 90 end