Mercurial > wow > libmoduledbshare-1-0
comparison LibModuleDBShare-1.0/LibModuleDBShare-1.0.lua @ 44:9e1b25004509 v1.3 release
Added GetSecondaryCommands() function.
| author | Andrew Knoll <andrewtknoll@gmail.com> |
|---|---|
| date | Wed, 10 Apr 2013 15:54:33 -0400 |
| parents | 288987af9e66 |
| children | eb3383e30b5e |
comparison
equal
deleted
inserted
replaced
| 43:288987af9e66 | 44:9e1b25004509 |
|---|---|
| 15 -- \\ | 15 -- \\ |
| 16 -- **Slash Command Support**\\ | 16 -- **Slash Command Support**\\ |
| 17 -- LibModuleDBShare can associate a slash command with a DBGroup. The default handler function | 17 -- LibModuleDBShare can associate a slash command with a DBGroup. The default handler function |
| 18 -- for the slash command opens the root options panel.\\ | 18 -- for the slash command opens the root options panel.\\ |
| 19 -- Additional handler functions can be registered to respond to specific arguments given to the | 19 -- Additional handler functions can be registered to respond to specific arguments given to the |
| 20 -- slash command. | 20 -- slash command. If you provide a custom handler function for the slash command, that function |
| 21 -- is responsible for detecting secondary commands. | |
| 21 -- | 22 -- |
| 22 -- @usage | 23 -- @usage |
| 23 -- local database; | 24 -- local database; |
| 24 -- -- this function is called after the ADDON_LOADED event fires | 25 -- -- this function is called after the ADDON_LOADED event fires |
| 25 -- function initializeDB() | 26 -- function initializeDB() |
| 62 -- @paramsig groupName, groupDescription, initialDB[, usesDualSpec] | 63 -- @paramsig groupName, groupDescription, initialDB[, usesDualSpec] |
| 63 -- @param groupName The name of the new DB group, as shown in the options panel. (string) | 64 -- @param groupName The name of the new DB group, as shown in the options panel. (string) |
| 64 -- @param groupDescription A description of the group to be shown in the root options panel. (string) | 65 -- @param groupDescription A description of the group to be shown in the root options panel. (string) |
| 65 -- @param initialDB The first DB to add to the group. (table) | 66 -- @param initialDB The first DB to add to the group. (table) |
| 66 -- @param usesDualSpec True if this group should use LibDualSpec, false otherwise. (boolean or nil) | 67 -- @param usesDualSpec True if this group should use LibDualSpec, false otherwise. (boolean or nil) |
| 67 -- @return the new DB group object | 68 -- @return the new DB group object (table) |
| 68 function LibModuleDBShare:NewGroup(groupName, groupDescription, initialDB, usesDualSpec) | 69 function LibModuleDBShare:NewGroup(groupName, groupDescription, initialDB, usesDualSpec) |
| 69 -- check to see if LibDualSpec has been loaded | 70 -- check to see if LibDualSpec has been loaded |
| 70 if not LibDualSpec then | 71 if not LibDualSpec then |
| 71 LibDualSpec = LibStub("LibDualSpec-1.0", true); | 72 LibDualSpec = LibStub("LibDualSpec-1.0", true); |
| 72 end | 73 end |
| 155 return group; | 156 return group; |
| 156 end | 157 end |
| 157 | 158 |
| 158 --- Retrieves an existing DB group. | 159 --- Retrieves an existing DB group. |
| 159 -- @param groupName The name of the DB group to retrieve. (string) | 160 -- @param groupName The name of the DB group to retrieve. (string) |
| 160 -- @return the DB group object, or ##nil## if not found | 161 -- @return the DB group object, or ##nil## if not found (table) |
| 161 function LibModuleDBShare:GetGroup(groupName) | 162 function LibModuleDBShare:GetGroup(groupName) |
| 162 if type(groupName) ~= "string" then | 163 if type(groupName) ~= "string" then |
| 163 error("Usage: LibModuleDBShare:GetGroup(groupName): 'groupName' must be a string.", 2); | 164 error("Usage: LibModuleDBShare:GetGroup(groupName): 'groupName' must be a string.", 2); |
| 164 end | 165 end |
| 165 return LibModuleDBShare.groups[groupName]; | 166 return LibModuleDBShare.groups[groupName]; |
| 217 end | 218 end |
| 218 | 219 |
| 219 -- LibDualSpec support | 220 -- LibDualSpec support |
| 220 | 221 |
| 221 --- Checks to see if this group uses LibDualSpec. | 222 --- Checks to see if this group uses LibDualSpec. |
| 222 -- @return ##true## if this group uses LibDualSpec, ##false## otherwise | 223 -- @return ##true## if this group uses LibDualSpec, ##false## otherwise (boolean) |
| 223 function DBGroup:IsUsingDualSpec() | 224 function DBGroup:IsUsingDualSpec() |
| 224 return self.usesDualSpec; | 225 return self.usesDualSpec; |
| 225 end | 226 end |
| 226 | 227 |
| 227 --- Enables dual spec support if not already enabled. | 228 --- Enables dual spec support if not already enabled. |
| 303 end; | 304 end; |
| 304 end | 305 end |
| 305 end | 306 end |
| 306 | 307 |
| 307 --- Checks to see if this group has a slash command. | 308 --- Checks to see if this group has a slash command. |
| 308 -- @return ##true## if this group has a slash command, ##false## otherwise | 309 -- @return ##true## if this group has a slash command, ##false## otherwise (boolean) |
| 309 function DBGroup:HasSlashCommand() | 310 function DBGroup:HasSlashCommand() |
| 310 if self.slug then | 311 if self.slug then |
| 311 return true; | 312 return true; |
| 312 else | 313 else |
| 313 return false; | 314 return false; |
| 357 end | 358 end |
| 358 | 359 |
| 359 self.subCmdList[name] = handler; | 360 self.subCmdList[name] = handler; |
| 360 end | 361 end |
| 361 | 362 |
| 363 --- Returns the list of secondary commands registered with this group. | |
| 364 -- @return A table containing name-function pairs for secondary commands. (table) | |
| 365 function DBGroup:GetSecondaryCommands() | |
| 366 if not self.slug then | |
| 367 error("Usage: DBGroup:GetSecondaryCommands(): Slash commands for this group have not been enabled", 2); | |
| 368 end | |
| 369 return self.subCmdList; | |
| 370 end | |
| 371 | |
| 362 -- callback handlers (new profiles are handled by OnProfileChanged) | 372 -- callback handlers (new profiles are handled by OnProfileChanged) |
| 363 | 373 |
| 364 function DBGroup:OnProfileChanged(callback, syncDB, profile) | 374 function DBGroup:OnProfileChanged(callback, syncDB, profile) |
| 365 if not self.squelchCallbacks then | 375 if not self.squelchCallbacks then |
| 366 for db, _ in pairs(self.members) do | 376 for db, _ in pairs(self.members) do |
