annotate Modules/OpenAll.lua @ 62:1a4b2e73cef3

Changelog update. Added a few tips. Removed the useless welcome and goodbye notifications. Fixed wording of the filters at open all to make things clearer.
author Zerotorescue
date Tue, 14 Sep 2010 00:32:00 +0200
parents 5f0e174c8adc
children eadff31e61e8
rev   line source
Zerotorescue@0 1 local MailOpener = LibStub("AceAddon-3.0"):GetAddon("MailOpener");
Zerotorescue@31 2 local mod = MailOpener:NewModule("OpenAll", "AceEvent-3.0", "AceTimer-3.0");
Zerotorescue@31 3
Zerotorescue@31 4 mod.moduleDescription = "The actual mail opening initiated by the core.";
Zerotorescue@31 5 mod.moduleRequired = true;
Zerotorescue@0 6
Zerotorescue@3 7 --[[
Zerotorescue@3 8 Dev notes:
Zerotorescue@3 9 When shift clicking the Open All button it should override all filters.
Zerotorescue@3 10 ]]
Zerotorescue@3 11
Zerotorescue@46 12 local MAIL_ITEM_INDEX, MAIL_OPEN_EVERYTHING, mailTimer, inventoryFull, inventoryFullSoundPlayed, inventoryFullSoundPlayedThisVisit, opening, lastSync, numCurrentMail, numHiddenMail, continue;
Zerotorescue@0 13
Zerotorescue@31 14 function mod:OnInitialize()
Zerotorescue@0 15 local defaults = {
Zerotorescue@0 16 profile = {
Zerotorescue@0 17 speed = 0.05,
Zerotorescue@0 18 keepFreeSpace = 0,
Zerotorescue@0 19 filter = {
Zerotorescue@0 20 AH = {
Zerotorescue@0 21 canceled = true,
Zerotorescue@0 22 expired = true,
Zerotorescue@0 23 outbid = true,
Zerotorescue@0 24 success = true,
Zerotorescue@0 25 won = true,
Zerotorescue@0 26 },
Zerotorescue@0 27 normalAttachments = false,
Zerotorescue@0 28 normalMoney = true,
Zerotorescue@50 29 allowShiftClick = true,
Zerotorescue@0 30 },
Zerotorescue@0 31 },
Zerotorescue@0 32 };
Zerotorescue@0 33
Zerotorescue@0 34 -- Register our saved variables NameSpace
Zerotorescue@0 35 self.db = MailOpener.db:RegisterNamespace("OpenAll", defaults);
Zerotorescue@0 36 end
Zerotorescue@0 37
Zerotorescue@31 38 function mod:OnEnable()
Zerotorescue@0 39 self:RegisterEvent("MAIL_SHOW");
Zerotorescue@42 40
Zerotorescue@0 41 if not self.btnOpenAll then
Zerotorescue@0 42 -- Open all button
Zerotorescue@46 43 local button = CreateFrame("Button", "btnMailOpenerOpenAll", InboxFrame, "UIPanelButtonTemplate");
Zerotorescue@50 44 button:SetText("Open all");
Zerotorescue@46 45 button:SetHeight(26);
Zerotorescue@46 46 button:SetWidth(120);
Zerotorescue@46 47 button:SetPoint("BOTTOM", InboxFrame, "CENTER", -10, -165);
Zerotorescue@48 48 button:RegisterForClicks("LeftButtonUp", "RightButtonUp");
Zerotorescue@48 49 button:SetScript("OnClick", function(self, mouseButton)
Zerotorescue@48 50 if mouseButton == "RightButton" then
Zerotorescue@48 51 -- Hide the gametooltip
Zerotorescue@48 52 GameTooltip:Hide();
Zerotorescue@48 53
Zerotorescue@48 54 if not mod.ddmFilters then
Zerotorescue@48 55 -- Build the drop down menu
Zerotorescue@48 56 local info = {};
Zerotorescue@48 57
Zerotorescue@48 58 local dropDownMenu = CreateFrame("Frame", "MailOpenerFiltersDropDownMenu");
Zerotorescue@48 59 dropDownMenu.displayMode = "MENU";
Zerotorescue@48 60 dropDownMenu.initialize = function(s, level)
Zerotorescue@48 61 if not level then return; end
Zerotorescue@48 62
Zerotorescue@48 63 if level == 1 then
Zerotorescue@48 64 -- Create the title of the menu
Zerotorescue@48 65 info.isTitle = true;
Zerotorescue@48 66 info.text = "Toggle filters for " .. MailOpener.db:GetCurrentProfile() .. " profile.";
Zerotorescue@48 67 info.notCheckable = true;
Zerotorescue@48 68 UIDropDownMenu_AddButton(info, level);
Zerotorescue@48 69
Zerotorescue@48 70 -- Reset title specific values
Zerotorescue@48 71 info.isTitle = nil;
Zerotorescue@48 72 info.disabled = nil;
Zerotorescue@48 73 info.notCheckable = nil;
Zerotorescue@48 74
Zerotorescue@48 75 -- We don't want to close the DDM when something is toggled
Zerotorescue@48 76 info.keepShownOnClick = true;
Zerotorescue@48 77
Zerotorescue@48 78 -- Make Auction canceled option
Zerotorescue@48 79 info.text = "Auction canceled";
Zerotorescue@48 80 info.func = function(this) mod.db.profile.filter.AH.canceled = this.checked; end;
Zerotorescue@48 81 info.checked = mod.db.profile.filter.AH.canceled;
Zerotorescue@48 82 UIDropDownMenu_AddButton(info, level);
Zerotorescue@48 83
Zerotorescue@48 84 -- Make Auction expired option
Zerotorescue@48 85 info.text = "Auction expired";
Zerotorescue@48 86 info.func = function(this) mod.db.profile.filter.AH.expired = this.checked; end;
Zerotorescue@48 87 info.checked = mod.db.profile.filter.AH.expired;
Zerotorescue@48 88 UIDropDownMenu_AddButton(info, level);
Zerotorescue@48 89
Zerotorescue@48 90 -- Make Auction outbid option
Zerotorescue@48 91 info.text = "Auction outbid";
Zerotorescue@48 92 info.func = function(this) mod.db.profile.filter.AH.outbid = this.checked; end;
Zerotorescue@48 93 info.checked = mod.db.profile.filter.AH.outbid;
Zerotorescue@48 94 UIDropDownMenu_AddButton(info, level);
Zerotorescue@48 95
Zerotorescue@48 96 -- Make Auction successful option
Zerotorescue@48 97 info.text = "Auction successful";
Zerotorescue@48 98 info.func = function(this) mod.db.profile.filter.AH.success = this.checked; end;
Zerotorescue@48 99 info.checked = mod.db.profile.filter.AH.success;
Zerotorescue@48 100 UIDropDownMenu_AddButton(info, level);
Zerotorescue@48 101
Zerotorescue@48 102 -- Make Auction won option
Zerotorescue@48 103 info.text = "Auction won";
Zerotorescue@48 104 info.func = function(this) mod.db.profile.filter.AH.won = this.checked; end;
Zerotorescue@48 105 info.checked = mod.db.profile.filter.AH.won;
Zerotorescue@48 106 UIDropDownMenu_AddButton(info, level);
Zerotorescue@48 107
Zerotorescue@48 108 -- Make Other mail with attachments
Zerotorescue@48 109 info.text = "Other mail with attachments";
Zerotorescue@48 110 info.func = function(this) mod.db.profile.filter.normalAttachments = this.checked; end;
Zerotorescue@48 111 info.checked = mod.db.profile.filter.normalAttachments;
Zerotorescue@48 112 UIDropDownMenu_AddButton(info, level);
Zerotorescue@48 113
Zerotorescue@48 114 -- Make Other mail with gold
Zerotorescue@48 115 info.text = "Other mail with gold";
Zerotorescue@48 116 info.func = function(this) mod.db.profile.filter.normalMoney = this.checked; end;
Zerotorescue@48 117 info.checked = mod.db.profile.filter.normalMoney;
Zerotorescue@48 118 UIDropDownMenu_AddButton(info, level);
Zerotorescue@48 119
Zerotorescue@48 120 -- Make Other mail with gold
Zerotorescue@48 121 info.text = CLOSE;
Zerotorescue@48 122 info.func = function() CloseDropDownMenus(); end;
Zerotorescue@48 123 info.checked = nil;
Zerotorescue@48 124 info.notCheckable = true;
Zerotorescue@48 125 UIDropDownMenu_AddButton(info, level);
Zerotorescue@48 126
Zerotorescue@48 127 wipe(info);
Zerotorescue@48 128 end
Zerotorescue@48 129 end
Zerotorescue@48 130
Zerotorescue@48 131 mod.ddmFilters = dropDownMenu;
Zerotorescue@48 132 end
Zerotorescue@48 133
Zerotorescue@48 134 ToggleDropDownMenu(1, nil, mod.ddmFilters, self:GetName(), 0, 0);
Zerotorescue@48 135 else
Zerotorescue@48 136 mod:Open(true, IsShiftKeyDown());
Zerotorescue@48 137 end
Zerotorescue@48 138 end);
Zerotorescue@50 139 button.tooltipTitle = "Open all";
Zerotorescue@62 140 button.tooltip = "Hold |cfffed000shift|r while clicking this button to temporarily override your filters and loot every single mail containing attachments and/or gold.\n\n|cfffed000Right|r click this button to quickly adjust mail opening filters for this profile.";
Zerotorescue@48 141 button:SetScript("OnEnter", function(self)
Zerotorescue@51 142 if MailOpener.db.profile.general.showHelpTooltips then
Zerotorescue@51 143 GameTooltip:SetOwner(self, "ANCHOR_NONE")
Zerotorescue@51 144 GameTooltip:SetPoint("BOTTOM", self, "TOP")
Zerotorescue@51 145 GameTooltip:SetText(self.tooltipTitle, 1, .82, 0, 1)
Zerotorescue@51 146
Zerotorescue@51 147 if type(self.tooltip) == "string" then
Zerotorescue@51 148 GameTooltip:AddLine(self.tooltip, 1, 1, 1, 1);
Zerotorescue@51 149 end
Zerotorescue@51 150
Zerotorescue@51 151 GameTooltip:Show();
Zerotorescue@48 152 end
Zerotorescue@48 153 end);
Zerotorescue@48 154 button:SetScript("OnLeave", function(self)
Zerotorescue@48 155 GameTooltip:Hide();
Zerotorescue@46 156 end);
Zerotorescue@0 157
Zerotorescue@0 158 self.btnOpenAll = button;
Zerotorescue@0 159 end
Zerotorescue@0 160
Zerotorescue@0 161 self.btnOpenAll:Show();
Zerotorescue@0 162
Zerotorescue@0 163 if not self.timeLeftFrame then
Zerotorescue@0 164 -- If the timeLeftFrame doesn't exist we will have to build it
Zerotorescue@0 165
Zerotorescue@0 166 self:Debug("Building text frame");
Zerotorescue@0 167
Zerotorescue@0 168 local frame = CreateFrame("Button", "MailOpenerTimeLeftButton", InboxFrame);
Zerotorescue@0 169
Zerotorescue@0 170 -- Mail counter
Zerotorescue@0 171 frame.text = frame:CreateFontString("MailOpenerTimeLeftFrameMailCount", "OVERLAY", "GameFontHighlight");
Zerotorescue@0 172 frame.text:SetPoint("CENTER", MailFrame, "TOPLEFT", 40, -35);
Zerotorescue@0 173
Zerotorescue@0 174 -- Long time left indicator
Zerotorescue@0 175 frame.smallText = frame:CreateFontString("MailOpenerTimeLeftFrameTimeRemaining", "OVERLAY", "GameFontNormal");
Zerotorescue@0 176 frame.smallText:SetFont(GameFontHighlight:GetFont(), 11, "OUTLINE");
Zerotorescue@0 177 frame.smallText:SetPoint("TOPLEFT", MailFrame, "TOPLEFT", 75, -38);
Zerotorescue@0 178 frame.smallText:SetWidth(270);
Zerotorescue@0 179 frame.smallText:SetJustifyH("LEFT");
Zerotorescue@0 180 frame.smallText:SetJustifyV("MIDDLE");
Zerotorescue@0 181
Zerotorescue@0 182 frame:SetPoint("TOPLEFT", MailFrame, "TOPLEFT", 75, -38);
Zerotorescue@0 183 frame:SetWidth(270);
Zerotorescue@0 184 frame:SetHeight(35);
Zerotorescue@0 185 frame:SetScript("OnClick", function(self)
Zerotorescue@0 186 local timeRemainingUntillOpened = frame.smallText:GetText();
Zerotorescue@0 187 if timeRemainingUntillOpened then
Zerotorescue@0 188 MailOpener.currentPopupContents = "|cffffd700" .. timeRemainingUntillOpened .. "|r";
Zerotorescue@0 189
Zerotorescue@0 190 StaticPopup_Show("MailOpenerCopyWindow");
Zerotorescue@0 191 end
Zerotorescue@0 192 end);
Zerotorescue@0 193
Zerotorescue@0 194 self.timeLeftFrame = frame;
Zerotorescue@0 195 end
Zerotorescue@0 196
Zerotorescue@0 197 self.timeLeftFrame:Show();
Zerotorescue@0 198
Zerotorescue@3 199 -- Go through all children of the mail frame to find QA's element and hide it
Zerotorescue@42 200 -- There's no other way to do this because QuickAuctions has a local referrence to it (not as a property of the object like most other frames)
Zerotorescue@0 201 local kids = { MailFrame:GetChildren() };
Zerotorescue@0 202
Zerotorescue@0 203 for _, child in ipairs(kids) do
Zerotorescue@0 204 if child and child.text then
Zerotorescue@0 205 child.text:Hide();
Zerotorescue@0 206 end
Zerotorescue@0 207 end
Zerotorescue@0 208
Zerotorescue@0 209 -- If we were toggling this module on while the mailbox is opened we must register all events again
Zerotorescue@0 210 if MailFrame:IsVisible() then
Zerotorescue@0 211 self:MAIL_SHOW();
Zerotorescue@0 212 end
Zerotorescue@0 213 end
Zerotorescue@0 214
Zerotorescue@31 215 function mod:OnDisable()
Zerotorescue@0 216 self:UnregisterEvent("MAIL_SHOW");
Zerotorescue@0 217
Zerotorescue@0 218 if self.btnOpenAll then
Zerotorescue@0 219 self.btnOpenAll:Hide();
Zerotorescue@0 220 end
Zerotorescue@0 221
Zerotorescue@0 222 if self.timeLeftFrame then
Zerotorescue@0 223 self.timeLeftFrame:Hide();
Zerotorescue@0 224 end
Zerotorescue@0 225
Zerotorescue@0 226 if MailOpener.PostalEnabled then
Zerotorescue@0 227 -- Enable Postal's openers again
Zerotorescue@0 228
Zerotorescue@0 229 MailOpener:TogglePostalModule("OpenAll", true);
Zerotorescue@0 230 MailOpener:TogglePostalModule("Select", true);
Zerotorescue@0 231 end
Zerotorescue@0 232
Zerotorescue@0 233 -- Go through all children of the mail frame to find QA's elements and SHOW these
Zerotorescue@42 234 -- There's no other way to do this because QuickAuctions has a local referrence to it (not as a property of the object like most other frames)
Zerotorescue@0 235 local kids = { MailFrame:GetChildren() };
Zerotorescue@0 236
Zerotorescue@0 237 for _, child in ipairs(kids) do
Zerotorescue@0 238 if child and child.text then
Zerotorescue@0 239 child.text:Show();
Zerotorescue@0 240 end
Zerotorescue@0 241 end
Zerotorescue@0 242
Zerotorescue@0 243 self:Stop();
Zerotorescue@0 244 end
Zerotorescue@0 245
Zerotorescue@31 246 function mod:MAIL_SHOW()
Zerotorescue@0 247 self:Debug("MAIL_SHOW");
Zerotorescue@0 248
Zerotorescue@0 249 self:StopOpening(false);
Zerotorescue@42 250
Zerotorescue@42 251 inventoryFullSoundPlayedThisVisit = nil;
Zerotorescue@0 252
Zerotorescue@0 253 if MailOpener.PostalEnabled then
Zerotorescue@0 254 -- Disable Postal's openers so we can do it ourselves
Zerotorescue@0 255
Zerotorescue@0 256 MailOpener:TogglePostalModule("OpenAll", false);
Zerotorescue@0 257 MailOpener:TogglePostalModule("Select", false);
Zerotorescue@0 258 end
Zerotorescue@0 259
Zerotorescue@0 260 -- Keep an eye for closing of the mailbox
Zerotorescue@0 261 self:RegisterEvent("MAIL_CLOSED", "Stop");
Zerotorescue@0 262 self:RegisterEvent("PLAYER_LEAVING_WORLD", "Stop");
Zerotorescue@0 263
Zerotorescue@0 264 -- Look if the mailbox is full
Zerotorescue@0 265 self:RegisterEvent("UI_ERROR_MESSAGE");
Zerotorescue@0 266 -- Only look again after bags updated
Zerotorescue@0 267 self:RegisterEvent("BAG_UPDATE");
Zerotorescue@0 268
Zerotorescue@0 269 -- We need to know when to start opening
Zerotorescue@0 270 self:RegisterMessage("MO_OPEN_MAIL", "Open");
Zerotorescue@0 271 self:RegisterMessage("MO_SERVER_SYNCED");
Zerotorescue@3 272 self:RegisterMessage("MO_MAIL_EMPTIED");
Zerotorescue@0 273
Zerotorescue@0 274 self:CancelTimer(self.tmrTimeRemaining, true);
Zerotorescue@0 275 self.tmrTimeRemaining = self:ScheduleRepeatingTimer("UpdateTimer", 1);
Zerotorescue@0 276 self:UpdateTimer();
Zerotorescue@0 277 end
Zerotorescue@0 278
Zerotorescue@31 279 function mod:Stop()
Zerotorescue@0 280 self:Debug("Stop");
Zerotorescue@0 281
Zerotorescue@0 282 -- We shutdown, so nothing to do when the mailbox is closed anymore
Zerotorescue@0 283 self:UnregisterEvent("MAIL_CLOSED");
Zerotorescue@0 284 self:UnregisterEvent("PLAYER_LEAVING_WORLD");
Zerotorescue@0 285
Zerotorescue@0 286 -- We care about a full inventory just a little
Zerotorescue@0 287 self:UnregisterEvent("UI_ERROR_MESSAGE");
Zerotorescue@0 288 self:UnregisterEvent("BAG_UPDATE");
Zerotorescue@0 289
Zerotorescue@0 290 -- We no longer care
Zerotorescue@0 291 self:UnregisterMessage("MO_OPEN_MAIL");
Zerotorescue@0 292 self:UnregisterMessage("MO_SERVER_SYNCED");
Zerotorescue@3 293 self:UnregisterMessage("MO_MAIL_EMPTIED");
Zerotorescue@0 294
Zerotorescue@0 295 self:CancelTimer(self.tmrMailOpener, true);
Zerotorescue@0 296 self:CancelTimer(self.tmrTimeRemaining, true);
Zerotorescue@0 297
Zerotorescue@0 298 self:SetOpeningStatus(false);
Zerotorescue@0 299 end
Zerotorescue@0 300
Zerotorescue@31 301 function mod:MO_SERVER_SYNCED()
Zerotorescue@0 302 self:Debug("MO_SERVER_SYNCED");
Zerotorescue@0 303
Zerotorescue@31 304 -- Stop opening now to prevent the opener from continueing while BeanCounter is counting
Zerotorescue@2 305 self:StopOpening(false);
Zerotorescue@2 306
Zerotorescue@0 307 lastSync = GetTime();
Zerotorescue@0 308
Zerotorescue@2 309 self:UpdateMailCount();
Zerotorescue@2 310 end
Zerotorescue@2 311
Zerotorescue@31 312 function mod:MO_MAIL_EMPTIED()
Zerotorescue@3 313 -- A mail has been processed so we can process the next
Zerotorescue@2 314 continue = true;
Zerotorescue@2 315
Zerotorescue@3 316 self:UpdateTimer();
Zerotorescue@2 317 end
Zerotorescue@2 318
Zerotorescue@31 319 function mod:UpdateMailCount()
Zerotorescue@0 320 local numItems, totalItems = GetInboxNumItems();
Zerotorescue@0 321
Zerotorescue@0 322 numCurrentMail = numItems;
Zerotorescue@0 323 numHiddenMail = ( totalItems - numItems );
Zerotorescue@0 324 end
Zerotorescue@0 325
Zerotorescue@31 326 function mod:BAG_UPDATE()
Zerotorescue@0 327 -- If the bags are updated we should check if the inventory is full again
Zerotorescue@0 328 inventoryFull = false;
Zerotorescue@1 329 -- Replay sound
Zerotorescue@1 330 inventoryFullSoundPlayed = nil;
Zerotorescue@0 331 end
Zerotorescue@0 332
Zerotorescue@0 333 -- We registered this event to look for the inventory full error message because this is faster than counting the amount of items in the inventory all the time
Zerotorescue@31 334 function mod:UI_ERROR_MESSAGE(e, errorMessage)
Zerotorescue@0 335 if errorMessage == ERR_INV_FULL then
Zerotorescue@0 336 -- Inventory is full.
Zerotorescue@0 337
Zerotorescue@0 338 if not inventoryFull then
Zerotorescue@0 339 inventoryFull = true;
Zerotorescue@0 340
Zerotorescue@0 341 -- Play the sound
Zerotorescue@42 342 if MailOpener.db.profile.notifications.bagsFullSound and (not MailOpener.db.profile.notifications.bagsFullSoundOnlyOnce or not inventoryFullSoundPlayed) and (not MailOpener.db.profile.notifications.bagsFullSoundOnlyOncePerMailboxVisit or not inventoryFullSoundPlayedThisVisit) then
Zerotorescue@0 343 PlaySoundFile(MailOpener.db.profile.notifications.bagsFullSoundFile);
Zerotorescue@0 344 inventoryFullSoundPlayed = true;
Zerotorescue@42 345 inventoryFullSoundPlayedThisVisit = true;
Zerotorescue@0 346 end
Zerotorescue@0 347 end
Zerotorescue@0 348
Zerotorescue@0 349 -- Continue opening mail (we still want to open gold mail)
Zerotorescue@0 350 continue = true;
Zerotorescue@0 351 elseif errorMessage == ERR_ITEM_MAX_COUNT or errorMessage == ERR_MAIL_DATABASE_ERROR then
Zerotorescue@0 352 -- Can't carry more of this item OR mail database error
Zerotorescue@0 353
Zerotorescue@0 354 -- Continue opening mail (we still want to retrieve other items or gold)
Zerotorescue@0 355 continue = true;
Zerotorescue@0 356 end
Zerotorescue@0 357 end
Zerotorescue@0 358
Zerotorescue@46 359 function mod:Open(forced, everything)
Zerotorescue@46 360 self:Debug("Open (" .. ((everything and "1") or "0") .. ")");
Zerotorescue@0 361
Zerotorescue@0 362 if not opening or forced == true then
Zerotorescue@0 363 local numItems, totalItems = GetInboxNumItems();
Zerotorescue@0 364 -- Start at the end, add one because OpenNext will take it away again
Zerotorescue@0 365 local newMailItemIndex = ( ( numItems or 0 ) + 1 );
Zerotorescue@0 366
Zerotorescue@0 367 if newMailItemIndex > 1 then
Zerotorescue@0 368 self:Debug("Open succes");
Zerotorescue@0 369
Zerotorescue@0 370 -- Stop the previous opening and restart
Zerotorescue@0 371 if forced == true then
Zerotorescue@0 372 self:StopOpening(false); -- this is not a "simple" stop, so also reset inventory full warning
Zerotorescue@0 373 else
Zerotorescue@0 374 self:StopOpening(true); -- forced is false - automated action - simple reset, skip inventory full reset to avoid sound spam
Zerotorescue@0 375 end
Zerotorescue@0 376
Zerotorescue@0 377 -- Update the caret
Zerotorescue@0 378 MAIL_ITEM_INDEX = newMailItemIndex;
Zerotorescue@46 379 -- Do we want to override filters and open every single mail?
Zerotorescue@50 380 if everything and self.db.profile.filter.allowShiftClick then
Zerotorescue@46 381 MAIL_OPEN_EVERYTHING = true;
Zerotorescue@46 382
Zerotorescue@46 383 print("|cff15ff00Mail Opener|r: Shift key was held while pressing the open all button. Temporarily overriding filters; going to open every mail with attachments.");
Zerotorescue@46 384 else
Zerotorescue@46 385 MAIL_OPEN_EVERYTHING = nil;
Zerotorescue@46 386 end
Zerotorescue@0 387
Zerotorescue@0 388 -- We're now going to be busy again
Zerotorescue@0 389 self:SetOpeningStatus(true);
Zerotorescue@0 390
Zerotorescue@0 391 -- Open the next mail in line
Zerotorescue@0 392 self:OpenNext();
Zerotorescue@0 393 else
Zerotorescue@0 394 if MailOpener.db.profile.notifications.mailboxIsEmpty then
Zerotorescue@0 395 print("|cffff0000There is currently no mail available.|r");
Zerotorescue@0 396 end
Zerotorescue@0 397
Zerotorescue@0 398 self:Debug("MO_OPEN_COMPLETE");
Zerotorescue@0 399
Zerotorescue@0 400 -- Report that we're all done
Zerotorescue@0 401 self:SendMessage("MO_OPEN_COMPLETE");
Zerotorescue@0 402 end
Zerotorescue@0 403 end
Zerotorescue@0 404 end
Zerotorescue@0 405
Zerotorescue@0 406 -- Return the type of mail a message subject is
Zerotorescue@0 407 local knownAHSubjectPatterns = {
Zerotorescue@0 408 canceled = AUCTION_REMOVED_MAIL_SUBJECT:replace("%s", ""),
Zerotorescue@0 409 expired = AUCTION_EXPIRED_MAIL_SUBJECT:replace("%s", ""),
Zerotorescue@0 410 outbid = AUCTION_OUTBID_MAIL_SUBJECT:replace("%s", ""),
Zerotorescue@0 411 success = AUCTION_SOLD_MAIL_SUBJECT:replace("%s", ""),
Zerotorescue@0 412 won = AUCTION_WON_MAIL_SUBJECT:replace("%s", ""),
Zerotorescue@0 413 };
Zerotorescue@31 414 function mod:GetAuctionMailType(subject)
Zerotorescue@0 415 if subject then
Zerotorescue@0 416 -- Check if any of our patterns match, sorted by most likely matches first (if one is true the rest shouldn't be evaluated)
Zerotorescue@0 417 if subject:find(knownAHSubjectPatterns.expired) then
Zerotorescue@0 418 return "expired";
Zerotorescue@0 419 elseif subject:find(knownAHSubjectPatterns.success) then
Zerotorescue@0 420 return "success";
Zerotorescue@0 421 elseif subject:find(knownAHSubjectPatterns.won) then
Zerotorescue@0 422 return "won";
Zerotorescue@0 423 elseif subject:find(knownAHSubjectPatterns.canceled) then
Zerotorescue@0 424 return "canceled";
Zerotorescue@0 425 elseif subject:find(knownAHSubjectPatterns.outbid) then
Zerotorescue@0 426 return "outbid";
Zerotorescue@0 427 end
Zerotorescue@0 428 end
Zerotorescue@0 429
Zerotorescue@0 430 return; -- not auction mail
Zerotorescue@0 431 end
Zerotorescue@0 432
Zerotorescue@31 433 function mod:OpenMail(index)
Zerotorescue@0 434 if index > 0 then
Zerotorescue@0 435 -- LUA arrays start at 1, so mail with index 0 doesn't exist, so we're finished
Zerotorescue@0 436
Zerotorescue@0 437 local sender, subject, gold, cod, _, items, _, _, _, _, isGM = select(3, GetInboxHeaderInfo(index));
Zerotorescue@0 438 local auctionMailType = self:GetAuctionMailType(subject);
Zerotorescue@0 439
Zerotorescue@0 440 if isGM then
Zerotorescue@0 441 -- GM Mail
Zerotorescue@0 442 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.GMMail then
Zerotorescue@0 443 print("Skipping " .. index .. ": " .. subject .. " (GM mail)");
Zerotorescue@0 444 end
Zerotorescue@0 445
Zerotorescue@0 446 self:OpenNext();
Zerotorescue@0 447
Zerotorescue@0 448 return;
Zerotorescue@0 449 elseif cod and cod > 0 then
Zerotorescue@0 450 -- Cost on delivery
Zerotorescue@0 451 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.COD then
Zerotorescue@0 452 print("Skipping " .. index .. ": " .. subject .. " (C.O.D.)");
Zerotorescue@0 453 end
Zerotorescue@0 454
Zerotorescue@0 455 self:OpenNext();
Zerotorescue@0 456
Zerotorescue@0 457 return;
Zerotorescue@0 458 elseif ((gold and gold > 0) or (items and items > 0)) then
Zerotorescue@0 459 -- Mail with some sort of attachments
Zerotorescue@0 460
Zerotorescue@0 461 local slotsAvailable = 0;
Zerotorescue@0 462 if self.db.profile.keepFreeSpace > 0 then
Zerotorescue@0 463 for bag = 0, 4 do
Zerotorescue@0 464 local numberOfFreeSlots = GetContainerNumFreeSlots(bag);
Zerotorescue@0 465 slotsAvailable = ( slotsAvailable + numberOfFreeSlots );
Zerotorescue@0 466 end
Zerotorescue@0 467 end
Zerotorescue@0 468
Zerotorescue@46 469 if inventoryFull and not MAIL_OPEN_EVERYTHING and not MailOpener.db.profile.general.continueOpeningStackableItems and items and items > 0 then
Zerotorescue@0 470 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.inventoryFull then
Zerotorescue@0 471 print("Skipping " .. index .. ": " .. subject .. " (inventory is full)");
Zerotorescue@0 472 end
Zerotorescue@0 473
Zerotorescue@0 474 self:OpenNext();
Zerotorescue@0 475
Zerotorescue@0 476 return;
Zerotorescue@0 477 elseif self.db.profile.keepFreeSpace > 0 and items and ( slotsAvailable - items ) < self.db.profile.keepFreeSpace then
Zerotorescue@0 478 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit then
Zerotorescue@0 479 print("Skipping " .. index .. ": " .. subject .. " (keep free space limit)");
Zerotorescue@0 480 end
Zerotorescue@0 481
Zerotorescue@0 482 self:OpenNext();
Zerotorescue@0 483
Zerotorescue@0 484 return;
Zerotorescue@0 485 else
Zerotorescue@0 486 -- This string will hold the mailtype, MailOpener.db.profile.notifications.skipped/processed[mailType] will be checked if this should be announced
Zerotorescue@0 487 local mailType = "other";
Zerotorescue@0 488
Zerotorescue@0 489 if not auctionMailType then
Zerotorescue@0 490 -- This is a normal mail
Zerotorescue@0 491
Zerotorescue@0 492 if gold and gold > 0 then
Zerotorescue@0 493 mailType = "normalGoldMail";
Zerotorescue@0 494 elseif items and items > 0 then
Zerotorescue@0 495 mailType = "normalItemsMail";
Zerotorescue@0 496 end
Zerotorescue@0 497 else
Zerotorescue@0 498 -- This is an auction house mail
Zerotorescue@0 499
Zerotorescue@0 500 mailType = "AH" .. auctionMailType;
Zerotorescue@0 501 end
Zerotorescue@0 502
Zerotorescue@46 503 if not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.normalMoney and mailType == "normalGoldMail" then
Zerotorescue@0 504 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then
Zerotorescue@0 505 print("Skipping " .. index .. ": " .. subject .. " (normal mail with gold)");
Zerotorescue@0 506 end
Zerotorescue@0 507
Zerotorescue@0 508 self:OpenNext();
Zerotorescue@0 509
Zerotorescue@0 510 return;
Zerotorescue@46 511 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.normalAttachments and mailType == "normalItemsMail" then
Zerotorescue@0 512 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then
Zerotorescue@0 513 print("Skipping " .. index .. ": " .. subject .. " (normal mail with attachments)");
Zerotorescue@0 514 end
Zerotorescue@0 515
Zerotorescue@0 516 self:OpenNext();
Zerotorescue@0 517
Zerotorescue@0 518 return;
Zerotorescue@46 519 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.expired and mailType == "AHexpired" then
Zerotorescue@0 520 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then
Zerotorescue@0 521 print("Skipping " .. index .. ": " .. subject .. " (expired auction)");
Zerotorescue@0 522 end
Zerotorescue@0 523
Zerotorescue@0 524 self:OpenNext();
Zerotorescue@0 525
Zerotorescue@0 526 return;
Zerotorescue@46 527 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.success and mailType == "AHsuccess" then
Zerotorescue@0 528 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then
Zerotorescue@0 529 print("Skipping " .. index .. ": " .. subject .. " (successful auction)");
Zerotorescue@0 530 end
Zerotorescue@0 531
Zerotorescue@0 532 self:OpenNext();
Zerotorescue@0 533
Zerotorescue@0 534 return;
Zerotorescue@46 535 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.won and mailType == "AHwon" then
Zerotorescue@0 536 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then
Zerotorescue@0 537 print("Skipping " .. index .. ": " .. subject .. " (auction won)");
Zerotorescue@0 538 end
Zerotorescue@0 539
Zerotorescue@0 540 self:OpenNext();
Zerotorescue@0 541
Zerotorescue@0 542 return;
Zerotorescue@46 543 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.canceled and mailType == "AHcanceled" then
Zerotorescue@0 544 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then
Zerotorescue@0 545 print("Skipping " .. index .. ": " .. subject .. " (canceled auction)");
Zerotorescue@0 546 end
Zerotorescue@0 547
Zerotorescue@0 548 self:OpenNext();
Zerotorescue@0 549
Zerotorescue@0 550 return;
Zerotorescue@46 551 elseif not MAIL_OPEN_EVERYTHING and not self.db.profile.filter.AH.outbid and mailType == "AHoutbid" then
Zerotorescue@0 552 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then
Zerotorescue@0 553 print("Skipping " .. index .. ": " .. subject .. " (outbid on auction)");
Zerotorescue@0 554 end
Zerotorescue@0 555
Zerotorescue@0 556 self:OpenNext();
Zerotorescue@0 557
Zerotorescue@0 558 return;
Zerotorescue@0 559 else
Zerotorescue@0 560 continue = false;
Zerotorescue@3 561
Zerotorescue@11 562 self:Debug("MO_OPENING_MAIL (#" .. index .. ")");
Zerotorescue@0 563
Zerotorescue@2 564 -- Notifiy other modules of opening
Zerotorescue@2 565 self:SendMessage("MO_OPENING_MAIL");
Zerotorescue@2 566
Zerotorescue@0 567 -- Open current mail
Zerotorescue@0 568 AutoLootMailItem(index);
Zerotorescue@0 569
Zerotorescue@0 570 if MailOpener.db.profile.notifications.processed.all and MailOpener.db.profile.notifications.processed[mailType] then
Zerotorescue@0 571 if gold and gold > 0 then
Zerotorescue@0 572 print("Processing " .. index .. ": " .. subject .. " (" .. MailOpener:FormatMoney(gold) .. ")");
Zerotorescue@0 573 else
Zerotorescue@0 574 print("Processing " .. index .. ": " .. subject);
Zerotorescue@0 575 end
Zerotorescue@0 576 end
Zerotorescue@0 577
Zerotorescue@0 578 -- And prepare for the next
Zerotorescue@0 579 self.tmrMailOpener = self:ScheduleTimer("OpenNext", self.db.profile.speed);
Zerotorescue@0 580 end
Zerotorescue@0 581 end
Zerotorescue@0 582 else
Zerotorescue@0 583 -- Unknown, probably just text
Zerotorescue@0 584 if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.other then
Zerotorescue@0 585 if subject then
Zerotorescue@0 586 print("Skipping " .. index .. ": " .. subject);
Zerotorescue@0 587 else
Zerotorescue@0 588 print("Skipping " .. index);
Zerotorescue@0 589 end
Zerotorescue@0 590 end
Zerotorescue@0 591
Zerotorescue@0 592 self:OpenNext();
Zerotorescue@0 593 end
Zerotorescue@0 594 else
Zerotorescue@0 595 -- Finished!
Zerotorescue@0 596 if MailOpener.db.profile.notifications.finishedCurrentBatch then
Zerotorescue@0 597 print("Finished opening the current batch.");
Zerotorescue@0 598 end
Zerotorescue@0 599
Zerotorescue@0 600 self:SetOpeningStatus(false);
Zerotorescue@3 601
Zerotorescue@0 602 self:Debug("MO_OPEN_COMPLETE");
Zerotorescue@0 603
Zerotorescue@0 604 -- Report that we're all done
Zerotorescue@0 605 self:SendMessage("MO_OPEN_COMPLETE");
Zerotorescue@0 606 end
Zerotorescue@0 607 end
Zerotorescue@0 608
Zerotorescue@31 609 function mod:OpenNext()
Zerotorescue@0 610 if continue then
Zerotorescue@0 611 -- If the previous mail was opened successful, open the next
Zerotorescue@0 612
Zerotorescue@0 613 -- Next mail in line
Zerotorescue@0 614 MAIL_ITEM_INDEX = ( MAIL_ITEM_INDEX - 1 );
Zerotorescue@0 615
Zerotorescue@0 616 -- Open it
Zerotorescue@0 617 self:OpenMail(MAIL_ITEM_INDEX);
Zerotorescue@0 618 else
Zerotorescue@0 619 -- Try again at the next interval
Zerotorescue@0 620
Zerotorescue@0 621 self.tmrMailOpener = self:ScheduleTimer("OpenNext", self.db.profile.speed);
Zerotorescue@0 622 end
Zerotorescue@0 623 end
Zerotorescue@0 624
Zerotorescue@31 625 function mod:Continue()
Zerotorescue@2 626 continue = true;
Zerotorescue@2 627 self:OpenNext();
Zerotorescue@2 628 end
Zerotorescue@2 629
Zerotorescue@0 630 local mailRemainingPatterns = {
Zerotorescue@3 631 minutesSeconds = "|cffffffff%d|r/|cffffffff%d|r mail remaining, opening everything will take about |cffffffff%d|r minutes and |cffffffff%d|r seconds (next refresh in |cffffffff%d|r seconds).";
Zerotorescue@3 632 minutes = "|cffffffff%d|r/|cffffffff%d|r mail remaining, opening everything will take about |cffffffff%d|r minutes (next refresh in |cffffffff%d|r seconds).";
Zerotorescue@3 633 seconds = "|cffffffff%d|r/|cffffffff%d|r mail remaining, opening everything will take about |cffffffff%d|r seconds (next refresh in |cffffffff%d|r seconds).";
Zerotorescue@3 634 nextRefresh = "|cffffffff%d|r/|cffffffff%d|r mail remaining, next refresh in |cffffffff%d|r seconds.";
Zerotorescue@0 635 waitingBatch = "|cffffffff%d|r/|cffffffff%d|r mail remaining - waiting for something from the current batch to be opened...";
Zerotorescue@0 636 waitingSync = "|cffffffff%d|r/|cffffffff%d|r mail remaining - waiting for the next mailbox refresh...";
Zerotorescue@0 637 soon = "|cffffffff%d|r/|cffffffff%d|r mail remaining - everything will be opened soon...";
Zerotorescue@0 638 };
Zerotorescue@0 639
Zerotorescue@31 640 function mod:UpdateTimer()
Zerotorescue@0 641 if lastSync then
Zerotorescue@3 642 self:UpdateMailCount();
Zerotorescue@3 643
Zerotorescue@0 644 -- Calculate the total amount of mail waiting
Zerotorescue@0 645 local numTotalMail = ( numHiddenMail + numCurrentMail );
Zerotorescue@0 646
Zerotorescue@0 647 -- Resize the font based on mail left so the counter always fits perfectly
Zerotorescue@0 648 if numTotalMail < 100 then
Zerotorescue@0 649 self.timeLeftFrame.text:SetFont(GameFontHighlight:GetFont(), 30, "THICKOUTLINE");
Zerotorescue@0 650 elseif numTotalMail < 1000 then
Zerotorescue@0 651 self.timeLeftFrame.text:SetFont(GameFontHighlight:GetFont(), 24, "THICKOUTLINE");
Zerotorescue@0 652 else
Zerotorescue@0 653 self.timeLeftFrame.text:SetFont(GameFontHighlight:GetFont(), 18, "THICKOUTLINE");
Zerotorescue@0 654 end
Zerotorescue@0 655 self.timeLeftFrame.text:SetText(numTotalMail);
Zerotorescue@3 656
Zerotorescue@3 657 -- Calculate the next server sync based on the last server sync plus sync interval
Zerotorescue@3 658 local nextSync = ( lastSync + 61 );
Zerotorescue@0 659
Zerotorescue@3 660 -- Calculate the timer remaining untill the next sync
Zerotorescue@3 661 local timeRemaining = floor( nextSync - GetTime() );
Zerotorescue@3 662
Zerotorescue@3 663 if numHiddenMail > 0 or timeRemaining > 0 then
Zerotorescue@3 664 -- If there is still mail being hidden or the timer is still know, display stuff
Zerotorescue@0 665
Zerotorescue@0 666 -- If the next sync was already due, our nextSync calculation was wrong and we must wait a little longer (lag?)
Zerotorescue@0 667 local syncTimeOut = false;
Zerotorescue@0 668 -- If time remaining is below 0, next sync should be soon
Zerotorescue@0 669 if timeRemaining < 0 then
Zerotorescue@0 670 timeRemaining = 0;
Zerotorescue@0 671 syncTimeOut = true;
Zerotorescue@0 672 end
Zerotorescue@0 673
Zerotorescue@0 674 -- Calculate the amount of server syncs required to open all mail
Zerotorescue@0 675 local syncsRequired = ceil( numHiddenMail / 50 );
Zerotorescue@0 676 -- Calculate the time required to execute all these syncs
Zerotorescue@0 677 local timeRequired = ( ( syncsRequired - 1 ) * 61 ) + timeRemaining;
Zerotorescue@0 678
Zerotorescue@0 679 local minutes = floor( timeRequired / 60 );
Zerotorescue@0 680 local seconds = floor( timeRequired % 60 );
Zerotorescue@0 681
Zerotorescue@0 682 local remainingText;
Zerotorescue@0 683 if syncTimeOut then
Zerotorescue@3 684 -- Previous server sync was expected earlier, notify user
Zerotorescue@3 685
Zerotorescue@0 686 if numCurrentMail == 50 then
Zerotorescue@3 687 -- Sync couldn't occur because we were still waiting for the current batch to be opened
Zerotorescue@0 688 remainingText = format(mailRemainingPatterns.waitingBatch, numCurrentMail, numTotalMail);
Zerotorescue@0 689 else
Zerotorescue@0 690 remainingText = format(mailRemainingPatterns.waitingSync, numCurrentMail, numTotalMail);
Zerotorescue@0 691 end
Zerotorescue@3 692 elseif numHiddenMail == 0 then
Zerotorescue@3 693 -- If no hidden mail is remaining, only show the timer for as long as we can be sure
Zerotorescue@3 694
Zerotorescue@3 695 remainingText = format(mailRemainingPatterns.nextRefresh, numCurrentMail, numTotalMail, timeRemaining);
Zerotorescue@0 696 elseif minutes ~= 0 then
Zerotorescue@0 697 if seconds ~= 0 then
Zerotorescue@0 698 remainingText = format(mailRemainingPatterns.minutesSeconds, numCurrentMail, numTotalMail, minutes, seconds, timeRemaining);
Zerotorescue@0 699 else
Zerotorescue@0 700 remainingText = format(mailRemainingPatterns.minutes, numCurrentMail, numTotalMail, minutes, timeRemaining);
Zerotorescue@0 701 end
Zerotorescue@0 702 elseif seconds ~= 0 then
Zerotorescue@0 703 remainingText = format(mailRemainingPatterns.seconds, numCurrentMail, numTotalMail, seconds, timeRemaining);
Zerotorescue@0 704 else
Zerotorescue@0 705 remainingText = format(mailRemainingPatterns.soon, numCurrentMail, numTotalMail);
Zerotorescue@0 706 end
Zerotorescue@0 707
Zerotorescue@0 708 self.timeLeftFrame.smallText:SetText(remainingText);
Zerotorescue@3 709 else
Zerotorescue@0 710 self.timeLeftFrame.smallText:SetText("");
Zerotorescue@0 711 end
Zerotorescue@0 712 end
Zerotorescue@0 713 end
Zerotorescue@0 714
Zerotorescue@31 715 function mod:StopOpening(simple)
Zerotorescue@2 716 -- Stop opener timer
Zerotorescue@2 717 self:CancelTimer(self.tmrMailOpener, true);
Zerotorescue@2 718
Zerotorescue@0 719 if not simple then
Zerotorescue@39 720 -- A simple stop is an automated stop, an advanced stop is one manually or after a sever sync
Zerotorescue@2 721
Zerotorescue@0 722 -- Recheck inventory full
Zerotorescue@0 723 inventoryFull = false;
Zerotorescue@0 724 -- Replay sound
Zerotorescue@0 725 inventoryFullSoundPlayed = nil;
Zerotorescue@0 726 end
Zerotorescue@0 727
Zerotorescue@0 728 -- Reset opener position
Zerotorescue@0 729 MAIL_ITEM_INDEX = 0;
Zerotorescue@46 730 -- Reset open everything state
Zerotorescue@46 731 MAIL_OPEN_EVERYTHING = nil;
Zerotorescue@0 732 -- Stopped opening, so allow to continue
Zerotorescue@0 733 continue = true;
Zerotorescue@31 734
Zerotorescue@0 735 self:SetOpeningStatus(false);
Zerotorescue@0 736 end
Zerotorescue@0 737
Zerotorescue@31 738 function mod:SetOpeningStatus(openingStatus)
Zerotorescue@0 739 opening = openingStatus;
Zerotorescue@0 740
Zerotorescue@0 741 if openingStatus then
Zerotorescue@0 742 self.btnOpenAll:SetText("Opening...");
Zerotorescue@0 743 else
Zerotorescue@50 744 self.btnOpenAll:SetText("Open all");
Zerotorescue@0 745 end
Zerotorescue@0 746 end
Zerotorescue@0 747
Zerotorescue@31 748 function mod:GetOptionsGroup()
Zerotorescue@0 749 local configGroup = {
Zerotorescue@0 750 order = 300,
Zerotorescue@0 751 type = "group",
Zerotorescue@0 752 name = "Open All",
Zerotorescue@0 753 desc = "Change open all settings.",
Zerotorescue@0 754 args = {
Zerotorescue@0 755 filters = {
Zerotorescue@0 756 order = 10,
Zerotorescue@0 757 type = "group",
Zerotorescue@0 758 inline = true,
Zerotorescue@0 759 name = "Filters",
Zerotorescue@0 760 args = {
Zerotorescue@0 761 description = {
Zerotorescue@0 762 order = 10,
Zerotorescue@0 763 type = "description",
Zerotorescue@0 764 name = "Toggle which mail the opener should autoloot.",
Zerotorescue@0 765 },
Zerotorescue@0 766 AHHeader = {
Zerotorescue@0 767 order = 15,
Zerotorescue@0 768 type = "header",
Zerotorescue@0 769 name = "Auction House Mail",
Zerotorescue@0 770 },
Zerotorescue@0 771 canceled = {
Zerotorescue@0 772 order = 20,
Zerotorescue@0 773 type = "toggle",
Zerotorescue@0 774 name = "Open all |cfffed000auction canceled|r mail",
Zerotorescue@54 775 desc = "Automatically loot all auction canceled mail from the auction house.",
Zerotorescue@0 776 set = function(i, v) self.db.profile.filter.AH.canceled = v; end,
Zerotorescue@0 777 get = function() return self.db.profile.filter.AH.canceled; end,
Zerotorescue@0 778 width = "double",
Zerotorescue@0 779 },
Zerotorescue@0 780 expired = {
Zerotorescue@0 781 order = 21,
Zerotorescue@0 782 type = "toggle",
Zerotorescue@0 783 name = "Open all |cfffed000auction expired|r mail",
Zerotorescue@54 784 desc = "Automatically loot all auction canceled mail from the auction house.",
Zerotorescue@0 785 set = function(i, v) self.db.profile.filter.AH.expired = v; end,
Zerotorescue@0 786 get = function() return self.db.profile.filter.AH.expired; end,
Zerotorescue@0 787 width = "double",
Zerotorescue@0 788 },
Zerotorescue@0 789 outbid = {
Zerotorescue@0 790 order = 22,
Zerotorescue@0 791 type = "toggle",
Zerotorescue@0 792 name = "Open all |cfffed000outbid on|r mail",
Zerotorescue@54 793 desc = "Automatically loot all auction outbid mail from the auction house.",
Zerotorescue@0 794 set = function(i, v) self.db.profile.filter.AH.outbid = v; end,
Zerotorescue@0 795 get = function() return self.db.profile.filter.AH.outbid; end,
Zerotorescue@0 796 width = "double",
Zerotorescue@0 797 },
Zerotorescue@0 798 success = {
Zerotorescue@0 799 order = 23,
Zerotorescue@0 800 type = "toggle",
Zerotorescue@0 801 name = "Open all |cfffed000auction successful|r mail",
Zerotorescue@54 802 desc = "Automatically loot all auction successful mail from the auction house.",
Zerotorescue@0 803 set = function(i, v) self.db.profile.filter.AH.success = v; end,
Zerotorescue@0 804 get = function() return self.db.profile.filter.AH.success; end,
Zerotorescue@0 805 width = "double",
Zerotorescue@0 806 },
Zerotorescue@0 807 won = {
Zerotorescue@0 808 order = 24,
Zerotorescue@0 809 type = "toggle",
Zerotorescue@0 810 name = "Open all |cfffed000auction won|r mail",
Zerotorescue@54 811 desc = "Automatically loot all auction won mail from the auction house.",
Zerotorescue@0 812 set = function(i, v) self.db.profile.filter.AH.won = v; end,
Zerotorescue@0 813 get = function() return self.db.profile.filter.AH.won; end,
Zerotorescue@0 814 width = "double",
Zerotorescue@0 815 },
Zerotorescue@0 816 normalHeader = {
Zerotorescue@0 817 order = 30,
Zerotorescue@0 818 type = "header",
Zerotorescue@0 819 name = "Remaining Mail",
Zerotorescue@0 820 },
Zerotorescue@0 821 normalAttachments = {
Zerotorescue@0 822 order = 40,
Zerotorescue@0 823 type = "toggle",
Zerotorescue@62 824 name = "Normal mail with |cfffed000attachments|r",
Zerotorescue@62 825 desc = "Automatically loot all normal mail containing attachments (CoDs and Blizzard mail will be skipped).",
Zerotorescue@0 826 set = function(i, v) self.db.profile.filter.normalAttachments = v; end,
Zerotorescue@0 827 get = function() return self.db.profile.filter.normalAttachments; end,
Zerotorescue@0 828 width = "double",
Zerotorescue@0 829 },
Zerotorescue@0 830 normalMoney = {
Zerotorescue@0 831 order = 50,
Zerotorescue@0 832 type = "toggle",
Zerotorescue@62 833 name = "Normal mail with |cfffed000gold|r",
Zerotorescue@62 834 desc = "Automatically loot all normal mail containing gold (CoDs and Blizzard mail will be skipped).",
Zerotorescue@0 835 set = function(i, v) self.db.profile.filter.normalMoney = v; end,
Zerotorescue@0 836 get = function() return self.db.profile.filter.normalMoney; end,
Zerotorescue@0 837 width = "double",
Zerotorescue@0 838 },
Zerotorescue@50 839 allowShiftClick = {
Zerotorescue@50 840 order = 60,
Zerotorescue@50 841 type = "toggle",
Zerotorescue@50 842 name = "Allow shift-clicking of the |cfffed000Open All|r button to autoloot |cfffed000everything|r, regardless of the above filters.",
Zerotorescue@50 843 desc = "Allow shift-clicking of the |cfffed000Open All|r button to autoloot |cfffed000everything|r with attachments, temporarily overriding all filters.",
Zerotorescue@50 844 set = function(i, v) self.db.profile.filter.allowShiftClick = v; end,
Zerotorescue@50 845 get = function() return self.db.profile.filter.allowShiftClick; end,
Zerotorescue@50 846 width = "full",
Zerotorescue@50 847 },
Zerotorescue@0 848 },
Zerotorescue@0 849 },
Zerotorescue@0 850 -- Continuous opening config inline group
Zerotorescue@0 851 continuousOpening = {
Zerotorescue@0 852 order = 20,
Zerotorescue@0 853 type = "group",
Zerotorescue@0 854 inline = true,
Zerotorescue@0 855 name = "Opening Interval",
Zerotorescue@0 856 args = {
Zerotorescue@0 857 description = {
Zerotorescue@0 858 order = 10,
Zerotorescue@0 859 type = "description",
Zerotorescue@0 860 name = function()
Zerotorescue@0 861 local defaultString = "The default behaviour for opening mail is to only do so right after new mail was received from the server. If you close the mailbox or your inventory is full before everything is opened you will have to click the open all button manually or wait for a next mailbox refresh.\n\n";
Zerotorescue@0 862
Zerotorescue@0 863 local currentSettings = "";
Zerotorescue@0 864 if MailOpener.db.profile.general.continueOpening then
Zerotorescue@0 865 currentSettings = currentSettings .. "Mail Opener will |cff00ff00continue|r to attempt to open the remaining mail every |cfffed000" .. MailOpener.db.profile.general.waitTime .. " seconds|r. ";
Zerotorescue@0 866 else
Zerotorescue@0 867 currentSettings = currentSettings .. "Mail Opener will |cffff0000not|r continue to attempt to open the remaining mail and will only start opening when new mail has just been received from the server. ";
Zerotorescue@0 868 end
Zerotorescue@0 869 currentSettings = currentSettings .. "The first batch after each server refresh will be opened after waiting |cfffed000" .. MailOpener.db.profile.general.initialDelay .. " seconds|r.";
Zerotorescue@0 870 return defaultString .. currentSettings;
Zerotorescue@0 871 end,
Zerotorescue@0 872 },
Zerotorescue@0 873 header = {
Zerotorescue@0 874 order = 15,
Zerotorescue@0 875 type = "header",
Zerotorescue@0 876 name = "",
Zerotorescue@0 877 },
Zerotorescue@0 878 continueOpening = {
Zerotorescue@0 879 order = 20,
Zerotorescue@0 880 type = "toggle",
Zerotorescue@0 881 name = "Continue opening mail",
Zerotorescue@0 882 desc = "Continue opening mail at the interval set below, even if the mailbox wasn't refreshed recently.",
Zerotorescue@0 883 width = "full",
Zerotorescue@0 884 get = function() return MailOpener.db.profile.general.continueOpening; end,
Zerotorescue@0 885 set = function(i, v) MailOpener.db.profile.general.continueOpening = v; end,
Zerotorescue@0 886 },
Zerotorescue@0 887 waitTime = {
Zerotorescue@0 888 order = 30,
Zerotorescue@0 889 type = "range",
Zerotorescue@0 890 width = "double",
Zerotorescue@0 891 min = 0.5,
Zerotorescue@0 892 max = 60,
Zerotorescue@0 893 step = 0.5,
Zerotorescue@0 894 name = "Continued Mail Opening Interval",
Zerotorescue@5 895 desc = "Change the interval at which Mail Opener tries to continue opening mail after opening the mailbox. Please note that this setting does not reduce the game's normal 60 seconds wait time for mail.\n\nThe default value is 5 seconds.",
Zerotorescue@0 896 get = function() return MailOpener.db.profile.general.waitTime; end,
Zerotorescue@0 897 set = function(i, v) MailOpener.db.profile.general.waitTime = v; end,
Zerotorescue@0 898 disabled = function() return (not MailOpener.db.profile.general.continueOpening); end,
Zerotorescue@0 899 },
Zerotorescue@0 900 initialDelay = {
Zerotorescue@0 901 order = 40,
Zerotorescue@0 902 type = "range",
Zerotorescue@0 903 width = "double",
Zerotorescue@0 904 min = 0.5,
Zerotorescue@0 905 max = 60,
Zerotorescue@0 906 step = 0.5,
Zerotorescue@0 907 name = "Initial Mail Opening Delay",
Zerotorescue@0 908 desc = "Change the delay before Mail Opener tries opening mail after opening the mailbox or new mail has been received from the server.\n\nThe default value is 0.5 seconds.",
Zerotorescue@0 909 get = function() return MailOpener.db.profile.general.initialDelay; end,
Zerotorescue@0 910 set = function(i, v) MailOpener.db.profile.general.initialDelay = v; end,
Zerotorescue@0 911 },
Zerotorescue@0 912 },
Zerotorescue@0 913 }, -- end Continuous opening config inline group
Zerotorescue@0 914 keepFree = {
Zerotorescue@0 915 order = 30,
Zerotorescue@0 916 type = "group",
Zerotorescue@0 917 inline = true,
Zerotorescue@0 918 name = "Keep Free Space",
Zerotorescue@0 919 args = {
Zerotorescue@0 920 description = {
Zerotorescue@0 921 order = 10,
Zerotorescue@0 922 type = "description",
Zerotorescue@0 923 name = "You can set an amount of bag space you wish to reserve when opening mail. Mail with a higher amount of attachments than available space will be skipped completely with this option set above 0.",
Zerotorescue@0 924 },
Zerotorescue@0 925 header = {
Zerotorescue@0 926 order = 15,
Zerotorescue@0 927 type = "header",
Zerotorescue@0 928 name = "",
Zerotorescue@0 929 },
Zerotorescue@0 930 keepFreeSpace = {
Zerotorescue@0 931 order = 20,
Zerotorescue@0 932 type = "range",
Zerotorescue@0 933 min = 0,
Zerotorescue@0 934 max = 100,
Zerotorescue@0 935 step = 1,
Zerotorescue@0 936 width = "double",
Zerotorescue@0 937 name = "Keep free space",
Zerotorescue@0 938 desc = "Change the amount of space to reserve for other things when opening mail. If this option is set higher than 0, mail with a higher amount of attachments than available space will be skipped completely.\n\nE.g. If this is set to 1 and you have a total of 12 slots left then any mail with 12 attachments will be skipped while one with 11 attachments would be opened.",
Zerotorescue@0 939 set = function(i, v) self.db.profile.keepFreeSpace = v; end,
Zerotorescue@0 940 get = function() return self.db.profile.keepFreeSpace; end,
Zerotorescue@0 941 },
Zerotorescue@0 942 },
Zerotorescue@0 943 },
Zerotorescue@0 944 speed = {
Zerotorescue@0 945 order = 40,
Zerotorescue@0 946 type = "group",
Zerotorescue@0 947 inline = true,
Zerotorescue@0 948 name = "Opening Speed",
Zerotorescue@0 949 args = {
Zerotorescue@0 950 description = {
Zerotorescue@0 951 order = 10,
Zerotorescue@0 952 type = "description",
Zerotorescue@0 953 name = "Change the speed at which mail is opened. You should set the opening speed to the lowest latency you have in a city or experiment with setting it to the minimum.",
Zerotorescue@0 954 },
Zerotorescue@0 955 header = {
Zerotorescue@0 956 order = 15,
Zerotorescue@0 957 type = "header",
Zerotorescue@0 958 name = "",
Zerotorescue@0 959 },
Zerotorescue@0 960 openMailInterval = {
Zerotorescue@0 961 order = 20,
Zerotorescue@0 962 type = "range",
Zerotorescue@0 963 min = 5,
Zerotorescue@0 964 max = 2500,
Zerotorescue@0 965 step = 5,
Zerotorescue@0 966 width = "double",
Zerotorescue@0 967 name = "Open single mail interval",
Zerotorescue@0 968 desc = "Change the mail opening speed (in microseconds) for each mail. Lower may not always be faster.",
Zerotorescue@0 969 get = function() return ( self.db.profile.speed * 1000 ); end,
Zerotorescue@0 970 set = function(i, v) self.db.profile.speed = ( v / 1000 ); end,
Zerotorescue@0 971 },
Zerotorescue@0 972 },
Zerotorescue@0 973 },
Zerotorescue@0 974 },
Zerotorescue@0 975 };
Zerotorescue@0 976
Zerotorescue@0 977 return configGroup;
Zerotorescue@0 978 end
Zerotorescue@0 979
Zerotorescue@31 980 function mod:Debug(t)
Zerotorescue@0 981 return MailOpener:Debug("|cff00ff00OpenAll|r:" .. t);
Zerotorescue@0 982 end