Skip to content

Commit f02c9cd

Browse files
committed
save all stats currently saved
1 parent 7ea493c commit f02c9cd

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

src/Modules/BuildDisplayStats.lua

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,12 @@ local StatList = {
123123
{ stat = "Mana", label = "Total Mana", fmt = "d", color = colorCodes.MANA, compPercent = true, displayStat = true },
124124
{ stat = "Spec:ManaInc", label = "%Inc Mana from Tree", color = colorCodes.MANA, fmt = "d%%", displayStat = true },
125125
{ stat = "ManaUnreserved", label = "Unreserved Mana", fmt = "d", color = colorCodes.MANA, condFunc = function(v,o) return v < o.Mana end, compPercent = true, warnFunc = function(v) return v < 0 and "Your unreserved Mana is negative" end, displayStat = true },
126-
{ stat = "ManaUnreservedPercent", label = "Unreserved Mana", fmt = "d%%", color = colorCodes.MANA, condFunc = function(v,o) return v < 100 end, displayStat = true },
126+
{ stat = "ManaUnreservedPercent", label = " Unreserved Mana", fmt = "d%%", color = colorCodes.MANA, condFunc = function(v,o) return v < 100 end, displayStat = true },
127127
{ stat = "ManaRegenRecovery", label = "Mana Regen", fmt = ".1f", color = colorCodes.MANA, displayStat = true },
128128
{ stat = "ManaLeechGainRate", label = "Mana Leech/On Hit Rate", fmt = ".1f", color = colorCodes.MANA, compPercent = true, displayStat = true },
129129
{ stat = "ManaLeechGainPerHit", label = "Mana Leech/Gain per Hit", fmt = ".1f", color = colorCodes.MANA, compPercent = true, displayStat = true },
130130
}, {
131131
{ stat = "EnergyShield", label = "Energy Shield", fmt = "d", color = colorCodes.ES, compPercent = true, displayStat = true, minionDisplayStat = true },
132-
{ stat = "EnergyShield", label = "Energy Shield", fmt = "d", color = colorCodes.ES, compPercent = true },
133132
{ stat = "EnergyShieldRecoveryCap", label = "Recoverable ES", color = colorCodes.ES, fmt = "d", condFunc = function(v,o) return o.CappingES end, displayStat = true },
134133
{ stat = "Spec:EnergyShieldInc", label = "%Inc ES from Tree", color = colorCodes.ES, fmt = "d%%", displayStat = true },
135134
{ stat = "EnergyShieldRegenRecovery", label = "Energy Shield Regen", color = colorCodes.ES, fmt = ".1f", displayStat = true, minionDisplayStat = true },
@@ -227,6 +226,29 @@ local extraSaveStats = {}
227226
local statCount = 0
228227
local settingsStatList = main.displayStatList
229228
if settingsStatList then
229+
-- first add all the missing stats that should be saved to extraSaveStats
230+
for _, statGroup in ipairs(StatList) do
231+
for _, stat in ipairs(statGroup) do
232+
if stat.displayStat or stat.minionDisplayStat or stat.extraSaveStat then
233+
local found = false
234+
for _, statGroup2 in ipairs(settingsStatList) do
235+
for _, stat2 in ipairs(statGroup2) do
236+
if stat2.label == stat.label then
237+
found = true
238+
break
239+
end
240+
end
241+
if found then
242+
break
243+
end
244+
end
245+
if not found then
246+
t_insert(extraSaveStats, stat.stat)
247+
end
248+
end
249+
end
250+
end
251+
-- then add all the stats from settings
230252
for _, statGroup in ipairs(settingsStatList) do
231253
if statCount > 0 then
232254
t_insert(displayStats, { })
@@ -241,9 +263,9 @@ if settingsStatList then
241263
for k, v in pairs(stat) do
242264
stat2[k] = v
243265
end
266+
stat2.extraSaveStat = stat2.extraSaveStat or stat2.displayStat or stat2.minionDisplayStat
244267
stat2.displayStat = stat.displayStat
245268
stat2.minionDisplayStat = stat.minionDisplayStat
246-
stat2.extraSaveStat = stat.extraSaveStat
247269
stat = stat2
248270
found = true
249271
break
@@ -253,6 +275,12 @@ if settingsStatList then
253275
break
254276
end
255277
end
278+
if stat.extraSaveStat then
279+
stat.extraSaveStat = nil
280+
if not (stat.displayStat or stat.minionDisplayStat) then
281+
t_insert(extraSaveStats, stat.stat)
282+
end
283+
end
256284
if stat.displayStat then
257285
stat.displayStat = nil
258286
t_insert(displayStats, stat)
@@ -262,10 +290,6 @@ if settingsStatList then
262290
stat.minionDisplayStat = nil
263291
t_insert(minionDisplayStats, stat)
264292
end
265-
if stat.extraSaveStat then
266-
stat.extraSaveStat = nil
267-
t_insert(extraSaveStats, stat.stat)
268-
end
269293
end
270294
end
271295
end

0 commit comments

Comments
 (0)