Mercurial > wow > mailopener
comparison Core.lua @ 174:463e29ca6b08
More merging'
| author | Zachary Kotlarek <zach@kotlarek.com> |
|---|---|
| date | Sun, 10 Mar 2013 16:08:39 -0700 |
| parents | 86d9e008b0ad |
| children |
comparison
equal
deleted
inserted
replaced
| 173:7452702f6f35 | 174:463e29ca6b08 |
|---|---|
| 4 | 4 |
| 5 -- You can check if MailOpener is busy with the global MailAddonBusy (if not MailAddonBusy then ...do something... end) | 5 -- You can check if MailOpener is busy with the global MailAddonBusy (if not MailAddonBusy then ...do something... end) |
| 6 -- MailAddonBusy will be nil when nothing is happening or filled with the addon name when MO is working | 6 -- MailAddonBusy will be nil when nothing is happening or filled with the addon name when MO is working |
| 7 -- Another addon can use this variable to indicate they're working too, MailOpener will then wait for that to finish | 7 -- Another addon can use this variable to indicate they're working too, MailOpener will then wait for that to finish |
| 8 | 8 |
| 9 local AutoOpenMail, MailOpenerConfig, lastAmount, lastQuickAuctionsStatus, freshList, mailboxEmptySoundPlayed, mailboxEmptySoundPlayedThisVisit; | 9 local AutoOpenMail, MailOpenerConfig, lastAmount, lastQuickAuctionsStatus, freshList, mailboxEmptySoundPlayed, mailboxEmptySoundPlayedThisVisit, hasOpenedMailAlready, originalCheckInbox; |
| 10 | 10 |
| 11 function MailOpener:OnInitialize() | 11 function MailOpener:OnInitialize() |
| 12 self:Debug("OnInitialize"); | 12 self:Debug("OnInitialize"); |
| 13 | 13 |
| 14 | 14 |
| 31 autoReenableQAAutoMail = false, | 31 autoReenableQAAutoMail = false, |
| 32 autoSetBackQAAutoMail = true, | 32 autoSetBackQAAutoMail = true, |
| 33 continueOpening = false, | 33 continueOpening = false, |
| 34 waitTime = 5, | 34 waitTime = 5, |
| 35 initialDelay = 0.5, | 35 initialDelay = 0.5, |
| 36 overrideCheckInbox = true, | |
| 36 }, | 37 }, |
| 37 modules = { | 38 modules = { |
| 38 BeanCounterSupport = true, | 39 BeanCounterSupport = true, |
| 39 Config = false, | 40 Config = false, |
| 40 Collected = true, | 41 Collected = true, |
| 143 | 144 |
| 144 -- Now create our own options frame | 145 -- Now create our own options frame |
| 145 local frame = CreateFrame("Frame", nil, UIParent); | 146 local frame = CreateFrame("Frame", nil, UIParent); |
| 146 frame:Hide(); | 147 frame:Hide(); |
| 147 frame.name = "Mail Opener"; | 148 frame.name = "Mail Opener"; |
| 149 frame.fresh = true; | |
| 148 frame:HookScript("OnShow", function(self) | 150 frame:HookScript("OnShow", function(self) |
| 149 -- Enable the config module | 151 if self.fresh then |
| 150 MailOpener:EnableConfigModule(); | 152 self.fresh = nil; |
| 151 | 153 |
| 152 -- Load the options and add it to the blizzard interface list | 154 -- Enable the config module |
| 153 MailOpenerConfig:Load(); | 155 MailOpener:EnableConfigModule(); |
| 154 | 156 |
| 155 -- Refresh the frame to instantly show the right options | 157 -- Load the options and add it to the blizzard interface list |
| 156 InterfaceOptionsFrame_OpenToCategory(self.name) | 158 MailOpenerConfig:Load(); |
| 159 | |
| 160 -- Refresh the frame to instantly show the right options | |
| 161 InterfaceOptionsFrame_OpenToCategory(self.name); | |
| 162 end | |
| 157 end); | 163 end); |
| 158 -- And add it to the interface options | 164 -- And add it to the interface options |
| 159 InterfaceOptions_AddCategory(frame); | 165 InterfaceOptions_AddCategory(frame); |
| 160 | 166 |
| 161 | 167 |
| 281 | 287 |
| 282 if select(6, GetAddOnInfo("Postal")) == nil then | 288 if select(6, GetAddOnInfo("Postal")) == nil then |
| 283 self.PostalEnabled = true; -- Set this as an object variable so we can use it in our modules | 289 self.PostalEnabled = true; -- Set this as an object variable so we can use it in our modules |
| 284 | 290 |
| 285 -- Ensure this addon is loaded if AddonLoader is installed | 291 -- Ensure this addon is loaded if AddonLoader is installed |
| 286 if AddonLoader and AddonLoader.LoadAddOn and not Postal then | 292 if AddonLoader and AddonLoader.LoadAddOn and not IsAddOnLoaded("Postal") and not Postal then |
| 287 AddonLoader:LoadAddOn("Postal"); | 293 AddonLoader:LoadAddOn("Postal"); |
| 288 end | 294 end |
| 289 end | 295 end |
| 290 | 296 |
| 291 if select(6, GetAddOnInfo("QuickAuctions")) == nil then | 297 if select(6, GetAddOnInfo("ZeroAuctions")) == nil then |
| 292 self.QuickAuctionsEnabled = true; -- Set this as an object variable so we can use it in our modules | 298 self.ZeroAuctionsEnabled = true; -- Set this as an object variable so we can use it in our modules |
| 293 | 299 |
| 294 -- Ensure this addon is loaded if AddonLoader is installed | 300 -- Ensure this addon is loaded if AddonLoader is installed |
| 295 if AddonLoader and AddonLoader.LoadAddOn then | 301 if AddonLoader and AddonLoader.LoadAddOn and not IsAddOnLoaded("ZeroAuctions") then |
| 296 AddonLoader:LoadAddOn("QuickAuctions"); | 302 AddonLoader:LoadAddOn("ZeroAuctions"); |
| 303 end | |
| 304 end | |
| 305 | |
| 306 if select(6, GetAddOnInfo("AuctionProfitMaster")) == nil then | |
| 307 self.ZeroAuctionsEnabled = true; -- Set this as an object variable so we can use it in our modules | |
| 308 | |
| 309 -- Ensure this addon is loaded if AddonLoader is installed | |
| 310 if AddonLoader and AddonLoader.LoadAddOn and not IsAddOnLoaded("AuctionProfitMaster") then | |
| 311 AddonLoader:LoadAddOn("AuctionProfitMaster"); | |
| 312 end | |
| 313 end | |
| 314 | |
| 315 if select(6, GetAddOnInfo("TradeSkillMaster_Mailing")) == nil then | |
| 316 self.TSMMailingEnabled = true; -- Set this as an object variable so we can use it in our modules | |
| 317 | |
| 318 -- Ensure this addon is loaded if AddonLoader is installed | |
| 319 if AddonLoader and AddonLoader.LoadAddOn and not IsAddOnLoaded("TradeSkillMaster_Mailing") then | |
| 320 AddonLoader:LoadAddOn("TradeSkillMaster_Mailing"); | |
| 297 end | 321 end |
| 298 end | 322 end |
| 299 | 323 |
| 300 | 324 |
| 301 | 325 |
| 302 | 326 |
| 303 | 327 |
| 304 -- ADJUST POSITIONS | 328 -- ADJUST POSITIONS |
| 305 | 329 |
| 306 if self.QuickAuctionsEnabled then | 330 if self.ZeroAuctionsEnabled then |
| 307 -- QA is enabled so move the checkbox further to the right | 331 -- QA is enabled so move the checkbox further to the right |
| 308 | 332 |
| 309 self.cbOpenAll:SetPoint("TOPLEFT", MailFrame, "TOPLEFT", 155, -13); | 333 self.cbOpenAll:SetPoint("TOPLEFT", MailFrame, "TOPLEFT", 155, -13); |
| 310 end | 334 end |
| 311 | 335 |
| 322 | 346 |
| 323 -- Reset variables | 347 -- Reset variables |
| 324 lastAmount = 0; | 348 lastAmount = 0; |
| 325 self.debugChannel = nil; | 349 self.debugChannel = nil; |
| 326 | 350 |
| 327 --BETA:if (self.db.profile.uses % 15) == 0 then | 351 if not originalCheckInbox then |
| 328 --BETA: -- Automatically show once every 15 uses | 352 -- Override the CheckInbox function |
| 329 --BETA: self:ShowBetaPopup(); | 353 -- Remember the original |
| 330 --BETA:end | 354 originalCheckInbox = CheckInbox; |
| 355 -- Then override that | |
| 356 CheckInbox = NewCheckInbox; | |
| 357 end | |
| 331 | 358 |
| 332 -- If we were toggling this addon on while the mailbox is opened we must register all events again | 359 -- If we were toggling this addon on while the mailbox is opened we must register all events again |
| 333 if MailFrame:IsVisible() then | 360 if MailFrame:IsVisible() then |
| 334 self:MAIL_SHOW(); | 361 self:MAIL_SHOW(); |
| 335 end | 362 end |
| 337 | 364 |
| 338 function MailOpener:OnDisable() | 365 function MailOpener:OnDisable() |
| 339 self:UnregisterEvent("MAIL_SHOW"); | 366 self:UnregisterEvent("MAIL_SHOW"); |
| 340 | 367 |
| 341 self.btnConfig:Hide(); | 368 self.btnConfig:Hide(); |
| 369 | |
| 370 if originalCheckInbox then | |
| 371 -- Change checkinbox back to the original value | |
| 372 CheckInbox = originalCheckInbox; | |
| 373 -- Forget the other reference | |
| 374 originalCheckInbox = nil; | |
| 375 end | |
| 342 | 376 |
| 343 MailOpener:Stop(); | 377 MailOpener:Stop(); |
| 344 end | 378 end |
| 345 | 379 |
| 346 -- We must disable Quick Auction's auto mail (if set up that way in the settings) before opening the mailbox or it will instantly start sending stuff | 380 -- We must disable Quick Auction's auto mail (if set up that way in the settings) before opening the mailbox or it will instantly start sending stuff |
| 417 | 451 |
| 418 -- Hide the InboxTooMuchMail warning to allow room for our mail remaining info line | 452 -- Hide the InboxTooMuchMail warning to allow room for our mail remaining info line |
| 419 InboxTooMuchMail:Hide() | 453 InboxTooMuchMail:Hide() |
| 420 InboxTooMuchMail.Show = function() end | 454 InboxTooMuchMail.Show = function() end |
| 421 | 455 |
| 422 if self.QuickAuctionsEnabled then | 456 if self.ZeroAuctionsEnabled then |
| 423 local QAMail = LibStub("AceAddon-3.0"):GetAddon("QuickAuctions", true):GetModule("Mail", true); | 457 local AHAddon = LibStub("AceAddon-3.0"):GetAddon("ZeroAuctions", true) or LibStub("AceAddon-3.0"):GetAddon("AuctionProfitMaster", true); |
| 424 | 458 if AHAddon then |
| 425 if QAMail then | 459 local QAMail = AHAddon:GetModule("Mail", true); |
| 426 -- Hide the open all button | 460 |
| 427 QAMail.massOpening:Hide(); | 461 if QAMail then |
| 428 -- Hide the x mail remaining text | 462 if QAMail.massOpening then |
| 429 QAMail.totalMail:Hide(); | 463 -- Hide the open all button |
| 430 end | 464 QAMail.massOpening:Hide(); |
| 431 end | 465 end |
| 432 | 466 if QAMail.totalMail then |
| 467 -- Hide the x mail remaining text | |
| 468 QAMail.totalMail:Hide(); | |
| 469 end | |
| 470 end | |
| 471 end | |
| 472 end | |
| 473 | |
| 474 hasOpenedMailAlready = nil; | |
| 433 mailboxEmptySoundPlayed = nil; | 475 mailboxEmptySoundPlayed = nil; |
| 434 mailboxEmptySoundPlayedThisVisit = nil; | 476 mailboxEmptySoundPlayedThisVisit = nil; |
| 435 | 477 |
| 436 self:Recheck(); | 478 self:Recheck(); |
| 437 | 479 |
| 540 if not MailAddonBusy then | 582 if not MailAddonBusy then |
| 541 -- No other addon is currently active | 583 -- No other addon is currently active |
| 542 | 584 |
| 543 self:CancelTimer(self.tmrTryAgain, true); -- Insurance | 585 self:CancelTimer(self.tmrTryAgain, true); -- Insurance |
| 544 | 586 |
| 545 if QuickAuctionsAutoMail then | 587 if self.ZeroAuctionsEnabled and ZeroAuctionsAutoMail then |
| 546 -- Remember the last known quick auctions status | 588 -- Remember the last known quick auctions status |
| 547 lastQuickAuctionsStatus = QuickAuctionsAutoMail:GetChecked(); | 589 lastQuickAuctionsStatus = ZeroAuctionsAutoMail:GetChecked(); |
| 548 end | 590 end |
| 549 if self.db.profile.general.autoDisableQAAutoMail and self.QuickAuctionsEnabled and QuickAuctionsAutoMail and QuickAuctionsAutoMail:GetChecked() then | 591 if self.db.profile.general.autoDisableQAAutoMail and self.ZeroAuctionsEnabled and ZeroAuctionsAutoMail and ZeroAuctionsAutoMail:GetChecked() then |
| 550 -- If auto disable "QA Auto mail" is enabled and QA's auto mail is currently toggled on, turn it off | 592 -- If auto disable "QA Auto mail" is enabled and QA's auto mail is currently toggled on, turn it off |
| 551 -- We need to do this with a :click to trigger the right events | 593 -- We need to do this with a :click to trigger the right events |
| 552 | 594 |
| 553 self:Debug("Turning automail |cffff0000off|r."); | 595 self:Debug("Turning automail |cffff0000off|r."); |
| 554 | 596 |
| 555 QuickAuctionsAutoMail:Click(); | 597 ZeroAuctionsAutoMail:Click(); |
| 556 end | 598 end |
| 599 | |
| 557 | 600 |
| 558 MailAddonBusy = self:GetName(); | 601 MailAddonBusy = self:GetName(); |
| 559 | 602 |
| 560 self:Debug("MO_OPEN_MAIL"); | 603 self:Debug("MO_OPEN_MAIL"); |
| 561 | 604 |
| 562 -- Summon the mail opening gods | 605 -- Summon the mail opening gods |
| 563 self:SendMessage("MO_OPEN_MAIL"); | 606 self:SendMessage("MO_OPEN_MAIL"); |
| 564 else | 607 elseif MailAddonBusy ~= self:GetName() then |
| 565 -- Another addon is ACTIVE | 608 -- Another addon is ACTIVE |
| 566 self:Debug("Another addon active, waiting .5 seconds... (" .. MailAddonBusy .. ")"); | 609 self:Debug("Another addon active, waiting .5 seconds... (" .. MailAddonBusy .. ")"); |
| 567 | 610 |
| 568 self:CancelTimer(self.tmrTryAgain, true); -- Insurance | 611 self:CancelTimer(self.tmrTryAgain, true); -- Insurance |
| 569 -- Try again every 0.5 seconds | 612 -- Try again every 0.5 seconds |
| 574 | 617 |
| 575 function MailOpener:MO_OPEN_COMPLETE() | 618 function MailOpener:MO_OPEN_COMPLETE() |
| 576 if MailAddonBusy == self:GetName() then | 619 if MailAddonBusy == self:GetName() then |
| 577 MailAddonBusy = nil; | 620 MailAddonBusy = nil; |
| 578 end | 621 end |
| 622 | |
| 623 hasOpenedMailAlready = true; | |
| 579 | 624 |
| 580 -- Try a recheck | 625 -- Try a recheck |
| 581 self:Recheck(); | 626 self:Recheck(); |
| 582 | 627 |
| 583 local current, total = GetInboxNumItems(); | 628 local current, total = GetInboxNumItems(); |
| 590 mailboxEmptySoundPlayed = true; | 635 mailboxEmptySoundPlayed = true; |
| 591 mailboxEmptySoundPlayedThisVisit = true; | 636 mailboxEmptySoundPlayedThisVisit = true; |
| 592 end | 637 end |
| 593 end | 638 end |
| 594 | 639 |
| 595 if self.QuickAuctionsEnabled then | 640 if self.ZeroAuctionsEnabled then |
| 596 -- Quick Auctions enabled? | 641 -- Zero Auctions enabled? |
| 597 -- Toggle automailing as per settings | 642 -- Toggle automailing as per settings |
| 598 | 643 |
| 599 if self.db.profile.general.autoReenableQAAutoMail and QuickAuctionsAutoMail and not QuickAuctionsAutoMail:GetChecked() then | 644 if self.db.profile.general.autoReenableQAAutoMail and ZeroAuctionsAutoMail and not ZeroAuctionsAutoMail:GetChecked() then |
| 600 -- If auto re-enable "QA Auto mail" is enabled and QA's auto mail is currently toggled OFF, turn it on | 645 -- If auto re-enable "QA Auto mail" is enabled and QA's auto mail is currently toggled OFF, turn it on |
| 601 -- We need to do this with a :click to trigger the right events | 646 -- We need to do this with a :click to trigger the right events |
| 602 | 647 |
| 603 self:Debug("Turning automail |cff00ff00on|r."); | 648 self:Debug("Turning automail |cff00ff00on|r."); |
| 604 | 649 |
| 605 QuickAuctionsAutoMail:Click(); | 650 ZeroAuctionsAutoMail:Click(); |
| 606 elseif self.db.profile.general.autoSetBackQAAutoMail and QuickAuctionsAutoMail and lastQuickAuctionsStatus ~= QuickAuctionsAutoMail:GetChecked() then | 651 elseif self.db.profile.general.autoSetBackQAAutoMail and ZeroAuctionsAutoMail and lastQuickAuctionsStatus ~= ZeroAuctionsAutoMail:GetChecked() then |
| 607 -- If auto set back "QA Auto mail" is enabled and QA's auto mail is currently not the same as it was before starting, toggle it | 652 -- If auto set back "QA Auto mail" is enabled and QA's auto mail is currently not the same as it was before starting, toggle it |
| 608 -- We need to do this with a :click to trigger the right events | 653 -- We need to do this with a :click to trigger the right events |
| 609 | 654 |
| 610 if lastQuickAuctionsStatus then | 655 if lastQuickAuctionsStatus then |
| 611 self:Debug("Turning automail |cff00ff00on|r."); | 656 self:Debug("Turning automail |cff00ff00on|r."); |
| 612 else | 657 else |
| 613 self:Debug("Turning automail |cffff0000off|r."); | 658 self:Debug("Turning automail |cffff0000off|r."); |
| 614 end | 659 end |
| 615 | 660 |
| 616 QuickAuctionsAutoMail:Click(); | 661 ZeroAuctionsAutoMail:Click(); |
| 617 end | 662 end |
| 618 end | 663 end |
| 619 | 664 |
| 620 if self.db.profile.general.continueOpening then | 665 if self.db.profile.general.continueOpening then |
| 621 self:ScheduleOpen(true); | 666 self:ScheduleOpen(true); |
| 638 | 683 |
| 639 -- BeanCounter is the only addon hiding the mail close button while busy, so we can look for that | 684 -- BeanCounter is the only addon hiding the mail close button while busy, so we can look for that |
| 640 --local BeanCounterActive = not InboxCloseButton:IsVisible(); | 685 --local BeanCounterActive = not InboxCloseButton:IsVisible(); |
| 641 | 686 |
| 642 --if not BeanCounterActive and AutoOpenMail and not MailAddonBusy then | 687 --if not BeanCounterActive and AutoOpenMail and not MailAddonBusy then |
| 643 if AutoOpenMail and not MailAddonBusy then | 688 --if AutoOpenMail and not MailAddonBusy then |
| 689 if not MailAddonBusy then | |
| 644 -- Query the server | 690 -- Query the server |
| 645 CheckInbox(); | 691 CheckInbox(); |
| 646 end | 692 end |
| 647 | 693 |
| 648 -- Stop previous timer | 694 -- Stop previous timer |
| 657 -- Stop checking for new mail and unregister the events we needed | 703 -- Stop checking for new mail and unregister the events we needed |
| 658 function MailOpener:Stop() | 704 function MailOpener:Stop() |
| 659 if MailAddonBusy == self:GetName() then | 705 if MailAddonBusy == self:GetName() then |
| 660 MailAddonBusy = nil; | 706 MailAddonBusy = nil; |
| 661 end | 707 end |
| 708 | |
| 709 hasOpenedMailAlready = nil; | |
| 662 | 710 |
| 663 -- We won't need this anymore | 711 -- We won't need this anymore |
| 664 self:UnregisterEvent("MAIL_CLOSED"); | 712 self:UnregisterEvent("MAIL_CLOSED"); |
| 665 self:UnregisterEvent("PLAYER_LEAVING_WORLD"); | 713 self:UnregisterEvent("PLAYER_LEAVING_WORLD"); |
| 666 self:UnregisterEvent("MAIL_INBOX_UPDATE"); | 714 self:UnregisterEvent("MAIL_INBOX_UPDATE"); |
| 713 -- Postal must be enabled | 761 -- Postal must be enabled |
| 714 | 762 |
| 715 -- Toggle module (let Postal handle this) | 763 -- Toggle module (let Postal handle this) |
| 716 Postal.ToggleModule(nil, name, Postal:GetModule(name), status); | 764 Postal.ToggleModule(nil, name, Postal:GetModule(name), status); |
| 717 end | 765 end |
| 766 | |
| 767 if self.TSMMailingEnabled then | |
| 768 local TSMMailing = LibStub("AceAddon-3.0"):GetAddon("TradeSkillMaster_Mailing"); | |
| 769 if TSMMailing and TSMMailing.massOpening then | |
| 770 if not status then | |
| 771 TSMMailing.massOpening:Hide(); | |
| 772 else | |
| 773 TSMMailing.massOpening:Show(); | |
| 774 end | |
| 775 end | |
| 776 end | |
| 718 end | 777 end |
| 719 | 778 |
| 720 -- Change Quick Auction's auto mail status based on our prefered settings | 779 -- Change Quick Auction's auto mail status based on our prefered settings |
| 721 function MailOpener:ToggleQAStatus() | 780 function MailOpener:ToggleQAStatus() |
| 722 self:Debug("defaultQAStatus:" .. self.db.profile.general.defaultQAStatus); | 781 self:Debug("defaultQAStatus:" .. self.db.profile.general.defaultQAStatus); |
| 723 | 782 |
| 724 if self.QuickAuctionsEnabled and self.db.profile.general.defaultQAStatus ~= "__remember" and QuickAuctionsAutoMail then | 783 if self.ZeroAuctionsEnabled and self.db.profile.general.defaultQAStatus ~= "__remember" and ZeroAuctionsAutoMail then |
| 725 if self.db.profile.general.defaultQAStatus == "_enabled" and not QuickAuctionsAutoMail:GetChecked() then | 784 if self.db.profile.general.defaultQAStatus == "_enabled" and not ZeroAuctionsAutoMail:GetChecked() then |
| 726 self:Debug("Turning automail |cff00ff00on|r."); | 785 self:Debug("Turning automail |cff00ff00on|r."); |
| 727 | 786 |
| 728 QuickAuctionsAutoMail:Click(); | 787 ZeroAuctionsAutoMail:Click(); |
| 729 elseif self.db.profile.general.defaultQAStatus == "disabled" and QuickAuctionsAutoMail:GetChecked() then | 788 elseif self.db.profile.general.defaultQAStatus == "disabled" and ZeroAuctionsAutoMail:GetChecked() then |
| 730 self:Debug("Turning automail |cffff0000off|r."); | 789 self:Debug("Turning automail |cffff0000off|r."); |
| 731 | 790 |
| 732 QuickAuctionsAutoMail:Click(); | 791 ZeroAuctionsAutoMail:Click(); |
| 733 end | 792 end |
| 734 end | 793 end |
| 735 end | 794 end |
| 736 | 795 |
| 737 function MailOpener:FormatMoney(copper) | 796 function MailOpener:FormatMoney(copper) |
| 751 -- General copy window for multiple things (clickable URLs, the time remaining, and such) | 810 -- General copy window for multiple things (clickable URLs, the time remaining, and such) |
| 752 StaticPopupDialogs["MailOpenerCopyWindow"] = { | 811 StaticPopupDialogs["MailOpenerCopyWindow"] = { |
| 753 text = L["Press CTRL-C to copy."], | 812 text = L["Press CTRL-C to copy."], |
| 754 button2 = CLOSE, | 813 button2 = CLOSE, |
| 755 hasEditBox = 1, | 814 hasEditBox = 1, |
| 756 hasWideEditBox = 1, | 815 editBoxWidth = 360, |
| 757 OnShow = function() | 816 OnShow = function(self) |
| 758 local editBox = _G[this:GetName().."WideEditBox"]; | 817 if self.editBox and MailOpener.currentPopupContents then |
| 759 if editBox and MailOpener.currentPopupContents then | 818 self.editBox:SetText(MailOpener.currentPopupContents); |
| 760 editBox:SetText(MailOpener.currentPopupContents); | 819 self.editBox:SetFocus(); |
| 761 editBox:SetFocus(); | 820 self.editBox:HighlightText(0); |
| 762 editBox:HighlightText(0); | |
| 763 end | 821 end |
| 764 | 822 |
| 765 -- Position the close button in the middle | 823 -- Position the close button in the middle |
| 766 local button = _G[this:GetName().."Button2"]; | 824 if self.button2 then |
| 767 if button then | |
| 768 -- Remove previous know position | 825 -- Remove previous know position |
| 769 button:ClearAllPoints(); | 826 self.button2:ClearAllPoints(); |
| 770 button:SetWidth(200); | 827 self.button2:SetWidth(200); |
| 771 -- Reposition in the center | 828 -- Reposition in the center |
| 772 button:SetPoint("CENTER", editBox, "CENTER", 0, -30); | 829 self.button2:SetPoint("CENTER", self.editBox, "CENTER", 0, -30); |
| 773 end | 830 end |
| 774 end, | 831 end, |
| 775 EditBoxOnEscapePressed = function(self) | 832 EditBoxOnEscapePressed = function(self) |
| 776 self:GetParent():Hide(); | 833 self:GetParent():Hide(); |
| 777 end, | 834 end, |
| 779 whileDead = 1, | 836 whileDead = 1, |
| 780 hideOnEscape = 1, | 837 hideOnEscape = 1, |
| 781 maxLetters = 1024, | 838 maxLetters = 1024, |
| 782 }; | 839 }; |
| 783 | 840 |
| 784 --BETA: The below either has to be removed or changed when releasing | 841 |
| 785 | 842 -- The idea for this is to wait with refresing while there is still mail remaining which can be opened |
| 786 --[[ | 843 -- This should speed things up a tiny bit, but might become buggy if coded wrong |
| 787 BETA/ALPHA request box | 844 -- We actually override the function in the onenable |
| 788 function MailOpener:ShowBetaPopup() | 845 function NewCheckInbox(...) |
| 789 function TableDump(key, val, jumps) | 846 if not MailOpener.db.profile.general.overrideCheckInbox or not MailOpener.db.profile.general.continueOpening or not AutoOpenMail or not lastAmount or lastAmount == 0 then |
| 790 local cache = ""; | 847 -- If the override Check Inbox option is off |
| 791 | 848 -- or continuous opening is off |
| 792 if not jumps then | 849 -- or there's currently no mail visible |
| 793 jumps = 0; | 850 |
| 794 end | 851 MailOpener:Debug("CheckInbox:" .. tostring((not MailOpener.db.profile.general.overrideCheckInbox)) .. "/" .. tostring((not MailOpener.db.profile.general.continueOpening)) .. "/" .. tostring(lastAmount == 0)); |
| 795 | 852 |
| 796 local spacer = ""; | 853 -- Just call the original function |
| 797 if jumps > 0 then | 854 return originalCheckInbox(...); |
| 798 for i = 1, jumps do | 855 end |
| 799 spacer = spacer .. " "; | 856 |
| 800 end | 857 if not hasOpenedMailAlready then |
| 801 end | 858 -- If MO hasn't opened mail yet, we wait. |
| 802 | 859 -- MO will call this function when mail opening is done |
| 803 if type(val) == "table" then | 860 |
| 804 cache = cache .. spacer .. key .. " = {\n"; | 861 MailOpener:Debug("CheckInbox:Waiting..."); |
| 805 foreach(val, function(k, v) | 862 |
| 806 cache = cache .. TableDump(k, v, (jumps + 1)); | 863 return false; |
| 807 end); | 864 else |
| 808 cache = cache .. spacer .. "},\n"; | 865 MailOpener:Debug("CheckInbox:Refresh!"); |
| 809 else | 866 |
| 810 cache = cache .. spacer .. key .. " = " .. tostring(val) .. ",\n"; | 867 return originalCheckInbox(...); |
| 811 end | 868 end |
| 812 | 869 end |
| 813 return cache; | |
| 814 end | |
| 815 | |
| 816 local cache = ""; | |
| 817 foreach(MailOpener.db.profile, function(k, v) | |
| 818 cache = cache .. TableDump(k, v, 0); | |
| 819 end); | |
| 820 | |
| 821 local AceGUI = LibStub("AceGUI-3.0"); | |
| 822 local frame = AceGUI:Create("Frame"); | |
| 823 frame:SetTitle("Mail Opener ALPHA"); | |
| 824 frame:SetWidth(575); | |
| 825 frame:SetHeight(375); | |
| 826 | |
| 827 -- Add a normal description label | |
| 828 local desc = AceGUI:Create("Label"); | |
| 829 desc:SetText("|cff00ff00After you have been using Mail Opener for a while and configured it just as you want it to be, please report your favorite settings by copying the text below at either of the below links. Thanks in advance!|r\n\n"); | |
| 830 desc:SetFont(GameFontHighlightSmall:GetFont(), 13); | |
| 831 desc:SetFullWidth(true); | |
| 832 frame:AddChild(desc); | |
| 833 | |
| 834 -- Add a MultiLineEditBox | |
| 835 local settingsMLEEB = AceGUI:Create("MultiLineEditBox"); | |
| 836 settingsMLEEB:SetText(cache); | |
| 837 settingsMLEEB:SetLabel("Hit CTRL-A to select all and CTRL-C to copy the text. You can then use CTRL-V to paste."); | |
| 838 settingsMLEEB:SetFullWidth(true); | |
| 839 settingsMLEEB:SetNumLines(8); | |
| 840 settingsMLEEB:DisableButton(true); | |
| 841 settingsMLEEB:SetCallback("OnTextChanged", function() | |
| 842 settingsMLEEB:SetText(cache); | |
| 843 end); | |
| 844 frame:AddChild(settingsMLEEB); | |
| 845 | |
| 846 -- Empty line between the two links | |
| 847 local label = AceGUI:Create("Label"); | |
| 848 label:SetText("Please post the above text at either of these two links:"); | |
| 849 label:SetFullWidth(true); | |
| 850 frame:AddChild(label); | |
| 851 | |
| 852 local desc1 = AceGUI:Create("InteractiveLabel"); | |
| 853 desc1:SetText("|cff00bbbb[http://wow.curseforge.com/addons/mailopener/create-ticket/]|r"); | |
| 854 desc1:SetFont(GameFontHighlightSmall:GetFont(), 13); | |
| 855 desc1:SetFullWidth(true); | |
| 856 desc1:SetCallback("OnClick", function() | |
| 857 MailOpener.currentPopupContents = "http://wow.curseforge.com/addons/mailopener/create-ticket/"; | |
| 858 | |
| 859 StaticPopup_Show("MailOpenerCopyWindow"); | |
| 860 end); | |
| 861 desc1:SetCallback("OnEnter", function() | |
| 862 frame:SetStatusText("Click to copy this URL."); | |
| 863 end); | |
| 864 desc1:SetCallback("OnLeave", function() | |
| 865 frame:SetStatusText(""); | |
| 866 end); | |
| 867 frame:AddChild(desc1); | |
| 868 | |
| 869 -- Empty line between the two links | |
| 870 local spacer = AceGUI:Create("Label"); | |
| 871 spacer:SetText(" "); | |
| 872 frame:AddChild(spacer); | |
| 873 | |
| 874 local desc2 = AceGUI:Create("InteractiveLabel"); | |
| 875 desc2:SetText("|cff00bbbb[http://20kleveling.com/JMTCforum/posting.php?mode=reply&f=9&t=1403]|r"); | |
| 876 desc2:SetFont(GameFontHighlightSmall:GetFont(), 13); | |
| 877 desc2:SetFullWidth(true); | |
| 878 desc2:SetCallback("OnClick", function() | |
| 879 MailOpener.currentPopupContents = "http://20kleveling.com/JMTCforum/posting.php?mode=reply&f=9&t=1403"; | |
| 880 | |
| 881 StaticPopup_Show("MailOpenerCopyWindow"); | |
| 882 end); | |
| 883 desc2:SetCallback("OnEnter", function() | |
| 884 frame:SetStatusText("Click to copy this URL."); | |
| 885 end); | |
| 886 desc2:SetCallback("OnLeave", function() | |
| 887 frame:SetStatusText(""); | |
| 888 end); | |
| 889 frame:AddChild(desc2); | |
| 890 | |
| 891 -- Empty line between the two links | |
| 892 local label = AceGUI:Create("Label"); | |
| 893 label:SetText("\n\nps. You can always view this window again at a later time by clicking the \"Config\" button in the mail frame.\nps2. The information above is completely Mail Opener related. It will be used to determine the best default settings."); | |
| 894 label:SetFullWidth(true); | |
| 895 frame:AddChild(label); | |
| 896 end | |
| 897 ]] |
