vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2  
3 BCUI Auto Mail Subject
4 ======================
5  
6 Description:
7 ------------
8 Automatically populates the subject of a mail message with the name and quantity of
9 the item you drag into the attachment box. Will only work if the subject line is
10 currently empty, so it won't erase what you've already typed there.
11  
12 Revision History:
13 -----------------
14 02/15/2005 v1.04
15 - New Interface number.
16  
17 02/02/2005 v1.03
18 - Added the number of items in the stack to the subject line.
19  
20 - Added more verbose comments throughout the code.
21  
22 - Added version numbers.
23  
24 12/??/2004 v1.0
25 Initial release.
26  
27 ]]
28  
29 function bcAMS_OnLoad()
30 -- Register for the needed events.
31 this:RegisterEvent("MAIL_SEND_INFO_UPDATE");
32  
33 -- Let the user know the mod loaded.
34 if ( DEFAULT_CHAT_FRAME ) then
35 DEFAULT_CHAT_FRAME:AddMessage("BC Auto Mail Subject loaded");
36 end
37 end
38  
39 function bcAMS_OnEvent()
40 -- Debug code: Used to tell when this function is called.
41 -- DEFAULT_CHAT_FRAME:AddMessage("bcAMS_OnEvent(): called");
42 if (event == "MAIL_SEND_INFO_UPDATE") then
43 -- Get the info about the item in the attachement box.
44 local itemName, itemTexture, stackCount, quality = GetSendMailItem();
45  
46 -- If there's anything there...
47 if (itemName) then
48 -- ... check to see if the subject line is empty.
49 local subject = SendMailSubjectEditBox:GetText();
50 if (string.len(subject) == 0) then
51 -- Subject is empty. Append the number of items in the stack if needed.
52 if (stackCount > 1) then
53 itemName = itemName.." x "..stackCount;
54 end
55  
56 -- Set the subject of the message.
57 SendMailSubjectEditBox:SetText(itemName);
58 end
59 end
60 end
61 end