Nenue@0: -------------------------------------------- Nenue@0: -- KrakTool Nenue@0: -- Nick Nenue@0: -- @project - r e v i s i o n @ @project-hash@ Nenue@0: -- @file - r e v i s i o n @ @file-hash@ Nenue@0: -- Created: 6/16/2016 3:46 AM Nenue@0: -------------------------------------------- Nenue@0: Nenue@0: local KT = select(2,...) Nenue@0: local PLAYER_NAMEPLATE Nenue@0: local PLAYER_WIDTH = 220 Nenue@0: local BUFF_SIZE = 24 Nenue@0: Nenue@0: Nenue@0: KT.register(KTplayerFrame) Nenue@0: KTplayerFrame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", "player") Nenue@0: KTplayerFrame:RegisterUnitEvent("UNIT_POWER_FREQUENT", "player") Nenue@0: KTplayerFrame:RegisterUnitEvent("UNIT_AURA", 'player') Nenue@0: KTplayerFrame:RegisterEvent("NAME_PLATE_UNIT_ADDED") Nenue@0: KTplayerFrame:RegisterEvent("NAME_PLATE_UNIT_REMOVED") Nenue@0: KTplayerFrame.event = function(self) Nenue@0: -- print(C_NamePlate.GetNamePlateForUnit('player')) Nenue@0: end Nenue@0: Nenue@0: local buttons = {} Nenue@0: local SetupButton = function(self, unit, index) Nenue@0: if not buttons[index] then Nenue@0: buttons[index] = CreateFrame('Frame', 'KT'..unit..'Buff'..index, self, 'KTAuraButton') Nenue@0: buttons[index]:SetSize(BUFF_SIZE, BUFF_SIZE) Nenue@0: buttons[index].cooldown:SetHideCountdownNumbers(true) Nenue@0: Nenue@0: end Nenue@0: return buttons[index] Nenue@0: end Nenue@0: Nenue@0: KTplayerFrame.UNIT_AURA = function(self, event, unit) Nenue@0: local buffOffset = 0 Nenue@0: for i = 1, 16 do Nenue@0: --UnitAura() Nenue@0: local aura, _, texture, count, dispelType, duration, expires, caster = UnitAura(unit, i, nil, 'HELPFUL') Nenue@0: if aura then Nenue@0: local button = SetupButton(self, unit, i) Nenue@0: Nenue@0: button.icon:SetTexture(texture) Nenue@0: button.cooldown:SetCooldown(expires - duration, duration) Nenue@0: button.cooldown:Show() Nenue@0: button.count:SetText(count > 0 and count or nil) Nenue@0: button:SetPoint('BOTTOMLEFT', self, 'TOPLEFT', buffOffset* BUFF_SIZE, 2) Nenue@0: button:Show() Nenue@0: buffOffset = buffOffset + 1 Nenue@0: else Nenue@0: if buttons[i] then Nenue@0: buttons[i]:Hide() Nenue@0: end Nenue@0: end Nenue@0: end Nenue@0: end Nenue@0: Nenue@0: KTplayerFrame.NAME_PLATE_UNIT_ADDED = function(self, event, unit) Nenue@0: print('|cFF008800'..unit) Nenue@0: if UnitIsUnit('player', unit) then Nenue@0: PLAYER_NAMEPLATE = unit Nenue@0: self:ClearAllPoints() Nenue@0: self:SetPoint('TOP', C_NamePlate.GetNamePlateForUnit(unit), 'BOTTOM', 0, 0) Nenue@0: end Nenue@0: end Nenue@0: KTplayerFrame.NAME_PLATE_UNIT_REMOVED = function(self, event, unit) Nenue@0: if unit == PLAYER_NAMEPLATE then Nenue@0: PLAYER_NAMEPLATE = nil Nenue@0: self:ClearAllPoints() Nenue@0: self:SetPoint('LEFT', UIParent, 'LEFT', 25, 0) Nenue@0: end Nenue@0: end Nenue@0: Nenue@0: KTplayerFrame.UNIT_HEALTH_FREQUENT = function(self, ...) Nenue@0: --print(UnitHealth('player') / UnitHealthMax('player')) Nenue@0: self.healthbar:SetWidth(PLAYER_WIDTH * UnitHealth('player') / UnitHealthMax('player')) Nenue@0: return true Nenue@0: end Nenue@0: Nenue@0: KTplayerFrame.UNIT_POWER_FREQUENT = function(self) Nenue@0: self.powerbar:SetWidth(PLAYER_WIDTH * UnitPower('player') / UnitPowerMax('player')) Nenue@0: return true Nenue@0: end Nenue@0: Nenue@0: KTplayerFrame:SetWidth(PLAYER_WIDTH) Nenue@0: KTplayerFrame.variables = function() Nenue@0: KTplayerFrame:UNIT_HEALTH_FREQUENT() Nenue@0: KTplayerFrame:UNIT_POWER_FREQUENT() Nenue@0: end