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