forked from Schaka/ArenaLive-TBC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPartyFrames.lua
267 lines (224 loc) · 10.1 KB
/
PartyFrames.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
local addonName = "ArenaLiveUnitFrames";
local function PartyFrameOnUpdate(self, elapsed)
if ( self.unit and UnitExists(self.unit) ) then
if ( UnitInRange(self.unit) ) then
self:SetAlpha(1);
else
self:SetAlpha(0.8);
end
end
end
local function PartyTargetOnUpdate(self, elapsed)
if ( self.unit ) then
local guid = UnitGUID(self.unit);
if ( UnitExists(self.unit) and guid ~= self.guid ) then
self:SetUnitGUID(self.unit);
self:Update();
end
end
end
local function InitialisePartyTargetFrame(self, parent)
parent.targetFrame = self;
parent.handlerList.targetFrame = "targetFrame";
local prefix = self:GetName();
local frameType = "PartyTargetFrame";
local onRightClick = nil;
local healthBar = _G[prefix.."HealthBar"];
local powerBar = _G[prefix.."PowerBar"];
local portrait = _G[prefix.."Portrait"];
local name = _G[prefix.."Name"];
ArenaLiveCore:AddFrame(self, "UnitFrame", addonName, frameType, onRightClick, false, false);
ArenaLiveCore:AddFrame(healthBar, "HealthBar", self, true);
ArenaLiveCore:AddFrame(powerBar, "PowerBar", self, true);
ArenaLiveCore:AddFrame(portrait, "Portrait", _G[prefix.."PortraitTexture"], _G[prefix.."Portrait3D"], self);
ArenaLiveCore:AddFrame(name, "NameText", self);
self:SetUnit("targettarget");
self:SetScript("OnUpdate", PartyTargetOnUpdate);
self:SetAttribute("alframelock", true);
end
local function InitialisePartyPetFrame(self, parent)
parent.petFrame = self;
parent.handlerList.petFrame = "petFrame";
local prefix = self:GetName();
local frameType = "PartyPetFrame";
local onRightClick = nil;
local healthBar = _G[prefix.."HealthBar"];
local healthBarText = _G[prefix.."HealthBarText"];
local portrait = _G[prefix.."Portrait"];
local name = _G[prefix.."Name"];
ArenaLiveCore:AddFrame(self, "UnitFrame", addonName, frameType, onRightClick, false, false);
ArenaLiveCore:AddFrame(_G[prefix.."TargetIndicator"], "TargetIndicator", self);
ArenaLiveCore:AddFrame(healthBar, "HealthBar", self, true);
ArenaLiveCore:AddFrame(healthBarText, "StatusBarText", "HealthBarText", "DEAD_OR_GHOST", nil, true, self);
ArenaLiveCore:AddFrame(portrait, "Portrait", _G[prefix.."PortraitTexture"], _G[prefix.."Portrait3D"], self);
ArenaLiveCore:AddFrame(name, "NameText", self);
self:SetAttribute("alframelock", true);
end
local function InitialisePartyFrame(self)
local prefix = self:GetName();
local frameType = "PartyFrames";
local onRightClick = "togglemenu";
local healthBar = _G[prefix.."HealthBar"];
local powerBar = _G[prefix.."PowerBar"];
local portrait = _G[prefix.."Portrait"];
local name = _G[prefix.."Name"];
local levelText = _G[prefix.."LevelText"];
local icon1 = _G[prefix.."Icon1"];
local icon2 = _G[prefix.."Icon2"];
local ccIndicator = _G[prefix.."PortraitOverlay"];
local id = self:GetID();
ArenaLiveCore:AddFrame(self, "UnitFrame", addonName, frameType, onRightClick, false, true);
ArenaLiveCore:AddFrame(_G[prefix.."TargetIndicator"], "TargetIndicator", self);
ArenaLiveCore:AddFrame(healthBar, "HealthBar", self, true);
ArenaLiveCore:AddFrame (_G[prefix.."HealthBarText"], "StatusBarText", "HealthBarText", "DEAD_OR_GHOST", nil, true, self);
ArenaLiveCore:AddFrame(powerBar, "PowerBar", self, false);
ArenaLiveCore:AddFrame (_G[prefix.."PowerBarText"], "StatusBarText", "PowerBarText", nil, true, nil, self)
ArenaLiveCore:AddFrame(portrait, "Portrait", _G[prefix.."PortraitTexture"], _G[prefix.."Portrait3D"], self);
ArenaLiveCore:AddFrame(name, "NameText", self);
ArenaLiveCore:AddFrame(levelText, "LevelText", nil, "(%s)", self);
ArenaLiveCore:AddFrame(icon1, "Icon", _G[prefix.."Icon1Texture"], _G[prefix.."Icon1Cooldown"], _G[prefix.."Icon1CooldownText"], self);
ArenaLiveCore:AddFrame(icon2, "Icon", _G[prefix.."Icon2Texture"], _G[prefix.."Icon2Cooldown"], _G[prefix.."Icon2CooldownText"], self);
ArenaLiveCore:AddFrame(ccIndicator, "CCIndicator", _G[prefix.."PortraitOverlayIcon"], _G[prefix.."PortraitOverlayCooldown"], _G[prefix.."PortraitOverlayCooldownText"], self);
ArenaLiveCore:AddFrame(_G[prefix.."CastBar"], "CastBar", _G[prefix.."CastBarBorder"], _G[prefix.."CastBarBorderShieldGlow"], _G[prefix.."CastBarIcon"], _G[prefix.."CastBarText"], true, true, self);
ArenaLiveCore:AddFrame (_G[prefix.."AuraFrame"], "Aura", _G[prefix.."AuraFrameBuffFrame"], _G[prefix.."AuraFrameDebuffFrame"], "ArenaLive_BuffTemplate", "ArenaLive_DebuffTemplate", self);
ArenaLiveCore:AddFrame(_G[prefix.."PVPIcon"], "PvPIcon", 24, 24, "HORIZONTAL", self);
ArenaLiveCore:AddFrame(_G[prefix.."LeaderIcon"], "LeaderIcon", 16, 16, "HORIZONTAL", self);
ArenaLiveCore:AddFrame(_G[prefix.."MasterLooterIcon"], "MasterLooterIcon", 16, 16, "HORIZONTAL", self);
ArenaLiveCore:AddFrame(_G[prefix.."ReadyCheck"], "ReadyCheck", self);
-- Initialise Pet and party target frames.
InitialisePartyTargetFrame(_G[prefix.."TargetFrame"], self);
InitialisePartyPetFrame(_G[prefix.."PetFrame"], self);
-- Party Frame OnUpdate script:
self:SetScript("OnUpdate", PartyFrameOnUpdate);
end
function ALUF_PartyFrames:Initialise()
local prefix = self:GetName();
local scale = ArenaLiveCore:GetDBEntry(addonName, "PartyFrames/Scale");
scale = scale / 100;
self:SetScale(scale);
ArenaLiveCore:AddFrame(self, "PartyHeader", addonName, "PartyFrames", _G["ALUF_PartyFrame1"], _G["ALUF_PartyFrame2"], _G["ALUF_PartyFrame3"], _G["ALUF_PartyFrame4"])
ArenaLiveCore:AddFrame(_G[prefix.."Mover"], "FrameMover", _G[prefix.."MoverText"], self);
local frame --[[= _G["ALUF_PartyPlayerFrame"];
InitialisePartyFrame(frame);]]
for i = 1, 4 do
frame = _G["ALUF_PartyFrame"..i]
InitialisePartyFrame(frame);
end
end
function ALUF_PartyFrames:Toggle()
local enabled = ArenaLiveCore:GetDBEntry("ArenaLiveUnitFrames", self.frameType.."/Enabled");
if ( enabled ) then
self:Enable();
else
self:Disable();
end
-- Set/Reset party frames
local frame --[[= self["partyPlayerFrame"]
local petFrame = frame.petFrame;
local targetFrame = frame.targetFrame;
frame:Hide()
if ( enabled ) then
if ( not self.unit ) then
frame:SetUnit("player");
end
ALUF_PartyFrames:TogglePetFrame(frame, "pet");
ALUF_PartyFrames:ToggleTargetFrame(frame, "target");
else
frame:ResetUnit();
petFrame:ResetUnit();
targetFrame:ResetUnit();
end ]]
for i = 1, 4 do
frame = self["partyFrame"..i];
petFrame = frame.petFrame;
targetFrame = frame.targetFrame;
if ( enabled ) then
if ( not self.unit ) then
frame:SetUnit("party"..i);
end
if ( not UnitGUID("party"..i) ) then
frame:Hide()
end
ALUF_PartyFrames:ToggleTargetFrame(frame, "party"..i.."target");
ALUF_PartyFrames:TogglePetFrame(frame, "partypet"..i);
else
frame:ResetUnit();
petFrame:ResetUnit();
targetFrame:ResetUnit();
end
end
end
function ALUF_PartyFrames:ToggleTargetFrame(partyFrame, targetUnit)
local enabled = ArenaLiveCore:GetDBEntry("ArenaLiveUnitFrames", self.frameType.."/TargetFrame/Enabled");
if (enabled) then
partyFrame.targetFrame:SetUnit(targetUnit);
else
partyFrame.targetFrame:ResetUnit();
end
end
function ALUF_PartyFrames:TogglePetFrame(partyFrame, petUnit)
local enabled = ArenaLiveCore:GetDBEntry("ArenaLiveUnitFrames", self.frameType.."/PetFrame/Enabled");
if (enabled) then
partyFrame.petFrame:SetUnit(petUnit);
else
partyFrame.petFrame:ResetUnit();
end
end
local castBarEnabled, castBarPosition, auraFrameEnabled, auraFramePosition, targetFrameEnabled, targetFramePosition, petFrameEnabled, petFramePosition;
local function UpdateFrameAttachements(self)
-- Reset all points
self.castBar:ClearAllPoints();
self.auraFrame:ClearAllPoints();
self.targetFrame:ClearAllPoints();
self.petFrame:ClearAllPoints();
-- Set new castbar position
if ( castBarPosition == targetFramePosition and targetFrameEnabled ) then
if ( castBarPosition == "LEFT" ) then
self.castBar:SetPoint("TOPRIGHT", self.targetFrame, "TOPLEFT", -3, -10)
elseif ( castBarPosition == "RIGHT" ) then
self.castBar:SetPoint("TOPLEFT", self.targetFrame, "TOPRIGHT", 28, -10)
end
else
if ( castBarPosition == "LEFT" ) then
self.castBar:SetPoint("TOPRIGHT", self, "TOPLEFT", -3, -14)
elseif ( castBarPosition == "RIGHT" ) then
self.castBar:SetPoint("TOPLEFT", self, "TOPRIGHT", 25, -14)
end
end
-- Set new pet frame direction
if ( petFramePosition == "LEFT" ) then
self.petFrame:SetPoint("BOTTOMRIGHT", self, "TOPLEFT", 10, -18);
elseif ( petFramePosition == "RIGHT" ) then
self.petFrame:SetPoint("BOTTOMLEFT", self, "TOPRIGHT", -10, -18);
end
-- Set new target frame direction
if ( targetFramePosition == "LEFT" ) then
self.targetFrame:SetPoint("BOTTOMRIGHT", self, "BOTTOMLEFT", -3, 5);
elseif ( targetFramePosition == "RIGHT" ) then
self.targetFrame:SetPoint("BOTTOMLEFT", self, "BOTTOMRIGHT", 0, 5);
end
-- Set new auraframe position
if ( auraFramePosition == "BELOW" ) then
self.auraFrame:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 28, 3);
ArenaLiveCore:SetDBEntry("ArenaLiveUnitFrames", "PartyFrames/AuraFrame/GrowUpwards", false);
elseif ( auraFramePosition == "ABOVE" ) then
self.auraFrame:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 28, 2);
ArenaLiveCore:SetDBEntry("ArenaLiveUnitFrames", "PartyFrames/AuraFrame/GrowUpwards", true);
end
end
function ALUF_PartyFrames:UpdateAttachements()
castBarEnabled = ArenaLiveCore:GetDBEntry("ArenaLiveUnitFrames", "PartyFrames/CastBar/Enabled");
castBarPosition = ArenaLiveCore:GetDBEntry("ArenaLiveUnitFrames", "PartyFrames/CastBar/Position");
auraFrameEnabled = ArenaLiveCore:GetDBEntry("ArenaLiveUnitFrames", "PartyFrames/AuraFrame/Enabled");
auraFramePosition = ArenaLiveCore:GetDBEntry("ArenaLiveUnitFrames", "PartyFrames/AuraFrame/Position");
targetFrameEnabled = ArenaLiveCore:GetDBEntry("ArenaLiveUnitFrames", "PartyFrames/TargetFrame/Enabled");
targetFramePosition = ArenaLiveCore:GetDBEntry("ArenaLiveUnitFrames", "PartyFrames/TargetFrame/Position");
petFrameEnabled = ArenaLiveCore:GetDBEntry("ArenaLiveUnitFrames", "PartyFrames/PetFrame/Enabled");
petFramePosition = ArenaLiveCore:GetDBEntry("ArenaLiveUnitFrames", "PartyFrames/PetFrame/Position");
local frame --[[= self["partyPlayerFrame"];
UpdateFrameAttachements(frame);]]
for i = 1 , 4 do
frame = self["partyFrame"..i];
UpdateFrameAttachements(frame);
end
end