Mercurial > wow > mailopener
comparison Modules/OpenAll.lua @ 46:1805df31794d
Only when holding the shift key while opening the mailbox will toggle the opening status. If you want to do it somewhere in the middle of your mailbox visit, just untick the mail opener checkbox.
Holding shift while clicking the open all button will now auto loot every single mail with attachments.
/mo d will now return the id of the chatframe being used, if it's using one already existing.
Changelog and TOC update.
| author | Zerotorescue |
|---|---|
| date | Sun, 12 Sep 2010 16:36:18 +0200 |
| parents | 8168280420ae |
| children | f630d882d008 |
comparison
equal
deleted
inserted
replaced
| 45:e9072491dc3f | 46:1805df31794d |
|---|---|
| 7 --[[ | 7 --[[ |
| 8 Dev notes: | 8 Dev notes: |
| 9 When shift clicking the Open All button it should override all filters. | 9 When shift clicking the Open All button it should override all filters. |
| 10 ]] | 10 ]] |
| 11 | 11 |
| 12 local MAIL_ITEM_INDEX, mailTimer, inventoryFull, inventoryFullSoundPlayed, inventoryFullSoundPlayedThisVisit, opening, lastSync, numCurrentMail, numHiddenMail, continue; | 12 local MAIL_ITEM_INDEX, MAIL_OPEN_EVERYTHING, mailTimer, inventoryFull, inventoryFullSoundPlayed, inventoryFullSoundPlayedThisVisit, opening, lastSync, numCurrentMail, numHiddenMail, continue; |
| 13 | 13 |
| 14 function mod:OnInitialize() | 14 function mod:OnInitialize() |
| 15 local defaults = { | 15 local defaults = { |
| 16 profile = { | 16 profile = { |
| 17 speed = 0.05, | 17 speed = 0.05, |
| 37 function mod:OnEnable() | 37 function mod:OnEnable() |
| 38 self:RegisterEvent("MAIL_SHOW"); | 38 self:RegisterEvent("MAIL_SHOW"); |
| 39 | 39 |
| 40 if not self.btnOpenAll then | 40 if not self.btnOpenAll then |
| 41 -- Open all button | 41 -- Open all button |
| 42 local button = CreateFrame("Button", "btnMailOpenerOpenAll", InboxFrame, "UIPanelButtonTemplate") | 42 local button = CreateFrame("Button", "btnMailOpenerOpenAll", InboxFrame, "UIPanelButtonTemplate"); |
| 43 button:SetText("Open all") | 43 button:SetText("Open all"); |
| 44 button:SetHeight(26) | 44 button:SetHeight(26); |
| 45 button:SetWidth(120) | 45 button:SetWidth(120); |
| 46 button:SetPoint("BOTTOM", InboxFrame, "CENTER", -10, -165) | 46 button:SetPoint("BOTTOM", InboxFrame, "CENTER", -10, -165); |
| 47 button:SetScript("OnClick", function() mod:Open(true) end) | 47 button:SetScript("OnClick", function() |
| 48 mod:Open(true, IsShiftKeyDown()); | |
| 49 end); | |
| 48 | 50 |
| 49 self.btnOpenAll = button; | 51 self.btnOpenAll = button; |
| 50 end | 52 end |
| 51 | 53 |
| 52 self.btnOpenAll:Show(); | 54 self.btnOpenAll:Show(); |
| 245 -- Continue opening mail (we still want to retrieve other items or gold) | 247 -- Continue opening mail (we still want to retrieve other items or gold) |
| 246 continue = true; | 248 continue = true; |
| 247 end | 249 end |
| 248 end | 250 end |
| 249 | 251 |
| 250 function mod:Open(forced) | 252 function mod:Open(forced, everything) |
| 251 self:Debug("Open"); | 253 self:Debug("Open (" .. ((everything and "1") or "0") .. ")"); |
| 252 | 254 |
| 253 if not opening or forced == true then | 255 if not opening or forced == true then |
| 254 local numItems, totalItems = GetInboxNumItems(); | 256 local numItems, totalItems = GetInboxNumItems(); |
| 255 -- Start at the end, add one because OpenNext will take it away again | 257 -- Start at the end, add one because OpenNext will take it away again |
| 256 local newMailItemIndex = ( ( numItems or 0 ) + 1 ); | 258 local newMailItemIndex = ( ( numItems or 0 ) + 1 ); |
| 265 self:StopOpening(true); -- forced is false - automated action - simple reset, skip inventory full reset to avoid sound spam | 267 self:StopOpening(true); -- forced is false - automated action - simple reset, skip inventory full reset to avoid sound spam |
| 266 end | 268 end |
| 267 | 269 |
| 268 -- Update the caret | 270 -- Update the caret |
| 269 MAIL_ITEM_INDEX = newMailItemIndex; | 271 MAIL_ITEM_INDEX = newMailItemIndex; |
| 272 -- Do we want to override filters and open every single mail? | |
| 273 if everything then | |
| 274 MAIL_OPEN_EVERYTHING = true; | |
| 275 | |
| 276 print("|cff15ff00Mail Opener|r: Shift key was held while pressing the open all button. Temporarily overriding filters; going to open every mail with attachments."); | |
| 277 else | |
| 278 MAIL_OPEN_EVERYTHING = nil; | |
| 279 end | |
| 270 | 280 |
| 271 -- We're now going to be busy again | 281 -- We're now going to be busy again |
| 272 self:SetOpeningStatus(true); | 282 self:SetOpeningStatus(true); |
| 273 | 283 |
| 274 -- Open the next mail in line | 284 -- Open the next mail in line |
| 347 local numberOfFreeSlots = GetContainerNumFreeSlots(bag); | 357 local numberOfFreeSlots = GetContainerNumFreeSlots(bag); |
| 348 slotsAvailable = ( slotsAvailable + numberOfFreeSlots ); | 358 slotsAvailable = ( slotsAvailable + numberOfFreeSlots ); |
| 349 end | 359 end |
| 350 end | 360 end |
| 351 | 361 |
| 352 if inventoryFull and not MailOpener.db.profile.general.continueOpeningStackableItems and items and items > 0 then | 362 if inventoryFull and not MAIL_OPEN_EVERYTHING and not MailOpener.db.profile.general.continueOpeningStackableItems and items and items > 0 then |
| 353 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.inventoryFull then | 363 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.inventoryFull then |
| 354 print("Skipping " .. index .. ": " .. subject .. " (inventory is full)"); | 364 print("Skipping " .. index .. ": " .. subject .. " (inventory is full)"); |
| 355 end | 365 end |
| 356 | 366 |
| 357 self:OpenNext(); | 367 self:OpenNext(); |
| 381 -- This is an auction house mail | 391 -- This is an auction house mail |
| 382 | 392 |
| 383 mailType = "AH" .. auctionMailType; | 393 mailType = "AH" .. auctionMailType; |
| 384 end | 394 end |
| 385 | 395 |
| 386 if not self.db.profile.filter.normalMoney and mailType == "normalGoldMail" then | 396 if not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.normalMoney and mailType == "normalGoldMail" then |
| 387 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 397 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 388 print("Skipping " .. index .. ": " .. subject .. " (normal mail with gold)"); | 398 print("Skipping " .. index .. ": " .. subject .. " (normal mail with gold)"); |
| 389 end | 399 end |
| 390 | 400 |
| 391 self:OpenNext(); | 401 self:OpenNext(); |
| 392 | 402 |
| 393 return; | 403 return; |
| 394 elseif not self.db.profile.filter.normalAttachments and mailType == "normalItemsMail" then | 404 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.normalAttachments and mailType == "normalItemsMail" then |
| 395 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 405 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 396 print("Skipping " .. index .. ": " .. subject .. " (normal mail with attachments)"); | 406 print("Skipping " .. index .. ": " .. subject .. " (normal mail with attachments)"); |
| 397 end | 407 end |
| 398 | 408 |
| 399 self:OpenNext(); | 409 self:OpenNext(); |
| 400 | 410 |
| 401 return; | 411 return; |
| 402 elseif not self.db.profile.filter.AH.expired and mailType == "AHexpired" then | 412 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.expired and mailType == "AHexpired" then |
| 403 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 413 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 404 print("Skipping " .. index .. ": " .. subject .. " (expired auction)"); | 414 print("Skipping " .. index .. ": " .. subject .. " (expired auction)"); |
| 405 end | 415 end |
| 406 | 416 |
| 407 self:OpenNext(); | 417 self:OpenNext(); |
| 408 | 418 |
| 409 return; | 419 return; |
| 410 elseif not self.db.profile.filter.AH.success and mailType == "AHsuccess" then | 420 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.success and mailType == "AHsuccess" then |
| 411 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 421 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 412 print("Skipping " .. index .. ": " .. subject .. " (successful auction)"); | 422 print("Skipping " .. index .. ": " .. subject .. " (successful auction)"); |
| 413 end | 423 end |
| 414 | 424 |
| 415 self:OpenNext(); | 425 self:OpenNext(); |
| 416 | 426 |
| 417 return; | 427 return; |
| 418 elseif not self.db.profile.filter.AH.won and mailType == "AHwon" then | 428 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.won and mailType == "AHwon" then |
| 419 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 429 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 420 print("Skipping " .. index .. ": " .. subject .. " (auction won)"); | 430 print("Skipping " .. index .. ": " .. subject .. " (auction won)"); |
| 421 end | 431 end |
| 422 | 432 |
| 423 self:OpenNext(); | 433 self:OpenNext(); |
| 424 | 434 |
| 425 return; | 435 return; |
| 426 elseif not self.db.profile.filter.AH.canceled and mailType == "AHcanceled" then | 436 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.canceled and mailType == "AHcanceled" then |
| 427 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 437 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 428 print("Skipping " .. index .. ": " .. subject .. " (canceled auction)"); | 438 print("Skipping " .. index .. ": " .. subject .. " (canceled auction)"); |
| 429 end | 439 end |
| 430 | 440 |
| 431 self:OpenNext(); | 441 self:OpenNext(); |
| 432 | 442 |
| 433 return; | 443 return; |
| 434 elseif not self.db.profile.filter.AH.outbid and mailType == "AHoutbid" then | 444 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.outbid and mailType == "AHoutbid" then |
| 435 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then | 445 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then |
| 436 print("Skipping " .. index .. ": " .. subject .. " (outbid on auction)"); | 446 print("Skipping " .. index .. ": " .. subject .. " (outbid on auction)"); |
| 437 end | 447 end |
| 438 | 448 |
| 439 self:OpenNext(); | 449 self:OpenNext(); |
| 608 inventoryFullSoundPlayed = nil; | 618 inventoryFullSoundPlayed = nil; |
| 609 end | 619 end |
| 610 | 620 |
| 611 -- Reset opener position | 621 -- Reset opener position |
| 612 MAIL_ITEM_INDEX = 0; | 622 MAIL_ITEM_INDEX = 0; |
| 623 -- Reset open everything state | |
| 624 MAIL_OPEN_EVERYTHING = nil; | |
| 613 -- Stopped opening, so allow to continue | 625 -- Stopped opening, so allow to continue |
| 614 continue = true; | 626 continue = true; |
| 615 | 627 |
| 616 self:SetOpeningStatus(false); | 628 self:SetOpeningStatus(false); |
| 617 end | 629 end |
