-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathComboPoints.lua
150 lines (120 loc) · 4.07 KB
/
ComboPoints.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
--[[ ArenaLive Core Functions: ComboPoint Handler
Created by: Vadrak
Creation Date: 21.06.2013
Last Update: "
TargetIndicator is used to indicate which unit the player is currently targeting.
Usually a border is shown around the frames to indicate that.
]]--
local addonName = "ArenaLiveCore";
-- Local version is said to be faster.
local ArenaLiveCore = ArenaLiveCore;
-- Set up a new handler.
local ComboPoints = ArenaLiveCore:AddHandler("ComboPoints", "EventCore");
-- Get the global UnitFrame handler.
local UnitFrame = ArenaLiveCore:GetHandler("UnitFrame");
-- Register the handler for all needed events.
ComboPoints:RegisterEvent("PLAYER_TARGET_CHANGED");
ComboPoints:RegisterEvent("PLAYER_COMBO_POINTS");
local function ComboPointShineFadeIn(frame)
-- Fade in the shine and then fade it out with the ComboPointShineFadeOut function
local fadeInfo = {};
fadeInfo.mode = "IN";
fadeInfo.timeToFade = COMBOFRAME_SHINE_FADE_IN;
fadeInfo.finishedFunc = ComboPointShineFadeOut;
fadeInfo.finishedArg1 = frame:GetName();
UIFrameFade(frame, fadeInfo);
end
--hack since a frame can't have a reference to itself in it
local function ComboPointShineFadeOut(frameName)
UIFrameFadeOut(getglobal(frameName), COMBOFRAME_SHINE_FADE_OUT);
end
-- *** FRAME FUNCTIONS ***
local function Update (self)
local unit = self.unitFrame.unit;
if ( not unit ) then
self:Reset();
return;
end
local comboPoints = GetComboPoints("player", unit);
local comboPointShine, comboPointHighlight;
if ( comboPoints > 0 ) then
if ( not self:IsShown() ) then
self:Show();
UIFrameFadeIn(self, COMBOFRAME_FADE_IN);
end
local fadeInfo = {}
for i = 1, 5 do
local comboPoint = self["comboPoint"..i];
local comboPointName = comboPoint:GetName();
if ( comboPointName ) then
comboPointShine = _G[comboPointName.."Shine"];
comboPointHighlight = _G[comboPointName.."Highlight"];
end
if ( i <= comboPoints ) then
comboPoint:Show();
if ( comboPointShine and ( i > self.lastNumComboPoints ) ) then
fadeInfo.mode = "IN";
fadeInfo.timeToFade = COMBOFRAME_HIGHLIGHT_FADE_IN;
fadeInfo.finishedFunc = ComboPointShineFadeIn;
fadeInfo.finishedArg1 = comboPointShine;
UIFrameFade(comboPointHighlight, fadeInfo);
end
else
comboPointHighlight:SetAlpha(0);
comboPointShine:SetAlpha(0);
comboPoint:Hide();
end
end
else
self:Hide();
end
self.lastNumComboPoints = comboPoints;
end
local function Reset (self)
self.comboPoint1:Hide();
self.comboPoint2:Hide();
self.comboPoint3:Hide();
self.comboPoint4:Hide();
self.comboPoint5:Hide();
self.lastNumComboPoints = 0;
self:Hide();
end
-- *** HANDLER FUNCTIONS ***
function ComboPoints:AddFrame (comboPointFrame, comboPoint1, comboPoint2, comboPoint3, comboPoint4, comboPoint5, unitFrame)
-- Create a reference for the target indicator inside the unit frame and vice versa.
unitFrame.comboPoints = comboPointFrame;
comboPointFrame.unitFrame = unitFrame;
-- Create references for combo points
comboPointFrame.comboPoint1 = comboPoint1;
comboPointFrame.comboPoint2 = comboPoint2;
comboPointFrame.comboPoint3 = comboPoint3;
comboPointFrame.comboPoint4 = comboPoint4;
comboPointFrame.comboPoint5 = comboPoint5;
comboPointFrame.lastNumComboPoints = 0;
unitFrame.handlerList.comboPoints = true;
-- Set the basic functions for the castbar.
comboPointFrame.Update = Update;
comboPointFrame.Reset = Reset;
end
--[[ Function: OnEvent
OnEvent function for the threat indicator handler.
Arguments:
event: The event that fired.
...: A list of arguments that accompany the event.
]]--
local affectedFrame;
function ComboPoints:OnEvent (event, ...)
if ( event == "PLAYER_TARGET_CHANGED" or event == "PLAYER_COMBO_POINTS") then
local unit = "target";
if ( UnitFrame.UnitIDTable[unit] ) then
for key, value in pairs(UnitFrame.UnitIDTable[unit]) do
if ( value and UnitFrame.UnitFrameTable[key] ) then
affectedFrame = UnitFrame.UnitFrameTable[key];
if ( affectedFrame.handlerList.comboPoints ) then
affectedFrame.comboPoints:Update();
end
end
end
end
end
end