comparison LibModuleDBShare-1.0/LibModuleDBShare-1.0.lua @ 33:3f329c676eac v1.0 release

Updated luadoc comments. Set minor version to 2, so any alpha versions are overwritten.
author Andrew Knoll <andrewtknoll@gmail.com>
date Tue, 19 Mar 2013 00:10:03 -0400
parents ff0e10fd2a5f
children 328df380892c
comparison
equal deleted inserted replaced
32:a63d1129c0d8 33:3f329c676eac
1 --- **LibModuleDBShare-1.0**\\ 1 --- **LibModuleDBShare-1.0** provides a shared profile manager for addons without a central core.
2 -- A description will eventually be here. 2 -- A basic options panel for the group is added to the Blizzard options panel, as well as a
3 -- standard profile manager as a subpanel. Changes through the profiles panel are propagated
4 -- to member databases. The root panel can be used as a parent for your module config panels,
5 -- to keep all your addon's config in one place. The root panel's name is the same as the group's
6 -- name.\\
7 -- \\
8 -- A group can be created using the ':NewGroup' library method. The returned object inherits
9 -- the ':AddDB' method of the DBGroup object described below.\\
10 -- \\
11 -- **LibDualSpec Support**\\
12 -- LibModuleDBShare can use LibDualSpec to manage automatic profile switching with talent spec
13 -- changes. This integration is handled by the library; there is no need to use LibDualSpec
14 -- on member databases directly.
3 -- 15 --
4 -- @usage 16 -- @usage
5 -- Also coming soon. 17 -- local database;
18 -- -- this function is called after the ADDON_LOADED event fires
19 -- function initializeDB()
20 -- database = LibStub("AceDB-3.0"):New("MyAddonDB", defaults, true);
21 -- local group = LibStub("LibModuleDBShare-1.0"):GetGroup("Group Name");
22 -- if not group then
23 -- group = LibStub("LibModuleDBShare-1.0"):NewGroup("Group Name", "A description for this group.", database);
24 -- else
25 -- group:AddDB(database);
26 -- end
27 -- end
6 -- @class file 28 -- @class file
7 -- @name LibModuleDBShare-1.0.lua 29 -- @name LibModuleDBShare-1.0
8 local MAJOR, MINOR = "LibModuleDBShare-1.0", 1 30 local MAJOR, MINOR = "LibModuleDBShare-1.0", 2
9 local LibModuleDBShare, oldminor = LibStub:NewLibrary(MAJOR, MINOR) 31 local LibModuleDBShare, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
10 32
11 if not LibModuleDBShare then return end -- No upgrade needed 33 if not LibModuleDBShare then return end -- No upgrade needed
12 34
13 -- Lua functions 35 -- Lua functions
25 LibModuleDBShare.groups = LibModuleDBShare.groups or {}; 47 LibModuleDBShare.groups = LibModuleDBShare.groups or {};
26 48
27 local DBGroup = {}; 49 local DBGroup = {};
28 50
29 --- Creates a new DB group. 51 --- Creates a new DB group.
30 -- @param groupName The name of the new DB group. 52 -- @param groupName The name of the new DB group, as shown in the options panel.
31 -- @param groupDescription A description of the group to be shown in the root options panel. 53 -- @param groupDescription A description of the group to be shown in the root options panel.
32 -- @param initialDB The first DB to add to the group. 54 -- @param initialDB The first DB to add to the group.
33 -- @param usesDualSpec True if this group should use LibDualSpec, false otherwise. 55 -- @param usesDualSpec True if this group should use LibDualSpec, false otherwise.
34 -- @usage 56 -- @usage
35 -- local myAddonDBGroup = LibStub("LibModuleDBShare-1.0"):NewGroup("MyAddonGroupName", true) 57 -- local myDB = LibStub("AceDB-3.0"):New("MySavedVar");
58 -- local myAddonDBGroup = LibStub("LibModuleDBShare-1.0"):NewGroup("MyAddonGroupName", "MyDescription", myDB, true)
36 -- @return the new DB group object 59 -- @return the new DB group object
60 -- @name LibModuleDBShare:NewGroup(groupName, groupDescription, initialDB[, usesDualSpec]);
37 function LibModuleDBShare:NewGroup(groupName, groupDescription, initialDB, usesDualSpec) 61 function LibModuleDBShare:NewGroup(groupName, groupDescription, initialDB, usesDualSpec)
38 -- verify parameters 62 -- verify parameters
39 if type(groupName) ~= "string" then 63 if type(groupName) ~= "string" then
40 error("Usage: LibModuleDBShare:NewGroup(groupName, groupDescription, initialDB, usesDualSpec): 'groupName' must be a string.", 2); 64 error("Usage: LibModuleDBShare:NewGroup(groupName, groupDescription, initialDB, usesDualSpec): 'groupName' must be a string.", 2);
41 elseif type(groupDescription) ~= "string" then 65 elseif type(groupDescription) ~= "string" then
233 self.members[db].char.altProfile = altProfile; 257 self.members[db].char.altProfile = altProfile;
234 self.members[db].char.dualSpecEnabled = dualSpecEnabled; 258 self.members[db].char.dualSpecEnabled = dualSpecEnabled;
235 self.members[db].char.activeSpecGroup = activeSpecGroup; 259 self.members[db].char.activeSpecGroup = activeSpecGroup;
236 end 260 end
237 end 261 end
262
263 -- update existing groups
264 for groupName, group in pairs(LibModuleDBShare.groups) do
265 for funcName, func in pairs(DBGroup) do
266 group[funcName] = func;
267 end
268 end