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.
This commit is contained in:
Parnic
2015-09-04 22:34:07 -05:00
parent 4d20a073ae
commit ad72976b24
3 changed files with 7 additions and 25 deletions

View File

@ -4,9 +4,7 @@ local validUnits = {"player", "target", "focus", "pet", "vehicle", "targettarget
local buffOrDebuff = {"buff", "debuff", "charges", "spell count"} local buffOrDebuff = {"buff", "debuff", "charges", "spell count"}
-- OVERRIDE -- OVERRIDE
function IceStackCounter_GetOptions(frame) function IceStackCounter_GetOptions(frame, opts)
local opts = {}
opts["customHeader"] = { opts["customHeader"] = {
type = 'header', type = 'header',
name = L["Aura settings"], name = L["Aura settings"],
@ -107,8 +105,6 @@ function IceStackCounter_GetOptions(frame)
usage = "<the maximum number of valid applications>", usage = "<the maximum number of valid applications>",
order = 30.9, order = 30.9,
} }
return opts
end end
function IceStackCounter_GetMaxCount(frame) function IceStackCounter_GetMaxCount(frame)
@ -120,14 +116,12 @@ function IceStackCounter_GetMaxCount(frame)
end end
end end
function IceStackCounter_GetDefaultSettings() function IceStackCounter_GetDefaultSettings(defaults)
local defaults = {}
defaults["maxCount"] = 5 defaults["maxCount"] = 5
defaults["auraTarget"] = "player" defaults["auraTarget"] = "player"
defaults["auraName"] = "" defaults["auraName"] = ""
defaults["onlyMine"] = true defaults["onlyMine"] = true
defaults["auraType"] = "buff" defaults["auraType"] = "buff"
return defaults
end end

View File

@ -17,10 +17,7 @@ end
-- OVERRIDE -- OVERRIDE
function IceCustomCount.prototype:GetOptions() function IceCustomCount.prototype:GetOptions()
local opts = IceCustomCount.super.prototype.GetOptions(self) local opts = IceCustomCount.super.prototype.GetOptions(self)
IceStackCounter_GetOptions(self, opts)
for k,v in pairs(IceStackCounter_GetOptions(self)) do
opts[k] = v
end
opts["deleteme"] = { opts["deleteme"] = {
type = 'execute', type = 'execute',
@ -261,10 +258,7 @@ end
function IceCustomCount.prototype:GetDefaultSettings() function IceCustomCount.prototype:GetDefaultSettings()
local defaults = IceCustomCount.super.prototype.GetDefaultSettings(self) local defaults = IceCustomCount.super.prototype.GetDefaultSettings(self)
IceStackCounter_GetDefaultSettings(defaults)
for k,v in pairs(IceStackCounter_GetDefaultSettings(self)) do
defaults[k] = v
end
defaults["vpos"] = 0 defaults["vpos"] = 0
defaults["hpos"] = 0 defaults["hpos"] = 0

View File

@ -15,10 +15,7 @@ end
function IceCustomCounterBar.prototype:GetOptions() function IceCustomCounterBar.prototype:GetOptions()
local opts = IceCustomCounterBar.super.prototype.GetOptions(self) local opts = IceCustomCounterBar.super.prototype.GetOptions(self)
IceStackCounter_GetOptions(self, opts)
for k,v in pairs(IceStackCounter_GetOptions(self)) do
opts[k] = v
end
opts["deleteme"] = { opts["deleteme"] = {
type = 'execute', type = 'execute',
@ -216,11 +213,8 @@ function IceCustomCounterBar.prototype:GetOptions()
end end
function IceCustomCounterBar.prototype:GetDefaultSettings() function IceCustomCounterBar.prototype:GetDefaultSettings()
local defaults = IceCustomCounterBar.super.prototype.GetDefaultSettings(self) local defaults = IceCustomCounterBar.super.prototype.GetDefaultSettings(self)
IceStackCounter_GetDefaultSettings(defaults)
for k,v in pairs(IceStackCounter_GetDefaultSettings(self)) do
defaults[k] = v
end
defaults.textVisible['lower'] = false defaults.textVisible['lower'] = false
defaults.offset = 9 defaults.offset = 9