vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 CT_RAMeters_ColorTable = {
2 [CT_RA_HUNTER] = "|c00AAD372",
3 [CT_RA_WARLOCK] = "|c009382c9",
4 [CT_RA_PRIEST] = "|c00FFFFFF",
5 [CT_RA_PALADIN] = "|c00F48CBA",
6 [CT_RA_MAGE] = "|c0068CCEF",
7 [CT_RA_ROGUE] = "|c00FFF468",
8 [CT_RA_DRUID] = "|c00FF7C0A",
9 [CT_RA_SHAMAN] = "|c00F48CBA",
10 [CT_RA_WARRIOR] = "|c00C69B6D"
11 };
12 CT_RAMeters_StatsTable = {
13 ["Generic"] = {
14 ["isDead"] = 0,
15 ["isAfk"] = 0,
16 ["isOffline"] = 0
17 },
18 [CT_RA_WARRIOR] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0 },
19 [CT_RA_DRUID] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0 },
20 [CT_RA_MAGE] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0 },
21 [CT_RA_WARLOCK] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0 },
22 [CT_RA_ROGUE] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0 },
23 [CT_RA_HUNTER] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0 },
24 [CT_RA_PRIEST] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0 },
25 [CT_RA_PALADIN] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0 },
26 [CT_RA_SHAMAN] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0 }
27 }
28  
29 function CT_RAMeters_InitDropDown()
30 local info;
31 if ( UIDROPDOWNMENU_MENU_LEVEL == 2 ) then
32 info = {};
33 info.text = UIDROPDOWNMENU_MENU_VALUE;
34 info.justifyH = "CENTER";
35 info.isTitle = 1;
36 info.notCheckable = 1;
37 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
38  
39 local nonManaUsers = {
40 [CT_RA_ROGUE] = 1,
41 [CT_RA_WARRIOR] = 1
42 };
43 for k, v in CT_RA_ClassPositions do
44 if ( ( UIDROPDOWNMENU_MENU_VALUE == "Health Display" or UIDROPDOWNMENU_MENU_VALUE == "Raid Health" ) or not nonManaUsers[k] ) then
45 if ( ( k ~= CT_RA_SHAMAN or ( UnitFactionGroup("player") and UnitFactionGroup("player") == "Horde" ) ) and ( k ~= CT_RA_PALADIN or ( UnitFactionGroup("player") and UnitFactionGroup("player") == "Alliance" ) ) ) then
46 info = { };
47 info.text = k;
48 info.value = { UIDROPDOWNMENU_MENU_VALUE, k };
49 info.checked = ( CT_RAMenu_Options["temp"]["StatusMeters"] and CT_RAMenu_Options["temp"]["StatusMeters"][UIDROPDOWNMENU_MENU_VALUE] and CT_RAMenu_Options["temp"]["StatusMeters"][UIDROPDOWNMENU_MENU_VALUE][k] );
50 info.keepShownOnClick = 1;
51 info.func = CT_RAMeters_DropDown_OnClick;
52 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
53 end
54 end
55 end
56 return;
57 end
58 info = {};
59 info.text = "RaidStatus";
60 info.justifyH = "CENTER";
61 info.isTitle = 1;
62 info.notCheckable = 1;
63 UIDropDownMenu_AddButton(info);
64  
65 info = {};
66 info.text = "Health Display";
67 info.hasArrow = 1;
68 info.notCheckable = 1;
69 UIDropDownMenu_AddButton(info);
70  
71 info = {};
72 info.text = "Mana Display";
73 info.hasArrow = 1;
74 info.notCheckable = 1;
75 UIDropDownMenu_AddButton(info);
76  
77 info = {};
78 info.text = "Raid Health";
79 info.hasArrow = 1;
80 info.notCheckable = 1;
81 UIDropDownMenu_AddButton(info);
82  
83 info = {};
84 info.text = "Raid Mana";
85 info.hasArrow = 1;
86 info.notCheckable = 1;
87 UIDropDownMenu_AddButton(info);
88  
89 info = {};
90 info.text = "AFK Count";
91 info.value = "AFK Count";
92 info.checked = ( CT_RAMenu_Options["temp"]["StatusMeters"] and CT_RAMenu_Options["temp"]["StatusMeters"]["AFK Count"] );
93 info.keepShownOnClick = 1;
94 info.func = CT_RAMeters_DropDown_OnClick;
95 UIDropDownMenu_AddButton(info);
96  
97 info = {};
98 info.text = "Dead Count";
99 info.value = "Dead Count";
100 info.checked = ( CT_RAMenu_Options["temp"]["StatusMeters"] and CT_RAMenu_Options["temp"]["StatusMeters"]["Dead Count"] );
101 info.keepShownOnClick = 1;
102 info.func = CT_RAMeters_DropDown_OnClick;
103 UIDropDownMenu_AddButton(info);
104  
105 info = {};
106 info.text = "Offline Count";
107 info.value = "Offline Count";
108 info.checked = ( CT_RAMenu_Options["temp"]["StatusMeters"] and CT_RAMenu_Options["temp"]["StatusMeters"]["Offline Count"] );
109 info.keepShownOnClick = 1;
110 info.func = CT_RAMeters_DropDown_OnClick;
111 UIDropDownMenu_AddButton(info);
112  
113 info = {};
114 info.disabled = 1;
115 UIDropDownMenu_AddButton(info);
116  
117 info = {};
118 if ( CT_RAMenu_Options["temp"]["StatusMeters"] and CT_RAMenu_Options["temp"]["StatusMeters"]["Lock"] ) then
119 info.text = "Unlock Window";
120 else
121 info.text = "Lock Window";
122 end
123 info.value = "LockMeter";
124 info.notCheckable = 1;
125 info.func = CT_RAMeters_DropDown_OnClick;
126 UIDropDownMenu_AddButton(info);
127  
128 info = { };
129 info.text = "Background Color";
130 info.hasColorSwatch = 1;
131 info.hasOpacity = 1;
132 if ( CT_RAMenu_Options["temp"]["StatusMeters"] and CT_RAMenu_Options["temp"]["StatusMeters"]["Background"] ) then
133 info.r = ( CT_RAMenu_Options["temp"]["StatusMeters"]["Background"].r );
134 info.g = ( CT_RAMenu_Options["temp"]["StatusMeters"]["Background"].g );
135 info.b = ( CT_RAMenu_Options["temp"]["StatusMeters"]["Background"].b );
136 info.opacity = ( CT_RAMenu_Options["temp"]["StatusMeters"]["Background"].a );
137 else
138 info.r = 0;
139 info.g = 0;
140 info.b = 1;
141 info.opacity = 0.5;
142 end
143 info.notClickable = 1;
144 info.swatchFunc = CT_RAMeters_DropDown_SwatchFunc;
145 info.opacityFunc = CT_RAMeters_DropDown_OpacityFunc;
146 info.cancelFunc = CT_RAMeters_DropDown_CancelFunc;
147 info.notCheckable = 1;
148 UIDropDownMenu_AddButton(info);
149  
150 info = {};
151 info.text = "|c00FF8080Hide Window|r";
152 info.value = "Hide";
153 info.notCheckable = 1;
154 info.func = CT_RAMeters_DropDown_OnClick;
155 UIDropDownMenu_AddButton(info);
156 end
157  
158 function CT_RAMeters_DropDown_SwatchFunc()
159 if ( not CT_RAMenu_Options["temp"]["StatusMeters"] ) then
160 CT_RAMenu_Options["temp"]["StatusMeters"] = {
161 ["Health Display"] = { },
162 ["Mana Display"] = { },
163 ["Raid Health"] = { },
164 ["Raid Mana"] = { },
165 ["Background"] = {
166 ["r"] = 0,
167 ["g"] = 0,
168 ["b"] = 1,
169 ["a"] = 0.5
170 }
171 };
172 end
173 local r, g, b = ColorPickerFrame:GetColorRGB();
174 CT_RAMenu_Options["temp"]["StatusMeters"]["Background"]["r"] = r;
175 CT_RAMenu_Options["temp"]["StatusMeters"]["Background"]["g"] = g;
176 CT_RAMenu_Options["temp"]["StatusMeters"]["Background"]["b"] = b;
177 CT_RAMetersFrame:SetBackdropColor(r, g, b, CT_RAMenu_Options["temp"]["StatusMeters"]["Background"]["a"]);
178 end
179  
180 function CT_RAMeters_DropDown_OpacityFunc()
181 if ( not CT_RAMenu_Options["temp"]["StatusMeters"] ) then
182 CT_RAMenu_Options["temp"]["StatusMeters"] = {
183 ["Health Display"] = { },
184 ["Mana Display"] = { },
185 ["Raid Health"] = { },
186 ["Raid Mana"] = { },
187 ["Background"] = {
188 ["r"] = 0,
189 ["g"] = 0,
190 ["b"] = 1,
191 ["a"] = 0.5
192 }
193 };
194 end
195 local a = OpacitySliderFrame:GetValue();
196 CT_RAMenu_Options["temp"]["StatusMeters"]["Background"]["a"] = a;
197 CT_RAMetersFrame:SetBackdropColor(CT_RAMenu_Options["temp"]["StatusMeters"]["Background"].r, CT_RAMenu_Options["temp"]["StatusMeters"]["Background"].g, CT_RAMenu_Options["temp"]["StatusMeters"]["Background"].b, a);
198 CT_RAMetersFrame:SetBackdropBorderColor(1, 1, 1, a);
199 end
200  
201 function CT_RAMeters_DropDown_CancelFunc(val)
202 CT_RAMenu_Options["temp"]["StatusMeters"]["Background"] = {
203 ["r"] = val.r,
204 ["g"] = val.g,
205 ["b"] = val.b,
206 ["a"] = val.opacity
207 };
208 CT_RAMetersFrame:SetBackdropColor(val.r, val.g, val.b, val.opacity);
209 CT_RAMetersFrame:SetBackdropBorderColor(1, 1, 1, val.opacity);
210 end
211  
212 function CT_RAMeters_OnLoad()
213 this:SetBackdropColor(0, 0, 1, 0.5);
214 end
215  
216 function CT_RAMeters_DropDown_OnLoad()
217 UIDropDownMenu_Initialize(this, CT_RAMeters_InitDropDown, "MENU");
218 end
219  
220 function CT_RAMeters_DropDown_OnClick()
221 -- Create the table if we haven't already
222 if ( not CT_RAMenu_Options["temp"]["StatusMeters"] ) then
223 CT_RAMenu_Options["temp"]["StatusMeters"] = {
224 ["Health Display"] = { },
225 ["Mana Display"] = { },
226 ["Raid Health"] = { },
227 ["Raid Mana"] = { },
228 ["Background"] = {
229 ["r"] = 0,
230 ["g"] = 0,
231 ["b"] = 1,
232 ["a"] = 0.5
233 }
234 };
235 end
236 if ( this.value == "LockMeter" ) then
237 CT_RAMenu_Options["temp"]["StatusMeters"]["Lock"] = not CT_RAMenu_Options["temp"]["StatusMeters"]["Lock"];
238 return;
239 elseif ( this.value == "Hide" ) then
240 CT_RAMenuFrameGeneralMiscShowMetersCB:SetChecked(false);
241 CT_RAMenu_Options["temp"]["StatusMeters"]["Show"] = nil;
242 CT_RAMetersFrame:Hide();
243 return;
244 end
245  
246 if ( type(this.value) == "table" ) then
247 -- We have either HP or Mana Display/Totals
248 CT_RAMenu_Options["temp"]["StatusMeters"][this.value[1]][this.value[2]] = not CT_RAMenu_Options["temp"]["StatusMeters"][this.value[1]][this.value[2]];
249 else
250 -- Just AFK Count/Dead Count
251 CT_RAMenu_Options["temp"]["StatusMeters"][this.value] = not CT_RAMenu_Options["temp"]["StatusMeters"][this.value];
252 end
253 CT_RAMeters_UpdateWindow();
254 end
255  
256 function CT_RAMeters_UpdateWindow()
257 if ( not CT_RAMenu_Options["temp"]["StatusMeters"] or GetNumRaidMembers() == 0 ) then
258 CT_RAMetersFrameText:SetText("No stats to track");
259 CT_RAMetersFrame:SetWidth(125);
260 CT_RAMetersFrame:SetHeight(41);
261 return;
262 end
263 CT_RAMeters_StatsTable = {
264 ["Generic"] = {
265 ["isDead"] = 0,
266 ["isAfk"] = 0,
267 ["isOffline"] = 0
268 },
269 [CT_RA_WARRIOR] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0 },
270 [CT_RA_DRUID] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0, ["numMana"] = 0 },
271 [CT_RA_MAGE] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0, ["numMana"] = 0 },
272 [CT_RA_WARLOCK] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0, ["numMana"] = 0 },
273 [CT_RA_ROGUE] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0 },
274 [CT_RA_HUNTER] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0, ["numMana"] = 0 },
275 [CT_RA_PRIEST] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0, ["numMana"] = 0 },
276 [CT_RA_PALADIN] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0, ["numMana"] = 0 },
277 [CT_RA_SHAMAN] = { ["health"] = 0, ["mana"] = 0, ["num"] = 0, ["numMana"] = 0 }
278 };
279 local stats = {
280 ["hpDisplay"] = { "", 0 },
281 ["mpDisplay"] = { "", 0 },
282 ["raidHp"] = { "", 1 },
283 ["raidMp"] = { "", 1 },
284 ["deadCount"] = { "", 1 },
285 ["afkCount"] = { "", 1 },
286 ["offlineCount"] = { "", 1 }
287 };
288  
289 -- Get all the stats
290 for i = 1, GetNumRaidMembers(), 1 do
291 local id = "raid" .. i;
292 if ( UnitIsConnected(id) ) then
293 local name = UnitName(id);
294 local class, health, mana, isDead, isAfk = UnitClass(id), 0, 0, ( ( UnitIsDead(id) or UnitIsGhost(id) ) and ( not CT_RA_Stats[name] or not CT_RA_Stats[name]["FD"] ) ), ( CT_RA_Stats[name] and CT_RA_Stats[name]["AFK"] );
295 if ( class and CT_RAMeters_StatsTable[class] ) then
296 if (
297 ( CT_RAMenu_Options["temp"]["StatusMeters"]["Raid Health"] and CT_RAMenu_Options["temp"]["StatusMeters"]["Raid Health"][class] ) or
298 ( CT_RAMenu_Options["temp"]["StatusMeters"]["Health Display"] and CT_RAMenu_Options["temp"]["StatusMeters"]["Health Display"][class] )
299 ) then
300 health = UnitHealth(id)/UnitHealthMax(id);
301 end
302 if (
303 UnitPowerType(id) == 0 and (
304 ( CT_RAMenu_Options["temp"]["StatusMeters"]["Raid Mana"] and CT_RAMenu_Options["temp"]["StatusMeters"]["Raid Mana"][class] ) or
305 ( CT_RAMenu_Options["temp"]["StatusMeters"]["Mana Display"] and CT_RAMenu_Options["temp"]["StatusMeters"]["Mana Display"][class] )
306 )
307 ) then
308 CT_RAMeters_StatsTable[class]["numMana"] = CT_RAMeters_StatsTable[class]["numMana"] + 1;
309 mana = UnitMana(id)/UnitManaMax(id);
310 end
311 CT_RAMeters_StatsTable[class]["health"] = CT_RAMeters_StatsTable[class]["health"] + health;
312 CT_RAMeters_StatsTable[class]["mana"] = CT_RAMeters_StatsTable[class]["mana"] + mana;
313 if ( isDead ) then
314 CT_RAMeters_StatsTable["Generic"]["isDead"] = CT_RAMeters_StatsTable["Generic"]["isDead"] + 1;
315 end
316 if ( isAfk ) then
317 CT_RAMeters_StatsTable["Generic"]["isAfk"] = CT_RAMeters_StatsTable["Generic"]["isAfk"] + 1;
318 end
319 CT_RAMeters_StatsTable[class]["num"] = CT_RAMeters_StatsTable[class]["num"] + 1;
320 end
321 else
322 CT_RAMeters_StatsTable["Generic"]["isOffline"] = CT_RAMeters_StatsTable["Generic"]["isOffline"] + 1;
323 end
324 end
325  
326 -- Raid Health
327 if ( CT_RAMenu_Options["temp"]["StatusMeters"]["Raid Health"] ) then
328 local combinedHealth, numHealth = 0, 0;
329 for k, v in CT_RAMenu_Options["temp"]["StatusMeters"]["Raid Health"] do
330 if ( v and CT_RAMeters_StatsTable[k] and CT_RAMeters_StatsTable[k]["num"] > 0 ) then
331 combinedHealth, numHealth = combinedHealth + CT_RAMeters_StatsTable[k]["health"], numHealth + CT_RAMeters_StatsTable[k]["num"];
332 end
333 end
334 if ( numHealth > 0 ) then
335 combinedHealth = floor(combinedHealth/numHealth*100+0.5);
336 stats["raidHp"][1] = "Raid Health: " .. combinedHealth .. "%";
337 end
338 end
339  
340 -- Raid Mana
341 if ( CT_RAMenu_Options["temp"]["StatusMeters"]["Raid Mana"] ) then
342 local combinedMana, numMana = 0, 0;
343 for k, v in CT_RAMenu_Options["temp"]["StatusMeters"]["Raid Mana"] do
344 if ( v and CT_RAMeters_StatsTable[k] and CT_RAMeters_StatsTable[k]["numMana"] > 0 ) then
345 combinedMana = combinedMana + CT_RAMeters_StatsTable[k]["mana"];
346 numMana = numMana + CT_RAMeters_StatsTable[k]["numMana"];
347 end
348 end
349 if ( numMana > 0 ) then
350 combinedMana = floor(combinedMana/numMana*100+0.5);
351 stats["raidMp"][1] = "Raid Mana: " .. combinedMana .. "%";
352 end
353 end
354  
355 -- AFK Count
356 if ( CT_RAMenu_Options["temp"]["StatusMeters"]["AFK Count"] ) then
357 stats["afkCount"][1] = "AFK Count: " .. CT_RAMeters_StatsTable["Generic"]["isAfk"];
358 end
359  
360 -- Dead Count
361 if ( CT_RAMenu_Options["temp"]["StatusMeters"]["Dead Count"] ) then
362 stats["deadCount"][1] = "Dead Count: " .. CT_RAMeters_StatsTable["Generic"]["isDead"];
363 end
364  
365 -- Offline Count
366 if ( CT_RAMenu_Options["temp"]["StatusMeters"]["Offline Count"] ) then
367 stats["offlineCount"][1] = "Offline Count: " .. CT_RAMeters_StatsTable["Generic"]["isOffline"];
368 end
369  
370 -- Health Display
371 if ( CT_RAMenu_Options["temp"]["StatusMeters"]["Health Display"] ) then
372 for k, v in CT_RAMenu_Options["temp"]["StatusMeters"]["Health Display"] do
373 if ( v and CT_RAMeters_StatsTable[k] and CT_RAMeters_StatsTable[k]["num"] > 0 ) then
374 if ( strlen(stats["hpDisplay"][1]) > 0 ) then
375 stats["hpDisplay"][1] = stats["hpDisplay"][1] .. "\n";
376 end
377 stats["hpDisplay"][1] = stats["hpDisplay"][1] .. CT_RAMeters_ColorTable[k] .. k .. " Health: " .. floor(CT_RAMeters_StatsTable[k]["health"]/CT_RAMeters_StatsTable[k]["num"]*100+0.5) .. "%|r";
378 stats["hpDisplay"][2] = stats["hpDisplay"][2] + 1;
379 end
380 end
381 end
382  
383 -- Mana Display
384 if ( CT_RAMenu_Options["temp"]["StatusMeters"]["Mana Display"]) then
385 for k, v in CT_RAMenu_Options["temp"]["StatusMeters"]["Mana Display"] do
386 if ( v and CT_RAMeters_StatsTable[k] and CT_RAMeters_StatsTable[k]["numMana"] > 0 ) then
387 if ( strlen(stats["mpDisplay"][1]) > 0 ) then
388 stats["mpDisplay"][1] = stats["mpDisplay"][1] .. "\n";
389 end
390 stats["mpDisplay"][1] = stats["mpDisplay"][1] .. CT_RAMeters_ColorTable[k] .. k .. " Mana: " .. floor(CT_RAMeters_StatsTable[k]["mana"]/CT_RAMeters_StatsTable[k]["numMana"]*100+0.5) .. "%|r";
391 stats["mpDisplay"][2] = stats["mpDisplay"][2] + 1;
392 end
393 end
394 end
395  
396 -- Add together all the stats
397 local out, numLines = "", 0;
398 local order = {
399 { "raidHp", "|c00FF2222", "|r" },
400 { "raidMp", "|c006666FF", "|r" },
401 { "hpDisplay", "", "" },
402 { "mpDisplay", "", "" },
403 { "deadCount", "|c00666666", "|r" },
404 { "afkCount", "|c00CCCCCC", "|r" },
405 { "offlineCount", "|c00999999", "|r" }
406 };
407 for i = 1, 7, 1 do
408 local val = stats[order[i][1]];
409 if ( strlen(val[1]) > 0 ) then
410 if ( strlen(out) > 0 ) then
411 out = out .. "\n";
412 end
413 out = out .. order[i][2] .. val[1] .. order[i][3];
414 numLines = numLines + val[2];
415 end
416 end
417 if ( out == "" ) then
418 numLines = 1;
419 CT_RAMetersFrameText:SetText("No stats to track");
420 else
421 CT_RAMetersFrameText:SetText(out);
422 end
423 local width = CT_RAMetersFrameText:GetStringWidth();
424 if ( width < 109 ) then
425 width = 109;
426 end
427 CT_RAMetersFrame:SetWidth(width+16);
428 CT_RAMetersFrame:SetHeight(25+(numLines*16));
429 end
430  
431 function CT_RAMeters_OnUpdate(elapsed)
432 this.update = this.update - elapsed;
433 if ( this.update <= 0 ) then
434 this.update = 2;
435 CT_RAMeters_UpdateWindow();
436 end
437 end