Mercurial > wow > mailopener
diff Modules/Config.lua @ 60:4cd3b02f6840
Added a part for Mail Opener tips to the bottom of the general config. Also, the first time you start the config you will be prompted to enable continuous opening or not.
| author | Zerotorescue |
|---|---|
| date | Mon, 13 Sep 2010 23:58:48 +0200 |
| parents | 5f0e174c8adc |
| children | 1a4b2e73cef3 |
line wrap: on
line diff
--- a/Modules/Config.lua Mon Sep 13 18:35:55 2010 +0200 +++ b/Modules/Config.lua Mon Sep 13 23:58:48 2010 +0200 @@ -22,9 +22,83 @@ Media:Register("sound", "You Will Die!", [[Sound\Creature\CThun\CThunYouWillDIe.wav]]); local AceConfigDialog; + +local tip; -- if this is nil, it will be filled with a table, once that table is processed, this var will be re-used with the currently selected tip function mod:OnEnable() MailOpener:Debug("Enabling |cff00ffffConfig|r module."); + + if MailOpener.db.global.currentTip == -1 and MailOpener.db.profile.general.continueOpening == false then + StaticPopupDialogs["MailOpenerFirstConfigUseConfirmBox"] = { + text = "Do you wish to enable \"continue opening mail\"? Read the tip at the bottom of the \"General\" config for more information.", + button1 = "Yes", + button2 = "No", + OnAccept = function() + MailOpener.db.profile.general.continueOpening = true; + + print("|cff15ff00Mail Opener|r: Enabling the functionality. Remember you can always change this setting in the \"Open All\" config (|cff00ffff/mo c|r)."); + end, + OnCancel = function (_,reason) + print("|cff15ff00Mail Opener|r: You can always change this setting in the \"Open All\" config (|cff00ffff/mo c|r)."); + end, + timeout = 0, + whileDead = 1, + hideOnEscape = 1, + }; + StaticPopup_Show("MailOpenerFirstConfigUseConfirmBox"); + end + + if tip == nil then + self:NextTip(); + + self:GetTip(); + end +end + +function mod:GetTip() + -- First we fill the global "tip" with our table + -- Then we erase tips that are irrelevant to us + -- and finally the table will be replaced with the currently selected tip + + -- Can't put this in the abive scope as the ADDONEnable vars would then always be empty + tip = { + "To let Mail Opener automatically continue opening a batch of mail you previously interupted, you will have to tick the \"Continue opening mail\"-box at the \"Open All\" config. By default Mail Opener will always automatically start opening mail right after a server refresh, but you will have to manually resume mail opening if it gets interupted (e.g. because you closed the mailbox or because your bags were full).", + "You can shift click a mail icon to auto loot that single mail.", + "You can click the time remaining text to get it into a popup dialog so you can copy it (with CTRL-C) and then paste it (with CTRL-V) elsewhere.", + { + txt = "If you are looking for an addon with many handy modifications for |cfffed000sending|r mail, you might want to consider |cfffed000Postal|r.", + shown = (not MailOpener.PostalEnabled), + }, + }; + + -- Remove any "hidden" tips + for i = table.getn(tip), 1 do + local val = tip[i]; + + if type(val) == "table" and val.shown == false then + table.remove(tip, i); + end + end + + -- Find our current tip + local tipsAvailable = table.getn(tip); + local selectedTip = ( ( MailOpener.db.global.currentTip % tipsAvailable ) + 1 ); -- this should return a value between 1 and tipsAvailable + + if selectedTip < 1 then + -- If we're going under zero, we'll use the last tip available instead + MailOpener.db.global.currentTip = tipsAvailable; + end + + -- We don't need to leave the tip-table in memory, so overwrite it + if type(tip[selectedTip]) == "table" then + tip = tip[selectedTip]['txt']; + else + tip = tip[selectedTip]; + end +end + +function mod:NextTip() + MailOpener.db.global.currentTip = ( MailOpener.db.global.currentTip + 1 ); end function mod:CommandHandler(message) @@ -383,6 +457,28 @@ }, }, }, -- end Profile config inline group + -- Tip + tipConfig = { + order = 20, + type = "group", + inline = true, + name = "Mail Opening Tip", + args = { + description = { + order = 10, + type = "description", + fontSize = "medium", + name = function() return tip; end, + }, + nextTip = { + order = 20, + type = "execute", + name = "Next Tip", + width = "half", + func = function() self:NextTip(); self:GetTip(); end, + }, + }, + }, -- end Tip }, };
