Mercurial > wow > libmoduledbshare-1-0
changeset 17:4ed8d6827ef7
basic implementation for LMDBS:NewGroup()
| author | Andrew Knoll <andrewtknoll@gmail.com> |
|---|---|
| date | Thu, 14 Mar 2013 00:00:45 -0400 |
| parents | 2384f5c2a707 |
| children | dacd01bf164f |
| files | LibModuleDBShare-1.0/LibModuleDBShare-1.0.lua |
| diffstat | 1 files changed, 23 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/LibModuleDBShare-1.0/LibModuleDBShare-1.0.lua Mon Mar 11 16:10:39 2013 -0400 +++ b/LibModuleDBShare-1.0/LibModuleDBShare-1.0.lua Thu Mar 14 00:00:45 2013 -0400 @@ -13,7 +13,11 @@ -- Lua APIs local assert = assert; +-- Required Libraries local AceDB = LibStub("AceDB-3.0"); +local AceDBOptions = LibStub("AceDBOptions-3.0"); +local AceConfigRegistry = LibStub("AceConfigRegistry-3.0"); +local AceConfigDialog = LibStub("AceConfigDialog-3.0"); LibModuleDBShare.groups = LibModuleDBShare.groups or {}; @@ -22,17 +26,33 @@ --- Creates a new DB group. -- @param groupName The name of the new DB group. -- @param usesDualSpec True if this group should use LibDualSpec, false otherwise. (NYI) --- @param initialProfile The name of the profile to start with. +-- @param initialProfile The name of the profile to start with. (Defaults to character-specific) -- @usage -- local myAddonDBGroup = LibStub("LibModuleDBShare-1.0"):NewGroup("MyAddonGroupName", true) -- @return the new DB group object function LibModuleDBShare:NewGroup(groupName, usesDualSpec, initialProfile) - assert(type(groupName) == "string", "Usage: LibModuleDBShare:NewGroup(groupName, usesDualSpec, initialProfile): 'groupName' is not a string."); + assert(type(groupName) == "string", "Usage: LibModuleDBShare:NewGroup(groupName, usesDualSpec, initialProfile): 'groupName' must be a string."); assert(type(LibModuleDBShare.groups[groupName]) == "nil", "LibModuleDBShare:NewGroup(groupName, usesDualSpec, initialProfile): 'groupName' already exists"); local group = {} group.name = groupName; + group.rootOptionsTable = { + type = "group", + name = groupName, + args = { + text = { + type = "description", + name = "placeholder text.", + }, + }, + }; + AceConfigRegistry:RegisterOptionsTable(groupName, group.rootOptionsTable); + AceConfigDialog:AddToBlizOptions(groupName); group.syncDBTable = {}; group.syncDB = AceDB:New(group.syncDBTable, nil, initialProfile); + group.profileOptionsTable = AceDBOptions:GetOptionsTable(group.syncDB, false); + AceConfigRegistry:RegisterOptionsTable(groupName.."Profiles", group.profileOptionsTable); + AceConfigDialog:AddToBlizOptions(groupName.."Profiles", "Profiles", groupName); -- need to figure out localization + -- profile change callbacks for k, v in pairs(DBGroup) do group[k] = v; end @@ -45,6 +65,7 @@ -- local myAddonDBGroup = LibStub("LibModuleDBShare-1.0"):GetGroup("MyAddonGroupName") -- @return the DB group object, or nil if not found function LibModuleDBShare:GetGroup(groupName) + assert(type(groupName) == "string", "Usage: LibModuleDBShare:GetGroup(groupName): 'groupName' must be a string"); return LibModuleDBShare.groups[groupName]; end
