Mercurial > wow > mailopener
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 59:92b98a9000b8 | 60:4cd3b02f6840 |
|---|---|
| 20 Media:Register("sound", "Wham!", [[Sound\Doodad\PVP_Lordaeron_Door_Open.wav]]); | 20 Media:Register("sound", "Wham!", [[Sound\Doodad\PVP_Lordaeron_Door_Open.wav]]); |
| 21 Media:Register("sound", "Whisper Ping", [[Sound\interface\iTellMessage.wav]]); | 21 Media:Register("sound", "Whisper Ping", [[Sound\interface\iTellMessage.wav]]); |
| 22 Media:Register("sound", "You Will Die!", [[Sound\Creature\CThun\CThunYouWillDIe.wav]]); | 22 Media:Register("sound", "You Will Die!", [[Sound\Creature\CThun\CThunYouWillDIe.wav]]); |
| 23 | 23 |
| 24 local AceConfigDialog; | 24 local AceConfigDialog; |
| 25 | |
| 26 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 | |
| 25 | 27 |
| 26 function mod:OnEnable() | 28 function mod:OnEnable() |
| 27 MailOpener:Debug("Enabling |cff00ffffConfig|r module."); | 29 MailOpener:Debug("Enabling |cff00ffffConfig|r module."); |
| 30 | |
| 31 if MailOpener.db.global.currentTip == -1 and MailOpener.db.profile.general.continueOpening == false then | |
| 32 StaticPopupDialogs["MailOpenerFirstConfigUseConfirmBox"] = { | |
| 33 text = "Do you wish to enable \"continue opening mail\"? Read the tip at the bottom of the \"General\" config for more information.", | |
| 34 button1 = "Yes", | |
| 35 button2 = "No", | |
| 36 OnAccept = function() | |
| 37 MailOpener.db.profile.general.continueOpening = true; | |
| 38 | |
| 39 print("|cff15ff00Mail Opener|r: Enabling the functionality. Remember you can always change this setting in the \"Open All\" config (|cff00ffff/mo c|r)."); | |
| 40 end, | |
| 41 OnCancel = function (_,reason) | |
| 42 print("|cff15ff00Mail Opener|r: You can always change this setting in the \"Open All\" config (|cff00ffff/mo c|r)."); | |
| 43 end, | |
| 44 timeout = 0, | |
| 45 whileDead = 1, | |
| 46 hideOnEscape = 1, | |
| 47 }; | |
| 48 StaticPopup_Show("MailOpenerFirstConfigUseConfirmBox"); | |
| 49 end | |
| 50 | |
| 51 if tip == nil then | |
| 52 self:NextTip(); | |
| 53 | |
| 54 self:GetTip(); | |
| 55 end | |
| 56 end | |
| 57 | |
| 58 function mod:GetTip() | |
| 59 -- First we fill the global "tip" with our table | |
| 60 -- Then we erase tips that are irrelevant to us | |
| 61 -- and finally the table will be replaced with the currently selected tip | |
| 62 | |
| 63 -- Can't put this in the abive scope as the ADDONEnable vars would then always be empty | |
| 64 tip = { | |
| 65 "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).", | |
| 66 "You can shift click a mail icon to auto loot that single mail.", | |
| 67 "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.", | |
| 68 { | |
| 69 txt = "If you are looking for an addon with many handy modifications for |cfffed000sending|r mail, you might want to consider |cfffed000Postal|r.", | |
| 70 shown = (not MailOpener.PostalEnabled), | |
| 71 }, | |
| 72 }; | |
| 73 | |
| 74 -- Remove any "hidden" tips | |
| 75 for i = table.getn(tip), 1 do | |
| 76 local val = tip[i]; | |
| 77 | |
| 78 if type(val) == "table" and val.shown == false then | |
| 79 table.remove(tip, i); | |
| 80 end | |
| 81 end | |
| 82 | |
| 83 -- Find our current tip | |
| 84 local tipsAvailable = table.getn(tip); | |
| 85 local selectedTip = ( ( MailOpener.db.global.currentTip % tipsAvailable ) + 1 ); -- this should return a value between 1 and tipsAvailable | |
| 86 | |
| 87 if selectedTip < 1 then | |
| 88 -- If we're going under zero, we'll use the last tip available instead | |
| 89 MailOpener.db.global.currentTip = tipsAvailable; | |
| 90 end | |
| 91 | |
| 92 -- We don't need to leave the tip-table in memory, so overwrite it | |
| 93 if type(tip[selectedTip]) == "table" then | |
| 94 tip = tip[selectedTip]['txt']; | |
| 95 else | |
| 96 tip = tip[selectedTip]; | |
| 97 end | |
| 98 end | |
| 99 | |
| 100 function mod:NextTip() | |
| 101 MailOpener.db.global.currentTip = ( MailOpener.db.global.currentTip + 1 ); | |
| 28 end | 102 end |
| 29 | 103 |
| 30 function mod:CommandHandler(message) | 104 function mod:CommandHandler(message) |
| 31 local cmd, arg = string.split(" ", (message or ""), 2); | 105 local cmd, arg = string.split(" ", (message or ""), 2); |
| 32 cmd = string.lower(cmd); | 106 cmd = string.lower(cmd); |
| 381 MailOpener.db:SetProfile(UnitName("player") .. " - " .. GetRealmName()); | 455 MailOpener.db:SetProfile(UnitName("player") .. " - " .. GetRealmName()); |
| 382 end, | 456 end, |
| 383 }, | 457 }, |
| 384 }, | 458 }, |
| 385 }, -- end Profile config inline group | 459 }, -- end Profile config inline group |
| 460 -- Tip | |
| 461 tipConfig = { | |
| 462 order = 20, | |
| 463 type = "group", | |
| 464 inline = true, | |
| 465 name = "Mail Opening Tip", | |
| 466 args = { | |
| 467 description = { | |
| 468 order = 10, | |
| 469 type = "description", | |
| 470 fontSize = "medium", | |
| 471 name = function() return tip; end, | |
| 472 }, | |
| 473 nextTip = { | |
| 474 order = 20, | |
| 475 type = "execute", | |
| 476 name = "Next Tip", | |
| 477 width = "half", | |
| 478 func = function() self:NextTip(); self:GetTip(); end, | |
| 479 }, | |
| 480 }, | |
| 481 }, -- end Tip | |
| 386 }, | 482 }, |
| 387 }; | 483 }; |
| 388 | 484 |
| 389 return generalConfigGroup; | 485 return generalConfigGroup; |
| 390 end | 486 end |
