vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 CT_RA_VersionNumber = 1.541; -- Used for number comparisons
2  
3 CT_RA_Version = "v" .. CT_RA_VersionNumber;
4 CT_RA_MOVINGMEMBER = nil;
5 CT_RA_CURRSLOT = nil;
6 CT_RA_CurrPositions = { };
7 CT_RA_CustomPositions = { };
8 CT_RA_MainTanks = { };
9 CT_RA_CurrMembers = { };
10 CT_RA_ButtonIndexes = { };
11  
12 function CT_RATab_OnLoad()
13 PanelTemplates_SetNumTabs(FriendsFrame, 5);
14 tinsert(FRIENDSFRAME_SUBFRAMES, "CT_RAOptionsFrame");
15 PanelTemplates_TabResize(0, this, 90);
16 end
17  
18 CT_oldFriendsFrame_Update = FriendsFrame_Update;
19  
20 function CT_newFriendsFrame_Update()
21 if ( FriendsFrame.selectedTab == 5 ) then
22 FriendsFrameTopLeft:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-TopLeft");
23 FriendsFrameTopRight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-TopRight");
24 FriendsFrameBottomLeft:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-BottomLeft");
25 FriendsFrameBottomRight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-General-BottomRight");
26 FriendsFrameTitleText:SetText("CT_RaidAssist " .. CT_RA_Version);
27 FriendsFrame_ShowSubFrame("CT_RAOptionsFrame");
28 else
29 CT_oldFriendsFrame_Update();
30 end
31 end
32  
33 FriendsFrame_Update = CT_newFriendsFrame_Update;
34  
35 function CT_RAOptionsGroupButton_OnMouseDown(button)
36 if ( button == "LeftButton" and CT_RAMenu_Options["temp"]["SORTTYPE"] == "custom" ) then
37 this:StartMoving();
38 CT_RA_MOVINGMEMBER = this;
39 elseif ( button == "RightButton" and this.name ) then
40 ToggleDropDownMenu(1, nil, getglobal("CT_RAOptionsGroupButton"..this:GetID().."DropDown"));
41 end
42 end
43  
44 function CT_RAOptionsGroupButton_OnMouseUp(button, raidButton)
45 if ( not raidButton ) then
46 raidButton = this;
47 end
48 if ( button ~= "RightButton" ) then
49 raidButton:StopMovingOrSizing();
50 CT_RA_MOVINGMEMBER = nil;
51 if ( CT_RA_CURRSLOT and CT_RA_CURRSLOT:GetParent():GetID() ~= raidButton.subgroup ) then
52 if (CT_RA_CURRSLOT.button) then
53 local target = getglobal(CT_RA_CURRSLOT.button);
54 CT_RA_CurrPositions[UnitName("raid" .. raidButton:GetID())] = { CT_RA_CURRSLOT:GetParent():GetID(), raidButton:GetID() };
55 CT_RA_CurrPositions[UnitName("raid" .. target:GetID())] = { raidButton.subgroup, target:GetID() };
56 else
57 CT_RA_CURRSLOT:UnlockHighlight();
58 local slot = CT_RA_CURRSLOT:GetParent():GetName().."Slot"..CT_RA_CURRSLOT:GetParent().nextIndex;
59 raidButton:SetPoint("TOPLEFT", slot, "TOPLEFT", 0, 0);
60 CT_RA_CurrPositions[UnitName("raid" .. raidButton:GetID())] = { CT_RA_CURRSLOT:GetParent():GetID(), raidButton:GetID() };
61 end
62 else
63 if ( CT_RA_CURRSLOT ) then
64 CT_RA_CURRSLOT:UnlockHighlight();
65 end
66 raidButton:SetPoint("TOPLEFT", raidButton.slot, "TOPLEFT", 0, 0);
67 end
68 end
69 CT_RAOptions_Update();
70 CT_RA_UpdateRaidGroup(0);
71 end
72  
73 function CT_RAOptions_Update()
74 -- Reset group index counters;
75 for i=1, NUM_RAID_GROUPS do
76 getglobal("CT_RAOptionsGroup"..i).nextIndex = 1;
77 end
78 -- Clear out all the slots buttons
79 CT_RAOptionsGroup_ResetSlotButtons();
80  
81 local numRaidMembers = GetNumRaidMembers();
82 local raidGroup, color;
83 local buttonName, buttonLevel, buttonClass, buttonRank;
84 local name, rank, subgroup, level, class, fileName, zone, online, reqChange;
85 local temp = { };
86 for i=1, MAX_RAID_MEMBERS do
87 button = getglobal("CT_RAOptionsGroupButton"..i);
88 if ( i <= numRaidMembers ) then
89 name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(i);
90 if ( name and CT_RAMenu_Options["temp"]["SORTTYPE"] == "custom" and CT_RA_CurrPositions[name] ) then
91 subgroup = CT_RA_CurrPositions[name][1];
92 elseif ( ( not name or not CT_RA_CurrPositions[name] ) and CT_RAMenu_Options["temp"]["SORTTYPE"] ~= "custom" ) then
93 if ( name ) then
94 CT_RA_CurrPositions[name] = { subgroup };
95 end
96 elseif ( CT_RAMenu_Options["temp"]["SORTTYPE"] == "custom" ) then
97 subgroup = nil;
98 reqChange = 1;
99 end
100 if ( name and CT_RA_CurrPositions[name] ) then
101 CT_RA_CurrPositions[name][2] = i;
102 end
103 if ( subgroup ) then
104 raidGroup = getglobal("CT_RAOptionsGroup"..subgroup);
105 -- To prevent errors when the server hiccups
106 if ( raidGroup.nextIndex <= MEMBERS_PER_RAID_GROUP ) then
107 buttonName = getglobal("CT_RAOptionsGroupButton"..i.."Name");
108 buttonLevel = getglobal("CT_RAOptionsGroupButton"..i.."Level");
109 buttonClass = getglobal("CT_RAOptionsGroupButton"..i.."Class");
110 buttonRank = getglobal("CT_RAOptionsGroupButton"..i.."Rank");
111 button.id = i;
112  
113 button.name = name;
114  
115 if ( level == 0 ) then
116 level = "";
117 end
118  
119 if ( not name ) then
120 name = UNKNOWN;
121 end
122  
123 buttonName:SetText(name);
124 buttonLevel:SetText(level);
125 buttonClass:SetText(class);
126 if ( CT_RAMenu_Options["temp"]["SORTTYPE"] ~= "class" ) then
127 if ( isDead ) then
128 buttonName:SetVertexColor(RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b);
129 buttonClass:SetVertexColor(RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b);
130 buttonLevel:SetVertexColor(RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b);
131 elseif ( online ) then
132 color = RAID_CLASS_COLORS[fileName];
133 if ( color ) then
134 buttonName:SetVertexColor(color.r, color.g, color.b);
135 buttonLevel:SetVertexColor(color.r, color.g, color.b);
136 buttonClass:SetVertexColor(color.r, color.g, color.b);
137 end
138 else
139 buttonName:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
140 buttonClass:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
141 buttonLevel:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
142 end
143 end
144  
145 buttonRank:SetText("");
146 for k, v in CT_RA_MainTanks do
147 if ( v == name ) then
148 buttonRank:SetText(k);
149 break;
150 end
151 end
152  
153 -- Anchor button to slot
154 local slot = raidGroup.nextIndex;
155 if ( not CT_RA_MOVINGMEMBER or CT_RA_MOVINGMEMBER ~= button ) then
156 button:SetPoint("TOPLEFT", "CT_RAOptionsGroup"..subgroup.."Slot"..slot, "TOPLEFT", 0, 0);
157 end
158  
159 -- Save slot for future use
160 button.slot = "CT_RAOptionsGroup"..subgroup.."Slot"..slot;
161 -- Save the button's subgroup too
162 button.subgroup = subgroup;
163 -- Tell the slot what button is in it
164 getglobal("CT_RAOptionsGroup"..subgroup.."Slot"..slot).button = button:GetName();
165 raidGroup.nextIndex = raidGroup.nextIndex + 1;
166 button:SetID(i);
167 button:Show();
168 end
169 end
170 else
171 button:Hide();
172 end
173 end
174 if ( reqChange and CT_RAMenu_Options["temp"]["SORTTYPE"] == "custom" ) then
175 local changed;
176 for i = 1, GetNumRaidMembers(), 1 do
177 local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(i);
178 if ( name and not CT_RA_CurrPositions[name] ) then
179 changed = 1;
180 if ( getglobal("CT_RAOptionsGroup" .. subgroup).nextIndex > 5 ) then
181 for y = 1, 8, 1 do
182 if ( not getglobal("CT_RAOptionsGroup" .. y).nextIndex or getglobal("CT_RAOptionsGroup" .. y).nextIndex <= 5 ) then
183 subgroup = y;
184 CT_RA_CurrPositions[name] = { y, i };
185 break;
186 end
187 end
188 end
189 if ( not CT_RA_CurrPositions[name] ) then
190 CT_RA_CurrPositions[name] = { subgroup, i };
191 end
192 end
193 end
194 if ( changed ) then
195 CT_RAOptions_Update();
196 end
197 end
198 end
199  
200 function CT_RA_UpdateCustomSorting()
201 local buttons = { };
202 for i = 1, 40, 1 do
203 local btn = getglobal("CT_RAMember" .. i);
204 local group = ceil(i/5);
205 local index = i;
206 if ( i <= GetNumRaidMembers() and CT_RA_CurrPositions[UnitName("raid" .. i)] ) then
207 group = CT_RA_CurrPositions[UnitName("raid" .. i)][1];
208 end
209 if ( not buttons[group] ) then
210 buttons[group] = { };
211 end
212 buttons[group][index] = i;
213 end
214 for i = 1, 8, 1 do
215 if ( buttons[i] ) then
216 for k, v in buttons[i] do
217 if ( k == 1 ) then
218 getglobal("CT_RAMember" .. v):SetPoint("TOPLEFT", "CT_RAGroup" .. i, "TOPLEFT", 0, -20);
219 else
220 if ( buttons[i][k-1] ) then
221 getglobal("CT_RAMember" .. v):SetPoint("TOPLEFT", "CT_RAMember" .. (buttons[i][k-1]), "BOTTOMLEFT", 0, 4);
222 end
223 end
224 end
225 end
226 end
227 end
228  
229 function CT_RAOptionsGroup_ResetSlotButtons()
230 for i=1, NUM_RAID_GROUPS do
231 for j=1, MEMBERS_PER_RAID_GROUP do
232 getglobal("CT_RAOptionsGroup"..i.."Slot"..j).button = nil;
233 end
234 end
235 end
236  
237 function CT_RAOptionsGroupFrame_OnUpdate(elapsed)
238 if ( CT_RA_MOVINGMEMBER ) then
239 local button, slot;
240 CT_RA_CURRSLOT = nil;
241 for i=1, NUM_RAID_GROUPS do
242 for j=1, MEMBERS_PER_RAID_GROUP do
243 slot = getglobal("CT_RAOptionsGroup"..i.."Slot"..j);
244 if ( MouseIsOver(slot) ) then
245 slot:LockHighlight();
246 CT_RA_CURRSLOT = slot;
247 else
248 slot:UnlockHighlight();
249 end
250 end
251 end
252 end
253 end
254  
255 function CT_RAMemberDropDown_OnLoad()
256 UIDropDownMenu_Initialize(this, CT_RAMemberDropDown_Initialize, "MENU");
257 end
258  
259 function CT_RAMemberDropDown_Initialize()
260 local dropdown, info;
261 if ( UIDROPDOWNMENU_OPEN_MENU ) then
262 dropdown = getglobal(UIDROPDOWNMENU_OPEN_MENU);
263 else
264 dropdown = this;
265 end
266 if ( type(UIDROPDOWNMENU_MENU_VALUE) == "table" and UIDROPDOWNMENU_MENU_VALUE[1] == "Main Tanks" ) then
267 info = {};
268 info.text = "Main Tanks";
269 info.isTitle = 1;
270 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
271 for i = 1, 10, 1 do
272 info = {};
273 if ( CT_RA_MainTanks[i] and CT_RA_MainTanks[i] == UIDROPDOWNMENU_MENU_VALUE[2] ) then
274 info.text = "|c00DFFFFFRemove MT #" .. i .. "|r";
275 info.value = { UIDROPDOWNMENU_MENU_VALUE[1], UIDROPDOWNMENU_MENU_VALUE[2], i, 1 };
276 info.tooltipTitle = "Remove Main Tank"
277 info.tooltipText = "Removes the Main Tank from the MT window.";
278 else
279 info.text = "Set MT #" .. i;
280 info.value = { UIDROPDOWNMENU_MENU_VALUE[1], UIDROPDOWNMENU_MENU_VALUE[2], i };
281 info.tooltipTitle = "Set Main Tank"
282 info.tooltipText = "Sets a main tank, which allows everyone to see the main tank(s) target info";
283 end
284 info.func = CT_RAMemberDropDown_OnClick;
285 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
286 end
287 return;
288 end
289 if ( type(UIDROPDOWNMENU_MENU_VALUE) == "table" and UIDROPDOWNMENU_MENU_VALUE[1] == "Player Targets" ) then
290 info = {};
291 info.text = "Player Targets";
292 info.isTitle = 1;
293 info.notCheckable = 1;
294 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
295 for i = 1, 10, 1 do
296 info = {};
297 if ( CT_RA_PTargets and CT_RA_PTargets[i] == UIDROPDOWNMENU_MENU_VALUE[2] ) then
298 info.text = "|c00DFFFFFRemove PT #" .. i .. "|r";
299 info.value = { UIDROPDOWNMENU_MENU_VALUE[1], UIDROPDOWNMENU_MENU_VALUE[2], i, 1 };
300 info.tooltipTitle = "Remove Player Target"
301 info.tooltipText = "Removes the Player Target from the PT window.";
302 else
303 info.text = "Set PT #" .. i;
304 info.value = { UIDROPDOWNMENU_MENU_VALUE[1], UIDROPDOWNMENU_MENU_VALUE[2], i };
305 info.tooltipTitle = "Set Player Target"
306 info.tooltipText = "Sets a player target, which allows you to easily see the person's health and target.";
307 end
308 info.func = CT_RAMemberDropDown_OnClick;
309 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
310 end
311 return;
312 end
313 info = {};
314 info.text = this.name;
315 info.isTitle = 1;
316 info.notCheckable = 1;
317 UIDropDownMenu_AddButton(info);
318 if ( CT_RA_Level < 1 ) then
319 info = { };
320 info.text = "|c00666666Main Tanks|r";
321 info.tooltipTitle = "Promotion Required";
322 info.tooltipText = "In order to set main tanks, you need to at least be a promoted user, or raid leader.";
323 info.notCheckable = 1;
324 UIDropDownMenu_AddButton(info);
325 else
326 info = {};
327 info.text = "Main Tanks";
328 info.value = { "Main Tanks", this.name };
329 info.hasArrow = 1;
330 info.notCheckable = 1;
331 UIDropDownMenu_AddButton(info);
332 end
333 info = {};
334 info.text = "Player Targets";
335 info.value = { "Player Targets", this.name };
336 info.hasArrow = 1;
337 info.notCheckable = 1;
338 UIDropDownMenu_AddButton(info);
339 end
340  
341 function CT_RAMemberDropDown_OnClick()
342 if ( this.value[1] == "Main Tanks" ) then
343 if ( this.value[4] ) then
344 CT_RA_SendMessage("R " .. this.value[2], 1);
345 else
346 CT_RA_SendMessage("SET " .. this.value[3] .. " " .. this.value[2], 1);
347 end
348 elseif ( this.value[1] == "Player Targets" ) then
349 if ( this.value[4] ) then
350 CT_RA_PTargets[this.value[3]] = nil;
351 else
352 CT_RA_PTargets[this.value[3]] = this.value[2];
353 end
354 end
355 CloseMenus();
356 end
357  
358 function CT_RAMemberDropDownRemove_OnLoad()
359 UIDropDownMenu_Initialize(this, CT_RAMemberDropDownRemove_Initialize, "MENU");
360 end
361  
362 function CT_RAMemberDropDownRemove_Initialize()
363 local dropdown, info;
364 if ( UIDROPDOWNMENU_OPEN_MENU ) then
365 dropdown = getglobal(UIDROPDOWNMENU_OPEN_MENU);
366 else
367 dropdown = this;
368 end
369 if ( this.id and this.name ) then
370 info = {};
371 info.text = this.name;
372 info.isTitle = 1;
373 info.notCheckable = 1;
374 UIDropDownMenu_AddButton(info);
375  
376 info = {};
377 info.text = "Remove MT";
378 info.value = this.name;
379 info.func = CT_RAMemberDropDownRemove_OnClick;
380 info.notCheckable = 1;
381 info.tooltipTitle = "Remove Main Tank"
382 info.tooltipText = "Removes the main tank";
383 UIDropDownMenu_AddButton(info);
384 end
385 end
386  
387 function CT_RAMemberDropDownRemove_OnClick()
388 for k, v in CT_RA_MainTanks do
389 if ( v == this.value ) then
390 CT_RA_SendMessage("R " .. v, 1);
391 return;
392 end
393 end
394 end