Compare with Previous | Blame | View Log
local LAM = LibStub("LibAddonMenu-2.0")
local LMP = LibStub("LibMediaProvider-1.0")
local fonts = LMP:List("font")
local fontStyles = {"normal", "outline", "thick-outline", "shadow", "soft-shadow-thick", "soft-shadow-thin"}
local alignments = {"CENTER", "LEFT", "RIGHT"}
local modules = ZAM_Stats.modules
local RGBPercToHex = ZAM_Stats.RGBPercToHex
local ConfigModule = ZAM_Stats.ConfigModule
local db
local defaults = {
locked = false,
font = "Arial Narrow",
fsize = 18,
fstyle = "soft-shadow-thin",
align = "CENTER",
preColor = {r=1, g=1, b=1},
sufColor = {r=1, g=1, b=1},
}
local panelData = {
type = "panel",
name = "ZAM Stats",
displayName = "|t72:36:ZAM_Stats\\ZAM_Logo.dds|t Stats",
author = "Seerah",
version = "1.1.3",
slashCommand = "/zamstats",
registerForDefaults = true,
resetFunc = function()
for _,frame in pairs(modules) do
frame:ClearAnchors()
frame:SetAnchor(CENTER, GuiRoot, CENTER, 0, 0)
db[frame:GetName()].point = {["a"]=CENTER, ["b"]=CENTER, ["x"]=0, ["y"]=0}
end
CALLBACK_MANAGER:FireCallbacks("ZAM_Stats_Force_Refresh")
end,
}
local optionsData = {
[1] = {
type = "checkbox",
name = "Lock Modules",
tooltip = "Lock or unlock the modules to move them.",
getFunc = function() return db.locked end,
setFunc = function(value)
db.locked = value
for _,frame in pairs(modules) do
frame:SetMovable(not db.locked)
frame.bg:SetCenterColor(0,0,0, db.locked and 0 or .4)
end
end,
default = defaults.locked,
},
[2] = {
type = "header",
name = "Font Settings",
},
[3] = {
type = "dropdown",
name = "Font",
tooltip = "Set the font for the text.",
choices = fonts,
getFunc = function() return db.font end,
setFunc = function(font)
db.font = font
for k,v in pairs(modules) do
ConfigModule(v)
end
end,
default = defaults.font,
},
[4] = {
type = "slider",
name = "Font Size",
tooltip = "Set the size of the modules' text.",
min = 8,
max = 30,
step = 1,
getFunc = function() return db.fsize end,
setFunc = function(value)
db.fsize = value
for k,v in pairs(modules) do
ConfigModule(v)
end
end,
default = defaults.fsize,
},
[5] = {
type = "dropdown",
name = "Font Style",
tooltip = "Set the style to apply to the text.",
choices = fontStyles,
getFunc = function() return db.fstyle end,
setFunc = function(style)
db.fstyle = style
for k,v in pairs(modules) do
ConfigModule(v)
end
end,
default = defaults.fstyle,
},
[6] = {
type = "dropdown",
name = "Text Alignment",
tooltip = "Set the text's horizontal alignment.",
choices = alignments,
getFunc = function() return db.align end,
setFunc = function(align)
db.align = align
for k,v in pairs(modules) do
ConfigModule(v)
end
end,
default = defaults.align,
},
[7] = {
type = "header",
name = "Color Settings",
},
[8] = {
type = "colorpicker",
name = "Prefix Color",
tooltip = "The color of the module's value.",
getFunc = function() return db.preColor.r, db.preColor.g, db.preColor.b end,
setFunc = function(r,g,b,a)
db.preColor.r = r
db.preColor.g = g
db.preColor.b = b
ZAM_Stats.preHex = RGBPercToHex(r,g,b)
end,
width = "half",
default = defaults.preColor,
},
[9] = {
type = "colorpicker",
name = "Suffix Color",
tooltip = "The color of the module's suffix text.",
getFunc = function() return db.sufColor.r, db.sufColor.g, db.sufColor.b end,
setFunc = function(r,g,b,a)
db.sufColor.r = r
db.sufColor.g = g
db.sufColor.b = b
ZAM_Stats.sufHex = RGBPercToHex(r,g,b)
end,
width = "half",
default = defaults.sufColor,
},
[10] = {
type = "button",
name = "Force Color Refresh",
tooltip = "Some modules may not change their text color until the data next updates. Click the button to force a refresh if you have a module like this enabled.",
func = function() CALLBACK_MANAGER:FireCallbacks("ZAM_Stats_Force_Refresh") end,
},
}
function ZAM_Stats.SetUpSavedVars()
ZAM_StatsDB = ZAM_StatsDB or {}
for k,v in pairs(defaults) do
if type(ZAM_StatsDB[k]) == "nil" then
ZAM_StatsDB[k] = v
end
end
db = ZAM_StatsDB
local name
for k,v in pairs(modules) do
name = v:GetName()
db[name] = db[name] or {}
end
return db
end
function ZAM_Stats.RegisterOptions()
LAM:RegisterAddonPanel("ZAMStatsOptions", panelData)
LAM:RegisterOptionControls("ZAMStatsOptions", optionsData)
end