vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local dewdrop = AceLibrary("Dewdrop-2.0")
2 local tablet = AceLibrary("Tablet-2.0")
3 local L = AceLibrary("AceLocale-2.2"):new("RegenFu")
4  
5  
6 RegenFu = AceLibrary("AceAddon-2.0"):new("FuBarPlugin-2.0", "AceEvent-2.0", "AceConsole-2.0", "AceDB-2.0", "AceDebug-2.0", "CandyBar-2.0")
7  
8  
9 local barTextures = { smooth = "Interface\\Addons\\FuBar_RegenFu\\Textures\\smooth.tga" }
10 local barIcon = "Interface\\Addons\\FuBar_RegenFu\\Textures\\5.tga"
11  
12 RegenFu.optionsTable = {
13 type = 'group',
14 args = {
15 showHP = {
16 order = 1,
17 type = 'toggle',
18 name = L["MENU_SHOW_HP"],
19 desc = L["MENU_SHOW_HP"],
20 set = "ToggleShowHP",
21 get = "IsShowHP",
22 },
23 showMP = {
24 order = 2,
25 type = 'toggle',
26 name = L["MENU_SHOW_MP"],
27 desc = L["MENU_SHOW_MP"],
28 set = "ToggleShowMP",
29 get = "IsShowMP",
30 },
31 showFSRT = {
32 order = 3,
33 type = 'toggle',
34 name = L["Show FSRT"],
35 desc = L["Show FSRT"],
36 set = "ToggleShowFSRT",
37 get = "IsShowFSRT",
38 },
39 fsrtGroup1 = {
40 type = 'header',
41 order = 10,
42 },
43 showPercent = {
44 order = 11,
45 type = 'toggle',
46 name = L["MENU_SHOW_PERCENT"],
47 desc = L["MENU_SHOW_PERCENT"],
48 set = "ToggleShowPercent",
49 get = "IsShowPercent",
50 },
51 showCurrent = {
52 order = 12,
53 type = 'toggle',
54 name = L["MENU_SHOW_CURRENT"],
55 desc = L["MENU_SHOW_CURRENT"],
56 set = "ToggleShowCurrent",
57 get = "IsShowCurrent",
58 },
59 showFightRegen = {
60 order = 13,
61 type = 'toggle',
62 name = L["Show In Combat Regen Total"],
63 desc = L["Show In Combat Regen Total"],
64 set = "ToggleShowFightRegen",
65 get = "IsShowFightRegen",
66 },
67  
68 hideLabel = {
69 order = 14,
70 type = 'toggle',
71 name = L["MENU_HIDE_LABEL"],
72 desc = L["MENU_HIDE_LABEL"],
73 set = "ToggleHideLabel",
74 get = "IsHideLabel",
75 },
76 fsrtGroup2 = {
77 type = 'header',
78 order = 20,
79 hidden = "IsHideFSRT",
80 },
81  
82 icr = {
83 type = 'range',
84 desc = L["Percent Regen While Casting"],
85 name = L["Percent Regen While Casting"],
86 get = "GetICR",
87 set = "SetICR",
88 min = 0,
89 max = 1,
90 step = 0.05,
91 isPercent = true,
92 order = 21,
93 hidden = "IsHideFSRT",
94 },
95  
96 mps = {
97 type = 'range',
98 desc = L["Mana Regen Forumula (Spirit/<value>)"],
99 name = L["Mana Regen Forumula (Spirit/<value>)"],
100 get = "GetMPS",
101 set = "SetMPS",
102 min = 4,
103 max = 5,
104 step = 0.5,
105 order = 22,
106 hidden = "IsHideFSRT",
107 },
108  
109 mpi = {
110 type = "text",
111 usage = "<number>",
112 name = L["Mana Per Int"],
113 desc = L["Mana Per Int"],
114 get = "GetMPI",
115 set = "SetMPI",
116 validate = function(v)
117 return tonumber(v) ~= nil
118 end,
119 order = 23,
120 hidden = "IsHideFSRT",
121 },
122  
123 fsrtGroup3 = {
124 type = 'header',
125 order = 30,
126 hidden = "IsHideFSRT",
127 },
128  
129  
130 showFSRB = {
131 type = "toggle",
132 name = L["FSR Countdown Bar"],
133 desc = L["FSR Countdown Bar"],
134 set = "ShowFSRBar",
135 get = function() return RegenFu.db.char.showFSRBar end,
136 order = 31,
137 hidden = "IsHideFSRT",
138 },
139  
140 fsrtGroup4 = {
141 type = 'header',
142 order = 40,
143 hidden = "IsHideFSRT",
144 },
145  
146  
147 reset = {
148 type = "execute",
149 name = L["Reset FSR Data"],
150 desc = L["Reset FSR Data"],
151 func = "ResetFSRT",
152 order = 41,
153 hidden = "IsHideFSRT",
154 },
155 },
156 }
157  
158  
159 RegenFu:RegisterDB("FuBar_RegenDB", "FuBar_RegenPerCharDB")
160 RegenFu:RegisterDefaults('char', {
161 mpi = 1.0/15,
162 icr = 0,
163 })
164 RegenFu:RegisterDefaults('class', {
165 mps = 0.0,
166 })
167 RegenFu:RegisterDefaults('profile', {
168 showHP = true,
169 showCurrent = false,
170 showPercent = false,
171 showFightRegen = false,
172 hideLabel = false,
173 })
174  
175  
176  
177  
178 -- Methods
179 function RegenFu:IsShowHP()
180 return self.db.profile.showHP;
181 end
182  
183 function RegenFu:IsShowMP()
184 return self.db.char.showMP;
185 end
186  
187 function RegenFu:IsShowFSRT()
188 return self.db.char.showFSRT;
189 end
190  
191 function RegenFu:IsHideFSRT()
192 return not self:IsShowFSRT()
193 end
194  
195 function RegenFu:IsShowCurrent()
196 return self.db.profile.showCurrent;
197 end
198  
199 function RegenFu:IsShowPercent()
200 return self.db.profile.showPercent;
201 end
202  
203 function RegenFu:IsShowFightRegen()
204 return self.db.profile.showFightRegen;
205 end
206  
207 function RegenFu:IsHideLabel()
208 return self.db.profile.hideLabel;
209 end
210  
211 function RegenFu:ToggleShowHP()
212 self.db.profile.showHP = not self.db.profile.showHP;
213 self:UpdateSettings();
214 end
215  
216 function RegenFu:ToggleShowMP()
217 self.db.char.showMP = not self.db.char.showMP;
218 self:UpdateSettings();
219 end
220  
221 function RegenFu:ToggleShowFSRT()
222 self.db.char.showFSRT = not self.db.char.showFSRT;
223 self:UpdateSettings();
224 end
225  
226 function RegenFu:ToggleShowCurrent()
227 self.db.profile.showCurrent = not self.db.profile.showCurrent;
228 self:UpdateSettings();
229 end
230  
231 function RegenFu:ToggleShowPercent()
232 self.db.profile.showPercent = not self.db.profile.showPercent;
233 self:Update();
234 end
235  
236 function RegenFu:ToggleHideLabel()
237 self.db.profile.hideLabel = not self.db.profile.hideLabel;
238 self:Update();
239 end
240  
241 function RegenFu:ToggleShowFightRegen()
242 self.db.profile.showFightRegen = not self.db.profile.showFightRegen;
243 self:Update();
244 end
245  
246  
247 function RegenFu:ResetFSRT()
248 self.vars.combatDurationTotal = 0
249 self.vars.timeInFSRTotal = 0
250 self:Update()
251 end
252  
253 function RegenFu:ResetLastCombatStats()
254 self.vars.combatDurationLast = 0
255 self.vars.timeInFSRLast = 0
256  
257 self.vars.regenMPDuringCombat = 0;
258 self.vars.regenHPDuringCombat = 0;
259 self.vars.usedMPDuringCombat = 0;
260  
261 self:Update()
262 end
263  
264 function RegenFu:GetCombatDuration()
265 return self.vars.combatDurationLast
266 end
267  
268 function RegenFu:SetCombatDuration(dur)
269 self.vars.combatDurationTotal = self.vars.combatDurationTotal + ( dur- self.vars.combatDurationLast)
270 self.vars.combatDurationLast = dur
271 end
272  
273 function RegenFu:GetFSRDuration()
274 return self.vars.timeInFSRLast
275 end
276  
277 function RegenFu:SetFSRDuration(dur)
278 self.vars.timeInFSRTotal = self.vars.timeInFSRTotal + ( dur- self.vars.timeInFSRLast)
279 self.vars.timeInFSRLast = dur
280 end
281  
282 function RegenFu:GetICR()
283 return self.db.char.icr
284 end
285 function RegenFu:SetICR(val)
286 self.db.char.icr = val
287 self:Update()
288 end
289  
290 function RegenFu:GetMPS()
291 return 1.0 / self.db.class.mps
292 end
293 function RegenFu:SetMPS(val)
294 self.db.class.mps = 1.0 / val
295 self:Update()
296 end
297  
298  
299 function RegenFu:GetMPI()
300 return 1.0 / self.db.char.mpi
301 end
302 function RegenFu:SetMPI(val)
303 self.db.char.mpi = 1.0 / val
304 self:Update()
305 end
306  
307 function RegenFu:ShowFSRBar(val)
308 local n,l = L["FSR"]
309 local c = "blue"
310 local a = 0.8
311 local t = barTextures["smooth"]
312  
313 self.db.char.showFSRBar = val
314  
315 if (val) then
316 self:RegisterCandyBar(n, 5, l, barIcon, c)
317 self:SetCandyBarTexture(n, t)
318 bwf = self:GetFrame()
319 self:SetCandyBarWidth(n, bwf:GetWidth())
320 if bwf:GetBottom() > 0 then
321 self:SetCandyBarPoint(n, "TOPLEFT", bwf, "BOTTOMLEFT")
322 else
323 self:SetCandyBarPoint(n, "BOTTOMLEFT", bwf, "TOPLEFT")
324 end
325  
326 else
327 self:StopCandyBar(n)
328 self:UnregisterCandyBar(n)
329 end
330 end
331  
332  
333 RegenFu.OnMenuRequest = RegenFu.optionsTable
334  
335  
336 function RegenFu:OnInitialize()
337 self:SetDebugging(self.db.profile.debug)
338  
339 self:RegisterChatCommand( L["AceConsole-commands"], RegenFu.optionsTable )
340  
341  
342  
343 self.vars = {
344 currHealth = 0,
345 currMana = 0,
346 regenHP = 0,
347 regenMP = 0,
348 checkedManaState = 0,
349 maxHPRate = 0,
350 minHPRate = 9999,
351 maxMPRate = 0,
352 minMPRate = 9999,
353 regenCombatTrack = 0,
354 regenMPDuringCombat = 0,
355 regenHPDuringCombat = 0,
356  
357 timeTillRegen = 0,
358 usedMPDuringCombat = 0,
359 combatDurationLast = 0,
360 combatDurationTotal = 0,
361 timeInFSRLast = 0,
362 timeInFSRTotal = 0,
363 lastUpdate = time(),
364 secondEventID = 0;
365 }
366  
367 self.data = {}
368  
369 end
370  
371 function RegenFu:OnEnable()
372 self:RegisterEvent("UNIT_HEALTH");
373 self:RegisterEvent("UNIT_MANA");
374 self:RegisterEvent("PLAYER_ENTERING_WORLD");
375 self:RegisterEvent("PLAYER_REGEN_DISABLED");
376 self:RegisterEvent("PLAYER_REGEN_ENABLED");
377  
378  
379 self:Setup()
380 self:ShowFSRBar(self.db.char.showFSRBar)
381 self.vars.secondEventID = self:ScheduleRepeatingEvent(self.OnUpdateInternal, 0.5, self)
382 end
383  
384 function RegenFu:OnDisable()
385 self:CancelScheduledEvent(self.vars.secondEventID)
386 end
387  
388  
389 function RegenFu:PLAYER_ENTERING_WORLD()
390 if self.vars.regenCombatTrack == 1 and not UnitAffectingCombat("player") then
391 self.vars.regenCombatTrack = 0
392 end
393 self:Update()
394 end
395  
396 function RegenFu:Setup()
397 local _, class = UnitClass("player");
398 self:Debug("Setup() - "..class)
399  
400 if self.db.char.showMP == nil then
401 if UnitManaMax("player") == 0 then
402 self.db.char.showMP = false
403 self.db.char.showFSRT = false
404 self.db.char.showFSRBar = false
405 else
406 self.db.char.showMP = true
407 self.db.char.showFSRT = true
408 self.db.char.showFSRBar = false
409 end
410  
411 if ( class == "PRIEST" ) or ( class == "DRUID" ) then
412 self.db.char.showFSRT = true
413 self.db.char.showFSRBar = true
414 end
415 end
416  
417  
418 if self.db.class.mps == 0.0 then
419 if ( class == "PRIEST" ) or ( class == "MAGE" ) then
420 self.db.class.mps = 0.25;
421 else
422 self.db.class.mps = 0.2;
423 end
424 end
425 end
426  
427  
428 function RegenFu:PLAYER_REGEN_DISABLED()
429 self.vars.regenCombatTrack = 1;
430  
431 self:ResetLastCombatStats()
432 end
433  
434 function RegenFu:PLAYER_REGEN_ENABLED()
435 self.vars.regenCombatTrack = 0;
436 self:Update()
437 end
438  
439 function RegenFu:UNIT_HEALTH()
440 if self:IsShowHP() then
441 local currHealth = UnitHealth("player");
442 if ( currHealth > self.vars.currHealth and self.vars.currHealth ~= 0 ) then
443 self.vars.regenHP = currHealth - self.vars.currHealth ;
444  
445 if ( self.vars.regenCombatTrack == 1) then
446 self.vars.regenHPDuringCombat = self.vars.regenHPDuringCombat + self.vars.regenHP;
447 end
448  
449 if (self.vars.regenHP > self.vars.maxHPRate) then
450 self.vars.maxHPRate = self.vars.regenHP ;
451 end
452 if (self.vars.regenHP < self.vars.minHPRate or self.vars.minHPRate == 9999) then
453 self.vars.minHPRate = self.vars.regenHP;
454 end
455 end
456 self.vars.currHealth = currHealth;
457 self:Update();
458 end
459 end
460  
461 function RegenFu:UNIT_MANA(unit)
462 if ( unit == "player" ) and ( UnitPowerType("player") == 0 ) then
463 if self:IsShowMP() or self:IsShowFSRT() then
464 local currMana = UnitMana("player");
465 if ( currMana > self.vars.currMana and self.vars.currMana ~= 0 ) then
466 self.vars.regenMP = currMana - self.vars.currMana ;
467  
468 if ( self.vars.regenCombatTrack == 1) then
469 self.vars.regenMPDuringCombat = self.vars.regenMPDuringCombat + self.vars.regenMP;
470 end
471  
472 if (self.vars.regenMP > self.vars.maxMPRate) then
473 self.vars.maxMPRate = self.vars.regenMP;
474 end
475 if (self.vars.regenMP < self.vars.minMPRate or self.vars.minMPRate == 9999) then
476 self.vars.minMPRate = self.vars.regenMP;
477 end
478 else
479 self.vars.timeTillRegen = 5;
480 if self:IsCandyBarRegistered(L["FSR"]) then
481 local bwf = self:GetFrame()
482 self:SetCandyBarWidth(L["FSR"], bwf:GetWidth())
483 self:StartCandyBar(L["FSR"], false)
484 end
485 -- self.vars.regenMP = 0;
486  
487 if (self.vars.regenCombatTrack == 1) then
488 self.vars.usedMPDuringCombat = self.vars.usedMPDuringCombat + currMana - self.vars.currMana;
489 end
490 end
491  
492 self.vars.currMana = currMana;
493 self:Update();
494 end
495 end
496 end
497  
498 function RegenFu:OnUpdateInternal()
499 local tm = time()
500 local elapsed = tm - self.vars.lastUpdate
501 self.vars.lastUpdate = tm
502 -- self.timeSinceUpdate = self.timeSinceUpdate + elapsed;
503  
504 local update = nil
505  
506 if self.vars.timeTillRegen > 0 then
507 self.vars.timeTillRegen = self.vars.timeTillRegen - elapsed;
508 update = true
509 end
510  
511 if (UnitMana("player") < UnitManaMax("player")) and self.vars.regenCombatTrack == 1 then
512 self:SetCombatDuration(self:GetCombatDuration() + elapsed)
513  
514 if self.vars.timeTillRegen > 0 then
515 self:SetFSRDuration(self:GetFSRDuration() + elapsed)
516 end
517  
518 update = true
519 end
520  
521 if (update) then
522 self:Update()
523 end
524 end
525  
526  
527 function RegenFu:OnDataUpdate()
528 self.data.regenHP = self.vars.regenHP
529 self.data.regenMP = self.vars.regenMP
530 self.data.regenHPCombat = self.vars.regenHPDuringCombat
531 self.data.regenMPCombat = self.vars.regenMPDuringCombat
532  
533 self.data.maxHPRate = self.vars.maxHPRate
534 self.data.minHPRate = self.vars.minHPRate
535 self.data.maxMPRate = self.vars.maxMPRate
536 self.data.minMPRate = self.vars.minMPRate
537  
538 self.data.usedMPCombat = self.vars.usedMPDuringCombat
539  
540 self.data.combatDurationTotal = self.vars.combatDurationTotal
541 self.data.combatDurationLast = self.vars.combatDurationLast
542 self.data.timeTillRegen = self.vars.timeTillRegen
543  
544 self.data.inCombat = self.vars.regenCombatTrack
545  
546 self.data.fsrpLast = self.vars.timeInFSRLast / (self.data.combatDurationLast + 0.001);
547 self.data.fsrpTotal = self.vars.timeInFSRTotal / (self.data.combatDurationTotal + 0.001);
548  
549 self.data.playerHP = UnitHealth("player")
550 self.data.playerMaxHP = UnitHealthMax("player")
551 self.data.playerMP = UnitMana("player")
552 self.data.playerMaxMP = UnitManaMax("player")
553  
554 self.data.regenMPPercent = (self.data.regenMP/self.data.playerMaxMP)*100
555 self.data.regenHPPercent = (self.data.regenHP/self.data.playerMaxHP)*100
556 self.data.regenHPPercentCombat = (self.data.regenHPCombat/self.data.playerMaxHP)*100
557 self.data.regenMPPercentCombat = (self.data.regenMPCombat/self.data.playerMaxMP)*100
558  
559  
560 if self.data.minHPRate == 9999 then self.data.minHPRate = 0 end
561 if self.data.minMPRate == 9999 then self.data.minMPRate = 0 end
562  
563 if self.data.playerHP == self.data.playerMaxHP then
564 self.data.regenHP = 0;
565 end
566  
567 if self.data.playerMP == self.data.playerMaxMP then
568 self.data.regenMP = 0;
569 end
570 end
571  
572  
573 function RegenFu:OnTextUpdate()
574 local labelTextHP = "";
575 local valueTextHP = "";
576 local labelTextMP = "";
577 local valueTextMP = "";
578 local labelTextFSRT = ""
579 local valueTextFSRT = ""
580  
581 -- safety in case both are off, then cant ever turn em on
582 if ( not self:IsShowHP() and not self:IsShowMP() ) then
583 self:ToggleShowHP();
584 end
585  
586 if ( self:IsShowHP() ) then
587 if not self:IsHideLabel() then
588 labelTextHP = L.HP_LABEL;
589 end
590  
591 if self:IsShowPercent() then
592 valueTextHP = string.format("%.2f%%", self.data.regenHPPercent);
593 else
594 valueTextHP = string.format("%d", self.data.regenHP);
595 end
596  
597 if self:IsShowFightRegen() and self.data.inCombat == 1 then
598 valueTextHP = string.format("|cff00ff00%s|r / |cff00ff00%s|r", valueTextHP, self.data.regenHPCombat);
599 else
600 valueTextHP = string.format("|cff00ff00%s|r", valueTextHP);
601 end
602  
603 if self:IsShowCurrent() then
604 valueTextHP = string.format("|cff00ff00%s|r/|cff00ff00%s|r(%s)",
605 self.data.playerHP, self.data.playerMaxHP, valueTextHP);
606 end
607  
608 end
609  
610 if ( self:IsShowMP() ) then
611 if not self:IsHideLabel() then
612 labelTextMP = L.MP_LABEL;
613 end
614  
615 if self:IsShowPercent() then
616 valueTextMP = string.format("%.2f%%", self.data.regenMPPercent);
617 else
618 valueTextMP = string.format("%d", self.data.regenMP);
619 end
620  
621 if self:IsShowFightRegen() and self.data.inCombat == 1 then
622 valueTextMP = string.format("|cff3399ff%s|r / |cff3399ff%s|r", valueTextMP, self.data.regenMPCombat);
623 else
624 valueTextMP = string.format("|cff3399ff%s|r", valueTextMP);
625 end
626  
627 if self:IsShowCurrent() then
628 valueTextMP = string.format("|cff3399ff%s|r/|cff3399ff%s|r(%s)",
629 self.data.playerMP, self.data.playerMaxMP, valueTextMP)
630 end
631  
632 end
633  
634 if ( self:IsShowFSRT() ) then
635 if not self:IsHideLabel() then
636 labelTextFSRT = L.FSR_LABEL
637 end
638 valueTextFSRT = string.format("%d%%", self.data.fsrpTotal*100)
639 end
640 self:SetText(labelTextHP..valueTextHP.." "..labelTextMP..valueTextMP.." "..labelTextFSRT..valueTextFSRT);
641  
642 if self:IsCandyBarRegistered(L["FSR"]) then
643 local bwf = self:GetFrame()
644 self:SetCandyBarWidth(L["FSR"], bwf:GetWidth())
645 self:Debug(bwf:GetBottom(), GetScreenHeight())
646 if bwf:GetBottom() > 0 then
647 self:SetCandyBarPoint(L["FSR"], "TOPLEFT", bwf, "BOTTOMLEFT")
648 else
649 self:SetCandyBarPoint(L["FSR"], "BOTTOMLEFT", bwf, "TOPLEFT")
650 end
651 end
652 end
653  
654 function RegenFu:OnTooltipUpdate()
655 local cat
656  
657 if self:IsShowHP() then
658 cat = tablet:AddCategory(
659 'columns', 2,
660 'child_textR', 1,
661 'child_textG', 1,
662 'child_textB', 0,
663 'child_text2R', 0,
664 'child_text2G', 1,
665 'child_text2B', 0
666 );
667  
668 cat:AddLine(
669 'text', L.TOOLTIP1_LEFT,
670 'text2', string.format("%s |cffffffff/|r %s |cffffffff(|r|cffff0000%s|cffffffff)|r",
671 self.data.playerHP, self.data.playerMaxHP, self.data.playerMaxHP-self.data.playerHP )
672 );
673 local cat_ratiosH = cat:AddCategory(
674 'columns', 2,
675 'child_textR', 0.60,
676 'child_textG', 0.60,
677 'child_textB', 0,
678 'child_text2R', 0,
679 'child_text2G', 1,
680 'child_text2B', 0,
681 'hideBlankLine', true,
682 'child_indentation', 10
683 )
684  
685 cat_ratiosH:AddLine(
686 'text', L.TOOLTIP3_LEFT,
687 'text2', self.data.maxHPRate
688 );
689 cat_ratiosH:AddLine(
690 'text', L.TOOLTIP4_LEFT,
691 'text2', self.data.minHPRate
692 );
693 cat_ratiosH:AddLine(
694 'text', L.TOOLTIP8_LEFT,
695 'text2', string.format("%s (%.2f%%)",
696 self.data.regenHPCombat, self.data.regenHPPercentCombat )
697 );
698 end
699  
700 if self:IsShowMP() then
701 cat = tablet:AddCategory(
702 'columns', 2,
703 'child_textR', 1,
704 'child_textG', 1,
705 'child_textB', 0,
706 'child_text2R', 0.2,
707 'child_text2G', 0.4,
708 'child_text2B', 1
709 );
710  
711 cat:AddLine(
712 'text', L.TOOLTIP2_LEFT,
713 'text2', string.format("%s |cffffffff/|r %s |cffffffff(|r|cffff0000%s|cffffffff)|r",
714 self.data.playerMP, self.data.playerMaxMP, self.data.playerMaxMP-self.data.playerMP)
715 );
716  
717 local cat_ratiosM = cat:AddCategory(
718 'columns', 2,
719 'child_textR', 0.60,
720 'child_textG', 0.60,
721 'child_textB', 0,
722 'child_text2R', 0.2,
723 'child_text2G', 0.4,
724 'child_text2B', 1,
725 'hideBlankLine', true,
726 'child_indentation', 10
727 )
728 cat_ratiosM:AddLine(
729 'text', L.TOOLTIP5_LEFT,
730 'text2', self.data.maxMPRate
731 );
732 cat_ratiosM:AddLine(
733 'text', L.TOOLTIP6_LEFT,
734 'text2', self.data.minMPRate
735 );
736 cat_ratiosM:AddLine(
737 'text', L.TOOLTIP7_LEFT,
738 'text2', string.format("%s (%.2f%%)",
739 self.data.regenMPCombat, self.data.regenMPPercentCombat)
740 );
741 cat_ratiosM:AddLine(
742 'text', L.TOOLTIP9_LEFT,
743 'text2', string.format("%s MP/5s",
744 self:GetCombatDuration() > 0 and math.floor((self.data.regenMPCombat/self:GetCombatDuration())*5) or 0)
745 );
746  
747 end
748  
749 if self:IsShowFSRT() then
750 -- usedMPDuringCombat = 0,
751 -- combatDuration = 0,
752 -- timeInFSR = 0,
753  
754  
755 local fsrp = self.data.fsrpLast
756 local str = string.format("%0.2f", 2/(5*self.db.class.mps*(1 - fsrp + self.db.char.icr*fsrp)));
757  
758 local combatTag
759 local timeFormat
760  
761 if self.data.inCombat == 1 then
762 combatTag = L["(This Fight)"]
763 timeFormat = string.format("|cff00ff00%s|r", self:FormatDurationString(self.data.combatDurationLast))
764 else
765 combatTag = L["(Last Fight)"]
766 timeFormat = self:FormatDurationString(self.data.combatDurationLast)
767 end
768  
769 local cat = tablet:AddCategory(
770 'columns', 2,
771 'child_textR', 1,
772 'child_textG', 1,
773 'child_textB', 0,
774 'child_text2R', 0.2,
775 'child_text2G', 0.4,
776 'child_text2B', 1
777 )
778 cat:AddLine(
779 'text', L["Time Spent In Regen"].." "..combatTag,
780 'text2', timeFormat
781 )
782  
783 local cat_ratios = cat:AddCategory(
784 'columns', 2,
785 'child_textR', 0.60,
786 'child_textG', 0.60,
787 'child_textB', 0,
788 'child_text2R', 0.2,
789 'child_text2G', 0.4,
790 'child_text2B', 1,
791 'hideBlankLine', true,
792 'child_indentation', 10
793 )
794 cat_ratios:AddLine(
795 'text', L["% Of That Time In FSR"],
796 'text2', string.format("%0.1f%%", fsrp*100)
797 )
798 cat_ratios:AddLine(
799 'text', L["Spirit Needed To Equal 1mp5"],
800 'text2', str
801 )
802 cat_ratios:AddLine(
803 'text', L["Int Needed To Equal 1mp5"],
804 'text2', string.format("%0.2f", self.data.combatDurationLast/5*self.db.char.mpi)
805 )
806  
807  
808 fsrp = self.data.fsrpTotal
809 str = string.format("%0.2f", 2/(5*self.db.class.mps*(1 - fsrp + self.db.char.icr*fsrp)));
810  
811 local cat2 = tablet:AddCategory(
812 'columns', 2,
813 'child_textR', 1,
814 'child_textG', 1,
815 'child_textB', 0,
816 'child_text2R', 0.2,
817 'child_text2G', 0.4,
818 'child_text2B', 1
819 )
820 cat2:AddLine(
821 'text', L["Total Regen Time Observed"],
822 'text2', self:FormatDurationString(self.data.combatDurationTotal)
823 )
824 local cat_ratios2 = cat2:AddCategory(
825 'columns', 2,
826 'child_textR', 0.60,
827 'child_textG', 0.60,
828 'child_textB', 0,
829 'child_text2R', 0.2,
830 'child_text2G', 0.4,
831 'child_text2B', 1,
832 'hideBlankLine', true,
833 'child_indentation', 10
834 )
835 cat_ratios2:AddLine(
836 'text', L["% Of That Time In FSR"],
837 'text2', string.format("%0.1f%%", fsrp*100)
838 )
839 cat_ratios2:AddLine(
840 'text', L["Spirit Needed To Equal 1mp5"],
841 'text2', str
842 )
843 end
844 end
845  
846  
847 function RegenFu:FormatDurationString(duration)
848 return string.format("%d:%04.1f" , floor(duration/60), floor(mod(duration*10, 600))/10)
849 end
850  
851  
852 function RegenFu:UpdateSettings()
853 -- safety in case both are off, then cant ever turn em on
854 if ( not self:IsShowHP() and not self:IsShowMP() ) then
855 self:ToggleShowHP();
856 end
857 self:Update();
858 end
859 function RegenFu:OnProfileEnable(oldName, _, copyFrom)
860 self:Debug("OnProfileEnable()")
861 self:Setup()
862  
863 local function func()
864 self:Update()
865 end
866 self:ScheduleEvent(func, 0.01)
867 end