Mercurial > wow > mailopener
diff Modules/Config.lua @ 31:90d58723ac0a
- Removed all BeanCounter checks in files.
+ Added a new module: BeanCounter Support. This module will now take care of preventing mail opening while BeanCounter is scanning.
+ Added AceHook library for the BeanCounter Support module.
~ Sorted the Core.lua OnInitialize to properly toggle modules before doing time consuming things.
~ All module comments are now a property of the modules themselves and can be retrieved with (string)?.moduleDescription? and (bool)?.moduleRequired?.
~ All module references are now called ?mod?.
! Added a new config group: Modules. This group will show the module statuses and descriptions and it will contain all optional modules (with their settings) as subgroups.
- Removed all libraries from the repository.
| author | Zerotorescue |
|---|---|
| date | Fri, 10 Sep 2010 18:59:58 +0200 |
| parents | 2dd6005d41f3 |
| children | b79bb7b449c3 |
line wrap: on
line diff
--- a/Modules/Config.lua Thu Sep 09 22:16:50 2010 +0200 +++ b/Modules/Config.lua Fri Sep 10 18:59:58 2010 +0200 @@ -1,11 +1,8 @@ local MailOpener = LibStub("AceAddon-3.0"):GetAddon("MailOpener"); -local Config = MailOpener:NewModule("Config", "AceEvent-3.0", "AceTimer-3.0"); +local mod = MailOpener:NewModule("Config", "AceEvent-3.0", "AceTimer-3.0"); ---[[ -Module name: Config -Description: Builds and loads the config frame(s) and handles the slash commands. -Required: No (default off). -]] +mod.moduleDescription = "Builds and loads the config frame(s) and handles the slash commands. Automatically loaded when needed."; +mod.moduleRequired = false; local Media = LibStub("LibSharedMedia-3.0"); Media:Register("sound", "Cartoon FX", [[Sound\Doodad\Goblin_Lottery_Open03.wav]]); @@ -26,11 +23,11 @@ local AceConfigDialog; -function Config:OnEnable() +function mod:OnEnable() MailOpener:Debug("Enabling |cff00ffffConfig|r module."); end -function Config:CommandHandler(message) +function mod:CommandHandler(message) local cmd, arg = string.split(" ", (message or ""), 2); cmd = string.lower(cmd); @@ -62,7 +59,7 @@ end end -function Config:Load() +function mod:Load() if not AceConfigDialog then local options = self:GetOptions(); @@ -83,13 +80,13 @@ end end -function Config:Show() +function mod:Show() self:Load(); AceConfigDialog:Open("Mail Opener"); end -function Config:GetOptions() +function mod:GetOptions() local options = { type = "group", name = "Mail Opener", @@ -110,17 +107,157 @@ return options; end -function Config:GetModuleOptions(options) +-- Get the options group for every one of our modules +function mod:GetModuleOptions(options) + -- Go through all our modules for name, module in MailOpener:IterateModules() do + -- Look if they even have an options group if module.GetOptionsGroup then - options.args[name] = module:GetOptionsGroup(); + -- Get that options group + local moduleGroup = module:GetOptionsGroup(); + + -- If it's set to be a subgroup of the modules group, put it there + if moduleGroup['type'] == "modulesSubGroup" then + moduleGroup['type'] = "group"; + + -- If the modules group doesn't exist yet, make it + if options.args.Modules == nil then + options.args.Modules = self:GetModuleGroupsContainer(); + end + + -- Add to the modules sub group + options.args.Modules.args[name] = moduleGroup; + else + options.args[name] = moduleGroup; + end + end end return options; end -function Config:GetGeneralOptions() +function mod:GetModuleGroupsContainer() + local modulesConfigGroup = { + order = 400, + type = "group", + childGroups = "tree", + name = "Modules", + desc = "Change settings for modules or toggle them on or off.", + args = { + General = { + order = 10, + type = "group", + inline = true, + name = "Modules Status", + args = { + headerName = { + order = 0, + width = "normal", + type = "description", + fontSize = "medium", + name = "|cfffed000Module Name|r", + }, + headerStatus = { + order = 1, + width = "half", + type = "description", + fontSize = "medium", + name = "|cfffed000Status|r", + }, + headerDefault = { + order = 2, + width = "normal", + type = "description", + fontSize = "medium", + name = "|cfffed000Default Status|r", + }, + headerseperator = { + order = 3, + type = "description", + name = "", + }, + }, + }, + }, + }; + + -- Make a list of modules and their statuses + local orderNo = 5; + for moduleName, module in MailOpener:IterateModules() do + -- Display each module as NAME CURRENT STATUS DEFAULT STATUS + + -- Name + modulesConfigGroup.args.General.args[moduleName .. "name"] = { + order = orderNo, + width = "normal", + type = "description", + fontSize = "medium", + name = function() + return moduleName; + end, + }; + -- Current status + modulesConfigGroup.args.General.args[moduleName .. "status"] = { + order = ( orderNo + 1 ), + width = "half", + type = "description", + fontSize = "medium", + name = function() + if module:IsEnabled() then + return "|cff00ff00Enabled|r"; + else + return "|cffff0000Disabled|r"; + end + end, + }; + -- Default status + modulesConfigGroup.args.General.args[moduleName .. "default"] = { + order = ( orderNo + 2 ), + width = "normal", + type = "description", + fontSize = "medium", + name = function() + local desc = ""; + if MailOpener.db.profile.modules[moduleName] == nil or MailOpener.db.profile.modules[moduleName] == true then + desc = "|cff00ff00Enabled|r"; + else + desc = "|cffff0000Disabled|r"; + end + + if module.moduleRequired then + desc = desc .. " (Required module)"; + end + + return desc; + end, + }; + + -- Seperator + modulesConfigGroup.args.General.args[moduleName .. "seperator"] = { + order = ( orderNo + 3 ), + type = "description", + name = "", + }; + + if module.moduleDescription then + -- Description + modulesConfigGroup.args.General.args[moduleName .. "description"] = { + order = ( orderNo + 4 ), + type = "description", + name = function() + return "|cfffed000" .. module.moduleDescription .. "|r"; + end, + }; + end + + orderNo = orderNo + 5; + end + + return modulesConfigGroup; +end + +function mod:GetGeneralOptions() local generalConfigGroup = { order = 100, type = "group", @@ -239,7 +376,7 @@ return generalConfigGroup; end -function Config:GetNotificationsOptions() +function mod:GetNotificationsOptions() local notificationsConfigGroup = { order = 200, type = "group",
