# HG changeset patch # User Andrew Knoll # Date 1363233645 14400 # Node ID 4ed8d6827ef7bd664d6df78b63a3e6eb64256e63 # Parent 2384f5c2a7074e0a85510e3817bac9382a0dbf71 basic implementation for LMDBS:NewGroup() diff -r 2384f5c2a707 -r 4ed8d6827ef7 LibModuleDBShare-1.0/LibModuleDBShare-1.0.lua --- 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