vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | |
2 | -- array holding bars |
||
3 | SW_Bars = {}; |
||
4 | |||
5 | SW_BARSEPX = 5; |
||
6 | SW_BARSEPY = 3; |
||
7 | |||
8 | function SW_BarRegister(oB) |
||
9 | |||
10 | local pName = oB:GetParent():GetName(); |
||
11 | |||
12 | if SW_Bars[pName] == nil then SW_Bars[pName] = {}; end |
||
13 | |||
14 | table.insert(SW_Bars[pName], oB); |
||
15 | end |
||
16 | |||
17 | function SW_SelOpt(optButton) |
||
18 | local wasShown = false; |
||
19 | if SW_BarSettingsFrameV2:IsVisible() then |
||
20 | wasShown= true; |
||
21 | SW_BarSettingsFrameV2:Hide(); |
||
22 | if ColorPickerFrame:IsVisible() then |
||
23 | ColorPickerFrame:Hide(); |
||
24 | end |
||
25 | end |
||
26 | local cont = optButton:GetParent():GetParent():GetName(); |
||
27 | |||
28 | SW_Settings["BarFrames"][cont]["Selected"] = optButton.optID; |
||
29 | SW_OptUpdateText(cont); |
||
30 | SW_BarsLayout(cont, true); |
||
31 | if wasShown then |
||
32 | getglobal("SW_BarSettingsFrameV2"):Show(); |
||
33 | end |
||
34 | end |
||
35 | function SW_ToggleReport(frameP) |
||
36 | local frame = getglobal("SW_BarReportFrame") |
||
37 | if( frame:IsVisible() ) then |
||
38 | frame:Hide(); |
||
39 | else |
||
40 | frame.caller = frameP; |
||
41 | frame:Show(); |
||
42 | end |
||
43 | end |
||
44 | function SW_ToggleSync() |
||
45 | local frame = getglobal("SW_BarSyncFrame") |
||
46 | if( frame:IsVisible() ) then |
||
47 | frame:Hide(); |
||
48 | else |
||
49 | frame:Show(); |
||
50 | end |
||
51 | end |
||
52 | function SW_UpdateSyncChanText(newChan) |
||
53 | if tonumber(newChan) then |
||
54 | StaticPopup_Show("SW_InvalidChan"); |
||
55 | end |
||
56 | end |
||
57 | |||
58 | function SW_OptUpdateText(pName) |
||
59 | local selOpt = SW_Settings["BarFrames"][pName]["Selected"]; |
||
60 | local bSet = SW_GetBarSettings(pName); |
||
61 | local b = getglobal(pName.."_Selector_Opt"..selOpt); |
||
62 | local txtOpt = ""; |
||
63 | local txtFrame = ""; |
||
64 | if bSet["OT"] == nil then |
||
65 | txtOpt = selOpt; |
||
66 | else |
||
67 | txtOpt = bSet["OT"]; |
||
68 | end |
||
69 | b.NormalText:SetText(txtOpt); |
||
70 | b.HighlightText:SetText(txtOpt); |
||
71 | if bSet["OTF"] == nil then |
||
72 | txtFrame = selOpt; |
||
73 | else |
||
74 | txtFrame = bSet["OTF"]; |
||
75 | end |
||
76 | getglobal(pName.."_Title_Text"):SetText(txtFrame); |
||
77 | end |
||
78 | function SW_SetOptTxt(opt) |
||
79 | local bS = SW_Settings["InfoSettings"][opt.optID]; |
||
80 | if bS == nil then return; end |
||
81 | local oc = bS["OC"]; |
||
82 | local txt = ""; |
||
83 | if bS == nil or bS["OT"] == nil then |
||
84 | txt = opt.optID; |
||
85 | else |
||
86 | txt = bS["OT"]; |
||
87 | end |
||
88 | opt.NormalText:SetText(txt); |
||
89 | opt.HighlightText:SetText(txt); |
||
90 | --old version check |
||
91 | if oc == nil or (oc[1] == 1 and oc[2] == 0 and oc[3] == 0 and oc[4] == 1) then |
||
92 | oc = SW_Settings["Colors"]["TitleBars"] |
||
93 | end |
||
94 | |||
95 | opt.NormalT:SetVertexColor(unpack(oc)); |
||
96 | opt.HighlightT:SetVertexColor(unpack(oc)); |
||
97 | |||
98 | end |
||
99 | |||
100 | function SW_GetBarSettings(pName) |
||
101 | if SW_Settings["BarFrames"] == nil then |
||
102 | SW_Settings["BarFrames"] = {}; |
||
103 | end |
||
104 | |||
105 | if SW_Settings["BarFrames"][pName] == nil then |
||
106 | SW_Settings["BarFrames"][pName] = {}; |
||
107 | SW_Settings["BarFrames"][pName]["Selected"] = 1; |
||
108 | SW_Settings["BarFrames"][pName]["Docked"] = {1}; |
||
109 | end |
||
110 | -- older version stored other stuff here |
||
111 | if SW_Settings["BarFrames"][pName]["Selected"] == nil then |
||
112 | SW_Settings["BarFrames"][pName] = {}; |
||
113 | SW_Settings["BarFrames"][pName]["Selected"] = 1; |
||
114 | SW_Settings["BarFrames"][pName]["Docked"] = {1}; |
||
115 | end |
||
116 | return SW_GetInfoSettings(SW_Settings["BarFrames"][pName]["Selected"]); |
||
117 | end |
||
118 | function SW_UpdateOptVis(reset) |
||
119 | local nShow = SW_Settings["QuickOptCount"]; |
||
120 | local pre = "SW_BarFrame1_Selector_Opt"; |
||
121 | local toSelect = 1; |
||
122 | if reset ~= nil then |
||
123 | if nShow > 0 then |
||
124 | if SW_Settings["BarFrames"] ~= nil and SW_Settings["BarFrames"]["SW_BarFrame1"] ~= nil then |
||
125 | toSelect = SW_Settings["BarFrames"]["SW_BarFrame1"]["Selected"]; |
||
126 | if toSelect == nil then |
||
127 | toSelect = 1; |
||
128 | end |
||
129 | end |
||
130 | if toSelect > nShow then |
||
131 | SW_SelOpt(getglobal(pre..nShow)); |
||
132 | end |
||
133 | else |
||
134 | SW_SelOpt(getglobal(pre.."1")); |
||
135 | end |
||
136 | end |
||
137 | for i= 1, SW_OPT_COUNT do |
||
138 | if i <= nShow then |
||
139 | getglobal(pre..i):Show(); |
||
140 | else |
||
141 | getglobal(pre..i):Hide(); |
||
142 | end |
||
143 | end |
||
144 | end |
||
145 | function SW_SelectFilter(fName) |
||
146 | getglobal("SW_Filter_NPC"):SetChecked(0); |
||
147 | getglobal("SW_Filter_PC"):SetChecked(0); |
||
148 | getglobal("SW_Filter_Group"):SetChecked(0); |
||
149 | getglobal("SW_Filter_EverGroup"):SetChecked(0); |
||
150 | getglobal("SW_Filter_None"):SetChecked(0); |
||
151 | getglobal(fName):SetChecked(1); |
||
152 | end |
||
153 | function SW_GetInfoSettings(infoNr) |
||
154 | if SW_Settings["InfoSettings"] == nil then |
||
155 | SW_Settings["InfoSettings"] = {} |
||
156 | end |
||
157 | local iS = SW_Settings["InfoSettings"][infoNr]; |
||
158 | |||
159 | |||
160 | if iS == nil then |
||
161 | SW_Settings["InfoSettings"][infoNr] = {} |
||
162 | iS = SW_Settings["InfoSettings"][infoNr]; |
||
163 | for k,v in pairs(SW_DefaultBar) do |
||
164 | if type(v) ~= "table" then |
||
165 | iS[k] = v; |
||
166 | else |
||
167 | iS[k] = {}; |
||
168 | for si, sv in ipairs(v) do |
||
169 | table.insert(iS[k], sv); |
||
170 | end |
||
171 | end |
||
172 | end |
||
173 | else |
||
174 | -- 1.4.2 merging removed bar width and adden colum count |
||
175 | if iS["COLC"] == nil then |
||
176 | iS["BW"] = nil; |
||
177 | iS["COLC"] = 1; |
||
178 | end |
||
179 | end |
||
180 | return iS; |
||
181 | end |
||
182 | -- 1.5 added pausing of data collection |
||
183 | function SW_ToggleRunning(doCollection) |
||
184 | if SW_Settings["SYNCLastChan"]~=nil and SW_SyncCheckInChan(SW_Settings["SYNCLastChan"]) then |
||
185 | doCollection = true; |
||
186 | end |
||
187 | |||
188 | local chkRunnig = getglobal("SW_OptChk_Running"); |
||
189 | local stateChanged = (doCollection ~= SW_Settings["IsRunning"]); |
||
190 | |||
191 | |||
192 | if doCollection then |
||
193 | chkRunnig:SetChecked(1); |
||
194 | SW_Settings["IsRunning"] = true; |
||
195 | else |
||
196 | chkRunnig:SetChecked(0); |
||
197 | SW_Settings["IsRunning"] = false; |
||
198 | end |
||
199 | |||
200 | if stateChanged then |
||
201 | if (doCollection) then |
||
202 | -- turn on stuff |
||
203 | SW_UnpauseEvents(); |
||
204 | else |
||
205 | -- turn off stuff |
||
206 | SW_PauseEvents(); |
||
207 | -- stop CastTrack Pending |
||
208 | SW_Timed_Calls:StopPending(); |
||
209 | -- stop DPS timer |
||
210 | SW_CombatTimeInfo.awaitingStart = false; |
||
211 | SW_CombatTimeInfo.awaitingEnd = false; |
||
212 | end |
||
213 | end |
||
214 | end |
||
215 | function SW_UpdateColor(pName) |
||
216 | local bs = SW_Bars[pName]; |
||
217 | local barSettings = SW_GetBarSettings(pName); |
||
218 | local bc = barSettings["BC"]; |
||
219 | local bfc = barSettings["BFC"]; |
||
220 | local oc = barSettings["OC"]; |
||
221 | |||
222 | local selOpt = SW_Settings["BarFrames"][pName]["Selected"]; |
||
223 | local b = getglobal(pName.."_Selector_Opt"..selOpt); |
||
224 | -- old version check |
||
225 | |||
226 | if oc == nil or (oc[1] == 1 and oc[2] == 0 and oc[3] == 0 and oc[4] == 1) then |
||
227 | oc = SW_Settings["Colors"]["TitleBars"] |
||
228 | end |
||
229 | b.NormalT:SetVertexColor(unpack(oc)); |
||
230 | b.HighlightT:SetVertexColor(unpack(oc)); |
||
231 | |||
232 | for i,b in ipairs(bs) do |
||
233 | getglobal(b:GetName().."_Texture"):SetVertexColor(bc[1],bc[2],bc[3],bc[4]); |
||
234 | getglobal(b:GetName().."_Text"):SetVertexColor(bfc[1],bfc[2],bfc[3],bfc[4]); |
||
235 | getglobal(b:GetName().."_TextVal"):SetVertexColor(bfc[1],bfc[2],bfc[3],bfc[4]); |
||
236 | end |
||
237 | end |
||
238 | function SW_BarsLayout(pName, changeAll) |
||
239 | local bs = SW_Bars[pName]; |
||
240 | if bs == nil then return; end |
||
241 | |||
242 | local bSet = SW_GetBarSettings(pName); |
||
243 | local startX, startY, fWidth, fHeight; |
||
244 | local bHeight, bWidth, fontSize; |
||
245 | local colPos=1; local rowPos=1; |
||
246 | local colCount=bSet["COLC"]; |
||
247 | local oTmp; |
||
248 | local posX = 0; |
||
249 | local posY = 0; |
||
250 | local oP = getglobal(pName); |
||
251 | |||
252 | |||
253 | local changeWidth = false; |
||
254 | local changeHeight = false; |
||
255 | local changeFont = false; |
||
256 | |||
257 | startX = oP.swoBarX; |
||
258 | startY = oP.swoBarY; |
||
259 | fWidth = oP:GetWidth(); |
||
260 | fHeight = oP:GetHeight(); |
||
261 | |||
262 | bAutoWidth = math.floor(((fWidth - 10 - ((colCount - 1) * SW_BARSEPX)) / colCount)); |
||
263 | for i,b in ipairs(bs) do |
||
264 | if oP.lastTexture == nil or oP.lastTexture ~= bSet["BT"] or changeAll then |
||
265 | b:SetStatusBarTexture("Interface\\AddOns\\SW_Stats\\images\\b"..bSet["BT"]); |
||
266 | end |
||
267 | if i == 1 then |
||
268 | fontSize = b:GetFontSize(); |
||
269 | if fontSize ~= bSet["BFS"] or changeAll then |
||
270 | fontSize = bSet["BFS"]; |
||
271 | b:SetFontSize(fontSize); |
||
272 | changeFont = true; |
||
273 | end |
||
274 | bHeight = b:GetHeight(); |
||
275 | if bHeight ~= bSet["BH"] or changeAll then |
||
276 | bHeight = bSet["BH"]; |
||
277 | b:SetHeight(bHeight); |
||
278 | changeHeight = true; |
||
279 | end |
||
280 | bWidth = b:GetWidth(); |
||
281 | if bWidth ~= bAutoWidth or changeAll then |
||
282 | bWidth = bAutoWidth; |
||
283 | b:SetWidth(bWidth); |
||
284 | changeWidth = true; |
||
285 | end |
||
286 | |||
287 | b:Show(); |
||
288 | b:SetPoint("TOPLEFT",pName,"TOPLEFT",startX,startY); |
||
289 | --colCount = math.floor(((fWidth - 10) / (SW_BARSEPX + bWidth))); |
||
290 | rowCount = math.floor(((fHeight - 30) / (SW_BARSEPY + bHeight))); |
||
291 | rowPos = rowPos + 1; |
||
292 | b.canBeSeen = true; |
||
293 | else |
||
294 | if rowPos > rowCount then |
||
295 | rowPos = 1; |
||
296 | colPos = colPos + 1; |
||
297 | end |
||
298 | posX = ((colPos -1) * SW_BARSEPX) + startX + ((colPos -1) * bWidth); |
||
299 | posY = startY -(((rowPos -1) * SW_BARSEPY) + ((rowPos -1) * bHeight)); |
||
300 | -- update |
||
301 | if changeWidth then |
||
302 | b:SetWidth(bWidth); |
||
303 | end |
||
304 | if changeHeight then |
||
305 | b:SetHeight(bHeight); |
||
306 | end |
||
307 | if changeFont then |
||
308 | b:SetFontSize(fontSize); |
||
309 | end |
||
310 | b:SetPoint("TOPLEFT",pName,"TOPLEFT",posX,posY); |
||
311 | |||
312 | rowPos = rowPos + 1; |
||
313 | if posX + bWidth > fWidth then |
||
314 | b:Hide(); |
||
315 | b.canBeSeen = false; |
||
316 | else |
||
317 | b:Show(); |
||
318 | b.canBeSeen = true; |
||
319 | end |
||
320 | |||
321 | end |
||
322 | end |
||
323 | |||
324 | if changeAll then |
||
325 | SW_UpdateColor(pName); |
||
326 | end |
||
327 | --this forces the ui to create new font objects -> text is clear |
||
328 | if changeFont then |
||
329 | local tmpScale = oP:GetScale(); |
||
330 | oP:SetScale(tmpScale + 0.01); |
||
331 | oP:SetScale(tmpScale); |
||
332 | end |
||
333 | |||
334 | oP.lastTexture = bSet["BT"]; |
||
335 | |||
336 | end |
||
337 | function SW_OptKey(num) |
||
338 | if not getglobal("SW_BarFrame1"):IsVisible() then |
||
339 | getglobal("SW_BarFrame1"):Show() |
||
340 | end |
||
341 | SW_SelOpt(getglobal("SW_BarFrame1_Selector_Opt"..num)); |
||
342 | end |
||
343 | function SW_BarLayoutRegisterd() |
||
344 | for f,_ in pairs(SW_Bars) do |
||
345 | SW_BarsLayout(f); |
||
346 | SW_UpdateColor(f); |
||
347 | SW_OptUpdateText(f); |
||
348 | end |
||
349 | end |
||
350 | function SW_BarLayoutRegisterdOnResize() |
||
351 | for f,_ in pairs(SW_Bars) do |
||
352 | if getglobal(f).isResizing then |
||
353 | SW_BarsLayout(f); |
||
354 | end |
||
355 | end |
||
356 | end |
||
357 | function SW_InitBarFrameBar(b) |
||
358 | local scTarget = b:GetName().."_Texture"; |
||
359 | getglobal(scTarget):SetVertexColor(0,0.8,0,1); |
||
360 | b:SetMinMaxValues(0,100); |
||
361 | b:SetValue(100); |
||
362 | SW_BarRegister(this); |
||
363 | b.LText = getglobal(b:GetName().."_Text"); |
||
364 | b.RText = getglobal(b:GetName().."_TextVal"); |
||
365 | b.SelfBar = this; |
||
366 | b.canBeSeen = false; |
||
367 | function b:SetBarText(text) |
||
368 | if text == nil then |
||
369 | self.LText:SetText(" "); |
||
370 | self.SelfBar:Hide(); |
||
371 | else |
||
372 | self.LText:SetText(text); |
||
373 | self.SelfBar:Show(); |
||
374 | end |
||
375 | end |
||
376 | function b:SetValText(text) |
||
377 | self.RText:SetText(text); |
||
378 | end |
||
379 | function b:GetFontSize() |
||
380 | return math.floor(self.LText:GetHeight() + 0.5); |
||
381 | end |
||
382 | function b:SetFontSize(h) |
||
383 | -- this distorts text check SW_BarsLayout() for fix |
||
384 | self.LText:SetTextHeight(h); |
||
385 | self.RText:SetTextHeight(h); |
||
386 | end |
||
387 | end |
||
388 | |||
389 | function SW_SetBarColor(what) |
||
390 | local R,G,B = ColorPickerFrame:GetColorRGB(); |
||
391 | local A = 1 - OpacitySliderFrame:GetValue(); |
||
392 | local bfc; |
||
393 | |||
394 | if what == "DIRECT" then |
||
395 | bfc = ColorPickerFrame.SWColorTable |
||
396 | else |
||
397 | local barSettings = SW_GetBarSettings(ColorPickerFrame.SWBarFrame); |
||
398 | bfc = barSettings[what]; |
||
399 | end |
||
400 | |||
401 | |||
402 | bfc[1] = R; bfc[2] = G; bfc[3] = B; bfc[4] = A; |
||
403 | |||
404 | if what == "DIRECT" then |
||
405 | if ColorPickerFrame.SWCallOnUpdate then |
||
406 | ColorPickerFrame.SWCallOnUpdate(bfc); |
||
407 | end |
||
408 | else |
||
409 | SW_UpdateColor(ColorPickerFrame.SWBarFrame); |
||
410 | end |
||
411 | if ColorPickerFrame.SWCSName ~= nil then |
||
412 | getglobal(ColorPickerFrame.SWCSName):SetColor(bfc); |
||
413 | end |
||
414 | end |
||
415 | function SW_CancelBarColor(oldVals, what) |
||
416 | local bfc; |
||
417 | |||
418 | if what == "DIRECT" then |
||
419 | bfc = ColorPickerFrame.SWColorTable |
||
420 | else |
||
421 | local barSettings = SW_GetBarSettings(ColorPickerFrame.SWBarFrame); |
||
422 | bfc = barSettings[what]; |
||
423 | end |
||
424 | |||
425 | bfc[1] = oldVals[1]; bfc[2] = oldVals[2]; |
||
426 | bfc[3] = oldVals[3]; bfc[4] = oldVals[4]; |
||
427 | if what == "DIRECT" then |
||
428 | if ColorPickerFrame.SWCallOnUpdate then |
||
429 | ColorPickerFrame.SWCallOnUpdate(bfc); |
||
430 | end |
||
431 | else |
||
432 | SW_UpdateColor(ColorPickerFrame.SWBarFrame); |
||
433 | end |
||
434 | if ColorPickerFrame.SWCSName ~= nil then |
||
435 | getglobal(ColorPickerFrame.SWCSName):SetColor(bfc); |
||
436 | end |
||
437 | end |
||
438 | -- 1.5.3 TODO Low Prio I should redo this sometime the color picker thing is getting messy |
||
439 | -- probably could just reduce it to "DIRECT" color and callOnUpdate |
||
440 | function SW_DoColorPicker(targetFrame, what, csName, callOnUpdate) |
||
441 | if ColorPickerFrame:IsVisible() then return; end |
||
442 | local bfc; |
||
443 | |||
444 | if what == "DIRECT" then |
||
445 | bfc = targetFrame; |
||
446 | ColorPickerFrame.SWBarFrame = "SW_BarFrame1"; |
||
447 | ColorPickerFrame.SWColorTable = targetFrame; |
||
448 | ColorPickerFrame.SWCallOnUpdate = callOnUpdate; |
||
449 | |||
450 | else |
||
451 | |||
452 | local barSettings = SW_GetBarSettings(targetFrame); |
||
453 | |||
454 | bfc = barSettings[what]; |
||
455 | if bfc == nil then |
||
456 | barSettings[what] = {1,0,0,1}; |
||
457 | bfc = barSettings[what]; |
||
458 | end |
||
459 | |||
460 | |||
461 | if bfc[1]==1 and bfc[2]==0 and bfc[3]==0 and bfc[4]==1 then |
||
462 | bfc = SW_Settings["Colors"]["TitleBars"]; |
||
463 | |||
464 | end |
||
465 | |||
466 | ColorPickerFrame.SWBarFrame = targetFrame; |
||
467 | ColorPickerFrame.SWColorTable = nil; |
||
468 | end |
||
469 | |||
470 | ColorPickerFrame.SWCSName = csName; |
||
471 | ColorPickerFrame.opacityFunc = function() SW_SetBarColor(what); end |
||
472 | ColorPickerFrame.func = function() SW_SetBarColor(what); end |
||
473 | ColorPickerFrame.cancelFunc = function(oldVals) SW_CancelBarColor(oldVals, what); end |
||
474 | ColorPickerFrame.hasOpacity = true; |
||
475 | ColorPickerFrame.opacity = 1 - bfc[4]; |
||
476 | ColorPickerFrame.previousValues = {bfc[1], bfc[2], bfc[3], bfc[4]}; |
||
477 | ColorPickerFrame:SetColorRGB(bfc[1], bfc[2], bfc[3]); |
||
478 | ColorPickerFrame:Show(); |
||
479 | end |
||
480 | function SW_UpdateClassColorAlpha(newColor) |
||
481 | local alpha = newColor[4]; |
||
482 | SW_Settings["Colors"]["DRUID"][4] = alpha; |
||
483 | SW_Settings["Colors"]["HUNTER"][4] = alpha; |
||
484 | SW_Settings["Colors"]["MAGE"][4] = alpha; |
||
485 | SW_Settings["Colors"]["PALADIN"][4] = alpha; |
||
486 | SW_Settings["Colors"]["PRIEST"][4] = alpha; |
||
487 | SW_Settings["Colors"]["ROGUE"][4] = alpha; |
||
488 | SW_Settings["Colors"]["SHAMAN"][4] = alpha; |
||
489 | SW_Settings["Colors"]["WARLOCK"][4] = alpha; |
||
490 | SW_Settings["Colors"]["WARRIOR"][4] = alpha; |
||
491 | end |
||
492 | function SW_UpdateFrameBackdrops(newColor) |
||
493 | local tmpTarget; |
||
494 | for i, k in ipairs(SW_Registerd_BF_Titles) do |
||
495 | tmpTarget = getglobal(k):GetParent(); |
||
496 | tmpTarget:SetBackdropBorderColor(unpack(newColor)); |
||
497 | end |
||
498 | local tmpCol = {unpack(newColor)}; |
||
499 | tmpCol[4] = 1; |
||
500 | |||
501 | --for SW_TabbedFrameInfo[pName][oTab:GetName()] |
||
502 | for k, v in pairs(SW_TabbedFrameInfo) do |
||
503 | for k2, v2 in pairs(v) do |
||
504 | tmpTarget = getglobal(k2); |
||
505 | if tmpTarget.IsSelectedTab then |
||
506 | tmpTarget:SetBackdropBorderColor(unpack(tmpCol)); |
||
507 | getglobal(k2.."_Text"):SetTextColor(unpack(tmpCol)); |
||
508 | end |
||
509 | end |
||
510 | end |
||
511 | end |
||
512 | function SW_LockFrames(isLocked) |
||
513 | if isLocked then |
||
514 | SW_Settings["BFLocked"] = true; |
||
515 | else |
||
516 | SW_Settings["BFLocked"] = nil; |
||
517 | end |
||
518 | for i, k in ipairs(SW_Registerd_BF_Titles) do |
||
519 | getglobal(k):GetParent().isLocked = isLocked; |
||
520 | end |
||
521 | end |
||
522 | function SW_UpdateMainWinBack(newColor) |
||
523 | SW_BarFrame1:SetBackdropColor(unpack(SW_Settings["Colors"]["MainWinBack"])) |
||
524 | end |
||
525 | function SW_UpdateTitleColor(newColor) |
||
526 | local tmpTarget; |
||
527 | local regEx = "SW_BarFrame1_Selector_Opt(%d+)" |
||
528 | local oc; |
||
529 | |||
530 | for i, k in ipairs(SW_Registerd_BF_Titles) do |
||
531 | tmpTarget = getglobal(k .. "_Texture"); |
||
532 | tmpTarget:SetVertexColor(unpack(newColor)); |
||
533 | end |
||
534 | |||
535 | for i, k in ipairs(SW_Registered_BF_TitleButtons) do |
||
536 | s,e, id = string.find(k, regEx); |
||
537 | oc = nil; |
||
538 | if id ~= nil then |
||
539 | id = tonumber(id); |
||
540 | |||
541 | if SW_Settings["InfoSettings"] and SW_Settings["InfoSettings"][id] then |
||
542 | oc = SW_Settings["InfoSettings"][id]["OC"]; |
||
543 | end |
||
544 | if not oc or (oc[1] == 1 and oc[2] == 0 and oc[3] == 0 and oc[4] == 1) then |
||
545 | --oc = SW_Settings["Colors"]["TitleBars"] |
||
546 | tmpTarget = getglobal(k); |
||
547 | tmpTarget.NormalT:SetVertexColor(unpack(newColor)); |
||
548 | tmpTarget.HighlightT:SetVertexColor(unpack(newColor)); |
||
549 | end |
||
550 | else |
||
551 | tmpTarget = getglobal(k); |
||
552 | tmpTarget.NormalT:SetVertexColor(unpack(newColor)); |
||
553 | tmpTarget.HighlightT:SetVertexColor(unpack(newColor)); |
||
554 | end |
||
555 | |||
556 | |||
557 | end |
||
558 | |||
559 | |||
560 | end |
||
561 | function SW_UpdateTitleTextColor(newColor) |
||
562 | local tmpTarget; |
||
563 | local regEx = "SW_BarFrame1_Selector_Opt(%d+)" |
||
564 | local id = 0; |
||
565 | for i, k in ipairs(SW_Registerd_BF_Titles) do |
||
566 | tmpTarget = getglobal(k .. "_Text"); |
||
567 | tmpTarget:SetVertexColor(unpack(newColor)); |
||
568 | end |
||
569 | local barSettings = SW_GetBarSettings("SW_BarFrame1"); |
||
570 | |||
571 | for i, k in ipairs(SW_Registered_BF_TitleButtons) do |
||
572 | s,e, id = string.find(k, regEx) |
||
573 | if not id then |
||
574 | tmpTarget = getglobal(k); |
||
575 | tmpTarget.NormalText:SetVertexColor(unpack(newColor)); |
||
576 | tmpTarget.NormalText:SetVertexColor(unpack(newColor)); |
||
577 | end |
||
578 | end |
||
579 | |||
580 | end |
||
581 | |||
582 | function SW_BarsCheckFilters(name, SF, CF, PF) |
||
583 | local selFil = ""; |
||
584 | local charFil = ""; |
||
585 | local cType = nil; |
||
586 | local petFil = nil; |
||
587 | |||
588 | if PF == nil then |
||
589 | petFil = getglobal("SW_PF_Inactive").petFil; |
||
590 | else |
||
591 | petFil = getglobal(PF).petFil; |
||
592 | end |
||
593 | |||
594 | -- only if the pet filters are set to inactive |
||
595 | -- add pets here, else they are handeled after this |
||
596 | if petFil.Inactive then |
||
597 | petFil = true; |
||
598 | else |
||
599 | if SW_PetInfo["PET_OWNER"][name] == nil then |
||
600 | -- this isn't, and never was a pet |
||
601 | petFil = true; |
||
602 | else |
||
603 | if SW_S_Details[name] ~= nil and SW_S_Details[name]["UTYPE"] == "GPET" then |
||
604 | petFil = false; |
||
605 | else |
||
606 | petFil = true; |
||
607 | end |
||
608 | end |
||
609 | end |
||
610 | |||
611 | if not petFil then return false; end |
||
612 | |||
613 | if SW_S_Details[name] == nil then return false; end |
||
614 | if SF == nil then |
||
615 | selFil = getglobal("SW_Filter_None").SW_Filter; |
||
616 | else |
||
617 | selFil = getglobal(SF).SW_Filter; |
||
618 | end |
||
619 | if CF == nil then |
||
620 | charFil = SW_ClassFilters[1] |
||
621 | else |
||
622 | charFil = SW_ClassFilters[ CF ] |
||
623 | end |
||
624 | if selFil == "NONE" and charFil == "NONE" then |
||
625 | return true; |
||
626 | end |
||
627 | |||
628 | if selFil == "NONE" then |
||
629 | selFil = true; |
||
630 | else |
||
631 | --1.5 filters added EGROUP types added GPET GPC |
||
632 | if selFil == "GROUP" then |
||
633 | if SW_Friends[name] == nil then |
||
634 | selFil = SW_PetHasOwner(name); |
||
635 | else |
||
636 | selFil = true; |
||
637 | end |
||
638 | elseif selFil == "EGROUP" then |
||
639 | cType = SW_S_Details[name]["UTYPE"]; |
||
640 | selFil = (cType == "GPC" or cType == "GPET"); |
||
641 | elseif selFil == "PC" then |
||
642 | cType = SW_S_Details[name]["UTYPE"]; |
||
643 | selFil = (cType == "GPC" or cType == "GPET" or cType == "PC"); |
||
644 | else |
||
645 | selFil = (selFil == SW_S_Details[name]["UTYPE"]); |
||
646 | end |
||
647 | end |
||
648 | if charFil == "NONE" then |
||
649 | charFil = true; |
||
650 | else |
||
651 | charFil = (charFil == SW_S_Details[name]["CLASSE"]); |
||
652 | end |
||
653 | if selFil and charFil then |
||
654 | return true; |
||
655 | else |
||
656 | return false; |
||
657 | end |
||
658 | end |
||
659 | --SW_EntityBarColor |
||
660 | function SW_EBC(ent, bs) |
||
661 | |||
662 | if bs["UCC"] then |
||
663 | if SW_Friends[ent] == nil or SW_Friends[ent]["CLASSE"] == nil then |
||
664 | if SW_S_Details[ent] == nil or SW_S_Details[ent]["CLASSE"] == nil then |
||
665 | return bs["BC"]; |
||
666 | else |
||
667 | return SW_Settings["Colors"][ SW_S_Details[ent]["CLASSE"] ]; |
||
668 | end |
||
669 | else |
||
670 | return SW_Settings["Colors"][ SW_S_Details[ent]["CLASSE"] ]; |
||
671 | end |
||
672 | else |
||
673 | return nil; |
||
674 | end |
||
675 | end |
||
676 | function SW_AddLatePetInfo(vals, petFil, type, index, bSet) |
||
677 | |||
678 | local SF = bSet["SF"]; |
||
679 | local CF = bSet["CF"]; |
||
680 | local PF = "SW_PF_Inactive"; |
||
681 | |||
682 | if petFil.Active then |
||
683 | for k,v in pairs(SW_PetInfo["PET_OWNER"]) do |
||
684 | if SW_BarsCheckFilters(k, SF, CF, PF) then |
||
685 | tmpVal = v[type][index]; |
||
686 | if tmpVal >0 then |
||
687 | table.insert(vals, {SW_STR_PET_PREFIX..k,tmpVal,SW_EBC(k,bSet)}); |
||
688 | end |
||
689 | end |
||
690 | end |
||
691 | elseif petFil.Current then |
||
692 | -- for EGROUP filter just do the same as active, it just makes more sense |
||
693 | -- from a user perspective current pets in in ever group..oO nah |
||
694 | local selFil; |
||
695 | if SF ~= nil then |
||
696 | selFil = getglobal(SF).SW_Filter; |
||
697 | end |
||
698 | if selFil == "EGROUP" then |
||
699 | for k,v in pairs(SW_PetInfo["PET_OWNER"]) do |
||
700 | if SW_BarsCheckFilters(k, SF, CF, PF) then |
||
701 | tmpVal = v[type][index]; |
||
702 | if tmpVal >0 then |
||
703 | table.insert(vals, {SW_STR_PET_PREFIX..k,tmpVal,SW_EBC(k,bSet)}); |
||
704 | end |
||
705 | end |
||
706 | end |
||
707 | else |
||
708 | for k,v in pairs(SW_PetInfo["PET_OWNER"]) do |
||
709 | if SW_PetHasOwner(k) then |
||
710 | tmpVal = v[type][index]; |
||
711 | if tmpVal > 0 then |
||
712 | table.insert(vals, {SW_STR_PET_PREFIX..k,tmpVal,SW_EBC(k,bSet)}); |
||
713 | end |
||
714 | end |
||
715 | end |
||
716 | end |
||
717 | elseif petFil.VPP then |
||
718 | for k,v in pairs(SW_PetInfo["OWNER_PET"]) do |
||
719 | if SW_BarsCheckFilters(k, SF, CF, PF) then |
||
720 | tmpVal = v[type][index]; |
||
721 | if tmpVal > 0 then |
||
722 | table.insert(vals, {SW_STR_VPP_PREFIX..k,tmpVal,SW_EBC(k,bSet)}); |
||
723 | end |
||
724 | end |
||
725 | end |
||
726 | elseif petFil.VPR then |
||
727 | tmpVal = 0; |
||
728 | for k,v in pairs(SW_PetInfo["PET_OWNER"]) do |
||
729 | if SW_BarsCheckFilters(k, SF, CF, PF) then |
||
730 | tmpVal = tmpVal + v[type][index]; |
||
731 | end |
||
732 | end |
||
733 | if tmpVal >0 then |
||
734 | table.insert(vals, {SW_STR_VPR,tmpVal,SW_EBC(k,bSet)}); |
||
735 | end |
||
736 | --elseif petFil.Ignore then -- well nothing to do here |
||
737 | end |
||
738 | end |
||
739 | function SW_GetDeathInfo(SF, CF, PF, bSet) |
||
740 | local vals = {}; |
||
741 | local tmpVal; |
||
742 | |||
743 | -- ignore pet filter here |
||
744 | for k,v in pairs(SW_S_Details) do |
||
745 | tmpVal = v[SW_PRINT_ITEM_DEATHS]; |
||
746 | if tmpVal ~= nil then |
||
747 | if SW_BarsCheckFilters(k, SF, CF, "SW_PF_Inactive") then |
||
748 | table.insert(vals, {k,tmpVal,SW_EBC(k,bSet)}); |
||
749 | end |
||
750 | end |
||
751 | end |
||
752 | |||
753 | table.sort(vals, |
||
754 | function(a,b) |
||
755 | return a[2] > b[2]; |
||
756 | end); |
||
757 | |||
758 | return vals; |
||
759 | end |
||
760 | |||
761 | function SW_GetDmgInfo(SF, CF, PF, bSet) |
||
762 | local vals = {}; |
||
763 | local tmpVal; |
||
764 | local petFil = nil; |
||
765 | if PF == nil then |
||
766 | petFil = getglobal("SW_PF_Inactive").petFil; |
||
767 | else |
||
768 | petFil = getglobal(PF).petFil; |
||
769 | end |
||
770 | |||
771 | for k,v in pairs(SW_S_Details) do |
||
772 | if v[SW_PRINT_ITEM_TOTAL_DONE] ~= nil then |
||
773 | tmpVal = v[SW_PRINT_ITEM_TOTAL_DONE][1]; |
||
774 | if SW_BarsCheckFilters(k, SF, CF, PF) then |
||
775 | if (petFil.MM or petFil.MB) and SW_PetInfo["OWNER_PET"][k] ~= nil then |
||
776 | tmpVal = tmpVal + SW_PetInfo["OWNER_PET"][k][SW_PRINT_ITEM_TOTAL_DONE][1]; |
||
777 | end |
||
778 | if tmpVal >0 then |
||
779 | table.insert(vals, {k,tmpVal,SW_EBC(k,bSet)}); |
||
780 | end |
||
781 | end |
||
782 | end |
||
783 | end |
||
784 | |||
785 | if petFil.latePets then |
||
786 | SW_AddLatePetInfo(vals, petFil, SW_PRINT_ITEM_TOTAL_DONE, 1, bSet); |
||
787 | end |
||
788 | table.sort(vals, |
||
789 | function(a,b) |
||
790 | return a[2] > b[2]; |
||
791 | end); |
||
792 | |||
793 | return vals; |
||
794 | end |
||
795 | function SW_GetDmgInfoDPS(SF, CF, PF, bSet) |
||
796 | local vals = {}; |
||
797 | local tmpVal; |
||
798 | local petFil = nil; |
||
799 | if PF == nil then |
||
800 | petFil = getglobal("SW_PF_Inactive").petFil; |
||
801 | else |
||
802 | petFil = getglobal(PF).petFil; |
||
803 | end |
||
804 | |||
805 | for k,v in pairs(SW_S_Details) do |
||
806 | if v[SW_PRINT_ITEM_TOTAL_DONE] ~= nil then |
||
807 | tmpVal = v[SW_PRINT_ITEM_TOTAL_DONE][1]; |
||
808 | if SW_BarsCheckFilters(k, "SW_Filter_EverGroup", CF, PF) then |
||
809 | if (petFil.MM or petFil.MB) and SW_PetInfo["OWNER_PET"][k] ~= nil then |
||
810 | tmpVal = tmpVal + SW_PetInfo["OWNER_PET"][k][SW_PRINT_ITEM_TOTAL_DONE][1]; |
||
811 | end |
||
812 | if tmpVal >0 then |
||
813 | table.insert(vals, {k,tmpVal,SW_EBC(k,bSet)}); |
||
814 | end |
||
815 | end |
||
816 | end |
||
817 | end |
||
818 | |||
819 | if petFil.latePets then |
||
820 | SW_AddLatePetInfo(vals, petFil, SW_PRINT_ITEM_TOTAL_DONE, 1, bSet); |
||
821 | end |
||
822 | local secs = SW_RPS.currentSecs + SW_RPS.totalSecs; |
||
823 | for k, v in ipairs(vals) do |
||
824 | --SW_printStr(v[2]..".."..secs); |
||
825 | v[2] = math.floor( (v[2] / secs) * 100 + 0.5) / 100; |
||
826 | end |
||
827 | |||
828 | table.sort(vals, |
||
829 | function(a,b) |
||
830 | return a[2] > b[2]; |
||
831 | end); |
||
832 | |||
833 | return vals; |
||
834 | end |
||
835 | function SW_GetDmgGotInfo(SF, CF, PF, bSet) |
||
836 | local vals = {}; |
||
837 | local tmpVal; |
||
838 | local petFil = nil; |
||
839 | if PF == nil then |
||
840 | petFil = getglobal("SW_PF_Inactive").petFil; |
||
841 | else |
||
842 | petFil = getglobal(PF).petFil; |
||
843 | end |
||
844 | |||
845 | for k,v in pairs(SW_S_Details) do |
||
846 | if v[SW_PRINT_ITEM_RECIEVED] ~= nil then |
||
847 | tmpVal = v[SW_PRINT_ITEM_RECIEVED][1]; |
||
848 | if SW_BarsCheckFilters(k, SF, CF, PF) then |
||
849 | if (petFil.MR or petFil.MB) and SW_PetInfo["OWNER_PET"][k] ~= nil then |
||
850 | tmpVal = tmpVal + SW_PetInfo["OWNER_PET"][k][SW_PRINT_ITEM_RECIEVED][1]; |
||
851 | end |
||
852 | if tmpVal >0 then |
||
853 | table.insert(vals, {k,tmpVal,SW_EBC(k,bSet)}); |
||
854 | end |
||
855 | end |
||
856 | end |
||
857 | end |
||
858 | if petFil.latePets then |
||
859 | SW_AddLatePetInfo(vals, petFil, SW_PRINT_ITEM_RECIEVED, 1, bSet); |
||
860 | end |
||
861 | |||
862 | table.sort(vals, |
||
863 | function(a,b) |
||
864 | return a[2] > b[2]; |
||
865 | end); |
||
866 | return vals; |
||
867 | end |
||
868 | |||
869 | function SW_GetHealGotInfo(SF, CF, PF, bSet) |
||
870 | local vals = {}; |
||
871 | local tmpVal; |
||
872 | local petFil = nil; |
||
873 | if PF == nil then |
||
874 | petFil = getglobal("SW_PF_Inactive").petFil; |
||
875 | else |
||
876 | petFil = getglobal(PF).petFil; |
||
877 | end |
||
878 | |||
879 | for k,v in pairs(SW_S_Details) do |
||
880 | if v[SW_PRINT_ITEM_RECIEVED] ~= nil then |
||
881 | tmpVal = v[SW_PRINT_ITEM_RECIEVED][2]; |
||
882 | if SW_BarsCheckFilters(k, SF, CF, PF) then |
||
883 | if (petFil.MR or petFil.MB) and SW_PetInfo["OWNER_PET"][k] ~= nil then |
||
884 | tmpVal = tmpVal + SW_PetInfo["OWNER_PET"][k][SW_PRINT_ITEM_RECIEVED][2]; |
||
885 | end |
||
886 | if tmpVal >0 then |
||
887 | table.insert(vals, {k,tmpVal,SW_EBC(k,bSet)}); |
||
888 | end |
||
889 | end |
||
890 | end |
||
891 | end |
||
892 | |||
893 | if petFil.latePets then |
||
894 | SW_AddLatePetInfo(vals, petFil, SW_PRINT_ITEM_RECIEVED, 2, bSet); |
||
895 | end |
||
896 | |||
897 | table.sort(vals, |
||
898 | function(a,b) |
||
899 | return a[2] > b[2]; |
||
900 | end); |
||
901 | |||
902 | return vals; |
||
903 | end |
||
904 | function SW_GetDamageManaInfo(SF, CF, PF, bSet) |
||
905 | local vals = {}; |
||
906 | local ratio; |
||
907 | local dmg; |
||
908 | |||
909 | for k,v in pairs(SW_S_Details) do |
||
910 | if SW_S_ManaUsage[k] ~= nil and SW_S_ManaUsage[k][1] > 0 then |
||
911 | if SW_BarsCheckFilters(k, SF, CF, "SW_PF_Inactive") then |
||
912 | -- filter out hunters |
||
913 | -- hm would have to filter out palas and shamans aswell |
||
914 | --if v["CLASSE"] ~= "HUNTER" then |
||
915 | if v[SW_PRINT_ITEM_TOTAL_DONE] ~= nil then |
||
916 | dmg = v[SW_PRINT_ITEM_TOTAL_DONE][1]; |
||
917 | if dmg > 0 then |
||
918 | ratio = math.floor( (dmg / SW_S_ManaUsage[k][1]) * 1000 + 0.5) / 1000; |
||
919 | table.insert(vals, {k,ratio,SW_EBC(k,bSet)}); |
||
920 | end |
||
921 | end |
||
922 | --end |
||
923 | end |
||
924 | end |
||
925 | end |
||
926 | |||
927 | table.sort(vals, |
||
928 | function(a,b) |
||
929 | return a[2] > b[2]; |
||
930 | end); |
||
931 | return vals; |
||
932 | end |
||
933 | function SW_GetEffectiveHealManaInfo(SF, CF, PF, bSet) |
||
934 | local vals = {}; |
||
935 | local eHeal; |
||
936 | local ratio; |
||
937 | |||
938 | for k,v in pairs(SW_S_Details) do |
||
939 | if SW_S_ManaUsage[k] ~= nil and SW_S_ManaUsage[k][2] > 0 then |
||
940 | if SW_BarsCheckFilters(k, SF, CF, "SW_PF_Inactive") then |
||
941 | |||
942 | eHeal = SW_GetEffectiveHealInfoFor(k); |
||
943 | if eHeal > 0 then |
||
944 | ratio = math.floor( (eHeal / SW_S_ManaUsage[k][2]) * 1000 + 0.5) / 1000; |
||
945 | table.insert(vals, {k,ratio,SW_EBC(k,bSet)}); |
||
946 | end |
||
947 | end |
||
948 | end |
||
949 | end |
||
950 | |||
951 | table.sort(vals, |
||
952 | function(a,b) |
||
953 | return a[2] > b[2]; |
||
954 | end); |
||
955 | return vals; |
||
956 | end |
||
957 | function SW_GetEffectiveHealInfoFor(name) |
||
958 | local tmpVal; |
||
959 | local eHeal; |
||
960 | local k = name; |
||
961 | |||
962 | local v = SW_S_Details[k]; |
||
963 | if v == nil then |
||
964 | return 0; |
||
965 | end |
||
966 | |||
967 | tmpVal = v[SW_PRINT_ITEM_TOTAL_DONE][2]; |
||
968 | |||
969 | if tmpVal >0 then |
||
970 | if SW_S_Healed[k] ~= nil and SW_S_Healed[k][SW_OVERHEAL] ~= nil then |
||
971 | eHeal = tmpVal - SW_S_Healed[k][SW_OVERHEAL]; |
||
972 | if eHeal > 0 then |
||
973 | return eHeal; |
||
974 | end |
||
975 | else |
||
976 | return tmpVal; |
||
977 | end |
||
978 | end |
||
979 | |||
980 | return 0; |
||
981 | |||
982 | end |
||
983 | |||
984 | function SW_GetEffectiveHealInfo(SF, CF, PF, bSet) |
||
985 | local vals = {}; |
||
986 | local tmpVal; |
||
987 | local eHeal; |
||
988 | |||
989 | for k,v in pairs(SW_S_Details) do |
||
990 | if v[SW_PRINT_ITEM_TOTAL_DONE] ~= nil then |
||
991 | tmpVal = v[SW_PRINT_ITEM_TOTAL_DONE][2]; |
||
992 | if SW_BarsCheckFilters(k, SF, CF, "SW_PF_Inactive") then |
||
993 | if tmpVal >0 then |
||
994 | if SW_S_Healed[k] ~= nil and SW_S_Healed[k][SW_OVERHEAL] ~= nil then |
||
995 | eHeal = tmpVal - SW_S_Healed[k][SW_OVERHEAL]; |
||
996 | if eHeal > 0 then |
||
997 | table.insert(vals, {k,eHeal,SW_EBC(k,bSet)}); |
||
998 | end |
||
999 | else |
||
1000 | table.insert(vals, {k,tmpVal,SW_EBC(k,bSet)}); |
||
1001 | end |
||
1002 | end |
||
1003 | end |
||
1004 | end |
||
1005 | end |
||
1006 | |||
1007 | table.sort(vals, |
||
1008 | function(a,b) |
||
1009 | return a[2] > b[2]; |
||
1010 | end); |
||
1011 | return vals; |
||
1012 | end |
||
1013 | function SW_GetHealInfo(SF, CF, PF, bSet) |
||
1014 | local vals = {}; |
||
1015 | local tmpVal; |
||
1016 | local petFil = nil; |
||
1017 | if PF == nil then |
||
1018 | petFil = getglobal("SW_PF_Inactive").petFil; |
||
1019 | else |
||
1020 | petFil = getglobal(PF).petFil; |
||
1021 | end |
||
1022 | |||
1023 | for k,v in pairs(SW_S_Details) do |
||
1024 | if v[SW_PRINT_ITEM_TOTAL_DONE] ~= nil then |
||
1025 | tmpVal = v[SW_PRINT_ITEM_TOTAL_DONE][2]; |
||
1026 | if SW_BarsCheckFilters(k, SF, CF, PF) then |
||
1027 | if (petFil.MM or petFil.MB) and SW_PetInfo["OWNER_PET"][k] ~= nil then |
||
1028 | tmpVal = tmpVal + SW_PetInfo["OWNER_PET"][k][SW_PRINT_ITEM_TOTAL_DONE][2]; |
||
1029 | end |
||
1030 | if tmpVal >0 then |
||
1031 | table.insert(vals, {k,tmpVal,SW_EBC(k,bSet)}); |
||
1032 | end |
||
1033 | end |
||
1034 | end |
||
1035 | end |
||
1036 | |||
1037 | if petFil.latePets then |
||
1038 | SW_AddLatePetInfo(vals, petFil, SW_PRINT_ITEM_TOTAL_DONE, 2, bSet); |
||
1039 | end |
||
1040 | |||
1041 | table.sort(vals, |
||
1042 | function(a,b) |
||
1043 | return a[2] > b[2]; |
||
1044 | end); |
||
1045 | return vals; |
||
1046 | end |
||
1047 | function SW_GetOverHealInfo(SF, CF, PF, bSet) |
||
1048 | local vals = {}; |
||
1049 | local tmpVal; |
||
1050 | local pOh; |
||
1051 | |||
1052 | for k,v in pairs(SW_S_Details) do |
||
1053 | if v[SW_PRINT_ITEM_TOTAL_DONE] ~= nil then |
||
1054 | tmpVal = v[SW_PRINT_ITEM_TOTAL_DONE][2]; |
||
1055 | if SW_BarsCheckFilters(k, SF, CF, "SW_PF_Inactive") then |
||
1056 | if tmpVal >0 then |
||
1057 | if SW_S_Healed[k] ~= nil and SW_S_Healed[k][SW_OVERHEAL] then |
||
1058 | pOh = math.floor((SW_S_Healed[k][SW_OVERHEAL]/ tmpVal) * 1000 +0.5)/10; |
||
1059 | table.insert(vals, {k.." ("..pOh.."%)",SW_S_Healed[k][SW_OVERHEAL], SW_EBC(k,bSet)}); |
||
1060 | end |
||
1061 | end |
||
1062 | end |
||
1063 | end |
||
1064 | end |
||
1065 | |||
1066 | table.sort(vals, |
||
1067 | function(a,b) |
||
1068 | return a[2] > b[2]; |
||
1069 | end); |
||
1070 | |||
1071 | return vals; |
||
1072 | end |
||
1073 | function SW_GetHealInfoHealer(whoName) |
||
1074 | local vals = {}; |
||
1075 | local who = SW_S_Healed[ whoName ]; |
||
1076 | |||
1077 | if who == nil then return {}; end; |
||
1078 | local bSet = SW_GetBarSettings("SW_BarFrame1"); |
||
1079 | |||
1080 | for k,v in pairs(who) do |
||
1081 | if v > 0 and k ~= SW_OVERHEAL then |
||
1082 | table.insert(vals, {k,v,SW_EBC(k,bSet)}); |
||
1083 | end |
||
1084 | end |
||
1085 | table.sort(vals, |
||
1086 | function(a,b) |
||
1087 | return a[2] > b[2]; |
||
1088 | end); |
||
1089 | return vals; |
||
1090 | end |
||
1091 | |||
1092 | function SW_GetDetailsPerTick(whoName) |
||
1093 | local who = SW_S_Details[ whoName ]; |
||
1094 | local val =""; |
||
1095 | local vMax = ""; |
||
1096 | |||
1097 | if who == nil then return {}; end; |
||
1098 | |||
1099 | local vals = {}; |
||
1100 | |||
1101 | local dCol = SW_Settings["Colors"]["Damage"]; |
||
1102 | local hCol = SW_Settings["Colors"]["Heal"]; |
||
1103 | |||
1104 | for k,v in pairs(who) do |
||
1105 | if k == SW_PRINT_ITEM_RECIEVED then |
||
1106 | |||
1107 | elseif k == SW_PRINT_ITEM_TYPE then |
||
1108 | |||
1109 | elseif k == SW_PRINT_ITEM_TOTAL_DONE then |
||
1110 | |||
1111 | elseif k == "UTYPE" then |
||
1112 | |||
1113 | elseif k == "CLASSE" then |
||
1114 | |||
1115 | elseif k == SW_PRINT_ITEM_DEATHS then |
||
1116 | |||
1117 | else |
||
1118 | if v[1] > 0 then |
||
1119 | table.insert(vals, {k.." "..SW_STR_EVENTCOUNT..v[4].." - "..(math.floor((v[6]/v[4]) *1000 + 0.5)/10).."%",math.floor((v[1]/v[4])*10)/10,dCol,1}); |
||
1120 | end |
||
1121 | if v[2] > 0 then |
||
1122 | table.insert(vals, {k.." "..SW_STR_EVENTCOUNT..v[4].." - "..(math.floor((v[7]/v[4]) *1000 + 0.5)/10).."%",math.floor((v[2]/v[4])*10)/10,hCol,2}); |
||
1123 | end |
||
1124 | end |
||
1125 | |||
1126 | end |
||
1127 | table.sort(vals, |
||
1128 | function(a,b) |
||
1129 | if a[4] == b[4] then |
||
1130 | return a[2] > b[2]; |
||
1131 | else |
||
1132 | return a[4] < b[4]; |
||
1133 | end |
||
1134 | end); |
||
1135 | return vals; |
||
1136 | end |
||
1137 | function SW_PowerGainInfo(whoName) |
||
1138 | local who = SW_S_Details[ whoName ]; |
||
1139 | local val =""; |
||
1140 | local vMax = ""; |
||
1141 | |||
1142 | if who == nil then return {}; end; |
||
1143 | local bSet = SW_GetBarSettings("SW_BarFrame1"); |
||
1144 | local vals = {}; |
||
1145 | |||
1146 | for k,v in pairs(who) do |
||
1147 | if k == SW_PRINT_ITEM_RECIEVED then |
||
1148 | -- SW_printStr(LIGHTYELLOW_FONT_COLOR_CODE..k..FONT_COLOR_CODE_CLOSE..": "..string.format(SW_PRINT_INFO_RECIEVED, v[1], v[2]), 1); |
||
1149 | elseif k == SW_PRINT_ITEM_TYPE then |
||
1150 | -- ignore in this printout |
||
1151 | elseif k == SW_PRINT_ITEM_TOTAL_DONE then |
||
1152 | --ignored for now |
||
1153 | elseif k == "UTYPE" then |
||
1154 | --PC or NPC ignore |
||
1155 | elseif k == "CLASSE" then |
||
1156 | |||
1157 | elseif k == SW_PRINT_ITEM_DEATHS then |
||
1158 | |||
1159 | else |
||
1160 | if v[1] == 0 and v[2] == 0 and v[4] ~= 0 then |
||
1161 | table.insert(vals, {k,v[4],SW_EBC(k,bSet)}); |
||
1162 | end |
||
1163 | end |
||
1164 | end |
||
1165 | table.sort(vals, |
||
1166 | function(a,b) |
||
1167 | if a[4] == b[4] then |
||
1168 | return a[2] > b[2]; |
||
1169 | else |
||
1170 | return a[4] < b[4]; |
||
1171 | end |
||
1172 | end); |
||
1173 | return vals; |
||
1174 | end |
||
1175 | function SW_DecurseCountInfo(SF, CF, PF, bSet) |
||
1176 | local vals = {}; |
||
1177 | |||
1178 | for k,v in pairs(SW_S_SpellInfo) do |
||
1179 | if v[SW_DECURSEDUMMY] ~= nil and v[SW_DECURSEDUMMY]["total"] ~= nil then |
||
1180 | |||
1181 | if SW_BarsCheckFilters(k, SF, CF, "SW_PF_Inactive") then |
||
1182 | table.insert(vals, {k,v[SW_DECURSEDUMMY]["total"],SW_EBC(k,bSet)}); |
||
1183 | end |
||
1184 | end |
||
1185 | end |
||
1186 | |||
1187 | table.sort(vals, |
||
1188 | function(a,b) |
||
1189 | return a[2] > b[2]; |
||
1190 | end); |
||
1191 | return vals; |
||
1192 | end |
||
1193 | function SW_GetManaRatio(whoName) |
||
1194 | if SW_S_SpellInfo[SW_SELF_STRING] == nil or whoName ~= SW_SELF_STRING then |
||
1195 | return {}; |
||
1196 | end |
||
1197 | |||
1198 | local who = SW_S_Details[ whoName ]; |
||
1199 | local val =""; |
||
1200 | local vMax = ""; |
||
1201 | |||
1202 | if who == nil then return {}; end; |
||
1203 | |||
1204 | local vals = {}; |
||
1205 | |||
1206 | local dCol = SW_Settings["Colors"]["Damage"]; |
||
1207 | local hCol = SW_Settings["Colors"]["Heal"]; |
||
1208 | |||
1209 | local manaUsed = 0; |
||
1210 | local ratio = 0; |
||
1211 | |||
1212 | for k,v in pairs(who) do |
||
1213 | if k == SW_PRINT_ITEM_RECIEVED then |
||
1214 | -- SW_printStr(LIGHTYELLOW_FONT_COLOR_CODE..k..FONT_COLOR_CODE_CLOSE..": "..string.format(SW_PRINT_INFO_RECIEVED, v[1], v[2]), 1); |
||
1215 | elseif k == SW_PRINT_ITEM_TYPE then |
||
1216 | -- ignore in this printout |
||
1217 | elseif k == SW_PRINT_ITEM_TOTAL_DONE then |
||
1218 | -- ignored for now |
||
1219 | elseif k == "UTYPE" then |
||
1220 | --PC or NPC ignore |
||
1221 | elseif k == "CLASSE" then |
||
1222 | |||
1223 | elseif k == SW_PRINT_ITEM_DEATHS then |
||
1224 | |||
1225 | else |
||
1226 | if SW_S_SpellInfo[SW_SELF_STRING][k] ~= nil then |
||
1227 | manaUsed = SW_S_SpellInfo[SW_SELF_STRING][k][2]; |
||
1228 | if manaUsed > 0 then |
||
1229 | |||
1230 | if v[1] > 0 then |
||
1231 | ratio = math.floor( (v[1] / manaUsed) * 100 + 0.5) / 100; |
||
1232 | table.insert(vals, {k.." #"..SW_S_SpellInfo[SW_SELF_STRING][k][1],ratio,dCol,1}); |
||
1233 | end |
||
1234 | |||
1235 | if v[2] > 0 then |
||
1236 | ratio = math.floor( (v[2] / manaUsed) * 100 + 0.5) / 100; |
||
1237 | table.insert(vals, {k.." #"..SW_S_SpellInfo[SW_SELF_STRING][k][1],ratio,hCol,2}); |
||
1238 | --table.insert(vals, {k.." ("..v[3]..")",v[2],hCol,2}); |
||
1239 | end |
||
1240 | end |
||
1241 | end |
||
1242 | end |
||
1243 | end |
||
1244 | table.sort(vals, |
||
1245 | function(a,b) |
||
1246 | if a[4] == b[4] then |
||
1247 | return a[2] > b[2]; |
||
1248 | else |
||
1249 | return a[4] < b[4]; |
||
1250 | end |
||
1251 | end); |
||
1252 | |||
1253 | return vals; |
||
1254 | end |
||
1255 | |||
1256 | function SW_GetTopHealDelta() |
||
1257 | return SW_GetTopDelta("TOPDELTAH"); |
||
1258 | end |
||
1259 | function SW_GetTopDmgDelta() |
||
1260 | return SW_GetTopDelta("TOPDELTAD"); |
||
1261 | end |
||
1262 | |||
1263 | function SW_GetTopDelta(what) |
||
1264 | local vals = {}; |
||
1265 | for k, v in pairs (SW_Sync_MsgTrack) do |
||
1266 | if v[what] > 0 then |
||
1267 | table.insert(vals, {k, v[what]}); |
||
1268 | end |
||
1269 | end |
||
1270 | table.sort(vals, |
||
1271 | function(a,b) |
||
1272 | return a[2] > b[2]; |
||
1273 | end); |
||
1274 | return vals; |
||
1275 | end |
||
1276 | function SW_GetRaidPS() |
||
1277 | local vals = {}; |
||
1278 | |||
1279 | local dps = SW_RPS:getVals(); |
||
1280 | |||
1281 | if dps[1] > 0 then |
||
1282 | table.insert(vals, {SW_RDPS_STRS["CURR"], dps[1], nil}); |
||
1283 | end |
||
1284 | if dps[2] > 0 then |
||
1285 | table.insert(vals, {SW_RDPS_STRS["ALL"], dps[2], nil}); |
||
1286 | end |
||
1287 | if dps[3] > 0 then |
||
1288 | table.insert(vals, {SW_RDPS_STRS["LAST"], dps[3], nil}); |
||
1289 | end |
||
1290 | if dps[4] and dps[4] > 0.1 then |
||
1291 | table.insert(vals, {SW_RDPS_STRS["TOTAL"], dps[4], nil}); |
||
1292 | end |
||
1293 | |||
1294 | if SW_RPS.maxDPS > 0 then |
||
1295 | table.insert(vals, {SW_RDPS_STRS["MAX"], SW_RPS.maxDPS, nil}); |
||
1296 | end |
||
1297 | |||
1298 | table.sort(vals, |
||
1299 | function(a,b) |
||
1300 | return a[2] > b[2]; |
||
1301 | end); |
||
1302 | |||
1303 | return vals; |
||
1304 | end |
||
1305 | |||
1306 | -- 1.5.3.beta.1 note to self make this more efficient for the next data model, a good number to use in cheat protection |
||
1307 | function SW_GetMaxHit(whoName, checkHeal) |
||
1308 | local who = SW_S_Details[ whoName ]; |
||
1309 | local vMax = 0; |
||
1310 | local tmpVal = 0; |
||
1311 | if who == nil then return 0; end; |
||
1312 | for k,v in pairs(who) do |
||
1313 | if k == SW_PRINT_ITEM_RECIEVED then |
||
1314 | elseif k == SW_PRINT_ITEM_TYPE then |
||
1315 | elseif k == SW_PRINT_ITEM_TOTAL_DONE then |
||
1316 | elseif k == "UTYPE" then |
||
1317 | elseif k == "CLASSE" then |
||
1318 | elseif k == SW_PRINT_ITEM_DEATHS then |
||
1319 | else |
||
1320 | if checkHeal then |
||
1321 | tmpVal = v[5]; |
||
1322 | else |
||
1323 | tmpVal = v[3]; |
||
1324 | end |
||
1325 | if tmpVal > vMax then |
||
1326 | vMax = tmpVal; |
||
1327 | end |
||
1328 | end |
||
1329 | end |
||
1330 | return vMax; |
||
1331 | end |
||
1332 | function SW_GetMaxHitList(SF, CF, PF, bSet) |
||
1333 | local vals = {}; |
||
1334 | local tmpVal; |
||
1335 | |||
1336 | for k,v in pairs(SW_S_Details) do |
||
1337 | if SW_BarsCheckFilters(k, SF, CF, "SW_PF_Inactive") then |
||
1338 | tmpVal = SW_GetMaxHit(k); |
||
1339 | if tmpVal > 0 then |
||
1340 | table.insert(vals, {k,tmpVal,SW_EBC(k,bSet)}) |
||
1341 | end |
||
1342 | end |
||
1343 | end |
||
1344 | table.sort(vals, |
||
1345 | function(a,b) |
||
1346 | return a[2] > b[2]; |
||
1347 | end); |
||
1348 | |||
1349 | return vals; |
||
1350 | end |
||
1351 | function SW_GetMaxHealList(SF, CF, PF, bSet) |
||
1352 | local vals = {}; |
||
1353 | local tmpVal; |
||
1354 | |||
1355 | for k,v in pairs(SW_S_Details) do |
||
1356 | if SW_BarsCheckFilters(k, SF, CF, "SW_PF_Inactive") then |
||
1357 | tmpVal = SW_GetMaxHit(k, true); |
||
1358 | if tmpVal > 0 then |
||
1359 | table.insert(vals, {k,tmpVal,SW_EBC(k,bSet)}) |
||
1360 | end |
||
1361 | end |
||
1362 | end |
||
1363 | table.sort(vals, |
||
1364 | function(a,b) |
||
1365 | return a[2] > b[2]; |
||
1366 | end); |
||
1367 | |||
1368 | return vals; |
||
1369 | end |
||
1370 | function SW_GetDetails(whoName) |
||
1371 | local who = SW_S_Details[ whoName ]; |
||
1372 | local val =""; |
||
1373 | local vMax = ""; |
||
1374 | |||
1375 | if who == nil then return {}; end; |
||
1376 | |||
1377 | local vals = {}; |
||
1378 | |||
1379 | local dCol = SW_Settings["Colors"]["Damage"]; |
||
1380 | local hCol = SW_Settings["Colors"]["Heal"]; |
||
1381 | |||
1382 | for k,v in pairs(who) do |
||
1383 | if k == SW_PRINT_ITEM_RECIEVED then |
||
1384 | -- SW_printStr(LIGHTYELLOW_FONT_COLOR_CODE..k..FONT_COLOR_CODE_CLOSE..": "..string.format(SW_PRINT_INFO_RECIEVED, v[1], v[2]), 1); |
||
1385 | elseif k == SW_PRINT_ITEM_TYPE then |
||
1386 | -- ignore in this printout |
||
1387 | elseif k == SW_PRINT_ITEM_TOTAL_DONE then |
||
1388 | --ignored for now |
||
1389 | elseif k == "UTYPE" then |
||
1390 | --PC or NPC ignore |
||
1391 | elseif k == "CLASSE" then |
||
1392 | |||
1393 | elseif k == SW_PRINT_ITEM_DEATHS then |
||
1394 | |||
1395 | else |
||
1396 | if v[1] > 0 then |
||
1397 | table.insert(vals, {k.." ("..v[3].." - "..(math.floor((v[6]/v[4]) *1000 + 0.5)/10).."%)",v[1],dCol,1}); |
||
1398 | end |
||
1399 | if v[2] > 0 then |
||
1400 | table.insert(vals, {k.." ("..v[5].." - "..(math.floor((v[7]/v[4]) *1000 + 0.5)/10).."%)",v[2],hCol,2}); |
||
1401 | end |
||
1402 | end |
||
1403 | end |
||
1404 | -- 1.5 added pet details |
||
1405 | who = SW_PetInfo["OWNER_PET"][whoName]; |
||
1406 | if who ~= nil then |
||
1407 | who = who["pets"]; |
||
1408 | |||
1409 | for k,v in pairs(who) do |
||
1410 | if v[SW_PRINT_ITEM_TOTAL_DONE][1] > 0 then |
||
1411 | table.insert(vals, {SW_STR_PET_PREFIX..k,v[SW_PRINT_ITEM_TOTAL_DONE][1],dCol,1}); |
||
1412 | end |
||
1413 | if v[SW_PRINT_ITEM_TOTAL_DONE][2] > 0 then |
||
1414 | table.insert(vals, {SW_STR_PET_PREFIX..k,v[SW_PRINT_ITEM_TOTAL_DONE][2],hCol,2}); |
||
1415 | end |
||
1416 | end |
||
1417 | end |
||
1418 | table.sort(vals, |
||
1419 | function(a,b) |
||
1420 | if a[4] == b[4] then |
||
1421 | return a[2] > b[2]; |
||
1422 | else |
||
1423 | return a[4] < b[4]; |
||
1424 | end |
||
1425 | end); |
||
1426 | return vals; |
||
1427 | end |
||
1428 | function SW_GetHealInfoTarget(whoName) |
||
1429 | local vals = {}; |
||
1430 | local tmpVal; |
||
1431 | local bSet = SW_GetBarSettings("SW_BarFrame1"); |
||
1432 | |||
1433 | for k,v in pairs(SW_S_Healed) do |
||
1434 | |||
1435 | if v[whoName] ~= nil then |
||
1436 | table.insert(vals, {k,v[whoName], SW_EBC(k,bSet)}); |
||
1437 | end |
||
1438 | end |
||
1439 | table.sort(vals, |
||
1440 | function(a,b) |
||
1441 | return a[2] > b[2]; |
||
1442 | end); |
||
1443 | return vals; |
||
1444 | end |
||
1445 | function SW_GetSchoolMadeSummary(SF, CF, PF, bSet) |
||
1446 | local vals = {}; |
||
1447 | local tmpVal; |
||
1448 | local summVals = {}; |
||
1449 | |||
1450 | for k,v in pairs(SW_S_Details) do |
||
1451 | if SW_BarsCheckFilters(k, SF, CF, "SW_PF_Inactive") then |
||
1452 | if SW_S_Details[k][SW_PRINT_ITEM_TYPE] ~= nil then |
||
1453 | for t,nums in pairs(SW_S_Details[k][SW_PRINT_ITEM_TYPE]) do |
||
1454 | if summVals[t] == nil then |
||
1455 | summVals[t] = nums[1]; |
||
1456 | else |
||
1457 | summVals[t] = summVals[t] + nums[1]; |
||
1458 | end |
||
1459 | end |
||
1460 | end |
||
1461 | end |
||
1462 | end |
||
1463 | for k,v in pairs(summVals) do |
||
1464 | if v > 0 then |
||
1465 | table.insert(vals, {k,v}); |
||
1466 | end |
||
1467 | end |
||
1468 | table.sort(vals, |
||
1469 | function(a,b) |
||
1470 | return a[2] > b[2]; |
||
1471 | end); |
||
1472 | |||
1473 | return vals; |
||
1474 | end |
||
1475 | function SW_GetSchoolGotSummary(SF, CF, PF, bSet) |
||
1476 | local vals = {}; |
||
1477 | local tmpVal; |
||
1478 | local summVals = {}; |
||
1479 | |||
1480 | for k,v in pairs(SW_S_Details) do |
||
1481 | if SW_BarsCheckFilters(k, SF, CF, "SW_PF_Inactive") then |
||
1482 | if SW_S_Details[k][SW_PRINT_ITEM_TYPE] ~= nil then |
||
1483 | for t,nums in pairs(SW_S_Details[k][SW_PRINT_ITEM_TYPE]) do |
||
1484 | if summVals[t] == nil then |
||
1485 | summVals[t] = nums[4]; |
||
1486 | else |
||
1487 | summVals[t] = summVals[t] + nums[4]; |
||
1488 | end |
||
1489 | end |
||
1490 | end |
||
1491 | end |
||
1492 | end |
||
1493 | for k,v in pairs(summVals) do |
||
1494 | if v > 0 then |
||
1495 | table.insert(vals, {k,v}); |
||
1496 | end |
||
1497 | end |
||
1498 | table.sort(vals, |
||
1499 | function(a,b) |
||
1500 | return a[2] > b[2]; |
||
1501 | end); |
||
1502 | |||
1503 | return vals; |
||
1504 | end |
||
1505 | function SW_GetSchoolMade(whoName) |
||
1506 | local vals = {}; |
||
1507 | local tmpVal; |
||
1508 | if SW_S_Details[whoName] == nil then return vals; end |
||
1509 | if SW_S_Details[whoName][SW_PRINT_ITEM_TYPE] == nil then return vals; end |
||
1510 | for k,v in pairs(SW_S_Details[whoName][SW_PRINT_ITEM_TYPE]) do |
||
1511 | if v[1] ~= 0 then |
||
1512 | table.insert(vals, {k,v[1]}); |
||
1513 | end |
||
1514 | end |
||
1515 | table.sort(vals, |
||
1516 | function(a,b) |
||
1517 | return a[2] > b[2]; |
||
1518 | end); |
||
1519 | |||
1520 | return vals; |
||
1521 | end |
||
1522 | function SW_GetSchoolGot(whoName) |
||
1523 | local vals = {}; |
||
1524 | local tmpVal; |
||
1525 | if SW_S_Details[whoName] == nil then return vals; end |
||
1526 | if SW_S_Details[whoName][SW_PRINT_ITEM_TYPE] == nil then return vals; end |
||
1527 | for k,v in pairs(SW_S_Details[whoName][SW_PRINT_ITEM_TYPE]) do |
||
1528 | if v[4] ~= 0 then |
||
1529 | table.insert(vals, {k,v[4]}); |
||
1530 | end |
||
1531 | end |
||
1532 | table.sort(vals, |
||
1533 | function(a,b) |
||
1534 | return a[2] > b[2]; |
||
1535 | end); |
||
1536 | |||
1537 | return vals; |
||
1538 | end |
||
1539 | function SW_UpdateBars() |
||
1540 | local f = getglobal("SW_BarFrame1"); |
||
1541 | local bSet = SW_GetBarSettings("SW_BarFrame1"); |
||
1542 | local last; |
||
1543 | local valText = ""; |
||
1544 | |||
1545 | --1.3.1 added DPS to Window title |
||
1546 | --1.3.2 changed this to extra counter and added an option |
||
1547 | --SW_OptUpdateText(pName) |
||
1548 | local selOpt = SW_Settings["BarFrames"]["SW_BarFrame1"]["Selected"]; |
||
1549 | if SW_Settings["OPT_ShowMainWinDPS"] ~= nil then |
||
1550 | local t = getglobal ("SW_BarFrame1_Title_Text"); |
||
1551 | if SW_DPS_Dmg > 0 and SW_CombatTime > 5 then |
||
1552 | local dps = math.floor( (SW_DPS_Dmg / SW_CombatTime) * 10 + 0.5) / 10; |
||
1553 | local otf = bSet["OTF"]; |
||
1554 | if otf ~= nil then |
||
1555 | t:SetText(otf.." (DPS:"..dps..")"); |
||
1556 | else |
||
1557 | t:SetText(selOpt.." (DPS:"..dps..")"); |
||
1558 | end |
||
1559 | else |
||
1560 | local otf = bSet["OTF"]; |
||
1561 | if otf ~= nil then |
||
1562 | t:SetText(otf); |
||
1563 | else |
||
1564 | t:SetText(selOpt); |
||
1565 | end |
||
1566 | end |
||
1567 | else |
||
1568 | local otf = bSet["OTF"]; |
||
1569 | local t = getglobal ("SW_BarFrame1_Title_Text"); |
||
1570 | if otf ~= nil then |
||
1571 | t:SetText(otf); |
||
1572 | else |
||
1573 | t:SetText(selOpt); |
||
1574 | end |
||
1575 | end |
||
1576 | --1.2.4 Added this to lessen the "funkyness" of filters |
||
1577 | -- also moved "class copy" here no need to check it in SW_BarsCheckFilters |
||
1578 | -- 1.5 added "GPC" and "GPET" pets and PCs ever in group |
||
1579 | -- do pets first, an MC'd party member will show up as pet |
||
1580 | -- will be overwritten when checking SW_Friends |
||
1581 | for k,v in pairs(SW_PetInfo["PET_OWNER"]) do |
||
1582 | if SW_S_Details[k] ~= nil then |
||
1583 | -- don't mark MC'd mobs as gpet |
||
1584 | if SW_S_Details[k]["UTYPE"] ~= "NPC" then |
||
1585 | SW_S_Details[k]["UTYPE"] = "GPET"; |
||
1586 | end |
||
1587 | if SW_S_Details[k]["CLASSE"] == nil then |
||
1588 | SW_S_Details[k]["CLASSE"] = v["CLASSE"]; |
||
1589 | end |
||
1590 | end |
||
1591 | end |
||
1592 | for k,v in pairs(SW_Friends) do |
||
1593 | --1.5.1 added Details init for filters to work even with 0 dmg/heal |
||
1594 | if SW_S_Details[k] == nil then |
||
1595 | SW_S_Details[k] = {}; |
||
1596 | SW_S_Details[k][SW_PRINT_ITEM_TOTAL_DONE] = {0,0}; --first = dmg; sec = heal |
||
1597 | SW_S_Details[k][SW_PRINT_ITEM_RECIEVED] = {0,0}; --first = dmg; sec = heal |
||
1598 | end |
||
1599 | |||
1600 | SW_S_Details[k]["UTYPE"] = "GPC"; |
||
1601 | if SW_S_Details[k]["CLASSE"] == nil then |
||
1602 | SW_S_Details[k]["CLASSE"] = SW_Friends[k]["CLASSE"]; |
||
1603 | end |
||
1604 | end |
||
1605 | |||
1606 | |||
1607 | --vals[1] = text [2]= value [3]= reserved (colorBar) [4] sort order num |
||
1608 | if f:IsVisible() then |
||
1609 | local vals; |
||
1610 | local total = {}; |
||
1611 | |||
1612 | if bSet["IN"] == nil then |
||
1613 | bSet["IN"] = 1; |
||
1614 | end |
||
1615 | local inf = SW_InfoTypes[ bSet["IN"] ]; |
||
1616 | if inf["varType"] == "TEXT" then |
||
1617 | vals = inf["f"](bSet["TV"]); |
||
1618 | elseif inf["varType"] == "SELF" then |
||
1619 | vals = inf["f"](SW_SELF_STRING); |
||
1620 | elseif inf["varType"] == "PETONLY" then |
||
1621 | vals = inf["f"](nil, nil, bSet["PF"], bSet); |
||
1622 | else |
||
1623 | vals = inf["f"](bSet["SF"], bSet["CF"], bSet["PF"], bSet); |
||
1624 | end |
||
1625 | |||
1626 | if bSet["ShowPercent"] ~= nil then |
||
1627 | for i, v in ipairs(vals) do |
||
1628 | if v[4] == nil then |
||
1629 | v[4] = 1; |
||
1630 | end |
||
1631 | |||
1632 | if total[ v[4] ] == nil then total[ v[4] ] = 0; end |
||
1633 | total[ v[4] ] = total[ v[4] ] + v[2]; |
||
1634 | |||
1635 | |||
1636 | end |
||
1637 | end |
||
1638 | |||
1639 | if vals[1] == nil then |
||
1640 | |||
1641 | for i, v in ipairs(SW_Bars["SW_BarFrame1"]) do |
||
1642 | if not v.toWide and v.canBeSeen then |
||
1643 | v:SetValText(" "); |
||
1644 | v:SetValue(100); |
||
1645 | v:SetBarText(); |
||
1646 | end |
||
1647 | end |
||
1648 | return; |
||
1649 | end |
||
1650 | local p1 = vals[1][2] / 100; |
||
1651 | local lastSortIndex = vals[1][4]; |
||
1652 | for i, v in ipairs(SW_Bars["SW_BarFrame1"]) do |
||
1653 | |||
1654 | if not v.toWide and v.canBeSeen then |
||
1655 | if vals[i] ~= nil then |
||
1656 | |||
1657 | if bSet["ShowRank"] ~= nil then |
||
1658 | v:SetBarText(i.." "..vals[i][1]); |
||
1659 | else |
||
1660 | v:SetBarText(vals[i][1]); |
||
1661 | end |
||
1662 | if bSet["ShowNumber"] ~= nil then |
||
1663 | valText = vals[i][2]; |
||
1664 | else |
||
1665 | valText = ""; |
||
1666 | end |
||
1667 | if bSet["ShowPercent"] ~= nil then |
||
1668 | v:SetValText(valText.." ("..(math.floor((vals[i][2]/total[ vals[i][4] ]) *1000 + 0.5)/10).."%)"); |
||
1669 | else |
||
1670 | v:SetValText(valText); |
||
1671 | end |
||
1672 | if lastSortIndex ~= nil then |
||
1673 | if vals[i][4] ~= lastSortIndex then |
||
1674 | lastSortIndex = vals[i][4]; |
||
1675 | p1 = vals[i][2] / 100; |
||
1676 | end |
||
1677 | end |
||
1678 | v:SetValue( vals[i][2] /p1); |
||
1679 | if vals[i][3] ~= nil then |
||
1680 | getglobal(v:GetName().."_Texture"):SetVertexColor(unpack(vals[i][3])); |
||
1681 | |||
1682 | end |
||
1683 | else |
||
1684 | v:SetBarText(); |
||
1685 | end |
||
1686 | end |
||
1687 | |||
1688 | end |
||
1689 | end |
||
1690 | end |
||
1691 | |||
1692 | function SW_SendRepLine(outStr, sVar) |
||
1693 | local sTarget = getglobal(SW_Settings["RepTarget"]).SW_TargetChat; |
||
1694 | if sTarget == "WHISPER" or sTarget == "CHANNEL" then |
||
1695 | if sVar == nil or sVar == "" then return; end |
||
1696 | if sTarget == "CHANNEL" then |
||
1697 | sVar = GetChannelName(sVar); |
||
1698 | end |
||
1699 | SendChatMessage(outStr, sTarget, nil, sVar); |
||
1700 | elseif sTarget == "CLIP" then |
||
1701 | local outWin = getglobal("SW_TextWindow"); |
||
1702 | if outWin.txtBuffer == nil then |
||
1703 | outWin.txtBuffer = ""; |
||
1704 | end |
||
1705 | outWin.txtBuffer = outWin.txtBuffer.."\r\n"..outStr; |
||
1706 | else |
||
1707 | SendChatMessage(outStr, sTarget); |
||
1708 | end |
||
1709 | end |
||
1710 | |||
1711 | |||
1712 | function SW_BuildTextReportData(caller) |
||
1713 | local bSet = SW_GetBarSettings(caller); |
||
1714 | local tw = getglobal("SW_TextWindow"); |
||
1715 | tw.repMeta = {}; |
||
1716 | tw.repData = {}; |
||
1717 | |||
1718 | local vals; |
||
1719 | local metaData = tw.repMeta; |
||
1720 | |||
1721 | local inf = SW_InfoTypes[ bSet["IN"] ]; |
||
1722 | if inf["varType"] == "TEXT" then |
||
1723 | vals = inf["f"](bSet["TV"]); |
||
1724 | metaData["InfoFor"] = bSet["TV"]; |
||
1725 | elseif inf["varType"] == "SELF" then |
||
1726 | vals = inf["f"](SW_SELF_STRING); |
||
1727 | metaData["InfoFor"] = SW_SELF_STRING; |
||
1728 | else |
||
1729 | vals = inf["f"](bSet["SF"], bSet["CF"], bSet["PF"], bSet); |
||
1730 | end |
||
1731 | |||
1732 | |||
1733 | metaData["InfoTypeString"] = inf["t"]; |
||
1734 | metaData["InfoTypeNum"] = bSet["IN"]; |
||
1735 | |||
1736 | if bSet["SF"] == nil then |
||
1737 | metaData["SelectedFilter"] = getglobal("SW_Filter_None").SW_Filter; |
||
1738 | else |
||
1739 | metaData["SelectedFilter"] = getglobal(bSet["SF"]).SW_Filter; |
||
1740 | end |
||
1741 | |||
1742 | local classF; |
||
1743 | if bSet["CF"] == nil then |
||
1744 | classF = SW_ClassFilters[1]; |
||
1745 | else |
||
1746 | classF = SW_ClassFilters[ bSet["CF"] ]; |
||
1747 | end |
||
1748 | |||
1749 | metaData["ClassFilter"] = classF; |
||
1750 | |||
1751 | metaData["ClassFilterLocalized"] = SW_ClassNames[classF]; |
||
1752 | if metaData["ClassFilterLocalized"] == "" then |
||
1753 | metaData["ClassFilterLocalized"] = classF; |
||
1754 | end |
||
1755 | |||
1756 | |||
1757 | if bSet["ShowPercent"] == nil then |
||
1758 | metaData["ShowPercent"] = false; |
||
1759 | else |
||
1760 | metaData["ShowPercent"] = true; |
||
1761 | end |
||
1762 | if bSet["ShowRank"] == nil then |
||
1763 | metaData["ShowRank"] = false; |
||
1764 | else |
||
1765 | metaData["ShowRank"] = true; |
||
1766 | end |
||
1767 | if bSet["ShowNumber"] == nil then |
||
1768 | metaData["ShowNumber"] = false; |
||
1769 | else |
||
1770 | metaData["ShowNumber"] = true; |
||
1771 | end |
||
1772 | metaData["ReportAmount"] = SW_Settings["ReportAmount"]; |
||
1773 | |||
1774 | if vals[1] == nil then |
||
1775 | return; |
||
1776 | end |
||
1777 | |||
1778 | local total = {}; |
||
1779 | for i, v in ipairs(vals) do |
||
1780 | if v[4] == nil then |
||
1781 | v[4] = 1; |
||
1782 | end |
||
1783 | if total[ v[4] ] == nil then total[ v[4] ] = 0; end |
||
1784 | total[ v[4] ] = total[ v[4] ] + v[2]; |
||
1785 | end |
||
1786 | for i, v in ipairs(vals) do |
||
1787 | |||
1788 | v[5] = (math.floor((v[2]/total[ v[4] ]) *1000 + 0.5)/10); |
||
1789 | |||
1790 | end |
||
1791 | tw.repData = vals; |
||
1792 | |||
1793 | end |
||
1794 | |||
1795 | function SW_SendReportOld(caller, sVar) |
||
1796 | if SW_Settings["RepTarget"] == nil then return; end |
||
1797 | |||
1798 | if getglobal(SW_Settings["RepTarget"]).SW_TargetChat == "CLIP" then |
||
1799 | SW_BuildTextReportData(caller); |
||
1800 | getglobal("SW_TextWindow"):Show(); |
||
1801 | return; |
||
1802 | end |
||
1803 | if not SW_PostCheck(getglobal(SW_Settings["RepTarget"]).SW_TargetChat) then |
||
1804 | StaticPopup_Show("SW_PostFail"); |
||
1805 | return; |
||
1806 | end |
||
1807 | |||
1808 | local bSet = SW_GetBarSettings(caller); |
||
1809 | local vals; |
||
1810 | local useMultiLines = false |
||
1811 | if SW_Settings["RE_Multiline"] ~= nil then |
||
1812 | useMultiLines = true; |
||
1813 | end |
||
1814 | if bSet["IN"] == nil then |
||
1815 | bSet["IN"] = 1; |
||
1816 | end |
||
1817 | local inf = SW_InfoTypes[ bSet["IN"] ]; |
||
1818 | if inf["varType"] == "TEXT" then |
||
1819 | vals = inf["f"](bSet["TV"]); |
||
1820 | elseif inf["varType"] == "SELF" then |
||
1821 | vals = inf["f"](SW_SELF_STRING); |
||
1822 | else |
||
1823 | vals = inf["f"](bSet["SF"], bSet["CF"], bSet["PF"], bSet); |
||
1824 | end |
||
1825 | |||
1826 | if vals[1] == nil then |
||
1827 | return; |
||
1828 | end |
||
1829 | |||
1830 | local outStr=inf["t"].." "; |
||
1831 | if inf["varType"] == "TEXT" then |
||
1832 | outStr = outStr..bSet["TV"].." "; |
||
1833 | end |
||
1834 | if bSet["CF"]~= nil and bSet["CF"] ~= 1 then |
||
1835 | outStr = outStr..SW_ClassNames[ SW_ClassFilters[ bSet["CF"] ] ].." "; |
||
1836 | end |
||
1837 | local tmpLen =string.len(outStr); |
||
1838 | local tmpStr; |
||
1839 | local total = {}; |
||
1840 | if bSet["ShowPercent"] ~= nil then |
||
1841 | for i, v in ipairs(vals) do |
||
1842 | if v[4] == nil then |
||
1843 | v[4] = 1; |
||
1844 | end |
||
1845 | |||
1846 | if total[ v[4] ] == nil then total[ v[4] ] = 0; end |
||
1847 | total[ v[4] ] = total[ v[4] ] + v[2]; |
||
1848 | |||
1849 | |||
1850 | end |
||
1851 | end |
||
1852 | if useMultiLines then |
||
1853 | SW_SendRepLine(outStr, sVar); |
||
1854 | outStr = ""; |
||
1855 | end |
||
1856 | |||
1857 | for i=1, SW_Settings["ReportAmount"] do |
||
1858 | if vals[i] ~= nil then |
||
1859 | |||
1860 | if bSet["ShowRank"] ~= nil then |
||
1861 | tmpStr = "["..i.."."; |
||
1862 | else |
||
1863 | tmpStr = "["; |
||
1864 | end |
||
1865 | tmpStr = tmpStr..vals[i][1]; |
||
1866 | |||
1867 | if bSet["ShowNumber"] ~= nil then |
||
1868 | tmpStr = tmpStr.." "..vals[i][2]; |
||
1869 | end |
||
1870 | if bSet["ShowPercent"] ~= nil then |
||
1871 | tmpStr = tmpStr.." "..(math.floor((vals[i][2]/total[ vals[i][4] ]) *1000 + 0.5)/10).."%"; |
||
1872 | end |
||
1873 | tmpStr = tmpStr.."] "; |
||
1874 | else |
||
1875 | break; |
||
1876 | end |
||
1877 | if useMultiLines then |
||
1878 | SW_SendRepLine(tmpStr, sVar); |
||
1879 | else |
||
1880 | tmpLen = tmpLen + string.len(tmpStr); |
||
1881 | if tmpLen < 256 then |
||
1882 | outStr = outStr..tmpStr; |
||
1883 | else |
||
1884 | break; |
||
1885 | end |
||
1886 | end |
||
1887 | end |
||
1888 | |||
1889 | if not useMultiLines then |
||
1890 | SW_SendRepLine(outStr, sVar); |
||
1891 | end |
||
1892 | |||
1893 | --[[ |
||
1894 | if getglobal(SW_Settings["RepTarget"]).SW_TargetChat == "CLIP" then |
||
1895 | local outWin = getglobal("SW_TextWindow"); |
||
1896 | local outBox = getglobal("SW_TextWindow_EditBox"); |
||
1897 | outBox:SetText( outWin.txtBuffer ); |
||
1898 | outWin.txtBuffer = ""; |
||
1899 | outBox:HighlightText(); |
||
1900 | outWin:Show(); |
||
1901 | return; |
||
1902 | end |
||
1903 | --]] |
||
1904 | end |
||
1905 | function SW_SendReport(caller, sVar) |
||
1906 | if SW_Settings["RepTarget"] == nil then return; end |
||
1907 | |||
1908 | if getglobal(SW_Settings["RepTarget"]).SW_TargetChat == "CLIP" then |
||
1909 | SW_BuildTextReportData(caller); |
||
1910 | getglobal("SW_TextWindow"):Show(); |
||
1911 | return; |
||
1912 | end |
||
1913 | if not SW_PostCheck(getglobal(SW_Settings["RepTarget"]).SW_TargetChat) then |
||
1914 | StaticPopup_Show("SW_PostFail"); |
||
1915 | return; |
||
1916 | end |
||
1917 | |||
1918 | local bSet = SW_GetBarSettings(caller); |
||
1919 | local vals; |
||
1920 | local useMultiLines = false |
||
1921 | if SW_Settings["RE_Multiline"] ~= nil then |
||
1922 | useMultiLines = true; |
||
1923 | end |
||
1924 | if bSet["IN"] == nil then |
||
1925 | bSet["IN"] = 1; |
||
1926 | end |
||
1927 | local inf = SW_InfoTypes[ bSet["IN"] ]; |
||
1928 | if inf["varType"] == "TEXT" then |
||
1929 | vals = inf["f"](bSet["TV"]); |
||
1930 | elseif inf["varType"] == "SELF" then |
||
1931 | vals = inf["f"](SW_SELF_STRING); |
||
1932 | else |
||
1933 | vals = inf["f"](bSet["SF"], bSet["CF"], bSet["PF"], bSet); |
||
1934 | end |
||
1935 | |||
1936 | if vals[1] == nil then |
||
1937 | return; |
||
1938 | end |
||
1939 | |||
1940 | local outStr=" -------- "..inf["t"].." "; |
||
1941 | if inf["varType"] == "TEXT" then |
||
1942 | outStr = outStr..":: "..bSet["TV"].." "; |
||
1943 | end |
||
1944 | if bSet["CF"]~= nil and bSet["CF"] ~= 1 then |
||
1945 | outStr = outStr..SW_ClassNames[ SW_ClassFilters[ bSet["CF"] ] ].." "; |
||
1946 | end |
||
1947 | local tmpLen =string.len(outStr); |
||
1948 | local tmpStr =""; |
||
1949 | local total = {}; |
||
1950 | if bSet["ShowPercent"] ~= nil then |
||
1951 | for i, v in ipairs(vals) do |
||
1952 | if v[4] == nil then |
||
1953 | v[4] = 1; |
||
1954 | end |
||
1955 | |||
1956 | if total[ v[4] ] == nil then total[ v[4] ] = 0; end |
||
1957 | total[ v[4] ] = total[ v[4] ] + v[2]; |
||
1958 | |||
1959 | |||
1960 | end |
||
1961 | end |
||
1962 | outStr=outStr.." -------- "; |
||
1963 | if useMultiLines then |
||
1964 | SW_SendRepLine(outStr, sVar); |
||
1965 | outStr = ""; |
||
1966 | end |
||
1967 | |||
1968 | for i=1, SW_Settings["ReportAmount"] do |
||
1969 | if vals[i] ~= nil then |
||
1970 | |||
1971 | if i < 10 then |
||
1972 | tmpStr = " #0"..i..": "; |
||
1973 | else |
||
1974 | tmpStr = " #"..i..": "; |
||
1975 | end |
||
1976 | |||
1977 | tmpStr = tmpStr..vals[i][1]; |
||
1978 | |||
1979 | if bSet["ShowNumber"] ~= nil then |
||
1980 | tmpStr = tmpStr.." - "..vals[i][2]; |
||
1981 | end |
||
1982 | if bSet["ShowPercent"] ~= nil then |
||
1983 | tmpStr = tmpStr.." - "..(math.floor((vals[i][2]/total[ vals[i][4] ]) *1000 + 0.5)/10).."%"; |
||
1984 | end |
||
1985 | else |
||
1986 | break; |
||
1987 | end |
||
1988 | if useMultiLines then |
||
1989 | SW_SendRepLine(tmpStr, sVar); |
||
1990 | else |
||
1991 | tmpLen = tmpLen + string.len(tmpStr); |
||
1992 | if tmpLen < 256 then |
||
1993 | outStr = outStr..tmpStr; |
||
1994 | else |
||
1995 | break; |
||
1996 | end |
||
1997 | end |
||
1998 | end |
||
1999 | |||
2000 | if not useMultiLines then |
||
2001 | SW_SendRepLine(outStr, sVar); |
||
2002 | end |
||
2003 | |||
2004 | --[[ |
||
2005 | if getglobal(SW_Settings["RepTarget"]).SW_TargetChat == "CLIP" then |
||
2006 | local outWin = getglobal("SW_TextWindow"); |
||
2007 | local outBox = getglobal("SW_TextWindow_EditBox"); |
||
2008 | outBox:SetText( outWin.txtBuffer ); |
||
2009 | outWin.txtBuffer = ""; |
||
2010 | outBox:HighlightText(); |
||
2011 | outWin:Show(); |
||
2012 | return; |
||
2013 | end |
||
2014 | --]] |
||
2015 | end |