BrokerPack/zz_MiscHelper/prefs.lua

84 lines
3.3 KiB
Lua

local addonName, addon = ...
local childName = addon['childName']
local child = addon[childName]
local config = LibStub:GetLibrary("zzConfig")
local options
local db
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
function child:PrefChanged(pref, value, oldvalue)
print(pref[#pref], value)
local modName = pref[#pref]
if(modName and child['mhmods'][modName]) then
local modul = child['mhmods'][modName]
if(value) then
modul:Enable()
else
modul:Disable()
end
end
end
function child:AddCE(modName)
local options = child['options']
local main = options['args'][childName]
config:AddConfigEntry(main, modName, "toggle", L[format('%s_message', modName)], nil, 1)
end
local mods = {
autogreed = function(menu)
config:AddConfigEntry(menu,"disenchant","header",L["Disenchant"],nil,1)
config:AddConfigEntry(menu,"deGreen","toggle",L["DE green"],nil,2)
config:AddConfigEntry(menu,"deBlue","toggle",L["DE blue"],nil,3)
config:AddConfigEntry(menu,"deEpic","toggle",L["DE epic"],nil,4)
config:AddConfigEntry(menu,"boe","header",L["Bind on Equip"],nil,5)
config:AddConfigEntry(menu,"greedBOE","toggle",L["Greed BoE"],nil,6)
config:AddConfigEntry(menu,"showBOE","range",L["Show BoE"],L['SkipGreed'],7,1,4,1,false)
config:AddConfigEntry(menu,"passGreen","toggle",L["Pass green BoE"],nil,8)
config:AddConfigEntry(menu,"passBlue","toggle",L["Pass blue BoE"],nil,9)
config:AddConfigEntry(menu,"passEpic","toggle",L["Pass epic BoE"],nil,10)
config:AddConfigEntry(menu,"misc","header",L["Misc"],nil,11)
config:AddConfigEntry(menu,"skipNeed","toggle",L["Show Need Rolls"],L["Show items you can roll need for. Set minimum quality to hide low level items."],12)
config:AddConfigEntry(menu,"skipQuality","range",L["Minimum Quality"],L["Dont show items with a quality lower than minimum quality when 'Show Need Rolls' is active. -1 means automagically your current average Itemlevel - 18"],13,-1,1000,1,false)
config:AddConfigEntry(menu,"ignoreOrbs","toggle",L["Ignore orbs"],nil,14)
config:AddConfigEntry(menu,"skipPet","toggle",L["Show Pets"],nil,15)
config:AddConfigEntry(menu,"skipMount","toggle",L["Show Mounts"],nil,16)
config:AddConfigEntry(menu,"skipHoliday","toggle",L["Show Holiday-Items"],nil,17)
config:AddConfigEntry(menu,"skipQuest","toggle",L["Show Questitems"],nil,18)
end
}
function child:AddME(modName)
child:AddCE(modName)
if(modName and type(mods[modName]) == 'function') then
local menu = config:AddConfigMenu(child['options'], L[format('%s_group', modName)], 2, { db = child['mhmods'][modName]['db']})
mods[modName](menu)
end
end
child['MH_GetPref'] = function(key)
return db[key]
end
child['MH_GetDB'] = function(subTable, def)
if(not subTable) then return db end
def = def or {}
local key = format("%sSettings", subTable)
db[key] = db[key] or CopyTable(def)
return db[key]
end
child['MH_SetPref'] = function(key, value)
db[key] = value
end
child['MH_GetOptions'] = function()
return child['options']
end
local init = {
Setup = function(self)
db = child['db']
options = child['options']
local main = options['args'][childName]
-- print("setup prefs", childName)
local menu = child:AddME('autogreed', {db = dbm})
end
}
addon.RegisterCallback(init, format("Init%s", childName), 'Setup')