Mercurial > wow > mailopener
comparison Modules/OpenAll.lua @ 106:5c06ce56297a
Only announce mail skipped the first OpenAll after a server refresh.
| author | Zerotorescue |
|---|---|
| date | Thu, 30 Sep 2010 14:30:02 +0200 |
| parents | 0a8e4a93316d |
| children | 981c6ac45a3f |
comparison
equal
deleted
inserted
replaced
| 105:9187c2bc5871 | 106:5c06ce56297a |
|---|---|
| 8 --[[ | 8 --[[ |
| 9 Dev notes: | 9 Dev notes: |
| 10 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. |
| 11 ]] | 11 ]] |
| 12 | 12 |
| 13 local MAIL_ITEM_INDEX, MAIL_OPEN_EVERYTHING, mailTimer, inventoryFull, inventoryFullSoundPlayed, inventoryFullSoundPlayedThisVisit, opening, lastSync, numCurrentMail, numHiddenMail, continue; | 13 local MAIL_ITEM_INDEX, MAIL_OPEN_EVERYTHING, mailTimer, inventoryFull, inventoryFullSoundPlayed, inventoryFullSoundPlayedThisVisit, opening, lastSync, numCurrentMail, numHiddenMail, continue, firstOpenThisSync; |
| 14 | 14 |
| 15 function mod:OnInitialize() | 15 function mod:OnInitialize() |
| 16 local defaults = { | 16 local defaults = { |
| 17 profile = { | 17 profile = { |
| 18 speed = 0.05, | 18 speed = 0.05, |
| 306 self:StopOpening(false); | 306 self:StopOpening(false); |
| 307 | 307 |
| 308 lastSync = GetTime(); | 308 lastSync = GetTime(); |
| 309 | 309 |
| 310 self:UpdateMailCount(); | 310 self:UpdateMailCount(); |
| 311 | |
| 312 -- While this is true, we'll announce mail skipped - will be set to false after opening happened once | |
| 313 firstOpenThisSync = true; | |
| 311 end | 314 end |
| 312 | 315 |
| 313 function mod:MO_MAIL_EMPTIED() | 316 function mod:MO_MAIL_EMPTIED() |
| 314 -- A mail has been processed so we can process the next | 317 -- A mail has been processed so we can process the next |
| 315 continue = true; | 318 continue = true; |
| 368 if newMailItemIndex > 1 then | 371 if newMailItemIndex > 1 then |
| 369 self:Debug("Open succes"); | 372 self:Debug("Open succes"); |
| 370 | 373 |
| 371 -- Stop the previous opening and restart | 374 -- Stop the previous opening and restart |
| 372 if forced == true then | 375 if forced == true then |
| 376 -- Show skips again | |
| 377 firstOpenThisSync = true; | |
| 378 | |
| 373 self:StopOpening(false); -- this is not a "simple" stop, so also reset inventory full warning | 379 self:StopOpening(false); -- this is not a "simple" stop, so also reset inventory full warning |
| 374 else | 380 else |
| 375 self:StopOpening(true); -- forced is false - automated action - simple reset, skip inventory full reset to avoid sound spam | 381 self:StopOpening(true); -- forced is false - automated action - simple reset, skip inventory full reset to avoid sound spam |
| 376 end | 382 end |
| 377 | 383 |
| 438 local sender, subject, gold, cod, _, items, _, _, _, _, isGM = select(3, GetInboxHeaderInfo(index)); | 444 local sender, subject, gold, cod, _, items, _, _, _, _, isGM = select(3, GetInboxHeaderInfo(index)); |
| 439 local auctionMailType = self:GetAuctionMailType(subject); | 445 local auctionMailType = self:GetAuctionMailType(subject); |
| 440 | 446 |
| 441 if not subject then subject = ""; end | 447 if not subject then subject = ""; end |
| 442 | 448 |
| 449 local onlyShowOnceCheck = firstOpenThisSync; | |
| 450 | |
| 443 local skippingString = L["Skipping %d: %s (%s)"]; | 451 local skippingString = L["Skipping %d: %s (%s)"]; |
| 444 | 452 |
| 445 if isGM then | 453 if isGM then |
| 446 -- Blizzard Mail | 454 -- Blizzard Mail |
| 447 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.GMMail then | 455 if MailOpener.db.profile.notifications.skipped.all and onlyShowOnceCheck and MailOpener.db.profile.notifications.skipped.GMMail then |
| 448 print(skippingString:format(index, subject, L["Blizzard mail"])); | 456 print(skippingString:format(index, subject, L["Blizzard mail"])); |
| 449 end | 457 end |
| 450 | 458 |
| 451 self:OpenNext(); | 459 self:OpenNext(); |
| 452 | 460 |
| 453 return; | 461 return; |
| 454 elseif cod and cod > 0 then | 462 elseif cod and cod > 0 then |
| 455 -- Cost on delivery | 463 -- Cost on delivery |
| 456 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.COD then | 464 if MailOpener.db.profile.notifications.skipped.all and onlyShowOnceCheck and MailOpener.db.profile.notifications.skipped.COD then |
| 457 print(skippingString:format(index, subject, L["C.O.D."])); | 465 print(skippingString:format(index, subject, L["C.O.D."])); |
| 458 end | 466 end |
| 459 | 467 |
| 460 self:OpenNext(); | 468 self:OpenNext(); |
| 461 | 469 |
| 478 end | 486 end |
| 479 | 487 |
| 480 -- and not MAIL_OPEN_EVERYTHING | 488 -- and not MAIL_OPEN_EVERYTHING |
| 481 -- Removed above part from below if statement, I forgot why I put it here and now it makes no sense | 489 -- Removed above part from below if statement, I forgot why I put it here and now it makes no sense |
| 482 if inventoryFull and not MailOpener.db.profile.general.continueOpeningStackableItems and items and items > 0 then | 490 if inventoryFull and not MailOpener.db.profile.general.continueOpeningStackableItems and items and items > 0 then |
| 483 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.inventoryFull then | 491 if MailOpener.db.profile.notifications.skipped.all and onlyShowOnceCheck and MailOpener.db.profile.notifications.skipped.inventoryFull then |
| 484 print(skippingString:format(index, subject, L["inventory is full"])); | 492 print(skippingString:format(index, subject, L["inventory is full"])); |
| 485 end | 493 end |
| 486 | 494 |
| 487 self:OpenNext(); | 495 self:OpenNext(); |
| 488 | 496 |
| 489 return; | 497 return; |
| 490 elseif self.db.profile.keepFreeSpace > 0 and items and slotsAvailable ~= nil and slotsAvailable <= 0 then | 498 elseif self.db.profile.keepFreeSpace > 0 and items and slotsAvailable ~= nil and slotsAvailable <= 0 then |
| 491 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit then | 499 if MailOpener.db.profile.notifications.skipped.all and onlyShowOnceCheck and MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit then |
| 492 print(skippingString:format(index, subject, L["keep free space limit"])); | 500 print(skippingString:format(index, subject, L["keep free space limit"])); |
| 493 end | 501 end |
| 494 | 502 |
| 495 self:OpenNext(); | 503 self:OpenNext(); |
| 496 | 504 |
| 512 | 520 |
| 513 mailType = "AH" .. auctionMailType; | 521 mailType = "AH" .. auctionMailType; |
| 514 end | 522 end |
| 515 | 523 |
| 516 if not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.normalMoney and mailType == "normalGoldMail" then | 524 if not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.normalMoney and mailType == "normalGoldMail" then |
| 517 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 525 if MailOpener.db.profile.notifications.skipped.all and onlyShowOnceCheck and MailOpener.db.profile.notifications.skipped[mailType] then |
| 518 print(skippingString:format(index, subject, L["normal mail with gold"])); | 526 print(skippingString:format(index, subject, L["normal mail with gold"])); |
| 519 end | 527 end |
| 520 | 528 |
| 521 self:OpenNext(); | 529 self:OpenNext(); |
| 522 | 530 |
| 523 return; | 531 return; |
| 524 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.normalAttachments and mailType == "normalItemsMail" then | 532 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.normalAttachments and mailType == "normalItemsMail" then |
| 525 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 533 if MailOpener.db.profile.notifications.skipped.all and onlyShowOnceCheck and MailOpener.db.profile.notifications.skipped[mailType] then |
| 526 print(skippingString:format(index, subject, L["normal mail with attachments"])); | 534 print(skippingString:format(index, subject, L["normal mail with attachments"])); |
| 527 end | 535 end |
| 528 | 536 |
| 529 self:OpenNext(); | 537 self:OpenNext(); |
| 530 | 538 |
| 531 return; | 539 return; |
| 532 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.expired and mailType == "AHexpired" then | 540 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.expired and mailType == "AHexpired" then |
| 533 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 541 if MailOpener.db.profile.notifications.skipped.all and onlyShowOnceCheck and MailOpener.db.profile.notifications.skipped[mailType] then |
| 534 print(skippingString:format(index, subject, L["expired auction"])); | 542 print(skippingString:format(index, subject, L["expired auction"])); |
| 535 end | 543 end |
| 536 | 544 |
| 537 self:OpenNext(); | 545 self:OpenNext(); |
| 538 | 546 |
| 539 return; | 547 return; |
| 540 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.success and mailType == "AHsuccess" then | 548 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.success and mailType == "AHsuccess" then |
| 541 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 549 if MailOpener.db.profile.notifications.skipped.all and onlyShowOnceCheck and MailOpener.db.profile.notifications.skipped[mailType] then |
| 542 print(skippingString:format(index, subject, L["successful auction"])); | 550 print(skippingString:format(index, subject, L["successful auction"])); |
| 543 end | 551 end |
| 544 | 552 |
| 545 self:OpenNext(); | 553 self:OpenNext(); |
| 546 | 554 |
| 547 return; | 555 return; |
| 548 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.won and mailType == "AHwon" then | 556 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.won and mailType == "AHwon" then |
| 549 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 557 if MailOpener.db.profile.notifications.skipped.all and onlyShowOnceCheck and MailOpener.db.profile.notifications.skipped[mailType] then |
| 550 print(skippingString:format(index, subject, L["auction won"])); | 558 print(skippingString:format(index, subject, L["auction won"])); |
| 551 end | 559 end |
| 552 | 560 |
| 553 self:OpenNext(); | 561 self:OpenNext(); |
| 554 | 562 |
| 555 return; | 563 return; |
| 556 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.canceled and mailType == "AHcanceled" then | 564 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.canceled and mailType == "AHcanceled" then |
| 557 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 565 if MailOpener.db.profile.notifications.skipped.all and onlyShowOnceCheck and MailOpener.db.profile.notifications.skipped[mailType] then |
| 558 print(skippingString:format(index, subject, L["canceled auction"])); | 566 print(skippingString:format(index, subject, L["canceled auction"])); |
| 559 end | 567 end |
| 560 | 568 |
| 561 self:OpenNext(); | 569 self:OpenNext(); |
| 562 | 570 |
| 563 return; | 571 return; |
| 564 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.outbid and mailType == "AHoutbid" then | 572 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.outbid and mailType == "AHoutbid" then |
| 565 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 573 if MailOpener.db.profile.notifications.skipped.all and onlyShowOnceCheck and MailOpener.db.profile.notifications.skipped[mailType] then |
| 566 print(skippingString:format(index, subject, L["outbid on auction"])); | 574 print(skippingString:format(index, subject, L["outbid on auction"])); |
| 567 end | 575 end |
| 568 | 576 |
| 569 self:OpenNext(); | 577 self:OpenNext(); |
| 570 | 578 |
| 593 | 601 |
| 594 -- Gained an item, lost an available slot | 602 -- Gained an item, lost an available slot |
| 595 slotsAvailable = ( slotsAvailable - 1 ); | 603 slotsAvailable = ( slotsAvailable - 1 ); |
| 596 else | 604 else |
| 597 -- No more room available, announce and go to next item | 605 -- No more room available, announce and go to next item |
| 598 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit then | 606 if MailOpener.db.profile.notifications.skipped.all and onlyShowOnceCheck and MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit then |
| 599 print(skippingString:format(index, subject, L["keep free space limit"])); | 607 print(skippingString:format(index, subject, L["keep free space limit"])); |
| 600 end | 608 end |
| 601 | 609 |
| 602 -- We're done with this mail, it isn't empty so that event won't be triggered, but we may still continue | 610 -- We're done with this mail, it isn't empty so that event won't be triggered, but we may still continue |
| 603 continue = true; | 611 continue = true; |
| 625 self.tmrMailOpener = self:ScheduleTimer("OpenNext", self.db.profile.speed); | 633 self.tmrMailOpener = self:ScheduleTimer("OpenNext", self.db.profile.speed); |
| 626 end | 634 end |
| 627 end | 635 end |
| 628 else | 636 else |
| 629 -- Unknown, probably just text | 637 -- Unknown, probably just text |
| 630 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.other then | 638 if MailOpener.db.profile.notifications.skipped.all and onlyShowOnceCheck and MailOpener.db.profile.notifications.skipped.other then |
| 631 print(L["Skipping %d: %s"]:format(index, subject)); | 639 print(L["Skipping %d: %s"]:format(index, subject)); |
| 632 end | 640 end |
| 633 | 641 |
| 634 self:OpenNext(); | 642 self:OpenNext(); |
| 635 end | 643 end |
| 636 else | 644 else |
| 637 -- Finished! | 645 -- Finished! |
| 638 if MailOpener.db.profile.notifications.finishedCurrentBatch then | 646 if MailOpener.db.profile.notifications.finishedCurrentBatch and firstOpenThisSync then |
| 639 print(L["Finished opening the current batch."]); | 647 print(L["Finished opening the current batch."]); |
| 640 end | 648 end |
| 649 | |
| 650 -- We have opened mail once this batch, so quit notifying | |
| 651 firstOpenThisSync = nil; | |
| 641 | 652 |
| 642 self:SetOpeningStatus(false); | 653 self:SetOpeningStatus(false); |
| 643 | 654 |
| 644 self:Debug("MO_OPEN_COMPLETE"); | 655 self:Debug("MO_OPEN_COMPLETE"); |
| 645 | 656 |
