Mercurial > wow > mailopener
comparison Modules/OpenAll.lua @ 68:eadff31e61e8
Localization of all files. Testing packager settings (especially automatic locale exports), localization is not yet finished.
| author | Zerotorescue |
|---|---|
| date | Wed, 15 Sep 2010 13:10:56 +0200 |
| parents | 1a4b2e73cef3 |
| children | 136aa3dd4dda |
comparison
equal
deleted
inserted
replaced
| 67:4166a335ca81 | 68:eadff31e61e8 |
|---|---|
| 1 local MailOpener = LibStub("AceAddon-3.0"):GetAddon("MailOpener"); | 1 local MailOpener = LibStub("AceAddon-3.0"):GetAddon("MailOpener"); |
| 2 local mod = MailOpener:NewModule("OpenAll", "AceEvent-3.0", "AceTimer-3.0"); | 2 local mod = MailOpener:NewModule("OpenAll", "AceEvent-3.0", "AceTimer-3.0"); |
| 3 | 3 local L = LibStub("AceLocale-3.0"):GetLocale("MailOpener"); |
| 4 mod.moduleDescription = "The actual mail opening initiated by the core."; | 4 |
| 5 mod.moduleDescription = L["The actual mail opening initiated by the core."]; | |
| 5 mod.moduleRequired = true; | 6 mod.moduleRequired = true; |
| 6 | 7 |
| 7 --[[ | 8 --[[ |
| 8 Dev notes: | 9 Dev notes: |
| 9 When shift clicking the Open All button it should override all filters. | 10 When shift clicking the Open All button it should override all filters. |
| 39 self:RegisterEvent("MAIL_SHOW"); | 40 self:RegisterEvent("MAIL_SHOW"); |
| 40 | 41 |
| 41 if not self.btnOpenAll then | 42 if not self.btnOpenAll then |
| 42 -- Open all button | 43 -- Open all button |
| 43 local button = CreateFrame("Button", "btnMailOpenerOpenAll", InboxFrame, "UIPanelButtonTemplate"); | 44 local button = CreateFrame("Button", "btnMailOpenerOpenAll", InboxFrame, "UIPanelButtonTemplate"); |
| 44 button:SetText("Open all"); | 45 button:SetText(L["Open all"]); |
| 45 button:SetHeight(26); | 46 button:SetHeight(26); |
| 46 button:SetWidth(120); | 47 button:SetWidth(120); |
| 47 button:SetPoint("BOTTOM", InboxFrame, "CENTER", -10, -165); | 48 button:SetPoint("BOTTOM", InboxFrame, "CENTER", -10, -165); |
| 48 button:RegisterForClicks("LeftButtonUp", "RightButtonUp"); | 49 button:RegisterForClicks("LeftButtonUp", "RightButtonUp"); |
| 49 button:SetScript("OnClick", function(self, mouseButton) | 50 button:SetScript("OnClick", function(self, mouseButton) |
| 61 if not level then return; end | 62 if not level then return; end |
| 62 | 63 |
| 63 if level == 1 then | 64 if level == 1 then |
| 64 -- Create the title of the menu | 65 -- Create the title of the menu |
| 65 info.isTitle = true; | 66 info.isTitle = true; |
| 66 info.text = "Toggle filters for " .. MailOpener.db:GetCurrentProfile() .. " profile."; | 67 info.text = L["Toggle filters for %s profile."]:format(MailOpener.db:GetCurrentProfile()); |
| 67 info.notCheckable = true; | 68 info.notCheckable = true; |
| 68 UIDropDownMenu_AddButton(info, level); | 69 UIDropDownMenu_AddButton(info, level); |
| 69 | 70 |
| 70 -- Reset title specific values | 71 -- Reset title specific values |
| 71 info.isTitle = nil; | 72 info.isTitle = nil; |
| 74 | 75 |
| 75 -- We don't want to close the DDM when something is toggled | 76 -- We don't want to close the DDM when something is toggled |
| 76 info.keepShownOnClick = true; | 77 info.keepShownOnClick = true; |
| 77 | 78 |
| 78 -- Make Auction canceled option | 79 -- Make Auction canceled option |
| 79 info.text = "Auction canceled"; | 80 info.text = L["Auction canceled"]; |
| 80 info.func = function(this) mod.db.profile.filter.AH.canceled = this.checked; end; | 81 info.func = function(this) mod.db.profile.filter.AH.canceled = this.checked; end; |
| 81 info.checked = mod.db.profile.filter.AH.canceled; | 82 info.checked = mod.db.profile.filter.AH.canceled; |
| 82 UIDropDownMenu_AddButton(info, level); | 83 UIDropDownMenu_AddButton(info, level); |
| 83 | 84 |
| 84 -- Make Auction expired option | 85 -- Make Auction expired option |
| 85 info.text = "Auction expired"; | 86 info.text = L["Auction expired"]; |
| 86 info.func = function(this) mod.db.profile.filter.AH.expired = this.checked; end; | 87 info.func = function(this) mod.db.profile.filter.AH.expired = this.checked; end; |
| 87 info.checked = mod.db.profile.filter.AH.expired; | 88 info.checked = mod.db.profile.filter.AH.expired; |
| 88 UIDropDownMenu_AddButton(info, level); | 89 UIDropDownMenu_AddButton(info, level); |
| 89 | 90 |
| 90 -- Make Auction outbid option | 91 -- Make Auction outbid option |
| 91 info.text = "Auction outbid"; | 92 info.text = L["Auction outbid"]; |
| 92 info.func = function(this) mod.db.profile.filter.AH.outbid = this.checked; end; | 93 info.func = function(this) mod.db.profile.filter.AH.outbid = this.checked; end; |
| 93 info.checked = mod.db.profile.filter.AH.outbid; | 94 info.checked = mod.db.profile.filter.AH.outbid; |
| 94 UIDropDownMenu_AddButton(info, level); | 95 UIDropDownMenu_AddButton(info, level); |
| 95 | 96 |
| 96 -- Make Auction successful option | 97 -- Make Auction successful option |
| 97 info.text = "Auction successful"; | 98 info.text = L["Auction successful"]; |
| 98 info.func = function(this) mod.db.profile.filter.AH.success = this.checked; end; | 99 info.func = function(this) mod.db.profile.filter.AH.success = this.checked; end; |
| 99 info.checked = mod.db.profile.filter.AH.success; | 100 info.checked = mod.db.profile.filter.AH.success; |
| 100 UIDropDownMenu_AddButton(info, level); | 101 UIDropDownMenu_AddButton(info, level); |
| 101 | 102 |
| 102 -- Make Auction won option | 103 -- Make Auction won option |
| 103 info.text = "Auction won"; | 104 info.text = L["Auction won"]; |
| 104 info.func = function(this) mod.db.profile.filter.AH.won = this.checked; end; | 105 info.func = function(this) mod.db.profile.filter.AH.won = this.checked; end; |
| 105 info.checked = mod.db.profile.filter.AH.won; | 106 info.checked = mod.db.profile.filter.AH.won; |
| 106 UIDropDownMenu_AddButton(info, level); | 107 UIDropDownMenu_AddButton(info, level); |
| 107 | 108 |
| 108 -- Make Other mail with attachments | 109 -- Make Other mail with attachments |
| 109 info.text = "Other mail with attachments"; | 110 info.text = L["Other mail with attachments"]; |
| 110 info.func = function(this) mod.db.profile.filter.normalAttachments = this.checked; end; | 111 info.func = function(this) mod.db.profile.filter.normalAttachments = this.checked; end; |
| 111 info.checked = mod.db.profile.filter.normalAttachments; | 112 info.checked = mod.db.profile.filter.normalAttachments; |
| 112 UIDropDownMenu_AddButton(info, level); | 113 UIDropDownMenu_AddButton(info, level); |
| 113 | 114 |
| 114 -- Make Other mail with gold | 115 -- Make Other mail with gold |
| 115 info.text = "Other mail with gold"; | 116 info.text = L["Other mail with gold"]; |
| 116 info.func = function(this) mod.db.profile.filter.normalMoney = this.checked; end; | 117 info.func = function(this) mod.db.profile.filter.normalMoney = this.checked; end; |
| 117 info.checked = mod.db.profile.filter.normalMoney; | 118 info.checked = mod.db.profile.filter.normalMoney; |
| 118 UIDropDownMenu_AddButton(info, level); | 119 UIDropDownMenu_AddButton(info, level); |
| 119 | 120 |
| 120 -- Make Other mail with gold | 121 -- Make Other mail with gold |
| 134 ToggleDropDownMenu(1, nil, mod.ddmFilters, self:GetName(), 0, 0); | 135 ToggleDropDownMenu(1, nil, mod.ddmFilters, self:GetName(), 0, 0); |
| 135 else | 136 else |
| 136 mod:Open(true, IsShiftKeyDown()); | 137 mod:Open(true, IsShiftKeyDown()); |
| 137 end | 138 end |
| 138 end); | 139 end); |
| 139 button.tooltipTitle = "Open all"; | 140 button.tooltipTitle = L["Open all"]; |
| 140 button.tooltip = "Hold |cfffed000shift|r while clicking this button to temporarily override your filters and loot every single mail containing attachments and/or gold.\n\n|cfffed000Right|r click this button to quickly adjust mail opening filters for this profile."; | 141 button.tooltip = L["Hold |cfffed000shift|r while clicking this button to temporarily override your filters and loot every single mail containing attachments and/or gold.\n\n|cfffed000Right|r click this button to quickly adjust mail opening filters for this profile."]; |
| 141 button:SetScript("OnEnter", function(self) | 142 button:SetScript("OnEnter", function(self) |
| 142 if MailOpener.db.profile.general.showHelpTooltips then | 143 if MailOpener.db.profile.general.showHelpTooltips then |
| 143 GameTooltip:SetOwner(self, "ANCHOR_NONE") | 144 GameTooltip:SetOwner(self, "ANCHOR_NONE") |
| 144 GameTooltip:SetPoint("BOTTOM", self, "TOP") | 145 GameTooltip:SetPoint("BOTTOM", self, "TOP") |
| 145 GameTooltip:SetText(self.tooltipTitle, 1, .82, 0, 1) | 146 GameTooltip:SetText(self.tooltipTitle, 1, .82, 0, 1) |
| 378 MAIL_ITEM_INDEX = newMailItemIndex; | 379 MAIL_ITEM_INDEX = newMailItemIndex; |
| 379 -- Do we want to override filters and open every single mail? | 380 -- Do we want to override filters and open every single mail? |
| 380 if everything and self.db.profile.filter.allowShiftClick then | 381 if everything and self.db.profile.filter.allowShiftClick then |
| 381 MAIL_OPEN_EVERYTHING = true; | 382 MAIL_OPEN_EVERYTHING = true; |
| 382 | 383 |
| 383 print("|cff15ff00Mail Opener|r: Shift key was held while pressing the open all button. Temporarily overriding filters; going to open every mail with attachments."); | 384 MailOpener:Print(L["Shift key was held while pressing the open all button. Temporarily overriding filters; going to open every mail with attachments."]); |
| 384 else | 385 else |
| 385 MAIL_OPEN_EVERYTHING = nil; | 386 MAIL_OPEN_EVERYTHING = nil; |
| 386 end | 387 end |
| 387 | 388 |
| 388 -- We're now going to be busy again | 389 -- We're now going to be busy again |
| 390 | 391 |
| 391 -- Open the next mail in line | 392 -- Open the next mail in line |
| 392 self:OpenNext(); | 393 self:OpenNext(); |
| 393 else | 394 else |
| 394 if MailOpener.db.profile.notifications.mailboxIsEmpty then | 395 if MailOpener.db.profile.notifications.mailboxIsEmpty then |
| 395 print("|cffff0000There is currently no mail available.|r"); | 396 print(L["|cffff0000There is currently no mail available.|r"]); |
| 396 end | 397 end |
| 397 | 398 |
| 398 self:Debug("MO_OPEN_COMPLETE"); | 399 self:Debug("MO_OPEN_COMPLETE"); |
| 399 | 400 |
| 400 -- Report that we're all done | 401 -- Report that we're all done |
| 429 | 430 |
| 430 return; -- not auction mail | 431 return; -- not auction mail |
| 431 end | 432 end |
| 432 | 433 |
| 433 function mod:OpenMail(index) | 434 function mod:OpenMail(index) |
| 434 if index > 0 then | 435 if index and index > 0 then |
| 435 -- LUA arrays start at 1, so mail with index 0 doesn't exist, so we're finished | 436 -- LUA arrays start at 1, so mail with index 0 doesn't exist, so we're finished |
| 436 | 437 |
| 437 local sender, subject, gold, cod, _, items, _, _, _, _, isGM = select(3, GetInboxHeaderInfo(index)); | 438 local sender, subject, gold, cod, _, items, _, _, _, _, isGM = select(3, GetInboxHeaderInfo(index)); |
| 438 local auctionMailType = self:GetAuctionMailType(subject); | 439 local auctionMailType = self:GetAuctionMailType(subject); |
| 439 | 440 |
| 441 if not subject then subject = ""; end | |
| 442 | |
| 443 local skippingString = L["Skipping %d: %s (%s)"]; | |
| 444 | |
| 440 if isGM then | 445 if isGM then |
| 441 -- GM Mail | 446 -- Blizzard Mail |
| 442 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.GMMail then | 447 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.GMMail then |
| 443 print("Skipping " .. index .. ": " .. subject .. " (GM mail)"); | 448 print(skippingString:format(index, subject, L["Blizzard mail"])); |
| 444 end | 449 end |
| 445 | 450 |
| 446 self:OpenNext(); | 451 self:OpenNext(); |
| 447 | 452 |
| 448 return; | 453 return; |
| 449 elseif cod and cod > 0 then | 454 elseif cod and cod > 0 then |
| 450 -- Cost on delivery | 455 -- Cost on delivery |
| 451 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.COD then | 456 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.COD then |
| 452 print("Skipping " .. index .. ": " .. subject .. " (C.O.D.)"); | 457 print(skippingString:format(index, subject, L["C.O.D."])); |
| 453 end | 458 end |
| 454 | 459 |
| 455 self:OpenNext(); | 460 self:OpenNext(); |
| 456 | 461 |
| 457 return; | 462 return; |
| 466 end | 471 end |
| 467 end | 472 end |
| 468 | 473 |
| 469 if inventoryFull and not MAIL_OPEN_EVERYTHING and not MailOpener.db.profile.general.continueOpeningStackableItems and items and items > 0 then | 474 if inventoryFull and not MAIL_OPEN_EVERYTHING and not MailOpener.db.profile.general.continueOpeningStackableItems and items and items > 0 then |
| 470 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.inventoryFull then | 475 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.inventoryFull then |
| 471 print("Skipping " .. index .. ": " .. subject .. " (inventory is full)"); | 476 print(skippingString:format(index, subject, L["inventory is full"])); |
| 472 end | 477 end |
| 473 | 478 |
| 474 self:OpenNext(); | 479 self:OpenNext(); |
| 475 | 480 |
| 476 return; | 481 return; |
| 477 elseif self.db.profile.keepFreeSpace > 0 and items and ( slotsAvailable - items ) < self.db.profile.keepFreeSpace then | 482 elseif self.db.profile.keepFreeSpace > 0 and items and ( slotsAvailable - items ) < self.db.profile.keepFreeSpace then |
| 478 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit then | 483 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit then |
| 479 print("Skipping " .. index .. ": " .. subject .. " (keep free space limit)"); | 484 print(skippingString:format(index, subject, L["keep free space limit"])); |
| 480 end | 485 end |
| 481 | 486 |
| 482 self:OpenNext(); | 487 self:OpenNext(); |
| 483 | 488 |
| 484 return; | 489 return; |
| 500 mailType = "AH" .. auctionMailType; | 505 mailType = "AH" .. auctionMailType; |
| 501 end | 506 end |
| 502 | 507 |
| 503 if not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.normalMoney and mailType == "normalGoldMail" then | 508 if not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.normalMoney and mailType == "normalGoldMail" then |
| 504 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 509 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 505 print("Skipping " .. index .. ": " .. subject .. " (normal mail with gold)"); | 510 print(skippingString:format(index, subject, L["normal mail with gold"])); |
| 506 end | 511 end |
| 507 | 512 |
| 508 self:OpenNext(); | 513 self:OpenNext(); |
| 509 | 514 |
| 510 return; | 515 return; |
| 511 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.normalAttachments and mailType == "normalItemsMail" then | 516 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.normalAttachments and mailType == "normalItemsMail" then |
| 512 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 517 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 513 print("Skipping " .. index .. ": " .. subject .. " (normal mail with attachments)"); | 518 print(skippingString:format(index, subject, L["normal mail with attachments"])); |
| 514 end | 519 end |
| 515 | 520 |
| 516 self:OpenNext(); | 521 self:OpenNext(); |
| 517 | 522 |
| 518 return; | 523 return; |
| 519 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.expired and mailType == "AHexpired" then | 524 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.expired and mailType == "AHexpired" then |
| 520 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 525 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 521 print("Skipping " .. index .. ": " .. subject .. " (expired auction)"); | 526 print(skippingString:format(index, subject, L["expired auction"])); |
| 522 end | 527 end |
| 523 | 528 |
| 524 self:OpenNext(); | 529 self:OpenNext(); |
| 525 | 530 |
| 526 return; | 531 return; |
| 527 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.success and mailType == "AHsuccess" then | 532 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.success and mailType == "AHsuccess" then |
| 528 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 533 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 529 print("Skipping " .. index .. ": " .. subject .. " (successful auction)"); | 534 print(skippingString:format(index, subject, L["successful auction"])); |
| 530 end | 535 end |
| 531 | 536 |
| 532 self:OpenNext(); | 537 self:OpenNext(); |
| 533 | 538 |
| 534 return; | 539 return; |
| 535 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.won and mailType == "AHwon" then | 540 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.won and mailType == "AHwon" then |
| 536 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 541 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 537 print("Skipping " .. index .. ": " .. subject .. " (auction won)"); | 542 print(skippingString:format(index, subject, L["auction won"])); |
| 538 end | 543 end |
| 539 | 544 |
| 540 self:OpenNext(); | 545 self:OpenNext(); |
| 541 | 546 |
| 542 return; | 547 return; |
| 543 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.canceled and mailType == "AHcanceled" then | 548 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.canceled and mailType == "AHcanceled" then |
| 544 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 549 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 545 print("Skipping " .. index .. ": " .. subject .. " (canceled auction)"); | 550 print(skippingString:format(index, subject, L["canceled auction"])); |
| 546 end | 551 end |
| 547 | 552 |
| 548 self:OpenNext(); | 553 self:OpenNext(); |
| 549 | 554 |
| 550 return; | 555 return; |
| 551 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.outbid and mailType == "AHoutbid" then | 556 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.outbid and mailType == "AHoutbid" then |
| 552 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 557 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 553 print("Skipping " .. index .. ": " .. subject .. " (outbid on auction)"); | 558 print(skippingString:format(index, subject, L["outbid on auction"])); |
| 554 end | 559 end |
| 555 | 560 |
| 556 self:OpenNext(); | 561 self:OpenNext(); |
| 557 | 562 |
| 558 return; | 563 return; |
| 567 -- Open current mail | 572 -- Open current mail |
| 568 AutoLootMailItem(index); | 573 AutoLootMailItem(index); |
| 569 | 574 |
| 570 if MailOpener.db.profile.notifications.processed.all and MailOpener.db.profile.notifications.processed[mailType] then | 575 if MailOpener.db.profile.notifications.processed.all and MailOpener.db.profile.notifications.processed[mailType] then |
| 571 if gold and gold > 0 then | 576 if gold and gold > 0 then |
| 572 print("Processing " .. index .. ": " .. subject .. " (" .. MailOpener:FormatMoney(gold) .. ")"); | 577 print(L["Processing %d: %s (%s)"]:format(index, subject, MailOpener:FormatMoney(gold))); |
| 573 else | 578 else |
| 574 print("Processing " .. index .. ": " .. subject); | 579 print(L["Processing %d: %s"]:format(index, subject)); |
| 575 end | 580 end |
| 576 end | 581 end |
| 577 | 582 |
| 578 -- And prepare for the next | 583 -- And prepare for the next |
| 579 self.tmrMailOpener = self:ScheduleTimer("OpenNext", self.db.profile.speed); | 584 self.tmrMailOpener = self:ScheduleTimer("OpenNext", self.db.profile.speed); |
| 580 end | 585 end |
| 581 end | 586 end |
| 582 else | 587 else |
| 583 -- Unknown, probably just text | 588 -- Unknown, probably just text |
| 584 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.other then | 589 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.other then |
| 585 if subject then | 590 print(L["Skipping %d: %s"]:format(index, subject)); |
| 586 print("Skipping " .. index .. ": " .. subject); | |
| 587 else | |
| 588 print("Skipping " .. index); | |
| 589 end | |
| 590 end | 591 end |
| 591 | 592 |
| 592 self:OpenNext(); | 593 self:OpenNext(); |
| 593 end | 594 end |
| 594 else | 595 else |
| 595 -- Finished! | 596 -- Finished! |
| 596 if MailOpener.db.profile.notifications.finishedCurrentBatch then | 597 if MailOpener.db.profile.notifications.finishedCurrentBatch then |
| 597 print("Finished opening the current batch."); | 598 print(L["Finished opening the current batch."]); |
| 598 end | 599 end |
| 599 | 600 |
| 600 self:SetOpeningStatus(false); | 601 self:SetOpeningStatus(false); |
| 601 | 602 |
| 602 self:Debug("MO_OPEN_COMPLETE"); | 603 self:Debug("MO_OPEN_COMPLETE"); |
| 626 continue = true; | 627 continue = true; |
| 627 self:OpenNext(); | 628 self:OpenNext(); |
| 628 end | 629 end |
| 629 | 630 |
| 630 local mailRemainingPatterns = { | 631 local mailRemainingPatterns = { |
| 631 minutesSeconds = "|cffffffff%d|r/|cffffffff%d|r mail remaining, opening everything will take about |cffffffff%d|r minutes and |cffffffff%d|r seconds (next refresh in |cffffffff%d|r seconds)."; | 632 minutesSeconds = L["|cffffffff%d|r/|cffffffff%d|r mail remaining, opening everything will take about |cffffffff%d|r minutes and |cffffffff%d|r seconds (next refresh in |cffffffff%d|r seconds)."], |
| 632 minutes = "|cffffffff%d|r/|cffffffff%d|r mail remaining, opening everything will take about |cffffffff%d|r minutes (next refresh in |cffffffff%d|r seconds)."; | 633 minutes = L["|cffffffff%d|r/|cffffffff%d|r mail remaining, opening everything will take about |cffffffff%d|r minutes (next refresh in |cffffffff%d|r seconds)."], |
| 633 seconds = "|cffffffff%d|r/|cffffffff%d|r mail remaining, opening everything will take about |cffffffff%d|r seconds (next refresh in |cffffffff%d|r seconds)."; | 634 seconds = L["|cffffffff%d|r/|cffffffff%d|r mail remaining, opening everything will take about |cffffffff%d|r seconds (next refresh in |cffffffff%d|r seconds)."], |
| 634 nextRefresh = "|cffffffff%d|r/|cffffffff%d|r mail remaining, next refresh in |cffffffff%d|r seconds."; | 635 nextRefresh = L["|cffffffff%d|r/|cffffffff%d|r mail remaining, next refresh in |cffffffff%d|r seconds."], |
| 635 waitingBatch = "|cffffffff%d|r/|cffffffff%d|r mail remaining - waiting for something from the current batch to be opened..."; | 636 waitingBatch = L["|cffffffff%d|r/|cffffffff%d|r mail remaining - waiting for something from the current batch to be opened..."], |
| 636 waitingSync = "|cffffffff%d|r/|cffffffff%d|r mail remaining - waiting for the next mailbox refresh..."; | 637 waitingSync = L["|cffffffff%d|r/|cffffffff%d|r mail remaining - waiting for the next mailbox refresh..."], |
| 637 soon = "|cffffffff%d|r/|cffffffff%d|r mail remaining - everything will be opened soon..."; | 638 soon = L["|cffffffff%d|r/|cffffffff%d|r mail remaining - everything will be opened soon..."], |
| 638 }; | 639 }; |
| 639 | 640 |
| 640 function mod:UpdateTimer() | 641 function mod:UpdateTimer() |
| 641 if lastSync then | 642 if lastSync then |
| 642 self:UpdateMailCount(); | 643 self:UpdateMailCount(); |
| 737 | 738 |
| 738 function mod:SetOpeningStatus(openingStatus) | 739 function mod:SetOpeningStatus(openingStatus) |
| 739 opening = openingStatus; | 740 opening = openingStatus; |
| 740 | 741 |
| 741 if openingStatus then | 742 if openingStatus then |
| 742 self.btnOpenAll:SetText("Opening..."); | 743 self.btnOpenAll:SetText(L["Opening..."]); |
| 743 else | 744 else |
| 744 self.btnOpenAll:SetText("Open all"); | 745 self.btnOpenAll:SetText(L["Open all"]); |
| 745 end | 746 end |
| 746 end | 747 end |
| 747 | 748 |
| 748 function mod:GetOptionsGroup() | 749 function mod:GetOptionsGroup() |
| 749 local configGroup = { | 750 local configGroup = { |
| 750 order = 300, | 751 order = 300, |
| 751 type = "group", | 752 type = "group", |
| 752 name = "Open All", | 753 name = L["Open All"], |
| 753 desc = "Change open all settings.", | 754 desc = L["Change open all settings."], |
| 754 args = { | 755 args = { |
| 755 filters = { | 756 filters = { |
| 756 order = 10, | 757 order = 10, |
| 757 type = "group", | 758 type = "group", |
| 758 inline = true, | 759 inline = true, |
| 759 name = "Filters", | 760 name = L["Filters"], |
| 760 args = { | 761 args = { |
| 761 description = { | 762 description = { |
| 762 order = 10, | 763 order = 10, |
| 763 type = "description", | 764 type = "description", |
| 764 name = "Toggle which mail the opener should autoloot.", | 765 name = L["Toggle which mail the opener should autoloot."], |
| 765 }, | 766 }, |
| 766 AHHeader = { | 767 AHHeader = { |
| 767 order = 15, | 768 order = 15, |
| 768 type = "header", | 769 type = "header", |
| 769 name = "Auction House Mail", | 770 name = L["Auction House Mail"], |
| 770 }, | 771 }, |
| 771 canceled = { | 772 canceled = { |
| 772 order = 20, | 773 order = 20, |
| 773 type = "toggle", | 774 type = "toggle", |
| 774 name = "Open all |cfffed000auction canceled|r mail", | 775 name = L["Open all |cfffed000auction canceled|r mail"], |
| 775 desc = "Automatically loot all auction canceled mail from the auction house.", | 776 desc = L["Automatically loot all auction canceled mail from the auction house."], |
| 776 set = function(i, v) self.db.profile.filter.AH.canceled = v; end, | 777 set = function(i, v) self.db.profile.filter.AH.canceled = v; end, |
| 777 get = function() return self.db.profile.filter.AH.canceled; end, | 778 get = function() return self.db.profile.filter.AH.canceled; end, |
| 778 width = "double", | 779 width = "double", |
| 779 }, | 780 }, |
| 780 expired = { | 781 expired = { |
| 781 order = 21, | 782 order = 21, |
| 782 type = "toggle", | 783 type = "toggle", |
| 783 name = "Open all |cfffed000auction expired|r mail", | 784 name = L["Open all |cfffed000auction expired|r mail"], |
| 784 desc = "Automatically loot all auction canceled mail from the auction house.", | 785 desc = L["Automatically loot all auction expired mail from the auction house."], |
| 785 set = function(i, v) self.db.profile.filter.AH.expired = v; end, | 786 set = function(i, v) self.db.profile.filter.AH.expired = v; end, |
| 786 get = function() return self.db.profile.filter.AH.expired; end, | 787 get = function() return self.db.profile.filter.AH.expired; end, |
| 787 width = "double", | 788 width = "double", |
| 788 }, | 789 }, |
| 789 outbid = { | 790 outbid = { |
| 790 order = 22, | 791 order = 22, |
| 791 type = "toggle", | 792 type = "toggle", |
| 792 name = "Open all |cfffed000outbid on|r mail", | 793 name = L["Open all |cfffed000outbid on|r mail"], |
| 793 desc = "Automatically loot all auction outbid mail from the auction house.", | 794 desc = L["Automatically loot all auction outbid mail from the auction house."], |
| 794 set = function(i, v) self.db.profile.filter.AH.outbid = v; end, | 795 set = function(i, v) self.db.profile.filter.AH.outbid = v; end, |
| 795 get = function() return self.db.profile.filter.AH.outbid; end, | 796 get = function() return self.db.profile.filter.AH.outbid; end, |
| 796 width = "double", | 797 width = "double", |
| 797 }, | 798 }, |
| 798 success = { | 799 success = { |
| 799 order = 23, | 800 order = 23, |
| 800 type = "toggle", | 801 type = "toggle", |
| 801 name = "Open all |cfffed000auction successful|r mail", | 802 name = L["Open all |cfffed000auction successful|r mail"], |
| 802 desc = "Automatically loot all auction successful mail from the auction house.", | 803 desc = L["Automatically loot all auction successful mail from the auction house."], |
| 803 set = function(i, v) self.db.profile.filter.AH.success = v; end, | 804 set = function(i, v) self.db.profile.filter.AH.success = v; end, |
| 804 get = function() return self.db.profile.filter.AH.success; end, | 805 get = function() return self.db.profile.filter.AH.success; end, |
| 805 width = "double", | 806 width = "double", |
| 806 }, | 807 }, |
| 807 won = { | 808 won = { |
| 808 order = 24, | 809 order = 24, |
| 809 type = "toggle", | 810 type = "toggle", |
| 810 name = "Open all |cfffed000auction won|r mail", | 811 name = L["Open all |cfffed000auction won|r mail"], |
| 811 desc = "Automatically loot all auction won mail from the auction house.", | 812 desc = L["Automatically loot all auction won mail from the auction house."], |
| 812 set = function(i, v) self.db.profile.filter.AH.won = v; end, | 813 set = function(i, v) self.db.profile.filter.AH.won = v; end, |
| 813 get = function() return self.db.profile.filter.AH.won; end, | 814 get = function() return self.db.profile.filter.AH.won; end, |
| 814 width = "double", | 815 width = "double", |
| 815 }, | 816 }, |
| 816 normalHeader = { | 817 normalHeader = { |
| 817 order = 30, | 818 order = 30, |
| 818 type = "header", | 819 type = "header", |
| 819 name = "Remaining Mail", | 820 name = L["Remaining Mail"], |
| 820 }, | 821 }, |
| 821 normalAttachments = { | 822 normalAttachments = { |
| 822 order = 40, | 823 order = 40, |
| 823 type = "toggle", | 824 type = "toggle", |
| 824 name = "Normal mail with |cfffed000attachments|r", | 825 name = L["Normal mail with |cfffed000attachments|r"], |
| 825 desc = "Automatically loot all normal mail containing attachments (CoDs and Blizzard mail will be skipped).", | 826 desc = L["Automatically loot all normal mail containing attachments (CoDs and Blizzard mail will be skipped)."], |
| 826 set = function(i, v) self.db.profile.filter.normalAttachments = v; end, | 827 set = function(i, v) self.db.profile.filter.normalAttachments = v; end, |
| 827 get = function() return self.db.profile.filter.normalAttachments; end, | 828 get = function() return self.db.profile.filter.normalAttachments; end, |
| 828 width = "double", | 829 width = "double", |
| 829 }, | 830 }, |
| 830 normalMoney = { | 831 normalMoney = { |
| 831 order = 50, | 832 order = 50, |
| 832 type = "toggle", | 833 type = "toggle", |
| 833 name = "Normal mail with |cfffed000gold|r", | 834 name = L["Normal mail with |cfffed000gold|r"], |
| 834 desc = "Automatically loot all normal mail containing gold (CoDs and Blizzard mail will be skipped).", | 835 desc = L["Automatically loot all normal mail containing gold (CoDs and Blizzard mail will be skipped)."], |
| 835 set = function(i, v) self.db.profile.filter.normalMoney = v; end, | 836 set = function(i, v) self.db.profile.filter.normalMoney = v; end, |
| 836 get = function() return self.db.profile.filter.normalMoney; end, | 837 get = function() return self.db.profile.filter.normalMoney; end, |
| 837 width = "double", | 838 width = "double", |
| 838 }, | 839 }, |
| 839 allowShiftClick = { | 840 allowShiftClick = { |
| 840 order = 60, | 841 order = 60, |
| 841 type = "toggle", | 842 type = "toggle", |
| 842 name = "Allow shift-clicking of the |cfffed000Open All|r button to autoloot |cfffed000everything|r, regardless of the above filters.", | 843 name = L["Allow shift-clicking of the |cfffed000Open All|r button to autoloot |cfffed000everything|r, regardless of the above filters."], |
| 843 desc = "Allow shift-clicking of the |cfffed000Open All|r button to autoloot |cfffed000everything|r with attachments, temporarily overriding all filters.", | 844 desc = L["Allow shift-clicking of the |cfffed000Open All|r button to autoloot |cfffed000everything|r with attachments, temporarily overriding all filters."], |
| 844 set = function(i, v) self.db.profile.filter.allowShiftClick = v; end, | 845 set = function(i, v) self.db.profile.filter.allowShiftClick = v; end, |
| 845 get = function() return self.db.profile.filter.allowShiftClick; end, | 846 get = function() return self.db.profile.filter.allowShiftClick; end, |
| 846 width = "full", | 847 width = "full", |
| 847 }, | 848 }, |
| 848 }, | 849 }, |
| 850 -- Continuous opening config inline group | 851 -- Continuous opening config inline group |
| 851 continuousOpening = { | 852 continuousOpening = { |
| 852 order = 20, | 853 order = 20, |
| 853 type = "group", | 854 type = "group", |
| 854 inline = true, | 855 inline = true, |
| 855 name = "Opening Interval", | 856 name = L["Opening Interval"], |
| 856 args = { | 857 args = { |
| 857 description = { | 858 description = { |
| 858 order = 10, | 859 order = 10, |
| 859 type = "description", | 860 type = "description", |
| 860 name = function() | 861 name = function() |
| 861 local defaultString = "The default behaviour for opening mail is to only do so right after new mail was received from the server. If you close the mailbox or your inventory is full before everything is opened you will have to click the open all button manually or wait for a next mailbox refresh.\n\n"; | 862 local defaultString = L["The default behavior for opening mail is to only do so right after new mail was received from the server. If you close the mailbox or your inventory is full before everything is opened you will have to click the open all button manually or wait for a next mailbox refresh."] .. "\n\n"; |
| 862 | 863 |
| 863 local currentSettings = ""; | 864 local currentSettings = ""; |
| 864 if MailOpener.db.profile.general.continueOpening then | 865 if MailOpener.db.profile.general.continueOpening then |
| 865 currentSettings = currentSettings .. "Mail Opener will |cff00ff00continue|r to attempt to open the remaining mail every |cfffed000" .. MailOpener.db.profile.general.waitTime .. " seconds|r. "; | 866 currentSettings = currentSettings .. L["Mail Opener will |cff00ff00continue|r to attempt to open the remaining mail every |cfffed000%d seconds|r."]:format(MailOpener.db.profile.general.waitTime) .. " "; |
| 866 else | 867 else |
| 867 currentSettings = currentSettings .. "Mail Opener will |cffff0000not|r continue to attempt to open the remaining mail and will only start opening when new mail has just been received from the server. "; | 868 currentSettings = currentSettings .. L["Mail Opener will |cffff0000not|r continue to attempt to open the remaining mail and will only start opening when new mail has just been received from the server."] .. " "; |
| 868 end | 869 end |
| 869 currentSettings = currentSettings .. "The first batch after each server refresh will be opened after waiting |cfffed000" .. MailOpener.db.profile.general.initialDelay .. " seconds|r."; | 870 currentSettings = currentSettings .. L["The first batch after each server refresh will be opened after waiting |cfffed000%d seconds|r."]:format(MailOpener.db.profile.general.initialDelay); |
| 870 return defaultString .. currentSettings; | 871 return defaultString .. currentSettings; |
| 871 end, | 872 end, |
| 872 }, | 873 }, |
| 873 header = { | 874 header = { |
| 874 order = 15, | 875 order = 15, |
| 876 name = "", | 877 name = "", |
| 877 }, | 878 }, |
| 878 continueOpening = { | 879 continueOpening = { |
| 879 order = 20, | 880 order = 20, |
| 880 type = "toggle", | 881 type = "toggle", |
| 881 name = "Continue opening mail", | 882 name = L["Continue opening mail"], |
| 882 desc = "Continue opening mail at the interval set below, even if the mailbox wasn't refreshed recently.", | 883 desc = L["Continue opening mail at the interval set below, even if the mailbox wasn't refreshed recently."], |
| 883 width = "full", | 884 width = "full", |
| 884 get = function() return MailOpener.db.profile.general.continueOpening; end, | 885 get = function() return MailOpener.db.profile.general.continueOpening; end, |
| 885 set = function(i, v) MailOpener.db.profile.general.continueOpening = v; end, | 886 set = function(i, v) MailOpener.db.profile.general.continueOpening = v; end, |
| 886 }, | 887 }, |
| 887 waitTime = { | 888 waitTime = { |
| 889 type = "range", | 890 type = "range", |
| 890 width = "double", | 891 width = "double", |
| 891 min = 0.5, | 892 min = 0.5, |
| 892 max = 60, | 893 max = 60, |
| 893 step = 0.5, | 894 step = 0.5, |
| 894 name = "Continued Mail Opening Interval", | 895 name = L["Continued Mail Opening Interval"], |
| 895 desc = "Change the interval at which Mail Opener tries to continue opening mail after opening the mailbox. Please note that this setting does not reduce the game's normal 60 seconds wait time for mail.\n\nThe default value is 5 seconds.", | 896 desc = L["Change the interval at which Mail Opener tries to continue opening mail after opening the mailbox. Please note that this setting does not reduce the game's normal 60 seconds wait time for mail.\n\nThe default value is 5 seconds."], |
| 896 get = function() return MailOpener.db.profile.general.waitTime; end, | 897 get = function() return MailOpener.db.profile.general.waitTime; end, |
| 897 set = function(i, v) MailOpener.db.profile.general.waitTime = v; end, | 898 set = function(i, v) MailOpener.db.profile.general.waitTime = v; end, |
| 898 disabled = function() return (not MailOpener.db.profile.general.continueOpening); end, | 899 disabled = function() return (not MailOpener.db.profile.general.continueOpening); end, |
| 899 }, | 900 }, |
| 900 initialDelay = { | 901 initialDelay = { |
| 902 type = "range", | 903 type = "range", |
| 903 width = "double", | 904 width = "double", |
| 904 min = 0.5, | 905 min = 0.5, |
| 905 max = 60, | 906 max = 60, |
| 906 step = 0.5, | 907 step = 0.5, |
| 907 name = "Initial Mail Opening Delay", | 908 name = L["Initial Mail Opening Delay"], |
| 908 desc = "Change the delay before Mail Opener tries opening mail after opening the mailbox or new mail has been received from the server.\n\nThe default value is 0.5 seconds.", | 909 desc = L["Change the delay before Mail Opener tries opening mail after opening the mailbox or new mail has been received from the server.\n\nThe default value is 0.5 seconds."], |
| 909 get = function() return MailOpener.db.profile.general.initialDelay; end, | 910 get = function() return MailOpener.db.profile.general.initialDelay; end, |
| 910 set = function(i, v) MailOpener.db.profile.general.initialDelay = v; end, | 911 set = function(i, v) MailOpener.db.profile.general.initialDelay = v; end, |
| 911 }, | 912 }, |
| 912 }, | 913 }, |
| 913 }, -- end Continuous opening config inline group | 914 }, -- end Continuous opening config inline group |
| 914 keepFree = { | 915 keepFree = { |
| 915 order = 30, | 916 order = 30, |
| 916 type = "group", | 917 type = "group", |
| 917 inline = true, | 918 inline = true, |
| 918 name = "Keep Free Space", | 919 name = L["Keep Free Space"], |
| 919 args = { | 920 args = { |
| 920 description = { | 921 description = { |
| 921 order = 10, | 922 order = 10, |
| 922 type = "description", | 923 type = "description", |
| 923 name = "You can set an amount of bag space you wish to reserve when opening mail. Mail with a higher amount of attachments than available space will be skipped completely with this option set above 0.", | 924 name = L["You can set an amount of bag space you wish to reserve when opening mail. Mail with a higher amount of attachments than available space will be skipped completely with this option set above 0."], |
| 924 }, | 925 }, |
| 925 header = { | 926 header = { |
| 926 order = 15, | 927 order = 15, |
| 927 type = "header", | 928 type = "header", |
| 928 name = "", | 929 name = "", |
| 932 type = "range", | 933 type = "range", |
| 933 min = 0, | 934 min = 0, |
| 934 max = 100, | 935 max = 100, |
| 935 step = 1, | 936 step = 1, |
| 936 width = "double", | 937 width = "double", |
| 937 name = "Keep free space", | 938 name = L["Keep free space"], |
| 938 desc = "Change the amount of space to reserve for other things when opening mail. If this option is set higher than 0, mail with a higher amount of attachments than available space will be skipped completely.\n\nE.g. If this is set to 1 and you have a total of 12 slots left then any mail with 12 attachments will be skipped while one with 11 attachments would be opened.", | 939 desc = L["Change the amount of space to reserve for other things when opening mail. If this option is set higher than 0, mail with a higher amount of attachments than available space will be skipped completely.\n\nE.g. If this is set to 1 and you have a total of 12 slots left then any mail with 12 attachments will be skipped while one with 11 attachments would be opened."], |
| 939 set = function(i, v) self.db.profile.keepFreeSpace = v; end, | 940 set = function(i, v) self.db.profile.keepFreeSpace = v; end, |
| 940 get = function() return self.db.profile.keepFreeSpace; end, | 941 get = function() return self.db.profile.keepFreeSpace; end, |
| 941 }, | 942 }, |
| 942 }, | 943 }, |
| 943 }, | 944 }, |
| 948 name = "Opening Speed", | 949 name = "Opening Speed", |
| 949 args = { | 950 args = { |
| 950 description = { | 951 description = { |
| 951 order = 10, | 952 order = 10, |
| 952 type = "description", | 953 type = "description", |
| 953 name = "Change the speed at which mail is opened. You should set the opening speed to the lowest latency you have in a city or experiment with setting it to the minimum.", | 954 name = L["Change the speed at which mail is opened. You should set the opening speed to the lowest latency you have in a city or experiment with setting it to the minimum."], |
| 954 }, | 955 }, |
| 955 header = { | 956 header = { |
| 956 order = 15, | 957 order = 15, |
| 957 type = "header", | 958 type = "header", |
| 958 name = "", | 959 name = "", |
| 962 type = "range", | 963 type = "range", |
| 963 min = 5, | 964 min = 5, |
| 964 max = 2500, | 965 max = 2500, |
| 965 step = 5, | 966 step = 5, |
| 966 width = "double", | 967 width = "double", |
| 967 name = "Open single mail interval", | 968 name = L["Open single mail interval"], |
| 968 desc = "Change the mail opening speed (in microseconds) for each mail. Lower may not always be faster.", | 969 desc = L["Change the mail opening speed (in microseconds) for each mail. Lower may not always be faster."], |
| 969 get = function() return ( self.db.profile.speed * 1000 ); end, | 970 get = function() return ( self.db.profile.speed * 1000 ); end, |
| 970 set = function(i, v) self.db.profile.speed = ( v / 1000 ); end, | 971 set = function(i, v) self.db.profile.speed = ( v / 1000 ); end, |
| 971 }, | 972 }, |
| 972 }, | 973 }, |
| 973 }, | 974 }, |
| 976 | 977 |
| 977 return configGroup; | 978 return configGroup; |
| 978 end | 979 end |
| 979 | 980 |
| 980 function mod:Debug(t) | 981 function mod:Debug(t) |
| 981 return MailOpener:Debug("|cff00ff00OpenAll|r:" .. t); | 982 return MailOpener:Debug(("|cff00ff00OpenAll|r:%s"):format(t)); |
| 982 end | 983 end |
