Mercurial > wow > mailopener
diff 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 |
line wrap: on
line diff
--- a/Modules/OpenAll.lua Sun Sep 12 20:28:39 2010 +0200 +++ b/Modules/OpenAll.lua Sun Sep 12 20:30:46 2010 +0200 @@ -40,12 +40,116 @@ if not self.btnOpenAll then -- Open all button local button = CreateFrame("Button", "btnMailOpenerOpenAll", InboxFrame, "UIPanelButtonTemplate"); - button:SetText("Open all"); + button.originalText = "Open all"; -- we will use this in the tooltip and to set this text back after opening + button:SetText(button.originalText); button:SetHeight(26); button:SetWidth(120); button:SetPoint("BOTTOM", InboxFrame, "CENTER", -10, -165); - button:SetScript("OnClick", function() - mod:Open(true, IsShiftKeyDown()); + button:RegisterForClicks("LeftButtonUp", "RightButtonUp"); + button:SetScript("OnClick", function(self, mouseButton) + if mouseButton == "RightButton" then + -- Hide the gametooltip + GameTooltip:Hide(); + + if not mod.ddmFilters then + -- Build the drop down menu + local info = {}; + + local dropDownMenu = CreateFrame("Frame", "MailOpenerFiltersDropDownMenu"); + dropDownMenu.displayMode = "MENU"; + dropDownMenu.initialize = function(s, level) + if not level then return; end + + if level == 1 then + -- Create the title of the menu + info.isTitle = true; + info.text = "Toggle filters for " .. MailOpener.db:GetCurrentProfile() .. " profile."; + info.notCheckable = true; + UIDropDownMenu_AddButton(info, level); + + -- Reset title specific values + info.isTitle = nil; + info.disabled = nil; + info.notCheckable = nil; + + -- We don't want to close the DDM when something is toggled + info.keepShownOnClick = true; + + -- Make Auction canceled option + info.text = "Auction canceled"; + info.func = function(this) mod.db.profile.filter.AH.canceled = this.checked; end; + info.checked = mod.db.profile.filter.AH.canceled; + UIDropDownMenu_AddButton(info, level); + + -- Make Auction expired option + info.text = "Auction expired"; + info.func = function(this) mod.db.profile.filter.AH.expired = this.checked; end; + info.checked = mod.db.profile.filter.AH.expired; + UIDropDownMenu_AddButton(info, level); + + -- Make Auction outbid option + info.text = "Auction outbid"; + info.func = function(this) mod.db.profile.filter.AH.outbid = this.checked; end; + info.checked = mod.db.profile.filter.AH.outbid; + UIDropDownMenu_AddButton(info, level); + + -- Make Auction successful option + info.text = "Auction successful"; + info.func = function(this) mod.db.profile.filter.AH.success = this.checked; end; + info.checked = mod.db.profile.filter.AH.success; + UIDropDownMenu_AddButton(info, level); + + -- Make Auction won option + info.text = "Auction won"; + info.func = function(this) mod.db.profile.filter.AH.won = this.checked; end; + info.checked = mod.db.profile.filter.AH.won; + UIDropDownMenu_AddButton(info, level); + + -- Make Other mail with attachments + info.text = "Other mail with attachments"; + info.func = function(this) mod.db.profile.filter.normalAttachments = this.checked; end; + info.checked = mod.db.profile.filter.normalAttachments; + UIDropDownMenu_AddButton(info, level); + + -- Make Other mail with gold + info.text = "Other mail with gold"; + info.func = function(this) mod.db.profile.filter.normalMoney = this.checked; end; + info.checked = mod.db.profile.filter.normalMoney; + UIDropDownMenu_AddButton(info, level); + + -- Make Other mail with gold + info.text = CLOSE; + info.func = function() CloseDropDownMenus(); end; + info.checked = nil; + info.notCheckable = true; + UIDropDownMenu_AddButton(info, level); + + wipe(info); + end + end + + mod.ddmFilters = dropDownMenu; + end + + ToggleDropDownMenu(1, nil, mod.ddmFilters, self:GetName(), 0, 0); + else + mod:Open(true, IsShiftKeyDown()); + end + end); + 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."; + button:SetScript("OnEnter", function(self) + GameTooltip:SetOwner(self, "ANCHOR_NONE") + GameTooltip:SetPoint("BOTTOM", self, "TOP") + GameTooltip:SetText(self.originalText, 1, .82, 0, 1) + + if type(button.tooltip) == "string" then + GameTooltip:AddLine(button.tooltip, 1, 1, 1, 1); + end + + GameTooltip:Show(); + end); + button:SetScript("OnLeave", function(self) + GameTooltip:Hide(); end); self.btnOpenAll = button; @@ -634,7 +738,7 @@ if openingStatus then self.btnOpenAll:SetText("Opening..."); else - self.btnOpenAll:SetText("Open all"); + self.btnOpenAll:SetText(self.btnOpenAll.originalText); end end
