Mercurial > wow > mailopener
view Modules/Config.lua @ 19:d633bf82328b
Added a popup dialog to confirm whether the user wants to always enable automatic mail opening when opening the mailbox.
| author | Zerotorescue |
|---|---|
| date | Thu, 09 Sep 2010 17:43:17 +0200 |
| parents | 2dd6005d41f3 |
| children | 90d58723ac0a |
line wrap: on
line source
local MailOpener = LibStub("AceAddon-3.0"):GetAddon("MailOpener"); local Config = 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). ]] local Media = LibStub("LibSharedMedia-3.0"); Media:Register("sound", "Cartoon FX", [[Sound\Doodad\Goblin_Lottery_Open03.wav]]); Media:Register("sound", "Cheer", [[Sound\Event Sounds\OgreEventCheerUnique.wav]]); Media:Register("sound", "Explosion", [[Sound\Doodad\Hellfire_Raid_FX_Explosion05.wav]]); Media:Register("sound", "Fel Nova", [[Sound\Spells\SeepingGaseous_Fel_Nova.wav]]); Media:Register("sound", "Fel Portal", [[Sound\Spells\Sunwell_Fel_PortalStand.wav]]); Media:Register("sound", "Magic Click", [[Sound\interface\MagicClick.wav]]); Media:Register("sound", "Rubber Ducky", [[Sound\Doodad\Goblin_Lottery_Open01.wav]]); Media:Register("sound", "Shing!", [[Sound\Doodad\PortcullisActive_Closed.wav]]); Media:Register("sound", "Simon Chime", [[Sound\Doodad\SimonGame_LargeBlueTree.wav]]); Media:Register("sound", "Simon Error", [[Sound\Spells\SimonGame_Visual_BadPress.wav]]); Media:Register("sound", "Simon Start", [[Sound\Spells\SimonGame_Visual_GameStart.wav]]); Media:Register("sound", "War Drums", [[Sound\Event Sounds\Event_wardrum_ogre.wav]]); Media:Register("sound", "Wham!", [[Sound\Doodad\PVP_Lordaeron_Door_Open.wav]]); Media:Register("sound", "Whisper Ping", [[Sound\interface\iTellMessage.wav]]); Media:Register("sound", "You Will Die!", [[Sound\Creature\CThun\CThunYouWillDIe.wav]]); local AceConfigDialog; function Config:OnEnable() MailOpener:Debug("Enabling |cff00ffffConfig|r module."); end function Config:CommandHandler(message) local cmd, arg = string.split(" ", (message or ""), 2); cmd = string.lower(cmd); if cmd == "c" or cmd == "config" or cmd == "conf" or cmd == "option" or cmd == "options" or cmd == "opt" or cmd == "setting" or cmd == "settings" then self:Show(); elseif cmd == "d" or cmd == "debug" then MailOpener.debugChannel = false; for i = 1, NUM_CHAT_WINDOWS do local name = GetChatWindowInfo(i); if name:upper() == "DEBUG" then MailOpener.debugChannel = _G["ChatFrame" .. i]; print("A debug channel already exists, used the old one."); return; end end if not MailOpener.debugChannel then -- Create a new debug channel local chatFrame = FCF_OpenNewWindow('Debug'); ChatFrame_RemoveAllMessageGroups(chatFrame); MailOpener.debugChannel = chatFrame; print("New debug channel created."); end else print("Wrong command, available: /mo config (or /mo c)"); end end function Config:Load() if not AceConfigDialog then local options = self:GetOptions(); -- Build options dialog AceConfigDialog = LibStub("AceConfigDialog-3.0"); -- Register options table LibStub("AceConfig-3.0"):RegisterOptionsTable("Mail Opener", options); -- Set a nice default size AceConfigDialog:SetDefaultSize("Mail Opener", 950, 600); -- In case the addon is loaded from another condition, always call the remove interface options if AddonLoader and AddonLoader.RemoveInterfaceOptions then AddonLoader:RemoveInterfaceOptions("Mail Opener"); end -- Add to the blizzard addons options thing AceConfigDialog:AddToBlizOptions("Mail Opener"); end end function Config:Show() self:Load(); AceConfigDialog:Open("Mail Opener"); end function Config:GetOptions() local options = { type = "group", name = "Mail Opener", childGroups = "tree", args = { }, }; options.args.general = self:GetGeneralOptions(); options.args.notifications = self:GetNotificationsOptions(); options = self:GetModuleOptions(options); options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(MailOpener.db, true); options.args.profiles.order = 1000; -- we want this as last group return options; end function Config:GetModuleOptions(options) for name, module in MailOpener:IterateModules() do if module.GetOptionsGroup then options.args[name] = module:GetOptionsGroup(); end end return options; end function Config:GetGeneralOptions() local generalConfigGroup = { order = 100, type = "group", name = "General", desc = "Change general Mail Opener settings.", args = { -- General config inline group generalConfig = { order = 10, type = "group", inline = true, name = "General", args = { defaultStatus = { order = 0, type = "select", name = "Default mail opener status", desc = "Select the default Mail Opener status when you open a mailbox for the first time since your log on.", values = { _enabled = "Completely enabled", disabled = "Auto opening disabled", xdisabled = "Addon Disabled", }, get = function() return MailOpener.db.profile.general.defaultStatus; end, set = function(i, v) MailOpener.db.profile.general.defaultStatus = v; end, }, defaultQAStatus = { order = 10, type = "select", name = "Default QA Auto Mail status", desc = "Select the default Quick Auctions auto mail status whenever you open a mailbox.", values = { __remember = "Remember", _enabled = "Enabled", disabled = "Disabled", }, get = function() return MailOpener.db.profile.general.defaultQAStatus; end, set = function(i, v) MailOpener.db.profile.general.defaultQAStatus = v; end, hidden = (not MailOpener.QuickAuctionsEnabled), }, continueOpeningStackableItems = { order = 15, type = "toggle", name = "Continue trying to open mail after your bags are full", desc = "If there are a lot of stackable items in your mailbox (e.g. glyphs) you may want to toggle this option on.\n\nThis will cause your Blizzard error frame to get extremely spammy if there are many mails remaining. With this disabled, Mail Opener will completely stop opening mail while your inventory is full.", width = "full", get = function() return MailOpener.db.profile.general.continueOpeningStackableItems; end, set = function(i, v) MailOpener.db.profile.general.continueOpeningStackableItems = v; end, }, autoDisableQAAutoMail = { order = 20, type = "toggle", name = "Turn Quick Auction's auto mailing |cffff0000off|r when opening mail", desc = "Quick Auction's auto mailing is buggy when using other mail opening addons. If you are collecting mail while auto mailer is enabled wrong items may be send to the wrong character.\n\nTo solve this you must disable Quick Auction's auto mail while opening mail and you can re-enable it when mail opening is finished.", width = "full", get = function() return MailOpener.db.profile.general.autoDisableQAAutoMail; end, set = function(i, v) MailOpener.db.profile.general.autoDisableQAAutoMail = v; end, hidden = (not MailOpener.QuickAuctionsEnabled), }, autoReenableQAAutoMail = { order = 30, type = "toggle", name = "Turn Quick Auction's auto mailing |cff00ff00on|r after opening mail has finished", desc = "Quick Auction's auto mailing is buggy when using other mail opening addons. If you are collecting mail while auto mailer is enabled wrong items may be send to the wrong character.\n\nTo solve this you must disable Quick Auction's auto mail while opening mail and you can re-enable it when mail opening is finished.", width = "full", get = function() return MailOpener.db.profile.general.autoReenableQAAutoMail; end, set = function(i, v) MailOpener.db.profile.general.autoReenableQAAutoMail = v; end, hidden = (not MailOpener.QuickAuctionsEnabled), disabled = function() return (MailOpener.db.profile.general.autoSetBackQAAutoMail and not MailOpener.db.profile.general.autoReenableQAAutoMail); end, }, autoSetBackQAAutoMail = { order = 40, type = "toggle", name = "Set Quick Auction's auto mailing |cff00ffffback|r after opening mail has finished (remember it)", desc = "Instead of always turning Quick Auction's auto mail on after mail opening you can choose to set it back to the value it was prior to opening mail.", width = "full", get = function() return MailOpener.db.profile.general.autoSetBackQAAutoMail; end, set = function(i, v) MailOpener.db.profile.general.autoSetBackQAAutoMail = v; end, hidden = (not MailOpener.QuickAuctionsEnabled), disabled = function() return (MailOpener.db.profile.general.autoReenableQAAutoMail and not MailOpener.db.profile.general.autoSetBackQAAutoMail); end, }, }, }, -- end General config inline group -- Profile config inline group profileConfig = { order = 15, type = "group", inline = true, name = "New Character Specfic Profile", args = { description = { order = 10, type = "description", name = "You can create a new profile to allow different behaviour for different characters. Imagine setting up a profile for your AH banker which will retrieve all sorts of mail containing items while other characters don't automatically open mail with items sent by other players.", }, header = { order = 15, type = "header", name = "", }, createNewProfile = { order = 20, type = "execute", name = "Create a new character specific profile", desc = "Create a new profile for this user. You can also make profile groups at the profiles tab to the left.", width = "double", func = function() MailOpener.db:SetProfile(UnitName("player") .. " - " .. GetRealmName()); end, }, }, }, -- end Profile config inline group }, }; return generalConfigGroup; end function Config:GetNotificationsOptions() local notificationsConfigGroup = { order = 200, type = "group", name = "Notifications", desc = "Toggle notifications.", args = { -- Notifications config inline group nofitications = { order = 10, type = "group", inline = true, name = "Notifications", args = { description = { order = 10, type = "description", name = "Toggle which notification you wish to see.", }, }, }, -- end Notifications config inline group -- General Notifications config inline group general = { order = 20, type = "group", inline = true, name = "General Notifications", args = { welcome = { order = 20, type = "toggle", name = "Show message when |cfffed000opening the mailbox|r", desc = "Print the welcome message whenever you open the mailbox.", set = function(i, v) MailOpener.db.profile.notifications.welcome = v; end, get = function() return MailOpener.db.profile.notifications.welcome; end, width = "double", }, bye = { order = 21, type = "toggle", name = "Show message when |cfffed000closing the mailbox|r", desc = "Print the bye message whenever you close the mailbox.", set = function(i, v) MailOpener.db.profile.notifications.bye = v; end, get = function() return MailOpener.db.profile.notifications.bye; end, width = "double", }, fishedOpeningBatch = { order = 22, type = "toggle", name = "Announce when |cfffed000finished opening the current batch|r", desc = "Announce when opening of the current batch of mails has been completed.", set = function(i, v) MailOpener.db.profile.notifications.finishedCurrentBatch = v; end, get = function() return MailOpener.db.profile.notifications.finishedCurrentBatch; end, width = "double", }, noMoreMailAvailable = { order = 23, type = "toggle", name = "Announce when |cfffed000the mailbox is completely empty|r", desc = "Announce when there is nothing left for Mail Opener to open.", set = function(i, v) MailOpener.db.profile.notifications.mailboxIsEmpty = v; end, get = function() return MailOpener.db.profile.notifications.mailboxIsEmpty; end, width = "double", }, }, }, -- end General Notifications config inline group -- Mail Skipped Notifications config inline group mailSkipped = { order = 30, type = "group", inline = true, name = "Mail Skipped Notifications", args = { descriptionMailSkipped = { order = 31, type = "description", name = "Announce when mail is skipped because...", }, skippedToggleAll = { order = 35, type = "toggle", name = "Toggle everything", desc = "Announce when mail is skipped for |cfffed000any|r reason.", set = function(i, v) MailOpener.db.profile.notifications.skipped.all = v; end, get = function() return MailOpener.db.profile.notifications.skipped.all; end, }, skippedInventoryFull = { order = 36, type = "toggle", name = "Your inventory is full", desc = "Announce when mail is skipped because |cfffed000your inventory is full|r.", set = function(i, v) MailOpener.db.profile.notifications.skipped.inventoryFull = v; end, get = function() return MailOpener.db.profile.notifications.skipped.inventoryFull; end, disabled = function() return (not MailOpener.db.profile.notifications.skipped.all); end, }, skippedKeepFreeSpaceLimit = { order = 37, type = "toggle", name = "Keep free space limit reached", desc = "Announce when mail is skipped because |cfffed000the keep free space limit has been reached|r.", set = function(i, v) MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit = v; end, get = function() return MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit; end, disabled = function() return (not MailOpener.db.profile.notifications.skipped.all); end, }, skippedGMMail = { order = 38, type = "toggle", name = "GM mail", desc = "Announce when mail is skipped because it's |cfffed000mail sent by a Game Master|r.", set = function(i, v) MailOpener.db.profile.notifications.skipped.GMMail = v; end, get = function() return MailOpener.db.profile.notifications.skipped.GMMail; end, disabled = function() return (not MailOpener.db.profile.notifications.skipped.all); end, }, skippedCOD = { order = 39, type = "toggle", name = "C.O.D. mail", desc = "Announce when mail is skipped because it's |cfffed000a Cost On Delivery mail|r.", set = function(i, v) MailOpener.db.profile.notifications.skipped.COD = v; end, get = function() return MailOpener.db.profile.notifications.skipped.COD; end, disabled = function() return (not MailOpener.db.profile.notifications.skipped.all); end, }, skippedNormalGoldMail = { order = 40, type = "toggle", name = "Normal mail with gold", desc = "Announce when mail is skipped because it's |cfffed000normal mail containing gold|r.", set = function(i, v) MailOpener.db.profile.notifications.skipped.normalGoldMail = v; end, get = function() return MailOpener.db.profile.notifications.skipped.normalGoldMail; end, disabled = function() return (not MailOpener.db.profile.notifications.skipped.all); end, }, skippedNormalItemsMail = { order = 41, type = "toggle", name = "Normal mail with attachments", desc = "Announce when mail is skipped because it's |cfffed000normal mail containing items|r.", set = function(i, v) MailOpener.db.profile.notifications.skipped.normalItemsMail = v; end, get = function() return MailOpener.db.profile.notifications.skipped.normalItemsMail; end, disabled = function() return (not MailOpener.db.profile.notifications.skipped.all); end, }, skippedAHExpired = { order = 42, type = "toggle", name = "Auction expired mail", desc = "Announce when mail is skipped because it's |cfffed000auction expired mail|r.", set = function(i, v) MailOpener.db.profile.notifications.skipped.AHexpired = v; end, get = function() return MailOpener.db.profile.notifications.skipped.AHexpired; end, disabled = function() return (not MailOpener.db.profile.notifications.skipped.all); end, }, skippedAHSuccessful = { order = 43, type = "toggle", name = "Auction successful mail", desc = "Announce when mail is skipped because it's |cfffed000auction successful mail|r.", set = function(i, v) MailOpener.db.profile.notifications.skipped.AHsuccess = v; end, get = function() return MailOpener.db.profile.notifications.skipped.AHsuccess; end, disabled = function() return (not MailOpener.db.profile.notifications.skipped.all); end, }, skippedAHWon = { order = 44, type = "toggle", name = "Auction won mail", desc = "Announce when mail is skipped because it's |cfffed000auction won mail|r.", set = function(i, v) MailOpener.db.profile.notifications.skipped.AHwon = v; end, get = function() return MailOpener.db.profile.notifications.skipped.AHwon; end, disabled = function() return (not MailOpener.db.profile.notifications.skipped.all); end, }, skippedAHCanceled = { order = 45, type = "toggle", name = "Auction canceled mail", desc = "Announce when mail is skipped because it's |cfffed000auction canceled mail|r.", set = function(i, v) MailOpener.db.profile.notifications.skipped.AHcanceled = v; end, get = function() return MailOpener.db.profile.notifications.skipped.AHcanceled; end, disabled = function() return (not MailOpener.db.profile.notifications.skipped.all); end, }, skippedAHOutbid = { order = 46, type = "toggle", name = "Auction outbid mail", desc = "Announce when mail is skipped because it's |cfffed000auction outbid mail|r.", set = function(i, v) MailOpener.db.profile.notifications.skipped.AHoutbid = v; end, get = function() return MailOpener.db.profile.notifications.skipped.AHoutbid; end, disabled = function() return (not MailOpener.db.profile.notifications.skipped.all); end, }, skippedOther = { order = 47, type = "toggle", name = "Other mail (e.g. plain text)", desc = "Announce when mail is skipped because it's |cfffed000any other kind of mail|r (e.g. plain text).", set = function(i, v) MailOpener.db.profile.notifications.skipped.other = v; end, get = function() return MailOpener.db.profile.notifications.skipped.other; end, disabled = function() return (not MailOpener.db.profile.notifications.skipped.all); end, }, }, }, -- end Mail Skipped Notifications config inline group -- Mail Processed Notifications config inline group mailProcessed = { order = 40, type = "group", inline = true, name = "Mail Processed Notifications", args = { descriptionMailProcessed = { order = 61, type = "description", name = "Announce when mail is processed because...", }, processedToggleAll = { order = 65, type = "toggle", name = "Toggle everything", desc = "Announce when mail is processed for |cfffed000any|r reason.", set = function(i, v) MailOpener.db.profile.notifications.processed.all = v; end, get = function() return MailOpener.db.profile.notifications.processed.all; end, }, processedNormalGoldMail = { order = 70, type = "toggle", name = "Normal mail with gold", desc = "Announce when mail is processed because it's |cfffed000normal mail containing gold|r.", set = function(i, v) MailOpener.db.profile.notifications.processed.normalGoldMail = v; end, get = function() return MailOpener.db.profile.notifications.processed.normalGoldMail; end, disabled = function() return (not MailOpener.db.profile.notifications.processed.all); end, }, processedNormalItemsMail = { order = 71, type = "toggle", name = "Normal mail with attachments", desc = "Announce when mail is processed because it's |cfffed000normal mail containing items|r.", set = function(i, v) MailOpener.db.profile.notifications.processed.normalItemsMail = v; end, get = function() return MailOpener.db.profile.notifications.processed.normalItemsMail; end, disabled = function() return (not MailOpener.db.profile.notifications.processed.all); end, }, processedAHExpired = { order = 72, type = "toggle", name = "Auction expired mail", desc = "Announce when mail is processed because it's |cfffed000auction expired mail|r.", set = function(i, v) MailOpener.db.profile.notifications.processed.AHexpired = v; end, get = function() return MailOpener.db.profile.notifications.processed.AHexpired; end, disabled = function() return (not MailOpener.db.profile.notifications.processed.all); end, }, processedAHSuccessful = { order = 73, type = "toggle", name = "Auction successful mail", desc = "Announce when mail is processed because it's |cfffed000auction successful mail|r.", set = function(i, v) MailOpener.db.profile.notifications.processed.AHsuccess = v; end, get = function() return MailOpener.db.profile.notifications.processed.AHsuccess; end, disabled = function() return (not MailOpener.db.profile.notifications.processed.all); end, }, processedAHWon = { order = 74, type = "toggle", name = "Auction won mail", desc = "Announce when mail is processed because it's |cfffed000auction won mail|r.", set = function(i, v) MailOpener.db.profile.notifications.processed.AHwon = v; end, get = function() return MailOpener.db.profile.notifications.processed.AHwon; end, disabled = function() return (not MailOpener.db.profile.notifications.processed.all); end, }, processedAHCanceled = { order = 75, type = "toggle", name = "Auction canceled mail", desc = "Announce when mail is processed because it's |cfffed000auction canceled mail|r.", set = function(i, v) MailOpener.db.profile.notifications.processed.AHcanceled = v; end, get = function() return MailOpener.db.profile.notifications.processed.AHcanceled; end, disabled = function() return (not MailOpener.db.profile.notifications.processed.all); end, }, processedAHOutbid = { order = 76, type = "toggle", name = "Auction outbid mail", desc = "Announce when mail is processed because it's |cfffed000auction outbid mail|r.", set = function(i, v) MailOpener.db.profile.notifications.processed.AHoutbid = v; end, get = function() return MailOpener.db.profile.notifications.processed.AHoutbid; end, disabled = function() return (not MailOpener.db.profile.notifications.processed.all); end, }, processedOther = { order = 77, type = "toggle", name = "Other mail (e.g. plain text)", desc = "Announce when mail is processed because it's |cfffed000any other kind of mail|r (e.g. plain text).", set = function(i, v) MailOpener.db.profile.notifications.processed.other = v; end, get = function() return MailOpener.db.profile.notifications.processed.other; end, disabled = function() return (not MailOpener.db.profile.notifications.processed.all); end, }, }, }, -- end Mail Processed Notifications config inline group -- Sound Notifications config inline group sound = { order = 50, type = "group", inline = true, name = "Sound Notifications", args = { bagsFullSound = { order = 100, type = "toggle", name = "Play a sound when your |cfffed000inventory is full|r", desc = "Play a sound when your inventory is full. You can select what sound in the select box next to this.", set = function(i, v) MailOpener.db.profile.notifications.bagsFullSound = v; end, get = function() return MailOpener.db.profile.notifications.bagsFullSound; end, width = "double", }, bagsFullSoundFile = { order = 101, type = "select", name = "Sound File", desc = "Sound file to play when your bags are full.", dialogControl = "LSM30_Sound", set = function(i, v) MailOpener.db.profile.notifications.bagsFullSoundFile = Media:Fetch("sound", v); MailOpener.db.profile.notifications.bagsFullSoundFileName = v; PlaySoundFile(MailOpener.db.profile.notifications.bagsFullSoundFile); print("|cff15ff00Mail Opener|r: You may have to increase the mail opening interval if this sound effect gets spammy. The recommended value is 10 seconds."); end, get = function() return MailOpener.db.profile.notifications.bagsFullSoundFileName end, values = function () return (Media:HashTable("sound") or nil); end, disabled = function() return (not MailOpener.db.profile.notifications.bagsFullSound); end, }, bagsFullSoundOnlyOnce = { order = 102, type = "toggle", name = "Only once", desc = "Only play this sound once each time new mail has been arrived.", set = function(i, v) MailOpener.db.profile.notifications.bagsFullSoundOnlyOnce = v; end, get = function() return MailOpener.db.profile.notifications.bagsFullSoundOnlyOnce; end, disabled = function() return (not MailOpener.db.profile.notifications.bagsFullSound); end, }, mailboxEmptySound = { order = 110, type = "toggle", name = "Play a sound when |cfffed000no more mail can be opened|r", desc = "Play a sound when no more mail can be opened. You can select what sound in the select box next to this.", set = function(i, v) MailOpener.db.profile.notifications.mailboxEmptySound = v; end, get = function() return MailOpener.db.profile.notifications.mailboxEmptySound; end, width = "double", }, mailboxEmptySoundFile = { order = 111, type = "select", name = "Sound File", desc = "Sound file to play when Mail Opener can't open any more mail.", dialogControl = "LSM30_Sound", set = function(i, v) MailOpener.db.profile.notifications.mailboxEmptySoundFile = Media:Fetch("sound", v); MailOpener.db.profile.notifications.mailboxEmptySoundFileName = v; PlaySoundFile(MailOpener.db.profile.notifications.mailboxEmptySoundFile); print("|cff15ff00Mail Opener|r: You may have to increase the mail opening interval if this sound effect gets spammy. The recommended value is 10 seconds."); end, get = function() return MailOpener.db.profile.notifications.mailboxEmptySoundFileName end, values = function () return (Media:HashTable("sound") or nil); end, disabled = function() return (not MailOpener.db.profile.notifications.mailboxEmptySound); end, }, mailboxEmptySoundOnlyOnce = { order = 112, type = "toggle", name = "Only once", desc = "Only play this sound once each time new mail has been arrived.", set = function(i, v) MailOpener.db.profile.notifications.mailboxEmptySoundOnlyOnce = v; end, get = function() return MailOpener.db.profile.notifications.mailboxEmptySoundOnlyOnce; end, disabled = function() return (not MailOpener.db.profile.notifications.mailboxEmptySound); end, }, }, }, -- end Sound Notifications config inline group }, }; return notificationsConfigGroup; end
