-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPostal.lua
More file actions
672 lines (608 loc) · 20.4 KB
/
Copy pathPostal.lua
File metadata and controls
672 lines (608 loc) · 20.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
local Postal = LibStub("AceAddon-3.0"):NewAddon("Postal", "AceEvent-3.0", "AceHook-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Postal")
_G["Postal"] = Postal
-- defaults for storage
local defaults = {
profile = {
ModuleEnabledState = {
["*"] = true
},
OpenSpeed = 0.50,
ChatOutput = 1,
Select = {
SpamChat = true,
KeepFreeSpace = 1,
},
OpenAll = {
AHCancelled = true,
AHExpired = true,
AHOutbid = true,
AHSuccess = true,
AHWon = true,
NeutralAHCancelled = true,
NeutralAHExpired = true,
NeutralAHOutbid = true,
NeutralAHSuccess = true,
NeutralAHWon = true,
Postmaster = true,
Attachments = true,
SpamChat = true,
KeepFreeSpace = 1,
},
Express = {
EnableAltClick = true,
AutoSend = true,
BulkSend = true,
MouseWheel = true,
MultiItemTooltip = true,
},
BlackBook = {
AutoFill = true,
contacts = {},
recent = {},
AutoCompleteAlts = true,
AutoCompleteAllAlts = true,
AutoCompleteRecent = true,
AutoCompleteContacts = true,
AutoCompleteFriends = true,
AutoCompleteGuild = true,
ExcludeRandoms = true,
DisableBlizzardAutoComplete = false,
UseAutoComplete = true,
},
QuickAttach = {
EnableBag0 = true,
EnableBag1 = true,
EnableBag2 = true,
EnableBag3 = true,
EnableBag4 = true,
EnableBag5 = true,
},
},
global = {
BlackBook = {
alts = {},
EnableDefault = false,
},
},
}
local _G = getfenv(0)
local t = {}
Postal3DB = {}
Postal.keepFreeOptions = {0, 1, 2, 3, 5, 10, 15, 20, 25, 30}
Postal.WOWClassic = false
Postal.WOWBCClassic = false
Postal.WOWWotLKClassic = false
Postal.WOWCataClassic = false
Postal.WOWMists = false
Postal.WOWRetail = false
-- Use a common frame and setup some common functions for the Postal dropdown menus
local Postal_DropDownMenu = CreateFrame("Frame", "Postal_DropDownMenu")
Postal_DropDownMenu.displayMode = "MENU"
Postal_DropDownMenu.info = {}
Postal_DropDownMenu.levelAdjust = 0
Postal_DropDownMenu.UncheckHack = function(dropdownbutton)
_G[dropdownbutton:GetName().."Check"]:Hide()
_G[dropdownbutton:GetName().."UnCheck"]:Hide()
end
Postal_DropDownMenu.HideMenu = function()
if UIDROPDOWNMENU_OPEN_MENU == Postal_DropDownMenu then
CloseDropDownMenus()
end
end
-- Functions for long subject mouseover
local function subjectHoverIn(self)
local s = _G["MailItem"..self:GetID().."Subject"]
if s:GetStringWidth() + 25 > s:GetWidth() then
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(s:GetText())
securecall(GameTooltip.Show, GameTooltip) -- calling Show() from addon code taints MoneyFrame button widths, breaking loot tooltip money display
end
end
local function subjectHoverOut(self)
GameTooltip:Hide()
end
function Postal:PLAYER_INTERACTION_MANAGER_FRAME_HIDE(eventName, ...)
local paneType = ...
if paneType == Enum.PlayerInteractionType.MailInfo then Postal:MAIL_CLOSED() end
end
---------------------------
-- Postal Core Functions --
---------------------------
function Postal:OnInitialize()
--print("Postal is Active and Running");
-- Detect which release of WOW is running and set appropriate flags
if _G.WOW_PROJECT_ID == _G.WOW_PROJECT_CLASSIC then Postal.WOWClassic = true end
if _G.WOW_PROJECT_ID == _G.WOW_PROJECT_BURNING_CRUSADE_CLASSIC then Postal.WOWBCClassic = true end
if _G.WOW_PROJECT_ID == _G.WOW_PROJECT_WRATH_CLASSIC then Postal.WOWWotLKClassic = true end
if _G.WOW_PROJECT_ID == _G.WOW_PROJECT_CATACLYSM_CLASSIC then Postal.WOWCataClassic = true end
if _G.WOW_PROJECT_ID == _G.WOW_PROJECT_MISTS_CLASSIC then Postal.WOWMists = true end
if _G.WOW_PROJECT_ID == _G.WOW_PROJECT_MAINLINE then Postal.WOWRetail = true end
if _G.WOW_PROJECT_ID == _G.LE_EXPANSION_11_0 then Postal.WOWRetail = true end
-- if Postal.WOWClassic then DEFAULT_CHAT_FRAME:AddMessage("Postal WOW Classic", 0.0, 0.69, 0.94) end
-- if Postal.WOWBCClassic then DEFAULT_CHAT_FRAME:AddMessage("Postal WOW BC Classic", 0.0, 0.69, 0.94) end
-- if Postal.WOWWotLKClassic then DEFAULT_CHAT_FRAME:AddMessage("Postal WOW WotLK Classic", 0.0, 0.69, 0.94) end
-- if Postal.WOWCataClassic then DEFAULT_CHAT_FRAME:AddMessage("Postal WOW Cataclysm Classic", 0.0, 0.69, 0.94) end
-- if Postal.WOWMists then DEFAULT_CHAT_FRAME:AddMessage("Postal WOW Mists Classic", 0.0, 0.69, 0.94) end
-- if Postal.WOWRetail then DEFAULT_CHAT_FRAME:AddMessage("Postal WOW Retail", 0.0, 0.69, 0.94) end
-- if Postal.WOWRetail then DEFAULT_CHAT_FRAME:AddMessage("LE_EXPANSION_11_0", 0.0, 0.69, 0.94) end
-- Version number
if not self.version then self.version = C_AddOns.GetAddOnMetadata("Postal", "Version") end
-- Initialize database
local EnableDefault = false
if Postal3DB and Postal3DB.global then
EnableDefault = Postal3DB.global.EnableDefault and true or false
end
-- if type(next(Postal3DB)) ~= "nil" then EnableDefault = Postal3DB.global.EnableDefault end
if EnableDefault == true then
self.db = LibStub("AceDB-3.0"):New("Postal3DB", defaults, true)
else
self.db = LibStub("AceDB-3.0"):New("Postal3DB", defaults)
end
-- self.db = LibStub("AceDB-3.0"):New("Postal3DB", defaults)
self.db.RegisterCallback(self, "OnProfileChanged", "OnProfileChanged")
self.db.RegisterCallback(self, "OnProfileCopied", "OnProfileChanged")
self.db.RegisterCallback(self, "OnProfileReset", "OnProfileChanged")
-- Enable/disable modules based on saved settings
for name, module in self:IterateModules() do
module:SetEnabledState(self.db.profile.ModuleEnabledState[name] or false)
if module.OnEnable then
hooksecurefunc(module, "OnEnable", self.OnModuleEnable_Common) -- Posthook
end
end
-- Register events
if Postal.WOWBCClassic then
self:RegisterEvent("MAIL_CLOSED")
else
self:RegisterEvent("PLAYER_INTERACTION_MANAGER_FRAME_HIDE")
end
-- Create the Menu Button
local Postal_ModuleMenuButton = CreateFrame("Button", "Postal_ModuleMenuButton", MailFrame)
Postal_ModuleMenuButton:SetWidth(25)
Postal_ModuleMenuButton:SetHeight(25)
Postal_ModuleMenuButton:SetPoint("TOPRIGHT", -22, 2)
if Postal.WOWRetail then Postal_ModuleMenuButton:SetFrameLevel(501) end -- Seems like a Blizzard bug to need this to make Postal menu visible.
Postal_ModuleMenuButton:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up")
Postal_ModuleMenuButton:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Round")
Postal_ModuleMenuButton:SetDisabledTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled")
Postal_ModuleMenuButton:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down")
Postal_ModuleMenuButton:SetScript("OnClick", function(self, button, down)
if Postal_DropDownMenu.initialize ~= Postal.Menu then
CloseDropDownMenus()
Postal_DropDownMenu.initialize = Postal.Menu
end
ToggleDropDownMenu(1, nil, Postal_DropDownMenu, self:GetName(), 0, 0)
end)
Postal_ModuleMenuButton:SetScript("OnHide", Postal_DropDownMenu.HideMenu)
-- Create 7 buttons for mouseover on long subject lines
for i = 1, 7 do
local b = CreateFrame("Button", "PostalSubjectHover"..i, _G["MailItem"..i])
b:SetID(i)
b:SetAllPoints(_G["MailItem"..i.."Subject"])
b:SetScript("OnEnter", subjectHoverIn)
b:SetScript("OnLeave", subjectHoverOut)
end
self.OnInitialize = nil
end
function Postal:OnProfileChanged(event, database, newProfileKey)
for name, module in self:IterateModules() do
if self.db.profile.ModuleEnabledState[name] then
module:Enable()
else
module:Disable()
end
end
end
function Postal:OnModuleEnable_Common()
-- If the module is enabled with the MailFrame open (at mailbox)
-- run the MAIL_SHOW() event function
if self.MAIL_SHOW and MailFrame:IsVisible() then
self:MAIL_SHOW()
end
end
-- Hides the minimap unread mail button if there are no unread mail on closing the mailbox.
-- Does not scan past the first 100 items since only the first 100 are viewable.
function Postal:MAIL_CLOSED()
for i = 1, GetInboxNumItems() do
if not select(9, GetInboxHeaderInfo(i)) then return end
end
if Postal.WOWClassic or Postal.WOWBCClassic or Postal.WOWWotLKClassic or Postal.WOWCataClassic or Postal.WOWMists then
MiniMapMailFrame:Hide()
else
MiniMapMailFrameMixin:OnLeave()
end
end
function Postal:Print(...)
local text = "|cff33ff99Postal|r:"
for i = 1, select("#", ...) do
text = text.." "..tostring(select(i, ...))
end
if not self:IsChatFrameActive(self.db.profile.ChatOutput) then
self.db.profile.ChatOutput = 1
end
local chatFrame = _G["ChatFrame"..self.db.profile.ChatOutput]
if chatFrame then
chatFrame:AddMessage(text)
end
end
function Postal:IsChatFrameActive(i)
local _, _, _, _, _, _, shown = FCF_GetChatWindowInfo(i);
local chatFrame = _G["ChatFrame"..i]
if chatFrame then
if shown or chatFrame.isDocked then
return true
end
end
return false
end
function Postal.SaveOption(dropdownbutton, arg1, arg2, checked)
Postal.db.profile[arg1][arg2] = checked
end
function Postal.ToggleModule(dropdownbutton, arg1, arg2, checked)
Postal.db.profile.ModuleEnabledState[arg1] = checked
if checked then arg2:Enable() else arg2:Disable() end
end
function Postal.SetOpenSpeed(dropdownbutton, arg1, arg2, checked)
Postal.db.profile.OpenSpeed = arg1
end
function Postal.SetChatOutput(dropdownbutton, arg1, arg2, checked)
Postal.db.profile.ChatOutput = arg1
end
function Postal.EnableDefault(dropdownbutton, arg1, arg2, checked)
Postal.db.global.EnableDefault = checked
end
function Postal.ProfileFunc(dropdownbutton, arg1, arg2, checked)
if arg1 == "NewProfile" then
StaticPopup_Show("POSTAL_NEW_PROFILE")
else
Postal.db[arg1](Postal.db, arg2)
end
CloseDropDownMenus()
end
StaticPopupDialogs["POSTAL_NEW_PROFILE"] = {
text = L["New Profile Name:"],
button1 = ACCEPT,
button2 = CANCEL,
hasEditBox = 1,
maxLetters = 128,
editBoxWidth = 350, -- Needed in Cata
OnAccept = function(self)
Postal.db:SetProfile(strtrim(StaticPopup1EditBox:GetText()))
end,
OnShow = function(self)
StaticPopup1EditBox:SetText(Postal.db:GetCurrentProfile())
StaticPopup1EditBox:SetFocus()
end,
OnHide = StaticPopupDialogs["SET_GUILDPLAYERNOTE"].OnHide,
EditBoxOnEnterPressed = function(self)
local parent = self:GetParent()
Postal.db:SetProfile(strtrim(StaticPopup1EditBox:GetText()))
parent:Hide()
end,
EditBoxOnEscapePressed = StaticPopupDialogs["SET_GUILDPLAYERNOTE"].EditBoxOnEscapePressed,
timeout = 0,
exclusive = 1,
whileDead = 1,
hideOnEscape = 1
}
function Postal.Menu(self, level)
if not level then return end
local info = self.info
wipe(info)
if level == 1 then
info.isTitle = 1
info.text = "Postal"
info.notCheckable = 1
UIDropDownMenu_AddButton(info, level)
info.disabled = nil
info.isTitle = nil
info.notCheckable = nil
info.keepShownOnClick = 1
info.isNotRadio = 1
for name, module in Postal:IterateModules() do
info.text = L[name]
info.func = Postal.ToggleModule
info.arg1 = name
info.arg2 = module
info.checked = module:IsEnabled()
info.hasArrow = module.ModuleMenu ~= nil
info.value = module
UIDropDownMenu_AddButton(info, level)
end
wipe(info)
info.disabled = 1
UIDropDownMenu_AddButton(info, level)
info.disabled = nil
info.text = L["Opening Speed"]
info.func = self.UncheckHack
info.notCheckable = 1
info.keepShownOnClick = 1
info.hasArrow = 1
info.value = "OpenSpeed"
UIDropDownMenu_AddButton(info, level)
info.text = L["Chat Output"]
info.func = self.UncheckHack
info.notCheckable = 1
info.keepShownOnClick = 1
info.hasArrow = 1
info.value = "ChatOutput"
UIDropDownMenu_AddButton(info, level)
info.text = L["Profile"]
info.func = self.UncheckHack
info.value = "Profile"
UIDropDownMenu_AddButton(info, level)
wipe(info)
info.notCheckable = 1
info.text = L["Help"]
info.func = Postal.About
UIDropDownMenu_AddButton(info, level)
info.disabled = 1
info.text = nil
info.func = nil
UIDropDownMenu_AddButton(info, level)
info.disabled = nil
info.text = CLOSE
info.func = self.HideMenu
info.tooltipTitle = CLOSE
UIDropDownMenu_AddButton(info, level)
elseif level == 2 then
if UIDROPDOWNMENU_MENU_VALUE == "OpenSpeed" then
local speed = Postal.db.profile.OpenSpeed
for i = 0, 0 do
local s = 0
info.text = format("%0.2f", s)
info.func = Postal.SetOpenSpeed
info.checked = s == speed
info.arg1 = s
UIDropDownMenu_AddButton(info, level)
end
for i = 0, 13 do
local s = 0.3 + i*0.05
info.text = format("%0.2f", s)
info.func = Postal.SetOpenSpeed
info.checked = s == speed
info.arg1 = s
UIDropDownMenu_AddButton(info, level)
end
for i = 0, 8 do
local s = 1 + i*0.5
info.text = format("%0.2f", s)
info.func = Postal.SetOpenSpeed
info.checked = s == speed
info.arg1 = s
UIDropDownMenu_AddButton(info, level)
end
elseif UIDROPDOWNMENU_MENU_VALUE == "ChatOutput" then
local selectedFrame = Postal.db.profile.ChatOutput
for i = 1, NUM_CHAT_WINDOWS do
if Postal:IsChatFrameActive(i) then
info.text = format("%d. %s", i, _G["ChatFrame"..i.."Tab"]:GetText())
info.func = Postal.SetChatOutput
info.checked = i == selectedFrame
info.arg1 = i
UIDropDownMenu_AddButton(info, level)
end
end
elseif UIDROPDOWNMENU_MENU_VALUE == "Profile" then
-- Profile stuff
info.hasArrow = 1
info.keepShownOnClick = 1
info.func = self.UncheckHack
info.notCheckable = 1
info.text = L["Choose"]
info.value = "SetProfile"
UIDropDownMenu_AddButton(info, level)
info.text = L["Copy From"]
info.value = "CopyProfile"
UIDropDownMenu_AddButton(info, level)
info.text = L["Delete"]
info.value = "DeleteProfile"
UIDropDownMenu_AddButton(info, level)
info.hasArrow = nil
info.keepShownOnClick = nil
info.func = Postal.ProfileFunc
info.arg1 = "NewProfile"
info.text = L["New Profile"]
UIDropDownMenu_AddButton(info, level)
info.text = L["Reset Profile"]
info.func = Postal.ProfileFunc
info.arg1 = "ResetProfile"
info.arg2 = nil
UIDropDownMenu_AddButton(info, level)
info.keepShownOnClick = 1
info.isNotRadio = 1
info.notCheckable = nil
info.text = L["Default"]
info.func = Postal.EnableDefault
info.checked = Postal.db.global.EnableDefault
UIDropDownMenu_AddButton(info, level)
elseif type(UIDROPDOWNMENU_MENU_VALUE) == "table" and UIDROPDOWNMENU_MENU_VALUE.ModuleMenu then
-- Submenus for modules
self.levelAdjust = 1
UIDROPDOWNMENU_MENU_VALUE.ModuleMenu(self, level)
self.levelAdjust = 0
self.module = UIDROPDOWNMENU_MENU_VALUE
end
elseif level == 3 then
if UIDROPDOWNMENU_MENU_VALUE == "SetProfile" then
local cur = Postal.db:GetCurrentProfile()
Postal.db:GetProfiles(t)
table.sort(t)
info.func = Postal.ProfileFunc
info.arg1 = "SetProfile"
for i = 1, #t do
local s = t[i]
info.text = s
info.arg2 = s
info.checked = cur == s
UIDropDownMenu_AddButton(info, level)
end
elseif UIDROPDOWNMENU_MENU_VALUE == "CopyProfile" or UIDROPDOWNMENU_MENU_VALUE == "DeleteProfile" then
local cur = Postal.db:GetCurrentProfile()
Postal.db:GetProfiles(t)
table.sort(t)
info.func = Postal.ProfileFunc
info.arg1 = UIDROPDOWNMENU_MENU_VALUE
info.notCheckable = 1
for i = 1, #t do
local s = t[i]
if s ~= cur then
info.text = s
info.arg2 = s
UIDropDownMenu_AddButton(info, level)
end
end
elseif self.module and self.module.ModuleMenu then
self.levelAdjust = 1
self.module.ModuleMenu(self, level)
self.levelAdjust = 0
end
elseif level > 3 then
if self.module and self.module.ModuleMenu then
self.levelAdjust = 1
self.module.ModuleMenu(self, level)
self.levelAdjust = 0
end
end
end
function Postal:CreateAboutFrame()
local aboutFrame = Postal.aboutFrame
if not aboutFrame and Chatter and ChatterCopyFrame then
aboutFrame = ChatterCopyFrame
aboutFrame.editBox = Chatter:GetModule("Chat Copy").editBox
end
if not aboutFrame or not aboutFrame.editBox then
aboutFrame = CreateFrame("Frame", "PostalAboutFrame", UIParent, BackdropTemplateMixin and "BackdropTemplate")
tinsert(UISpecialFrames, "PostalAboutFrame")
aboutFrame:SetBackdrop({
bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]],
edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 3, right = 3, top = 5, bottom = 3 }
})
aboutFrame:SetBackdropColor(0,0,0,1)
aboutFrame:SetWidth(500)
aboutFrame:SetHeight(400)
aboutFrame:SetPoint("CENTER", UIParent, "CENTER")
aboutFrame:Hide()
aboutFrame:SetFrameStrata("DIALOG")
aboutFrame:SetToplevel(true)
local scrollArea = CreateFrame("ScrollFrame", "PostalAboutScroll", aboutFrame, "UIPanelScrollFrameTemplate")
scrollArea:SetPoint("TOPLEFT", aboutFrame, "TOPLEFT", 8, -30)
scrollArea:SetPoint("BOTTOMRIGHT", aboutFrame, "BOTTOMRIGHT", -30, 8)
local editBox = CreateFrame("EditBox", nil, aboutFrame)
editBox:SetMultiLine(true)
editBox:SetMaxLetters(99999)
editBox:EnableMouse(true)
editBox:SetAutoFocus(false)
editBox:SetFontObject(ChatFontNormal)
editBox:SetWidth(400)
editBox:SetHeight(270)
editBox:SetScript("OnEscapePressed", function() aboutFrame:Hide() end)
aboutFrame.editBox = editBox
scrollArea:SetScrollChild(editBox)
local close = CreateFrame("Button", nil, aboutFrame, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", aboutFrame, "TOPRIGHT")
end
Postal.aboutFrame = aboutFrame
Postal.CreateAboutFrame = nil -- Kill ourselves
end
function Postal.About()
if Postal.CreateAboutFrame then Postal:CreateAboutFrame() end
local version = C_AddOns.GetAddOnMetadata("Postal", "Version")
wipe(t)
tinsert(t, "|cFFFFCC00"..C_AddOns.GetAddOnMetadata("Postal", "Title").." v"..version.."|r")
tinsert(t, "-----")
tinsert(t, "")
for name, module in Postal:IterateModules() do
tinsert(t, "|cffffcc00"..L[name].."|r")
if module.description then
tinsert(t, module.description)
end
if module.description2 then
tinsert(t, "")
tinsert(t, module.description2)
end
tinsert(t, "")
end
tinsert(t, "-----")
tinsert(t, L["Please post bugs or suggestions at the CurseForge forums thread at |cFF00FFFFhttp://www.curseforge.com/wow/addons/postal/issues|r. When posting bugs, indicate your locale and Postal's version number v%s."]:format(version))
tinsert(t, "")
tinsert(t, "- Xinhuan (Blackrock/Barthilas US Alliance)")
tinsert(t, "")
Postal.aboutFrame.editBox:SetText(table.concat(t, "\n"))
Postal.aboutFrame:Show()
wipe(t) -- For garbage collection
end
---------------------------
-- Common Mail Functions --
---------------------------
-- Disable Inbox Clicks
local function noop() end
function Postal:DisableInbox(disable)
if disable then
if not self:IsHooked("InboxFrame_OnClick") then
self:RawHook("InboxFrame_OnClick", noop, true)
for i = 1, 7 do
_G["MailItem" .. i .. "ButtonIcon"]:SetDesaturated(true)
end
end
else
if self:IsHooked("InboxFrame_OnClick") then
self:Unhook("InboxFrame_OnClick")
for i = 1, 7 do
_G["MailItem" .. i .. "ButtonIcon"]:SetDesaturated(false)
end
end
end
end
-- Return the type of mail a message subject is
local SubjectPatterns = {
AHCancelled = gsub(AUCTION_REMOVED_MAIL_SUBJECT, "%%s", ".*"),
AHExpired = gsub(AUCTION_EXPIRED_MAIL_SUBJECT, "%%s", ".*"),
AHOutbid = gsub(AUCTION_OUTBID_MAIL_SUBJECT, "%%s", ".*"),
AHSuccess = gsub(AUCTION_SOLD_MAIL_SUBJECT, "%%s", ".*"),
AHWon = gsub(AUCTION_WON_MAIL_SUBJECT, "%%s", ".*"),
}
function Postal:GetMailType(msgSubject)
if msgSubject then
for k, v in pairs(SubjectPatterns) do
if msgSubject:find(v) then return k end
end
end
return "NonAHMail"
end
function Postal:GetMoneyString(money)
local gold = floor(money / 10000)
local silver = floor((money - gold * 10000) / 100)
local copper = mod(money, 100)
if gold > 0 then
return format(GOLD_AMOUNT_TEXTURE.." "..SILVER_AMOUNT_TEXTURE.." "..COPPER_AMOUNT_TEXTURE, gold, 0, 0, silver, 0, 0, copper, 0, 0)
elseif silver > 0 then
return format(SILVER_AMOUNT_TEXTURE.." "..COPPER_AMOUNT_TEXTURE, silver, 0, 0, copper, 0, 0)
else
return format(COPPER_AMOUNT_TEXTURE, copper, 0, 0)
end
end
function Postal:GetMoneyStringPlain(money)
local gold = floor(money / 10000)
local silver = floor((money - gold * 10000) / 100)
local copper = mod(money, 100)
if gold > 0 then
return gold..GOLD_AMOUNT_SYMBOL.." "..silver..SILVER_AMOUNT_SYMBOL.." "..copper..COPPER_AMOUNT_SYMBOL
elseif silver > 0 then
return silver..SILVER_AMOUNT_SYMBOL.." "..copper..COPPER_AMOUNT_SYMBOL
else
return copper..COPPER_AMOUNT_SYMBOL
end
end
function Postal:CountItemsAndMoney()
local numAttach = 0
local numGold = 0
for i = 1, GetInboxNumItems() do
local msgMoney, _, _, msgItem = select(5, GetInboxHeaderInfo(i))
numAttach = numAttach + (msgItem or 0)
numGold = numGold + msgMoney
end
return numAttach, numGold
end