Description
We need a library to handle configurable user settings for each addon.
Some considerations:
- Unlike the v4 equivalent it should probably work with Lua files instead of XML, faster, users are used to it by now (from GS and various other addons) and less error prone, which would allow us to focus on handling the next issue...
- We need stable multiboxing handling, something v4's library has always been lacking
The current config's API is largely good and I'd keep most of its features:
config.load() -- 1
config.load(path) -- 2
config.load(defaults) -- 3
config.load(path, defaults) -- 4
Function 1 loads settings from a default1 path
Function 2 loads settings from the specfied path
Function 3 loads settings from a default1 path, overriding the provided defaults
Function 4 loads settings from the specified path, overriding the provided defaults
Functions 3 and 4 should both also add the default settings provided to the file, where missing.
All functions should create the settings file, if missing.
1 we use settings.xml
in v4, could be settings.lua
or w/e
config.reload(settings)
Reloads the provided settings from the file. Afterwards executes all registered functions pertaining to the settings (see below).
config.register(settings, fn, ...) -- 1
config.unregister(settings, key) -- 2
Function 1 receives and stores a function and arguments to be executed every time the settings are reloaded. Returns an arbitrary key it uses to refer to the stored function.
Function 2 unregisters the function corresponding to the provided key, which was received from 1).
local events = {'load', 'logout', 'login'}
These events should trigger a reload (config.reload
), and execute all functions registered to all loaded settings.
In addition to this it should be able to load and manage multiple settings parsed from multiple files.