annotate Core.lua @ 45:e9072491dc3f

Added tag v1.1.1 for changeset 5cd81a462159
author Zerotorescue
date Sun, 12 Sep 2010 15:53:19 +0200
parents 8168280420ae
children 1805df31794d
rev   line source
Zerotorescue@3 1 -- You can access this addon's object through: LibStub("AceAddon-3.0"):GetAddon("MailOpener")
Zerotorescue@3 2 local MailOpener = LibStub("AceAddon-3.0"):NewAddon("MailOpener", "AceEvent-3.0", "AceTimer-3.0");
Zerotorescue@0 3
Zerotorescue@8 4 -- You can check if MailOpener is busy with the global MailAddonBusy (if not MailAddonBusy then ...do something... end)
Zerotorescue@8 5 -- MailAddonBusy will be nil when nothing is happening or filled with the addon name when MO is working
Zerotorescue@8 6 -- Another addon can use this variable to indicate they're working too, MailOpener will then wait for that to finish
Zerotorescue@3 7
Zerotorescue@42 8 local AutoOpenMail, MailOpenerConfig, lastAmount, lastQuickAuctionsStatus, freshList, mailboxEmptySoundPlayed, mailboxEmptySoundPlayedThisVisit;
Zerotorescue@0 9
Zerotorescue@0 10 function MailOpener:OnInitialize()
Zerotorescue@31 11 self:Debug("OnInitialize");
Zerotorescue@31 12
Zerotorescue@31 13
Zerotorescue@31 14
Zerotorescue@31 15
Zerotorescue@31 16 -- SAVED VARIABLES
Zerotorescue@31 17
Zerotorescue@0 18 local defaults = {
Zerotorescue@0 19 profile = {
Zerotorescue@8 20 uses = 0,
Zerotorescue@0 21 general = {
Zerotorescue@8 22 defaultStatus = "disabled", -- addon enabled, but mail opening not auto on
Zerotorescue@0 23 defaultQAStatus = "__remember",
Zerotorescue@0 24 continueOpeningStackableItems = false,
Zerotorescue@0 25 autoDisableQAAutoMail = true,
Zerotorescue@0 26 autoReenableQAAutoMail = false,
Zerotorescue@0 27 autoSetBackQAAutoMail = true,
Zerotorescue@0 28 continueOpening = false,
Zerotorescue@0 29 waitTime = 5,
Zerotorescue@0 30 initialDelay = 0.5,
Zerotorescue@0 31 },
Zerotorescue@0 32 modules = {
Zerotorescue@31 33 BeanCounterSupport = true,
Zerotorescue@31 34 Config = false,
Zerotorescue@0 35 Collected = true,
Zerotorescue@5 36 FailSafe = true,
Zerotorescue@0 37 },
Zerotorescue@0 38 notifications = {
Zerotorescue@3 39 welcome = false,
Zerotorescue@3 40 bye = false,
Zerotorescue@0 41 finishedCurrentBatch = true,
Zerotorescue@0 42 mailboxIsEmpty = true,
Zerotorescue@0 43
Zerotorescue@0 44 skipped = {
Zerotorescue@0 45 all = true,
Zerotorescue@0 46 inventoryFull = true,
Zerotorescue@0 47 keepFreeSpaceLimit = true,
Zerotorescue@0 48 GMMail = true,
Zerotorescue@0 49 COD = true,
Zerotorescue@0 50 normalGoldMail = true,
Zerotorescue@0 51 normalItemsMail = true,
Zerotorescue@0 52 AHexpired = true,
Zerotorescue@0 53 AHsuccess = true,
Zerotorescue@0 54 AHwon = true,
Zerotorescue@0 55 AHcanceled = true,
Zerotorescue@0 56 AHoutbid = true,
Zerotorescue@0 57 other = true,
Zerotorescue@0 58 },
Zerotorescue@0 59 processed = {
Zerotorescue@0 60 all = true,
Zerotorescue@0 61 normalGoldMail = true,
Zerotorescue@0 62 normalItemsMail = true,
Zerotorescue@0 63 AHexpired = true,
Zerotorescue@0 64 AHsuccess = true,
Zerotorescue@0 65 AHwon = true,
Zerotorescue@0 66 AHcanceled = true,
Zerotorescue@0 67 AHoutbid = true,
Zerotorescue@0 68 other = true,
Zerotorescue@0 69 },
Zerotorescue@0 70
Zerotorescue@0 71 bagsFullSound = false,
Zerotorescue@0 72 bagsFullSoundFile = "Sound\\Spells\\SimonGame_Visual_BadPress.wav",
Zerotorescue@0 73 bagsFullSoundFileName = "Simon Error",
Zerotorescue@0 74 bagsFullSoundOnlyOnce = true,
Zerotorescue@42 75 bagsFullSoundOnlyOncePerMailboxVisit = false,
Zerotorescue@0 76 mailboxEmptySound = false,
Zerotorescue@0 77 mailboxEmptySoundFile = "Sound\\Spells\\SimonGame_Visual_GameStart.wav",
Zerotorescue@0 78 mailboxEmptySoundFileName = "Simon Start",
Zerotorescue@0 79 mailboxEmptySoundOnlyOnce = true,
Zerotorescue@42 80 mailboxEmptySoundOnlyOncePerMailboxVisit = false,
Zerotorescue@0 81 },
Zerotorescue@0 82 },
Zerotorescue@0 83 };
Zerotorescue@0 84
Zerotorescue@0 85 -- Register our saved variables database
Zerotorescue@0 86 self.db = LibStub("AceDB-3.0"):New("MailOpenerDB", defaults, true);
Zerotorescue@0 87
Zerotorescue@0 88
Zerotorescue@31 89
Zerotorescue@31 90
Zerotorescue@31 91
Zerotorescue@31 92 -- MODULE TOGGLING
Zerotorescue@0 93
Zerotorescue@0 94 -- Don't enable the config module until we need it
Zerotorescue@0 95 for name, module in self:IterateModules() do
Zerotorescue@31 96 if self.db.profile.modules[name] ~= nil then
Zerotorescue@0 97 if self.db.profile.modules[name] then
Zerotorescue@0 98 self:Debug("|cff00ff00Enabling|r module: " .. name);
Zerotorescue@0 99 else
Zerotorescue@0 100 self:Debug("|cffff0000Disabling|r module: " .. name);
Zerotorescue@0 101 end
Zerotorescue@0 102
Zerotorescue@0 103 module:SetEnabledState(self.db.profile.modules[name]);
Zerotorescue@0 104 end
Zerotorescue@0 105 end
Zerotorescue@0 106
Zerotorescue@31 107
Zerotorescue@31 108
Zerotorescue@31 109
Zerotorescue@31 110
Zerotorescue@31 111 -- SLASH COMMANDS
Zerotorescue@31 112
Zerotorescue@31 113 -- Disable the AddonLoader slash commands
Zerotorescue@31 114 SLASH_MO1 = nil;
Zerotorescue@31 115 SLASH_MAILOPEN1 = nil;
Zerotorescue@31 116 SLASH_MAILOPENER1 = nil;
Zerotorescue@31 117
Zerotorescue@31 118 -- Register our own slash commands
Zerotorescue@31 119 SLASH_MAILOPENER1 = "/mo";
Zerotorescue@31 120 SLASH_MAILOPENER2 = "/mailopen";
Zerotorescue@31 121 SLASH_MAILOPENER3 = "/mailopener";
Zerotorescue@31 122 SlashCmdList["MAILOPENER"] = function(msg)
Zerotorescue@31 123 MailOpener:EnableConfigModule();
Zerotorescue@31 124
Zerotorescue@31 125 MailOpenerConfig:CommandHandler(msg);
Zerotorescue@31 126 end
Zerotorescue@31 127
Zerotorescue@31 128
Zerotorescue@31 129
Zerotorescue@31 130
Zerotorescue@31 131
Zerotorescue@31 132 -- INTERFACE OPTIONS
Zerotorescue@31 133
Zerotorescue@31 134 -- Attempt to remove the interface options added by AddonLoader (if enabled)
Zerotorescue@31 135 if AddonLoader and AddonLoader.RemoveInterfaceOptions then
Zerotorescue@31 136 AddonLoader:RemoveInterfaceOptions("Mail Opener");
Zerotorescue@31 137 end
Zerotorescue@31 138
Zerotorescue@31 139 -- Now create our own options frame
Zerotorescue@31 140 local frame = CreateFrame("Frame", nil, UIParent);
Zerotorescue@31 141 frame:Hide();
Zerotorescue@31 142 frame.name = "Mail Opener";
Zerotorescue@31 143 frame:HookScript("OnShow", function(self)
Zerotorescue@31 144 -- Enable the config module
Zerotorescue@31 145 MailOpener:EnableConfigModule();
Zerotorescue@31 146
Zerotorescue@31 147 -- Load the options and add it to the blizzard interface list
Zerotorescue@31 148 MailOpenerConfig:Load();
Zerotorescue@31 149
Zerotorescue@31 150 -- Refresh the frame to instantly show the right options
Zerotorescue@31 151 InterfaceOptionsFrame_OpenToCategory(self.name)
Zerotorescue@31 152 end);
Zerotorescue@31 153 -- And add it to the interface options
Zerotorescue@31 154 InterfaceOptions_AddCategory(frame);
Zerotorescue@31 155
Zerotorescue@31 156
Zerotorescue@31 157
Zerotorescue@31 158
Zerotorescue@31 159
Zerotorescue@31 160 -- ADDON / MAIL OPENING STATUS TOGGLER
Zerotorescue@31 161
Zerotorescue@0 162 -- Make the open all checkbox
Zerotorescue@0 163 local check = CreateFrame("CheckButton", "cbMailOpenerEnable", MailFrame, "ChatConfigCheckButtonTemplate");
Zerotorescue@0 164 check:SetHeight(26);
Zerotorescue@0 165 check:SetWidth(26);
Zerotorescue@3 166 check:SetChecked(true);
Zerotorescue@0 167 check:SetHitRectInsets(0, -80, 0, 0);
Zerotorescue@0 168 check:SetScript("OnClick", function(self)
Zerotorescue@3 169 if IsShiftKeyDown() then
Zerotorescue@3 170 -- Shift key = toggle addon on or off, since addon is already on there's only one option
Zerotorescue@3 171
Zerotorescue@3 172 if not MailOpener:IsEnabled() then
Zerotorescue@3 173 print("|cff15ff00Mail Opener|r: Shift key was held down, so |cff00ff00enabling|r the entire addon as well as automatic opening of mail.");
Zerotorescue@3 174
Zerotorescue@3 175 MailOpener:Enable();
Zerotorescue@3 176
Zerotorescue@3 177 -- The above calls MAIL_SHOW which changes AutoOpenMail, so we can't remember the old setting
Zerotorescue@3 178 AutoOpenMail = true;
Zerotorescue@3 179
Zerotorescue@3 180 self:SetChecked(true);
Zerotorescue@3 181 else
Zerotorescue@3 182 print("|cff15ff00Mail Opener|r: Shift key was held down, so |cffff0000disabling|r the entire addon.");
Zerotorescue@3 183
Zerotorescue@3 184 MailOpener:Disable();
Zerotorescue@3 185
Zerotorescue@3 186 self:SetChecked(false);
Zerotorescue@3 187 end
Zerotorescue@0 188 else
Zerotorescue@3 189 -- Normal click
Zerotorescue@3 190
Zerotorescue@3 191 if self:GetChecked() then
Zerotorescue@3 192 print("|cff15ff00Mail Opener|r: |cff00ff00Enabling|r automatic opening of mail.");
Zerotorescue@3 193
Zerotorescue@3 194 AutoOpenMail = true;
Zerotorescue@8 195 MailOpener:ScheduleOpen(false);
Zerotorescue@3 196 else
Zerotorescue@3 197 print("|cff15ff00Mail Opener|r: |cffff0000Disabling|r automatic opening of mail.");
Zerotorescue@3 198
Zerotorescue@3 199 AutoOpenMail = false;
Zerotorescue@3 200 end
Zerotorescue@0 201 end
Zerotorescue@0 202 end);
Zerotorescue@3 203 check.tooltip = "Toggle automatic mail opening on or off (you can force this by holding shift when opening the mailbox.\n\nHold the |cffffffffSHIFT|r key to disable the entire addon.";
Zerotorescue@31 204 check:SetPoint("TOPLEFT", MailFrame, "TOPLEFT", 68, -13);
Zerotorescue@0 205
Zerotorescue@0 206 -- Get reference to the text field
Zerotorescue@0 207 local checkboxText = _G[check:GetName() .. "Text"];
Zerotorescue@0 208 checkboxText:SetText("Mail Opener");
Zerotorescue@0 209 -- We like this color more
Zerotorescue@0 210 checkboxText:SetTextColor(1, 0.8, 0, 1);
Zerotorescue@0 211
Zerotorescue@0 212 self.cbOpenAll = check;
Zerotorescue@0 213
Zerotorescue@31 214
Zerotorescue@31 215
Zerotorescue@31 216
Zerotorescue@31 217 -- CONFIG BUTTON
Zerotorescue@31 218
Zerotorescue@0 219 -- Make the config button
Zerotorescue@0 220 local button = CreateFrame("Button", "btnMailOpenerConfig", MailFrame, "UIPanelButtonTemplate")
Zerotorescue@0 221 button:SetText("Config")
Zerotorescue@0 222 button:SetHeight(23)
Zerotorescue@0 223 button:SetWidth(55)
Zerotorescue@31 224 button:SetPoint("TOPRIGHT", MailFrame, "TOPRIGHT", -55, -13);
Zerotorescue@0 225 button:SetScript("OnClick", function()
Zerotorescue@0 226 MailOpener:EnableConfigModule();
Zerotorescue@0 227
Zerotorescue@0 228 MailOpenerConfig:Show();
Zerotorescue@0 229
Zerotorescue@8 230 --BETA:if MailOpener.db.profile.uses >= 15 then
Zerotorescue@7 231 --BETA: MailOpener:ShowBetaPopup();
Zerotorescue@7 232 --BETA:end
Zerotorescue@0 233 end);
Zerotorescue@0 234
Zerotorescue@0 235 self.btnConfig = button;
Zerotorescue@0 236
Zerotorescue@31 237
Zerotorescue@31 238
Zerotorescue@31 239
Zerotorescue@31 240
Zerotorescue@31 241 -- ADDON LOADING
Zerotorescue@31 242 -- THE BELOW WILL TAKE SOME TIME; WE WILL BE LOADING OTHER ADDONS
Zerotorescue@31 243
Zerotorescue@31 244 if select(6, GetAddOnInfo("Postal")) == nil then
Zerotorescue@31 245 self.PostalEnabled = true; -- Set this as an object variable so we can use it in our modules
Zerotorescue@0 246
Zerotorescue@31 247 -- Ensure this addon is loaded if AddonLoader is installed
Zerotorescue@31 248 if AddonLoader and AddonLoader.LoadAddOn and not Postal then
Zerotorescue@31 249 AddonLoader:LoadAddOn("Postal");
Zerotorescue@31 250 end
Zerotorescue@0 251 end
Zerotorescue@0 252
Zerotorescue@31 253 if select(6, GetAddOnInfo("QuickAuctions")) == nil then
Zerotorescue@31 254 self.QuickAuctionsEnabled = true; -- Set this as an object variable so we can use it in our modules
Zerotorescue@0 255
Zerotorescue@31 256 -- Ensure this addon is loaded if AddonLoader is installed
Zerotorescue@31 257 if AddonLoader and AddonLoader.LoadAddOn then
Zerotorescue@31 258 AddonLoader:LoadAddOn("QuickAuctions");
Zerotorescue@31 259 end
Zerotorescue@31 260 end
Zerotorescue@31 261
Zerotorescue@31 262
Zerotorescue@31 263
Zerotorescue@31 264
Zerotorescue@31 265
Zerotorescue@31 266 -- ADJUST POSITIONS
Zerotorescue@31 267
Zerotorescue@31 268 if self.QuickAuctionsEnabled then
Zerotorescue@31 269 -- QA is enabled so move the checkbox further to the right
Zerotorescue@0 270
Zerotorescue@31 271 self.cbOpenAll:SetPoint("TOPLEFT", MailFrame, "TOPLEFT", 155, -13);
Zerotorescue@31 272 end
Zerotorescue@31 273
Zerotorescue@31 274 if self.PostalEnabled then
Zerotorescue@31 275 self.btnConfig:SetPoint("TOPRIGHT", MailFrame, "TOPRIGHT", -75, -13);
Zerotorescue@31 276 end
Zerotorescue@0 277 end
Zerotorescue@0 278
Zerotorescue@0 279 function MailOpener:OnEnable()
Zerotorescue@0 280 self:RegisterEvent("MAIL_SHOW");
Zerotorescue@0 281 self:RegisterEvent("PLAYER_ENTERING_WORLD");
Zerotorescue@0 282
Zerotorescue@0 283 self.btnConfig:Show();
Zerotorescue@0 284
Zerotorescue@0 285 -- Reset variables
Zerotorescue@0 286 lastAmount = 0;
Zerotorescue@0 287 self.debugChannel = nil;
Zerotorescue@0 288
Zerotorescue@8 289 --BETA:if (self.db.profile.uses % 15) == 0 then
Zerotorescue@7 290 --BETA: -- Automatically show once every 15 uses
Zerotorescue@7 291 --BETA: self:ShowBetaPopup();
Zerotorescue@7 292 --BETA:end
Zerotorescue@0 293
Zerotorescue@0 294 -- If we were toggling this addon on while the mailbox is opened we must register all events again
Zerotorescue@0 295 if MailFrame:IsVisible() then
Zerotorescue@0 296 self:MAIL_SHOW();
Zerotorescue@0 297 end
Zerotorescue@0 298 end
Zerotorescue@0 299
Zerotorescue@0 300 function MailOpener:OnDisable()
Zerotorescue@0 301 self:UnregisterEvent("MAIL_SHOW");
Zerotorescue@0 302
Zerotorescue@0 303 self.btnConfig:Hide();
Zerotorescue@0 304
Zerotorescue@0 305 MailOpener:Stop();
Zerotorescue@0 306 end
Zerotorescue@0 307
Zerotorescue@0 308 -- 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
Zerotorescue@0 309 function MailOpener:PLAYER_ENTERING_WORLD()
Zerotorescue@0 310 self:UnregisterEvent("PLAYER_ENTERING_WORLD");
Zerotorescue@0 311
Zerotorescue@0 312 self:ToggleQAStatus();
Zerotorescue@0 313 end
Zerotorescue@0 314
Zerotorescue@0 315 -- Fired when the mailbox is opened
Zerotorescue@0 316 function MailOpener:MAIL_SHOW()
Zerotorescue@0 317 -- To stop the timer when the mailbox is closed
Zerotorescue@0 318 self:RegisterEvent("MAIL_CLOSED", "Stop");
Zerotorescue@0 319 self:RegisterEvent("PLAYER_LEAVING_WORLD", "Stop");
Zerotorescue@0 320
Zerotorescue@0 321 -- To set the timer for when to refresh again
Zerotorescue@0 322 self:RegisterEvent("MAIL_INBOX_UPDATE");
Zerotorescue@0 323
Zerotorescue@0 324 -- We need to know when opening has completed
Zerotorescue@0 325 self:RegisterMessage("MO_OPEN_COMPLETE");
Zerotorescue@0 326
Zerotorescue@19 327 if self.db.profile.uses == 0 and MailOpener.db.profile.general.defaultStatus ~= "_enabled" then
Zerotorescue@19 328 StaticPopupDialogs["MailOpenerFirstUseConfirmBox"] = {
Zerotorescue@19 329 text = "You are using |cff15ff00Mail Opener|r for the first time. Do you wish to always |cf00ff000enable|r |cfffed000automatic mail opening when you open the mailbox|r?\n\nYou can always change the standard behaviour in the General options.",
Zerotorescue@19 330 button1 = "Yes",
Zerotorescue@19 331 button2 = "No",
Zerotorescue@19 332 OnAccept = function()
Zerotorescue@19 333 MailOpener.db.profile.general.defaultStatus = "_enabled";
Zerotorescue@19 334 print("|cff15ff00Mail Opener|r: You can always change the default status in the General config (|cff00ffff/mo c|r).");
Zerotorescue@19 335
Zerotorescue@19 336 print("|cff15ff00Mail Opener|r: |cff00ff00Enabling|r automatic opening of mail.");
Zerotorescue@19 337 MailOpener.cbOpenAll:SetChecked(true);
Zerotorescue@19 338
Zerotorescue@19 339 AutoOpenMail = true;
Zerotorescue@19 340 MailOpener:ScheduleOpen(false);
Zerotorescue@19 341 end,
Zerotorescue@19 342 OnCancel = function (_,reason)
Zerotorescue@19 343 print("|cff15ff00Mail Opener|r: You can always change the default status in the General config (|cff00ffff/mo c|r).");
Zerotorescue@19 344 end,
Zerotorescue@19 345 timeout = 0,
Zerotorescue@19 346 whileDead = 1,
Zerotorescue@19 347 hideOnEscape = 1,
Zerotorescue@19 348 };
Zerotorescue@19 349 StaticPopup_Show("MailOpenerFirstUseConfirmBox");
Zerotorescue@8 350 end
Zerotorescue@8 351
Zerotorescue@8 352 self.db.profile.uses = ( self.db.profile.uses + 1 );
Zerotorescue@8 353
Zerotorescue@0 354 self:Debug("defaultStatus:" .. self.db.profile.general.defaultStatus);
Zerotorescue@0 355 -- Change the mail opening status according to our settings
Zerotorescue@0 356 if self.db.profile.general.defaultStatus == "_enabled" then
Zerotorescue@3 357 AutoOpenMail = true;
Zerotorescue@3 358 self.cbOpenAll:SetChecked(true);
Zerotorescue@3 359 elseif self.db.profile.general.defaultStatus == "disabled" then
Zerotorescue@3 360 -- Disable auto opening but leave mail opener enabled
Zerotorescue@3 361
Zerotorescue@3 362 AutoOpenMail = false;
Zerotorescue@3 363 self.cbOpenAll:SetChecked(false);
Zerotorescue@3 364 elseif self.db.profile.general.defaultStatus == "xdisabled" then
Zerotorescue@3 365 -- Disable entire addon
Zerotorescue@3 366
Zerotorescue@3 367 MailOpener:Disable();
Zerotorescue@3 368 self.cbOpenAll:SetChecked(false);
Zerotorescue@0 369 end
Zerotorescue@0 370
Zerotorescue@0 371 self:ToggleQAStatus();
Zerotorescue@0 372
Zerotorescue@0 373 -- Hide the InboxTooMuchMail warning to allow room for our mail remaining info line
Zerotorescue@0 374 InboxTooMuchMail:Hide()
Zerotorescue@0 375 InboxTooMuchMail.Show = function() end
Zerotorescue@0 376
Zerotorescue@0 377 if self.QuickAuctionsEnabled then
Zerotorescue@8 378 local QAMail = LibStub("AceAddon-3.0"):GetAddon("QuickAuctions", true):GetModule("Mail", true);
Zerotorescue@0 379
Zerotorescue@8 380 if QAMail then
Zerotorescue@8 381 -- Hide the open all button
Zerotorescue@8 382 QAMail.massOpening:Hide();
Zerotorescue@8 383 -- Hide the x mail remaining text
Zerotorescue@8 384 QAMail.totalMail:Hide();
Zerotorescue@8 385 end
Zerotorescue@0 386 end
Zerotorescue@0 387
Zerotorescue@0 388 if self.db.profile.notifications.welcome then
Zerotorescue@0 389 -- Welcome notification
Zerotorescue@0 390 local _, c = UnitClass("player");
Zerotorescue@0 391 c = RAID_CLASS_COLORS[c];
Zerotorescue@0 392 c = string.format("|cff%02x%02x%02x", c.r * 255 + 0.5, c.g * 255 + 0.5, c.b * 255 + 0.5);
Zerotorescue@0 393
Zerotorescue@0 394 print("|cff15ff00Mail Opener|r: Welcome back "..c..UnitName("player").."|r. Requesting new mail from the local Postal Service, your mail will automatically be opened when it becomes available.");
Zerotorescue@0 395 end
Zerotorescue@0 396
Zerotorescue@0 397 mailboxEmptySoundPlayed = nil;
Zerotorescue@42 398 mailboxEmptySoundPlayedThisVisit = nil;
Zerotorescue@0 399
Zerotorescue@0 400 self:Recheck();
Zerotorescue@0 401
Zerotorescue@0 402 if self.db.profile.general.continueOpening then
Zerotorescue@6 403 -- Continue opening mail, but use the "initial mail opening interval" as time
Zerotorescue@6 404 self:ScheduleOpen(false);
Zerotorescue@0 405 end
Zerotorescue@0 406 end
Zerotorescue@0 407
Zerotorescue@0 408 -- Fired after a successful server sync
Zerotorescue@0 409 -- Fired when mail is deleted (which happens after taking all attachments from a mail sent by the game)
Zerotorescue@0 410 function MailOpener:MAIL_INBOX_UPDATE()
Zerotorescue@0 411 local current, total = GetInboxNumItems();
Zerotorescue@0 412
Zerotorescue@3 413 -- Calculate the amount of mail waiting that actually have attachments
Zerotorescue@3 414 -- If we just compare numbers we won't be including mail that isn't automatically deleted when opened, such as mail with attachments sent by other players
Zerotorescue@3 415 local currentMailWithAttachments = 0;
Zerotorescue@3 416 for i = 1, current do
Zerotorescue@3 417 local _, _, _, _, money, _, _, items = GetInboxHeaderInfo(i);
Zerotorescue@3 418
Zerotorescue@3 419 if (items and items > 0) or (money and money > 0) then
Zerotorescue@3 420 currentMailWithAttachments = currentMailWithAttachments + 1;
Zerotorescue@3 421 end
Zerotorescue@0 422 end
Zerotorescue@0 423
Zerotorescue@3 424 local tempLastAmount = lastAmount;
Zerotorescue@3 425 lastAmount = currentMailWithAttachments;
Zerotorescue@3 426
Zerotorescue@11 427 --if currentMailWithAttachments ~= tempLastAmount then
Zerotorescue@11 428 -- self:Debug("MAIL_INBOX_UPDATE - lastAmount:" .. tempLastAmount .. " - current:" .. currentMailWithAttachments);
Zerotorescue@11 429 --end
Zerotorescue@3 430
Zerotorescue@3 431 if currentMailWithAttachments > tempLastAmount then
Zerotorescue@0 432 -- New messages arrived in our mailbox, so this was a refresh, so set a timer
Zerotorescue@0 433
Zerotorescue@3 434 self:Debug("MO_SERVER_SYNCED");
Zerotorescue@3 435
Zerotorescue@0 436 -- Yell that we successfully synced with the server
Zerotorescue@0 437 self:SendMessage("MO_SERVER_SYNCED");
Zerotorescue@0 438
Zerotorescue@29 439 if MailAddonBusy == MailOpener:GetName() then
Zerotorescue@29 440 MailAddonBusy = nil;
Zerotorescue@29 441 end
Zerotorescue@29 442
Zerotorescue@0 443 -- This list is fresh
Zerotorescue@0 444 freshList = true;
Zerotorescue@0 445 mailboxEmptySoundPlayed = nil;
Zerotorescue@0 446
Zerotorescue@0 447 -- Stop previous timer
Zerotorescue@0 448 self:CancelTimer(self.tmrRecheck, true);
Zerotorescue@0 449 -- More will arrive in 60 seconds
Zerotorescue@0 450 self.tmrRecheck = self:ScheduleTimer(function()
Zerotorescue@0 451 self:Debug("tmrRecheck 61 finished");
Zerotorescue@0 452
Zerotorescue@0 453 -- We can get a fresh list now, so query the server
Zerotorescue@0 454 freshList = false;
Zerotorescue@0 455
Zerotorescue@0 456 -- Look for mail
Zerotorescue@0 457 self:Recheck();
Zerotorescue@0 458 end, 61);
Zerotorescue@0 459 self:Debug("tmrRecheck 61");
Zerotorescue@0 460
Zerotorescue@0 461 if not IsShiftKeyDown() then
Zerotorescue@0 462 -- Allow overriding of mailopening with the shift key
Zerotorescue@0 463
Zerotorescue@0 464 -- Open the current mail
Zerotorescue@0 465 self:ScheduleOpen(false);
Zerotorescue@0 466 end
Zerotorescue@3 467 elseif currentMailWithAttachments < tempLastAmount then
Zerotorescue@2 468 -- We lost a mail
Zerotorescue@2 469
Zerotorescue@19 470 --TODO: NYI: May need to delay this until the mail is actually deleted to keep the mail count more realtime
Zerotorescue@3 471
Zerotorescue@3 472 self:Debug("MO_MAIL_EMPTIED");
Zerotorescue@3 473
Zerotorescue@2 474 -- Yell that we successfully opened/removed a mail
Zerotorescue@3 475 self:SendMessage("MO_MAIL_EMPTIED");
Zerotorescue@3 476 elseif (currentMailWithAttachments == 50 and tempLastAmount == 50) then
Zerotorescue@0 477 if not IsShiftKeyDown() then
Zerotorescue@0 478 -- Allow overriding of mailopening with the shift key
Zerotorescue@0 479
Zerotorescue@0 480 -- Open the current mail
Zerotorescue@0 481 self:ScheduleOpen(false);
Zerotorescue@0 482 end
Zerotorescue@0 483 end
Zerotorescue@0 484 end
Zerotorescue@0 485
Zerotorescue@0 486 function MailOpener:ScheduleOpen(continued)
Zerotorescue@0 487 if lastAmount > 0 then
Zerotorescue@0 488 local waitTime;
Zerotorescue@0 489 if continued then
Zerotorescue@0 490 waitTime = self.db.profile.general.waitTime;
Zerotorescue@0 491 else
Zerotorescue@0 492 -- Even though this is not a continuation and should be instant, we set a .5 second timer to prevent multiple calls of the OpenNow function
Zerotorescue@0 493 waitTime = self.db.profile.general.initialDelay;
Zerotorescue@0 494 end
Zerotorescue@0 495
Zerotorescue@0 496 -- Stop previous timer
Zerotorescue@0 497 self:CancelTimer(self.tmrOpenNow, true);
Zerotorescue@0 498 -- Schedule the next open
Zerotorescue@0 499 self.tmrOpenNow = self:ScheduleTimer("OpenNow", waitTime);
Zerotorescue@0 500 end
Zerotorescue@0 501 end
Zerotorescue@0 502
Zerotorescue@0 503 function MailOpener:OpenNow()
Zerotorescue@8 504 self:Debug("OpenNow (" .. ((MailAddonBusy and "1") or "0") .. ")");
Zerotorescue@8 505 if MailFrame:IsVisible() and AutoOpenMail then
Zerotorescue@0 506 self:Debug("OpenNow");
Zerotorescue@0 507
Zerotorescue@0 508 -- BeanCounter is the only addon hiding the mail close button while busy, so we can look for that
Zerotorescue@31 509 --local BeanCounterActive = not InboxCloseButton:IsVisible();
Zerotorescue@0 510
Zerotorescue@31 511 --if not BeanCounterActive and not MailAddonBusy then
Zerotorescue@31 512 if not MailAddonBusy then
Zerotorescue@8 513 -- No other addon is currently active
Zerotorescue@0 514
Zerotorescue@0 515 self:CancelTimer(self.tmrTryAgain, true); -- Insurance
Zerotorescue@0 516
Zerotorescue@0 517 if QuickAuctionsAutoMail then
Zerotorescue@0 518 -- Remember the last known quick auctions status
Zerotorescue@0 519 lastQuickAuctionsStatus = QuickAuctionsAutoMail:GetChecked();
Zerotorescue@0 520 end
Zerotorescue@0 521 if self.db.profile.general.autoDisableQAAutoMail and self.QuickAuctionsEnabled and QuickAuctionsAutoMail and QuickAuctionsAutoMail:GetChecked() then
Zerotorescue@0 522 -- If auto disable "QA Auto mail" is enabled and QA's auto mail is currently toggled on, turn it off
Zerotorescue@0 523 -- We need to do this with a :click to trigger the right events
Zerotorescue@0 524
Zerotorescue@0 525 self:Debug("Turning automail |cffff0000off|r.");
Zerotorescue@0 526
Zerotorescue@0 527 QuickAuctionsAutoMail:Click();
Zerotorescue@0 528 end
Zerotorescue@0 529
Zerotorescue@8 530 MailAddonBusy = self:GetName();
Zerotorescue@0 531
Zerotorescue@0 532 self:Debug("MO_OPEN_MAIL");
Zerotorescue@0 533
Zerotorescue@0 534 -- Summon the mail opening gods
Zerotorescue@0 535 self:SendMessage("MO_OPEN_MAIL");
Zerotorescue@0 536 else
Zerotorescue@8 537 -- Another addon is ACTIVE
Zerotorescue@31 538 self:Debug("Another addon active, waiting .5 seconds... (" .. MailAddonBusy .. ")");
Zerotorescue@0 539
Zerotorescue@0 540 self:CancelTimer(self.tmrTryAgain, true); -- Insurance
Zerotorescue@8 541 -- Try again every 0.5 seconds
Zerotorescue@0 542 self.tmrTryAgain = self:ScheduleTimer("OpenNow", 0.5);
Zerotorescue@0 543 end
Zerotorescue@0 544 end
Zerotorescue@0 545 end
Zerotorescue@0 546
Zerotorescue@0 547 function MailOpener:MO_OPEN_COMPLETE()
Zerotorescue@8 548 if MailAddonBusy == self:GetName() then
Zerotorescue@8 549 MailAddonBusy = nil;
Zerotorescue@8 550 end
Zerotorescue@1 551
Zerotorescue@1 552 -- Try a recheck
Zerotorescue@1 553 self:Recheck();
Zerotorescue@1 554
Zerotorescue@0 555 local current, total = GetInboxNumItems();
Zerotorescue@0 556
Zerotorescue@0 557 if (total - current) == 0 then
Zerotorescue@3 558 -- There is probably no unopenable mail remaining, so play the sound (if enabled)
Zerotorescue@3 559
Zerotorescue@42 560 if self.db.profile.notifications.mailboxEmptySound and (not MailOpener.db.profile.notifications.mailboxEmptySoundOnlyOnce or not mailboxEmptySoundPlayed) and (not MailOpener.db.profile.notifications.mailboxEmptySoundOnlyOncePerMailboxVisit or not mailboxEmptySoundPlayedThisVisit) then
Zerotorescue@0 561 PlaySoundFile(self.db.profile.notifications.mailboxEmptySoundFile);
Zerotorescue@0 562 mailboxEmptySoundPlayed = true;
Zerotorescue@42 563 mailboxEmptySoundPlayedThisVisit = true;
Zerotorescue@0 564 end
Zerotorescue@0 565 end
Zerotorescue@0 566
Zerotorescue@3 567 if self.QuickAuctionsEnabled then
Zerotorescue@3 568 -- Quick Auctions enabled?
Zerotorescue@3 569 -- Toggle automailing as per settings
Zerotorescue@0 570
Zerotorescue@3 571 if self.db.profile.general.autoReenableQAAutoMail and QuickAuctionsAutoMail and not QuickAuctionsAutoMail:GetChecked() then
Zerotorescue@3 572 -- If auto re-enable "QA Auto mail" is enabled and QA's auto mail is currently toggled OFF, turn it on
Zerotorescue@3 573 -- We need to do this with a :click to trigger the right events
Zerotorescue@3 574
Zerotorescue@0 575 self:Debug("Turning automail |cff00ff00on|r.");
Zerotorescue@3 576
Zerotorescue@3 577 QuickAuctionsAutoMail:Click();
Zerotorescue@3 578 elseif self.db.profile.general.autoSetBackQAAutoMail and QuickAuctionsAutoMail and lastQuickAuctionsStatus ~= QuickAuctionsAutoMail:GetChecked() then
Zerotorescue@3 579 -- 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
Zerotorescue@3 580 -- We need to do this with a :click to trigger the right events
Zerotorescue@3 581
Zerotorescue@3 582 if lastQuickAuctionsStatus then
Zerotorescue@3 583 self:Debug("Turning automail |cff00ff00on|r.");
Zerotorescue@3 584 else
Zerotorescue@3 585 self:Debug("Turning automail |cffff0000off|r.");
Zerotorescue@3 586 end
Zerotorescue@3 587
Zerotorescue@3 588 QuickAuctionsAutoMail:Click();
Zerotorescue@0 589 end
Zerotorescue@0 590 end
Zerotorescue@0 591
Zerotorescue@0 592 if self.db.profile.general.continueOpening then
Zerotorescue@0 593 self:ScheduleOpen(true);
Zerotorescue@0 594 end
Zerotorescue@0 595 end
Zerotorescue@0 596
Zerotorescue@0 597 -- Run another CheckInbox
Zerotorescue@0 598 function MailOpener:Recheck()
Zerotorescue@0 599 self:Debug("|cffffff00Recheck|r");
Zerotorescue@0 600
Zerotorescue@0 601 -- Freshlist prevents this from being run too often
Zerotorescue@0 602 -- It is set to true after a server sync
Zerotorescue@0 603 -- and set to false 61 seconds afterwards with a recheck called instantly after it
Zerotorescue@3 604
Zerotorescue@3 605 -- We're not refreshing while we're opening because it is automatically done when current batch was completely opened
Zerotorescue@8 606 if not freshList and MailFrame:IsVisible() then
Zerotorescue@0 607 self:Debug("|cff00ff00Recheck|r");
Zerotorescue@0 608
Zerotorescue@0 609 -- If this isn't a fresh list (so messages weren't received within the last 60 seconds) and the mailbox wasn't closed
Zerotorescue@0 610
Zerotorescue@0 611 -- BeanCounter is the only addon hiding the mail close button while busy, so we can look for that
Zerotorescue@31 612 --local BeanCounterActive = not InboxCloseButton:IsVisible();
Zerotorescue@0 613
Zerotorescue@31 614 --if not BeanCounterActive and AutoOpenMail and not MailAddonBusy then
Zerotorescue@31 615 if AutoOpenMail and not MailAddonBusy then
Zerotorescue@0 616 -- Query the server
Zerotorescue@0 617 CheckInbox();
Zerotorescue@0 618 end
Zerotorescue@0 619
Zerotorescue@0 620 -- Stop previous timer
Zerotorescue@0 621 self:CancelTimer(self.tmrRecheck, true);
Zerotorescue@0 622 -- Keep trying until it works
Zerotorescue@0 623 self.tmrRecheck = self:ScheduleTimer("Recheck", 2);
Zerotorescue@0 624
Zerotorescue@0 625 self:Debug("tmrRecheck 2");
Zerotorescue@0 626 end
Zerotorescue@0 627 end
Zerotorescue@0 628
Zerotorescue@0 629 -- Stop checking for new mail and unregister the events we needed
Zerotorescue@0 630 function MailOpener:Stop()
Zerotorescue@0 631 if self.db.profile.notifications.bye then
Zerotorescue@0 632 print("|cff15ff00Mail Opener|r: Have a nice day. :)");
Zerotorescue@0 633 end
Zerotorescue@0 634
Zerotorescue@8 635 if MailAddonBusy == self:GetName() then
Zerotorescue@8 636 MailAddonBusy = nil;
Zerotorescue@8 637 end
Zerotorescue@0 638
Zerotorescue@0 639 -- We won't need this anymore
Zerotorescue@0 640 self:UnregisterEvent("MAIL_CLOSED");
Zerotorescue@0 641 self:UnregisterEvent("PLAYER_LEAVING_WORLD");
Zerotorescue@0 642 self:UnregisterEvent("MAIL_INBOX_UPDATE");
Zerotorescue@0 643
Zerotorescue@0 644 -- Messages
Zerotorescue@0 645 self:UnregisterMessage("MO_OPEN_COMPLETE");
Zerotorescue@0 646
Zerotorescue@0 647 -- Timers
Zerotorescue@0 648 self:CancelTimer(self.tmrTryAgain, true);
Zerotorescue@0 649 self:CancelTimer(self.tmrOpenNow, true);
Zerotorescue@0 650
Zerotorescue@0 651 -- If we wait with disabling QA automail until MAIL_SHOW, QA will beat us to it and already start sending stuff
Zerotorescue@0 652 self:ToggleQAStatus();
Zerotorescue@0 653 end
Zerotorescue@0 654
Zerotorescue@0 655 function MailOpener:Debug(t)
Zerotorescue@0 656 if not self.debugChannel and self.debugChannel ~= false then
Zerotorescue@0 657 -- We want to check just once, so if you add a debug channel later just do a /reload (registering an event for this is wasted resources)
Zerotorescue@0 658 self.debugChannel = false;
Zerotorescue@0 659
Zerotorescue@0 660 for i = 1, NUM_CHAT_WINDOWS do
Zerotorescue@0 661 local name = GetChatWindowInfo(i);
Zerotorescue@0 662
Zerotorescue@0 663 if name:upper() == "DEBUG" then
Zerotorescue@0 664 self.debugChannel = _G["ChatFrame" .. i];
Zerotorescue@0 665 end
Zerotorescue@0 666 end
Zerotorescue@0 667 end
Zerotorescue@0 668
Zerotorescue@0 669 if self.debugChannel then
Zerotorescue@0 670 self.debugChannel:AddMessage(t);
Zerotorescue@0 671 end
Zerotorescue@0 672 end
Zerotorescue@0 673
Zerotorescue@0 674 -- Enable our config module if it's disabled and make a reference to it
Zerotorescue@0 675 function MailOpener:EnableConfigModule()
Zerotorescue@0 676 if not MailOpenerConfig then
Zerotorescue@0 677 MailOpenerConfig = self:GetModule("Config");
Zerotorescue@0 678 MailOpenerConfig:Enable();
Zerotorescue@0 679 end
Zerotorescue@0 680 end
Zerotorescue@0 681
Zerotorescue@0 682 -- Toggle Postal's opening modules on or off
Zerotorescue@0 683 function MailOpener:TogglePostalModule(name, status)
Zerotorescue@0 684 if MailOpener.PostalEnabled and Postal then
Zerotorescue@0 685 -- Postal must be enabled
Zerotorescue@0 686
Zerotorescue@3 687 -- Toggle module (let Postal handle this)
Zerotorescue@3 688 Postal.ToggleModule(nil, name, Postal:GetModule(name), status);
Zerotorescue@0 689 end
Zerotorescue@0 690 end
Zerotorescue@0 691
Zerotorescue@0 692 -- Change Quick Auction's auto mail status based on our prefered settings
Zerotorescue@0 693 function MailOpener:ToggleQAStatus()
Zerotorescue@0 694 self:Debug("defaultQAStatus:" .. self.db.profile.general.defaultQAStatus);
Zerotorescue@0 695
Zerotorescue@0 696 if self.QuickAuctionsEnabled and self.db.profile.general.defaultQAStatus ~= "__remember" and QuickAuctionsAutoMail then
Zerotorescue@0 697 if self.db.profile.general.defaultQAStatus == "_enabled" and not QuickAuctionsAutoMail:GetChecked() then
Zerotorescue@0 698 self:Debug("Turning automail |cff00ff00on|r.");
Zerotorescue@0 699
Zerotorescue@0 700 QuickAuctionsAutoMail:Click();
Zerotorescue@0 701 elseif self.db.profile.general.defaultQAStatus == "disabled" and QuickAuctionsAutoMail:GetChecked() then
Zerotorescue@0 702 self:Debug("Turning automail |cffff0000off|r.");
Zerotorescue@0 703
Zerotorescue@0 704 QuickAuctionsAutoMail:Click();
Zerotorescue@0 705 end
Zerotorescue@0 706 end
Zerotorescue@0 707 end
Zerotorescue@0 708
Zerotorescue@0 709 function MailOpener:FormatMoney(copper)
Zerotorescue@0 710 local gold = floor( copper / 10000 );
Zerotorescue@0 711 local silver = floor( ( copper - ( gold * 10000 ) ) / 100 );
Zerotorescue@0 712 local copper = mod(copper, 100);
Zerotorescue@0 713
Zerotorescue@0 714 if gold > 0 then
Zerotorescue@0 715 return format(GOLD_AMOUNT_TEXTURE .. " " .. SILVER_AMOUNT_TEXTURE .. " " .. COPPER_AMOUNT_TEXTURE, gold, 0, 0, silver, 0, 0, copper, 0, 0);
Zerotorescue@0 716 elseif silver > 0 then
Zerotorescue@0 717 return format(SILVER_AMOUNT_TEXTURE .. " " .. COPPER_AMOUNT_TEXTURE, silver, 0, 0, copper, 0, 0);
Zerotorescue@0 718 else
Zerotorescue@0 719 return format(COPPER_AMOUNT_TEXTURE, copper, 0, 0);
Zerotorescue@0 720 end
Zerotorescue@0 721 end
Zerotorescue@0 722
Zerotorescue@7 723 -- General copy window for multiple things (clickable URLs, the time remaining, and such)
Zerotorescue@0 724 StaticPopupDialogs["MailOpenerCopyWindow"] = {
Zerotorescue@0 725 text = "Please CTRL-C to copy.",
Zerotorescue@0 726 button2 = CLOSE,
Zerotorescue@0 727 hasEditBox = 1,
Zerotorescue@0 728 hasWideEditBox = 1,
Zerotorescue@0 729 OnShow = function()
Zerotorescue@0 730 local editBox = _G[this:GetName().."WideEditBox"];
Zerotorescue@0 731 if editBox and MailOpener.currentPopupContents then
Zerotorescue@0 732 editBox:SetText(MailOpener.currentPopupContents);
Zerotorescue@0 733 editBox:SetFocus();
Zerotorescue@0 734 editBox:HighlightText(0);
Zerotorescue@0 735 end
Zerotorescue@0 736
Zerotorescue@0 737 -- Position the close button in the middle
Zerotorescue@0 738 local button = _G[this:GetName().."Button2"];
Zerotorescue@0 739 if button then
Zerotorescue@0 740 -- Remove previous know position
Zerotorescue@0 741 button:ClearAllPoints();
Zerotorescue@0 742 button:SetWidth(200);
Zerotorescue@0 743 -- Reposition in the center
Zerotorescue@0 744 button:SetPoint("CENTER", editBox, "CENTER", 0, -30);
Zerotorescue@0 745 end
Zerotorescue@0 746 end,
Zerotorescue@0 747 EditBoxOnEscapePressed = function()
Zerotorescue@0 748 this:GetParent():Hide();
Zerotorescue@0 749 end,
Zerotorescue@0 750 timeout = 0,
Zerotorescue@0 751 whileDead = 1,
Zerotorescue@0 752 hideOnEscape = 1,
Zerotorescue@0 753 maxLetters = 1024,
Zerotorescue@1 754 };
Zerotorescue@1 755
Zerotorescue@7 756 --BETA: The below either has to be removed or changed when releasing
Zerotorescue@0 757
Zerotorescue@7 758 --[[
Zerotorescue@7 759 BETA/ALPHA request box
Zerotorescue@0 760 function MailOpener:ShowBetaPopup()
Zerotorescue@0 761 function TableDump(key, val, jumps)
Zerotorescue@0 762 local cache = "";
Zerotorescue@0 763
Zerotorescue@0 764 if not jumps then
Zerotorescue@0 765 jumps = 0;
Zerotorescue@0 766 end
Zerotorescue@0 767
Zerotorescue@0 768 local spacer = "";
Zerotorescue@0 769 if jumps > 0 then
Zerotorescue@0 770 for i = 1, jumps do
Zerotorescue@0 771 spacer = spacer .. " ";
Zerotorescue@0 772 end
Zerotorescue@0 773 end
Zerotorescue@0 774
Zerotorescue@0 775 if type(val) == "table" then
Zerotorescue@0 776 cache = cache .. spacer .. key .. " = {\n";
Zerotorescue@0 777 foreach(val, function(k, v)
Zerotorescue@0 778 cache = cache .. TableDump(k, v, (jumps + 1));
Zerotorescue@0 779 end);
Zerotorescue@0 780 cache = cache .. spacer .. "},\n";
Zerotorescue@0 781 else
Zerotorescue@0 782 cache = cache .. spacer .. key .. " = " .. tostring(val) .. ",\n";
Zerotorescue@0 783 end
Zerotorescue@0 784
Zerotorescue@0 785 return cache;
Zerotorescue@0 786 end
Zerotorescue@0 787
Zerotorescue@0 788 local cache = "";
Zerotorescue@0 789 foreach(MailOpener.db.profile, function(k, v)
Zerotorescue@0 790 cache = cache .. TableDump(k, v, 0);
Zerotorescue@0 791 end);
Zerotorescue@0 792
Zerotorescue@0 793 local AceGUI = LibStub("AceGUI-3.0");
Zerotorescue@0 794 local frame = AceGUI:Create("Frame");
Zerotorescue@0 795 frame:SetTitle("Mail Opener ALPHA");
Zerotorescue@0 796 frame:SetWidth(575);
Zerotorescue@0 797 frame:SetHeight(375);
Zerotorescue@0 798
Zerotorescue@0 799 -- Add a normal description label
Zerotorescue@0 800 local desc = AceGUI:Create("Label");
Zerotorescue@0 801 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");
Zerotorescue@0 802 desc:SetFont(GameFontHighlightSmall:GetFont(), 13);
Zerotorescue@0 803 desc:SetFullWidth(true);
Zerotorescue@0 804 frame:AddChild(desc);
Zerotorescue@0 805
Zerotorescue@0 806 -- Add a MultiLineEditBox
Zerotorescue@0 807 local settingsMLEEB = AceGUI:Create("MultiLineEditBox");
Zerotorescue@0 808 settingsMLEEB:SetText(cache);
Zerotorescue@0 809 settingsMLEEB:SetLabel("Hit CTRL-A to select all and CTRL-C to copy the text. You can then use CTRL-V to paste.");
Zerotorescue@0 810 settingsMLEEB:SetFullWidth(true);
Zerotorescue@0 811 settingsMLEEB:SetNumLines(8);
Zerotorescue@0 812 settingsMLEEB:DisableButton(true);
Zerotorescue@0 813 settingsMLEEB:SetCallback("OnTextChanged", function()
Zerotorescue@0 814 settingsMLEEB:SetText(cache);
Zerotorescue@0 815 end);
Zerotorescue@0 816 frame:AddChild(settingsMLEEB);
Zerotorescue@0 817
Zerotorescue@0 818 -- Empty line between the two links
Zerotorescue@0 819 local label = AceGUI:Create("Label");
Zerotorescue@0 820 label:SetText("Please post the above text at either of these two links:");
Zerotorescue@0 821 label:SetFullWidth(true);
Zerotorescue@0 822 frame:AddChild(label);
Zerotorescue@0 823
Zerotorescue@0 824 local desc1 = AceGUI:Create("InteractiveLabel");
Zerotorescue@0 825 desc1:SetText("|cff00bbbb[http://wow.curseforge.com/addons/mailopener/create-ticket/]|r");
Zerotorescue@0 826 desc1:SetFont(GameFontHighlightSmall:GetFont(), 13);
Zerotorescue@0 827 desc1:SetFullWidth(true);
Zerotorescue@0 828 desc1:SetCallback("OnClick", function()
Zerotorescue@0 829 MailOpener.currentPopupContents = "http://wow.curseforge.com/addons/mailopener/create-ticket/";
Zerotorescue@0 830
Zerotorescue@0 831 StaticPopup_Show("MailOpenerCopyWindow");
Zerotorescue@0 832 end);
Zerotorescue@0 833 desc1:SetCallback("OnEnter", function()
Zerotorescue@0 834 frame:SetStatusText("Click to copy this URL.");
Zerotorescue@0 835 end);
Zerotorescue@0 836 desc1:SetCallback("OnLeave", function()
Zerotorescue@0 837 frame:SetStatusText("");
Zerotorescue@0 838 end);
Zerotorescue@0 839 frame:AddChild(desc1);
Zerotorescue@0 840
Zerotorescue@0 841 -- Empty line between the two links
Zerotorescue@0 842 local spacer = AceGUI:Create("Label");
Zerotorescue@0 843 spacer:SetText(" ");
Zerotorescue@0 844 frame:AddChild(spacer);
Zerotorescue@0 845
Zerotorescue@0 846 local desc2 = AceGUI:Create("InteractiveLabel");
Zerotorescue@0 847 desc2:SetText("|cff00bbbb[http://20kleveling.com/JMTCforum/posting.php?mode=reply&f=9&t=1403]|r");
Zerotorescue@0 848 desc2:SetFont(GameFontHighlightSmall:GetFont(), 13);
Zerotorescue@0 849 desc2:SetFullWidth(true);
Zerotorescue@0 850 desc2:SetCallback("OnClick", function()
Zerotorescue@0 851 MailOpener.currentPopupContents = "http://20kleveling.com/JMTCforum/posting.php?mode=reply&f=9&t=1403";
Zerotorescue@0 852
Zerotorescue@0 853 StaticPopup_Show("MailOpenerCopyWindow");
Zerotorescue@0 854 end);
Zerotorescue@0 855 desc2:SetCallback("OnEnter", function()
Zerotorescue@0 856 frame:SetStatusText("Click to copy this URL.");
Zerotorescue@0 857 end);
Zerotorescue@0 858 desc2:SetCallback("OnLeave", function()
Zerotorescue@0 859 frame:SetStatusText("");
Zerotorescue@0 860 end);
Zerotorescue@0 861 frame:AddChild(desc2);
Zerotorescue@0 862
Zerotorescue@0 863 -- Empty line between the two links
Zerotorescue@0 864 local label = AceGUI:Create("Label");
Zerotorescue@0 865 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.");
Zerotorescue@0 866 label:SetFullWidth(true);
Zerotorescue@0 867 frame:AddChild(label);
Zerotorescue@7 868 end
Zerotorescue@7 869 ]]