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