vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 CT_RA_VersionNumber = 1.45; -- 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, 60);
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 and CT_RA_Level >= 1 ) 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();
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 ( CT_RA_Level < 1 ) then
267 info = {};
268 info.text = "Set Main Tanks";
269 info.isTitle = 1;
270 info.notCheckable = 1;
271 UIDropDownMenu_AddButton(info);
272  
273 info = { };
274 info.text = "Promotion required";
275 info.tooltipTitle = "Promotion required";
276 info.tooltipText = "In order to set main tanks, you need to at least be a promoted user, or raid leader.";
277 info.notCheckable = 1;
278 UIDropDownMenu_AddButton(info);
279 elseif ( this.id and this.name and CT_RA_Channel and GetChannelName(CT_RA_Channel) ~= 0 ) then
280 info = {};
281 info.text = this.name;
282 info.isTitle = 1;
283 info.notCheckable = 1;
284 UIDropDownMenu_AddButton(info);
285  
286 for i = 1, 10, 1 do
287 info = {};
288 if ( CT_RA_MainTanks[i] and CT_RA_MainTanks[i] == this.name ) then
289 info.text = "|c00DFFFFFRemove MT #" .. i .. "|r";
290 info.value = { this.name, i, 1 };
291 info.tooltipTitle = "Remove Main Tank"
292 info.tooltipText = "Removes the Main Tank from the MT window.";
293 else
294 info.text = "Set MT #" .. i;
295 info.value = { this.name, i };
296 info.tooltipTitle = "Set Main Tank"
297 info.tooltipText = "Sets a main tank, which allows everyone to see the main tank(s) target info";
298 end
299 info.func = CT_RAMemberDropDown_OnClick;
300 info.notCheckable = 1;
301 UIDropDownMenu_AddButton(info);
302 end
303 elseif ( not CT_RA_Channel ) then
304 info = {};
305 info.text = "Set Main Tanks";
306 info.isTitle = 1;
307 info.notCheckable = 1;
308 UIDropDownMenu_AddButton(info);
309  
310 info = { };
311 info.text = "No CTRA channel set";
312 info.tooltipTitle = "No channel set";
313 info.tooltipText = "No CT_RaidAssist channel is set. Ask your raid if they have a designated channel already, or come up with one that the raid will use. Then, type /rajoin <channelName>, and the mod will be set up to use the channel <channelName>.";
314 info.notCheckable = 1;
315 UIDropDownMenu_AddButton(info);
316 elseif ( CT_RA_Channel and GetChannelName(CT_RA_Channel) == 0 ) then
317 info = {};
318 info.text = "Set Main Tanks";
319 info.isTitle = 1;
320 info.notCheckable = 1;
321 UIDropDownMenu_AddButton(info);
322  
323 info = { };
324 info.text = "No CTRA channel found";
325 info.tooltipTitle = "No channel found";
326 info.tooltipText = "You have a CT_RaidAssist channel set, but it appears that you have not joined it. You need to be in a channel to be able to set Main Tanks. To join the current channel ('" .. CT_RA_Channel .. "'), type /rajoin.";
327 info.notCheckable = 1;
328 UIDropDownMenu_AddButton(info);
329 end
330 end
331  
332 function CT_RAMemberDropDown_OnClick()
333 if ( this.value[3] ) then
334 CT_RA_SendMessage("R " .. this.value[1], 1);
335 else
336 if ( this.value[2] > 5 ) then
337 CT_RA_SendMessage("SET2 " .. this.value[2] .. " " .. this.value[1], 1);
338 else
339 CT_RA_SendMessage("SET " .. this.value[2] .. " " .. this.value[1], 1);
340 end
341 end
342 end
343  
344 function CT_RAMemberDropDownRemove_OnLoad()
345 UIDropDownMenu_Initialize(this, CT_RAMemberDropDownRemove_Initialize, "MENU");
346 end
347  
348 function CT_RAMemberDropDownRemove_Initialize()
349 local dropdown, info;
350 if ( UIDROPDOWNMENU_OPEN_MENU ) then
351 dropdown = getglobal(UIDROPDOWNMENU_OPEN_MENU);
352 else
353 dropdown = this;
354 end
355 if ( this.id and this.name ) then
356 info = {};
357 info.text = this.name;
358 info.isTitle = 1;
359 info.notCheckable = 1;
360 UIDropDownMenu_AddButton(info);
361  
362 info = {};
363 info.text = "Remove MT";
364 info.value = this.name;
365 info.func = CT_RAMemberDropDownRemove_OnClick;
366 info.notCheckable = 1;
367 info.tooltipTitle = "Remove Main Tank"
368 info.tooltipText = "Removes the main tank";
369 UIDropDownMenu_AddButton(info);
370 end
371 end
372  
373 function CT_RAMemberDropDownRemove_OnClick()
374 for k, v in CT_RA_MainTanks do
375 if ( v == this.value ) then
376 CT_RA_SendMessage("R " .. v, 1);
377 return;
378 end
379 end
380 end