Mercurial > wow > mailopener
comparison Modules/OpenAll.lua @ 48:f630d882d008
Added a tooltip to the "Open all"-button showing the possible events (shift click and right click).
Right clicking the "Open all"-button will now show a drop down menu with the possible filters, allowing you to quickly toggle them.
| author | Zerotorescue |
|---|---|
| date | Sun, 12 Sep 2010 20:30:46 +0200 |
| parents | 1805df31794d |
| children | 8e2138877ebf |
comparison
equal
deleted
inserted
replaced
| 47:1243c2d2b85e | 48:f630d882d008 |
|---|---|
| 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.originalText = "Open all"; -- we will use this in the tooltip and to set this text back after opening |
| 44 button:SetText(button.originalText); | |
| 44 button:SetHeight(26); | 45 button:SetHeight(26); |
| 45 button:SetWidth(120); | 46 button:SetWidth(120); |
| 46 button:SetPoint("BOTTOM", InboxFrame, "CENTER", -10, -165); | 47 button:SetPoint("BOTTOM", InboxFrame, "CENTER", -10, -165); |
| 47 button:SetScript("OnClick", function() | 48 button:RegisterForClicks("LeftButtonUp", "RightButtonUp"); |
| 48 mod:Open(true, IsShiftKeyDown()); | 49 button:SetScript("OnClick", function(self, mouseButton) |
| 50 if mouseButton == "RightButton" then | |
| 51 -- Hide the gametooltip | |
| 52 GameTooltip:Hide(); | |
| 53 | |
| 54 if not mod.ddmFilters then | |
| 55 -- Build the drop down menu | |
| 56 local info = {}; | |
| 57 | |
| 58 local dropDownMenu = CreateFrame("Frame", "MailOpenerFiltersDropDownMenu"); | |
| 59 dropDownMenu.displayMode = "MENU"; | |
| 60 dropDownMenu.initialize = function(s, level) | |
| 61 if not level then return; end | |
| 62 | |
| 63 if level == 1 then | |
| 64 -- Create the title of the menu | |
| 65 info.isTitle = true; | |
| 66 info.text = "Toggle filters for " .. MailOpener.db:GetCurrentProfile() .. " profile."; | |
| 67 info.notCheckable = true; | |
| 68 UIDropDownMenu_AddButton(info, level); | |
| 69 | |
| 70 -- Reset title specific values | |
| 71 info.isTitle = nil; | |
| 72 info.disabled = nil; | |
| 73 info.notCheckable = nil; | |
| 74 | |
| 75 -- We don't want to close the DDM when something is toggled | |
| 76 info.keepShownOnClick = true; | |
| 77 | |
| 78 -- Make Auction canceled option | |
| 79 info.text = "Auction canceled"; | |
| 80 info.func = function(this) mod.db.profile.filter.AH.canceled = this.checked; end; | |
| 81 info.checked = mod.db.profile.filter.AH.canceled; | |
| 82 UIDropDownMenu_AddButton(info, level); | |
| 83 | |
| 84 -- Make Auction expired option | |
| 85 info.text = "Auction expired"; | |
| 86 info.func = function(this) mod.db.profile.filter.AH.expired = this.checked; end; | |
| 87 info.checked = mod.db.profile.filter.AH.expired; | |
| 88 UIDropDownMenu_AddButton(info, level); | |
| 89 | |
| 90 -- Make Auction outbid option | |
| 91 info.text = "Auction outbid"; | |
| 92 info.func = function(this) mod.db.profile.filter.AH.outbid = this.checked; end; | |
| 93 info.checked = mod.db.profile.filter.AH.outbid; | |
| 94 UIDropDownMenu_AddButton(info, level); | |
| 95 | |
| 96 -- Make Auction successful option | |
| 97 info.text = "Auction successful"; | |
| 98 info.func = function(this) mod.db.profile.filter.AH.success = this.checked; end; | |
| 99 info.checked = mod.db.profile.filter.AH.success; | |
| 100 UIDropDownMenu_AddButton(info, level); | |
| 101 | |
| 102 -- Make Auction won option | |
| 103 info.text = "Auction won"; | |
| 104 info.func = function(this) mod.db.profile.filter.AH.won = this.checked; end; | |
| 105 info.checked = mod.db.profile.filter.AH.won; | |
| 106 UIDropDownMenu_AddButton(info, level); | |
| 107 | |
| 108 -- Make Other mail with attachments | |
| 109 info.text = "Other mail with attachments"; | |
| 110 info.func = function(this) mod.db.profile.filter.normalAttachments = this.checked; end; | |
| 111 info.checked = mod.db.profile.filter.normalAttachments; | |
| 112 UIDropDownMenu_AddButton(info, level); | |
| 113 | |
| 114 -- Make Other mail with gold | |
| 115 info.text = "Other mail with gold"; | |
| 116 info.func = function(this) mod.db.profile.filter.normalMoney = this.checked; end; | |
| 117 info.checked = mod.db.profile.filter.normalMoney; | |
| 118 UIDropDownMenu_AddButton(info, level); | |
| 119 | |
| 120 -- Make Other mail with gold | |
| 121 info.text = CLOSE; | |
| 122 info.func = function() CloseDropDownMenus(); end; | |
| 123 info.checked = nil; | |
| 124 info.notCheckable = true; | |
| 125 UIDropDownMenu_AddButton(info, level); | |
| 126 | |
| 127 wipe(info); | |
| 128 end | |
| 129 end | |
| 130 | |
| 131 mod.ddmFilters = dropDownMenu; | |
| 132 end | |
| 133 | |
| 134 ToggleDropDownMenu(1, nil, mod.ddmFilters, self:GetName(), 0, 0); | |
| 135 else | |
| 136 mod:Open(true, IsShiftKeyDown()); | |
| 137 end | |
| 138 end); | |
| 139 button.tooltip = "Hold |cfffed000shift|r while clicking this button to temporarily override your filters and loot every single mail contain attachments and gold.\n\n|cfffed000Right|r click this button to quickly adjust mail opening filters for this profile."; | |
| 140 button:SetScript("OnEnter", function(self) | |
| 141 GameTooltip:SetOwner(self, "ANCHOR_NONE") | |
| 142 GameTooltip:SetPoint("BOTTOM", self, "TOP") | |
| 143 GameTooltip:SetText(self.originalText, 1, .82, 0, 1) | |
| 144 | |
| 145 if type(button.tooltip) == "string" then | |
| 146 GameTooltip:AddLine(button.tooltip, 1, 1, 1, 1); | |
| 147 end | |
| 148 | |
| 149 GameTooltip:Show(); | |
| 150 end); | |
| 151 button:SetScript("OnLeave", function(self) | |
| 152 GameTooltip:Hide(); | |
| 49 end); | 153 end); |
| 50 | 154 |
| 51 self.btnOpenAll = button; | 155 self.btnOpenAll = button; |
| 52 end | 156 end |
| 53 | 157 |
| 632 opening = openingStatus; | 736 opening = openingStatus; |
| 633 | 737 |
| 634 if openingStatus then | 738 if openingStatus then |
| 635 self.btnOpenAll:SetText("Opening..."); | 739 self.btnOpenAll:SetText("Opening..."); |
| 636 else | 740 else |
| 637 self.btnOpenAll:SetText("Open all"); | 741 self.btnOpenAll:SetText(self.btnOpenAll.originalText); |
| 638 end | 742 end |
| 639 end | 743 end |
| 640 | 744 |
| 641 function mod:GetOptionsGroup() | 745 function mod:GetOptionsGroup() |
| 642 local configGroup = { | 746 local configGroup = { |
