comparison Core.lua @ 68:eadff31e61e8

Localization of all files. Testing packager settings (especially automatic locale exports), localization is not yet finished.
author Zerotorescue
date Wed, 15 Sep 2010 13:10:56 +0200
parents 4166a335ca81
children c15dbeb84ddc
comparison
equal deleted inserted replaced
67:4166a335ca81 68:eadff31e61e8
1 -- You can access this addon's object through: LibStub("AceAddon-3.0"):GetAddon("MailOpener") 1 -- You can access this addon's object through: LibStub("AceAddon-3.0"):GetAddon("MailOpener")
2 local MailOpener = LibStub("AceAddon-3.0"):NewAddon("MailOpener", "AceEvent-3.0", "AceTimer-3.0"); 2 local MailOpener = LibStub("AceAddon-3.0"):NewAddon("MailOpener", "AceEvent-3.0", "AceTimer-3.0");
3 local L = LibStub("AceLocale-3.0"):GetLocale("MailOpener");
3 4
4 -- You can check if MailOpener is busy with the global MailAddonBusy (if not MailAddonBusy then ...do something... end) 5 -- You can check if MailOpener is busy with the global MailAddonBusy (if not MailAddonBusy then ...do something... end)
5 -- MailAddonBusy will be nil when nothing is happening or filled with the addon name when MO is working 6 -- MailAddonBusy will be nil when nothing is happening or filled with the addon name when MO is working
6 -- Another addon can use this variable to indicate they're working too, MailOpener will then wait for that to finish 7 -- Another addon can use this variable to indicate they're working too, MailOpener will then wait for that to finish
7 8
97 98
98 -- Don't enable the config module until we need it 99 -- Don't enable the config module until we need it
99 for name, module in self:IterateModules() do 100 for name, module in self:IterateModules() do
100 if self.db.profile.modules[name] ~= nil then 101 if self.db.profile.modules[name] ~= nil then
101 if self.db.profile.modules[name] then 102 if self.db.profile.modules[name] then
102 self:Debug("|cff00ff00Enabling|r module: " .. name); 103 self:Debug(("|cff00ff00Enabling|r module: "):format(name));
103 else 104 else
104 self:Debug("|cffff0000Disabling|r module: " .. name); 105 self:Debug(("|cffff0000Disabling|r module: "):format(name));
105 end 106 end
106 107
107 module:SetEnabledState(self.db.profile.modules[name]); 108 module:SetEnabledState(self.db.profile.modules[name]);
108 end 109 end
109 end 110 end
173 check:SetScript("OnClick", function(self) 174 check:SetScript("OnClick", function(self)
174 if IsShiftKeyDown() then 175 if IsShiftKeyDown() then
175 -- Shift key = toggle addon on or off, since addon is already on there's only one option 176 -- Shift key = toggle addon on or off, since addon is already on there's only one option
176 177
177 if not MailOpener:IsEnabled() then 178 if not MailOpener:IsEnabled() then
178 print("|cff15ff00Mail Opener|r: Shift key was held down, so |cff00ff00enabling|r the entire addon as well as automatic opening of mail."); 179 self:Print(L["Shift key was held down, so |cff00ff00enabling|r the entire addon as well as automatic opening of mail."]);
179 180
180 MailOpener:Enable(); 181 MailOpener:Enable();
181 182
182 -- The above calls MAIL_SHOW which changes AutoOpenMail, so we can't remember the old setting 183 -- The above calls MAIL_SHOW which changes AutoOpenMail, so we can't remember the old setting
183 AutoOpenMail = true; 184 AutoOpenMail = true;
184 185
185 self:SetChecked(true); 186 self:SetChecked(true);
186 else 187 else
187 print("|cff15ff00Mail Opener|r: Shift key was held down, so |cffff0000disabling|r the entire addon."); 188 self:Print(L["Shift key was held down, so |cffff0000disabling|r the entire addon."]);
188 189
189 MailOpener:Disable(); 190 MailOpener:Disable();
190 191
191 self:SetChecked(false); 192 self:SetChecked(false);
192 end 193 end
193 else 194 else
194 -- Normal click 195 -- Normal click
195 196
196 if self:GetChecked() then 197 if self:GetChecked() then
197 print("|cff15ff00Mail Opener|r: |cff00ff00Enabling|r automatic opening of mail."); 198 self:Print(L["|cff00ff00Enabling|r automatic opening of mail."]);
198 199
199 AutoOpenMail = true; 200 AutoOpenMail = true;
200 MailOpener:ScheduleOpen(false); 201 MailOpener:ScheduleOpen(false);
201 else 202 else
202 print("|cff15ff00Mail Opener|r: |cffff0000Disabling|r automatic opening of mail."); 203 self:Print(L["|cffff0000Disabling|r automatic opening of mail."]);
203 204
204 AutoOpenMail = false; 205 AutoOpenMail = false;
205 end 206 end
206 end 207 end
207 end); 208 end);
208 check.tooltipTitle = "Mail Opener status"; 209 check.tooltipTitle = L["Mail Opener status"];
209 check.tooltip = "Toggle automatic mail opening |cff00ff00on|r or |cffff0000off|r (you can also enforce this by holding shift when opening the mailbox).\n\nYou can toggle this addon |cff00ff00on|r or |cffff0000off|r by |cfffed000shift-clicking|r this checkbox."; 210 check.tooltip = L["Toggle automatic mail opening |cff00ff00on|r or |cffff0000off|r (you can also enforce this by holding shift when opening the mailbox).\n\nYou can toggle this addon |cff00ff00on|r or |cffff0000off|r by |cfffed000shift-clicking|r this checkbox."];
210 check:SetScript("OnEnter", function(self) 211 check:SetScript("OnEnter", function(self)
211 if MailOpener.db.profile.general.showHelpTooltips then 212 if MailOpener.db.profile.general.showHelpTooltips then
212 GameTooltip:SetOwner(self, "ANCHOR_BOTTOM") 213 GameTooltip:SetOwner(self, "ANCHOR_BOTTOM")
213 GameTooltip:SetPoint("BOTTOM", self, "BOTTOM") 214 GameTooltip:SetPoint("BOTTOM", self, "BOTTOM")
214 GameTooltip:SetText(self.tooltipTitle, 1, .82, 0, 1) 215 GameTooltip:SetText(self.tooltipTitle, 1, .82, 0, 1)
224 GameTooltip:Hide(); 225 GameTooltip:Hide();
225 end); 226 end);
226 227
227 -- Get reference to the text field 228 -- Get reference to the text field
228 local checkboxText = _G[check:GetName() .. "Text"]; 229 local checkboxText = _G[check:GetName() .. "Text"];
229 checkboxText:SetText("Mail Opener"); 230 checkboxText:SetText(L["Mail Opener"]);
230 231
231 self.cbOpenAll = check; 232 self.cbOpenAll = check;
232 233
233 234
234 235
235 236
236 -- CONFIG BUTTON 237 -- CONFIG BUTTON
237 238
238 -- Make the config button 239 -- Make the config button
239 local button = CreateFrame("Button", "btnMailOpenerConfig", MailFrame, "UIPanelButtonTemplate") 240 local button = CreateFrame("Button", "btnMailOpenerConfig", MailFrame, "UIPanelButtonTemplate")
240 button:SetText("Config") 241 button:SetText(L["Config"])
241 button:SetHeight(23) 242 button:SetHeight(23)
242 button:SetWidth(55) 243 button:SetWidth(55)
243 button:SetPoint("TOPRIGHT", MailFrame, "TOPRIGHT", -55, -13); 244 button:SetPoint("TOPRIGHT", MailFrame, "TOPRIGHT", -55, -13);
244 button:SetScript("OnClick", function() 245 button:SetScript("OnClick", function()
245 MailOpener:EnableConfigModule(); 246 MailOpener:EnableConfigModule();
248 249
249 --BETA:if MailOpener.db.profile.uses >= 15 then 250 --BETA:if MailOpener.db.profile.uses >= 15 then
250 --BETA: MailOpener:ShowBetaPopup(); 251 --BETA: MailOpener:ShowBetaPopup();
251 --BETA:end 252 --BETA:end
252 end); 253 end);
253 button.tooltipTitle = "Mail Opener Config"; 254 button.tooltipTitle = L["Mail Opener Config"];
254 button.tooltip = "Click to open the configuration window for Mail Opener."; 255 button.tooltip = L["Click to open the configuration window for Mail Opener."];
255 button:SetScript("OnEnter", function(self) 256 button:SetScript("OnEnter", function(self)
256 if MailOpener.db.profile.general.showHelpTooltips then 257 if MailOpener.db.profile.general.showHelpTooltips then
257 GameTooltip:SetOwner(self, "ANCHOR_BOTTOM") 258 GameTooltip:SetOwner(self, "ANCHOR_BOTTOM")
258 GameTooltip:SetPoint("BOTTOM", self, "TOP") 259 GameTooltip:SetPoint("BOTTOM", self, "TOP")
259 GameTooltip:SetText(self.tooltipTitle, 1, .82, 0, 1) 260 GameTooltip:SetText(self.tooltipTitle, 1, .82, 0, 1)
361 -- We need to know when opening has completed 362 -- We need to know when opening has completed
362 self:RegisterMessage("MO_OPEN_COMPLETE"); 363 self:RegisterMessage("MO_OPEN_COMPLETE");
363 364
364 if self.db.profile.uses == 0 and MailOpener.db.profile.general.defaultStatus ~= "_enabled" then 365 if self.db.profile.uses == 0 and MailOpener.db.profile.general.defaultStatus ~= "_enabled" then
365 StaticPopupDialogs["MailOpenerFirstUseConfirmBox"] = { 366 StaticPopupDialogs["MailOpenerFirstUseConfirmBox"] = {
366 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.", 367 text = L["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 behavior in the General options."],
367 button1 = "Yes", 368 button1 = L["Yes"],
368 button2 = "No", 369 button2 = L["No"],
369 OnAccept = function() 370 OnAccept = function()
370 MailOpener.db.profile.general.defaultStatus = "_enabled"; 371 MailOpener.db.profile.general.defaultStatus = "_enabled";
371 print("|cff15ff00Mail Opener|r: You can always change the default status in the General config (|cff00ffff/mo c|r)."); 372 self:Print(L["You can always change the default status in the General config (|cff00ffff/mo c|r)."]);
372 373
373 print("|cff15ff00Mail Opener|r: |cff00ff00Enabling|r automatic opening of mail."); 374 self:Print(L["|cff00ff00Enabling|r automatic opening of mail."]);
374 MailOpener.cbOpenAll:SetChecked(true); 375 MailOpener.cbOpenAll:SetChecked(true);
375 376
376 AutoOpenMail = true; 377 AutoOpenMail = true;
377 MailOpener:ScheduleOpen(false); 378 MailOpener:ScheduleOpen(false);
378 end, 379 end,
379 OnCancel = function (_,reason) 380 OnCancel = function (_,reason)
380 print("|cff15ff00Mail Opener|r: You can always change the default status in the General config (|cff00ffff/mo c|r)."); 381 self:Print(L["You can always change the default status in the General config (|cff00ffff/mo c|r)."]);
381 end, 382 end,
382 timeout = 0, 383 timeout = 0,
383 whileDead = 1, 384 whileDead = 1,
384 hideOnEscape = 1, 385 hideOnEscape = 1,
385 }; 386 };
404 MailOpener:Disable(); 405 MailOpener:Disable();
405 self.cbOpenAll:SetChecked(false); 406 self.cbOpenAll:SetChecked(false);
406 end 407 end
407 408
408 if IsShiftKeyDown() then 409 if IsShiftKeyDown() then
409 print("|cff15ff00Mail Opener|r: |cffff0000Disabling|r automatic opening of mail, shift key was down when opening the mailbox."); 410 self:Print(L["|cffff0000Disabling|r automatic opening of mail, shift key was down when opening the mailbox."]);
410 411
411 AutoOpenMail = false; 412 AutoOpenMail = false;
412 self.cbOpenAll:SetChecked(false); 413 self.cbOpenAll:SetChecked(false);
413 end 414 end
414 415
425 -- Hide the open all button 426 -- Hide the open all button
426 QAMail.massOpening:Hide(); 427 QAMail.massOpening:Hide();
427 -- Hide the x mail remaining text 428 -- Hide the x mail remaining text
428 QAMail.totalMail:Hide(); 429 QAMail.totalMail:Hide();
429 end 430 end
430 end
431
432 if self.db.profile.notifications.welcome then
433 -- Welcome notification
434 local _, c = UnitClass("player");
435 c = RAID_CLASS_COLORS[c];
436 c = string.format("|cff%02x%02x%02x", c.r * 255 + 0.5, c.g * 255 + 0.5, c.b * 255 + 0.5);
437
438 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.");
439 end 431 end
440 432
441 mailboxEmptySoundPlayed = nil; 433 mailboxEmptySoundPlayed = nil;
442 mailboxEmptySoundPlayedThisVisit = nil; 434 mailboxEmptySoundPlayedThisVisit = nil;
443 435
662 end 654 end
663 end 655 end
664 656
665 -- Stop checking for new mail and unregister the events we needed 657 -- Stop checking for new mail and unregister the events we needed
666 function MailOpener:Stop() 658 function MailOpener:Stop()
667 if self.db.profile.notifications.bye then
668 print("|cff15ff00Mail Opener|r: Have a nice day. :)");
669 end
670
671 if MailAddonBusy == self:GetName() then 659 if MailAddonBusy == self:GetName() then
672 MailAddonBusy = nil; 660 MailAddonBusy = nil;
673 end 661 end
674 662
675 -- We won't need this anymore 663 -- We won't need this anymore
703 end 691 end
704 692
705 if self.debugChannel then 693 if self.debugChannel then
706 self.debugChannel:AddMessage(t); 694 self.debugChannel:AddMessage(t);
707 end 695 end
696 end
697
698 function MailOpener:Print(text)
699 print(L["|cff15ff00Mail Opener|r: %s"]:format(text));
708 end 700 end
709 701
710 -- Enable our config module if it's disabled and make a reference to it 702 -- Enable our config module if it's disabled and make a reference to it
711 function MailOpener:EnableConfigModule() 703 function MailOpener:EnableConfigModule()
712 if not MailOpenerConfig then 704 if not MailOpenerConfig then
756 end 748 end
757 end 749 end
758 750
759 -- General copy window for multiple things (clickable URLs, the time remaining, and such) 751 -- General copy window for multiple things (clickable URLs, the time remaining, and such)
760 StaticPopupDialogs["MailOpenerCopyWindow"] = { 752 StaticPopupDialogs["MailOpenerCopyWindow"] = {
761 text = "Please CTRL-C to copy.", 753 text = L["Press CTRL-C to copy."],
762 button2 = CLOSE, 754 button2 = CLOSE,
763 hasEditBox = 1, 755 hasEditBox = 1,
764 hasWideEditBox = 1, 756 hasWideEditBox = 1,
765 OnShow = function() 757 OnShow = function()
766 local editBox = _G[this:GetName().."WideEditBox"]; 758 local editBox = _G[this:GetName().."WideEditBox"];