From ad72976b24279105a1309475b8b43528786821d3 Mon Sep 17 00:00:00 2001 From: Parnic Date: Fri, 4 Sep 2015 22:34:07 -0500 Subject: [PATCH] Cleaner way of getting defaults and options from stack counters Now we pass in the options or defaults table directly to the helper class's getter methods since they're passed by reference and can be modified in place. This saves us creation of yet more tables and obviates the need to merge tables together. --- IceStackCounter.lua | 10 ++-------- modules/CustomCount.lua | 10 ++-------- modules/CustomCounterBar.lua | 12 +++--------- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/IceStackCounter.lua b/IceStackCounter.lua index adeb3d9..ca53098 100644 --- a/IceStackCounter.lua +++ b/IceStackCounter.lua @@ -4,9 +4,7 @@ local validUnits = {"player", "target", "focus", "pet", "vehicle", "targettarget local buffOrDebuff = {"buff", "debuff", "charges", "spell count"} -- OVERRIDE -function IceStackCounter_GetOptions(frame) - local opts = {} - +function IceStackCounter_GetOptions(frame, opts) opts["customHeader"] = { type = 'header', name = L["Aura settings"], @@ -107,8 +105,6 @@ function IceStackCounter_GetOptions(frame) usage = "", order = 30.9, } - - return opts end function IceStackCounter_GetMaxCount(frame) @@ -120,14 +116,12 @@ function IceStackCounter_GetMaxCount(frame) end end -function IceStackCounter_GetDefaultSettings() - local defaults = {} +function IceStackCounter_GetDefaultSettings(defaults) defaults["maxCount"] = 5 defaults["auraTarget"] = "player" defaults["auraName"] = "" defaults["onlyMine"] = true defaults["auraType"] = "buff" - return defaults end diff --git a/modules/CustomCount.lua b/modules/CustomCount.lua index b322955..f178aef 100644 --- a/modules/CustomCount.lua +++ b/modules/CustomCount.lua @@ -17,10 +17,7 @@ end -- OVERRIDE function IceCustomCount.prototype:GetOptions() local opts = IceCustomCount.super.prototype.GetOptions(self) - - for k,v in pairs(IceStackCounter_GetOptions(self)) do - opts[k] = v - end + IceStackCounter_GetOptions(self, opts) opts["deleteme"] = { type = 'execute', @@ -261,10 +258,7 @@ end function IceCustomCount.prototype:GetDefaultSettings() local defaults = IceCustomCount.super.prototype.GetDefaultSettings(self) - - for k,v in pairs(IceStackCounter_GetDefaultSettings(self)) do - defaults[k] = v - end + IceStackCounter_GetDefaultSettings(defaults) defaults["vpos"] = 0 defaults["hpos"] = 0 diff --git a/modules/CustomCounterBar.lua b/modules/CustomCounterBar.lua index ccbdabc..e08a76b 100644 --- a/modules/CustomCounterBar.lua +++ b/modules/CustomCounterBar.lua @@ -15,10 +15,7 @@ end function IceCustomCounterBar.prototype:GetOptions() local opts = IceCustomCounterBar.super.prototype.GetOptions(self) - - for k,v in pairs(IceStackCounter_GetOptions(self)) do - opts[k] = v - end + IceStackCounter_GetOptions(self, opts) opts["deleteme"] = { type = 'execute', @@ -216,11 +213,8 @@ function IceCustomCounterBar.prototype:GetOptions() end function IceCustomCounterBar.prototype:GetDefaultSettings() - local defaults = IceCustomCounterBar.super.prototype.GetDefaultSettings(self) - - for k,v in pairs(IceStackCounter_GetDefaultSettings(self)) do - defaults[k] = v - end + local defaults = IceCustomCounterBar.super.prototype.GetDefaultSettings(self) + IceStackCounter_GetDefaultSettings(defaults) defaults.textVisible['lower'] = false defaults.offset = 9