vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 SimpleMail
3  
4 copyright 2005 by Charettejc
5  
6 - keeps the recipient's name in the name box, and auto fills the subject line when:
7 1. you drop and item on the attachment slot, and
8 2. the subject line is empty of letters and spaces.
9  
10 - version 1.13
11  
12 - Thanks goes out to Thott and Kugnar, they're the one's that developed this code in
13 their email addons.
14  
15 - History
16  
17 2/27/05 v1.13
18 - SimpleMail will remember recipient's name between sessions.
19  
20 v1.12
21 - update toc file to v4222
22  
23 2/21/05 v1.1.1
24 - updated toc file to v4211
25 ]]
26  
27 local SIMPLEMAIL_VERSION = "1.13";
28  
29 local TEXT_LOAD1 = "|cffffff00SimpleMail|r |cff00ff00v%.2f|r|cffffff00 loaded.|r";
30  
31 local SimpleMail_SavedMailFrameReset;
32  
33 function SimpleMail_OnLoad()
34 --[[
35 I'm replacing the SendMailFrame_Reset() used by Blizzard. It's this function
36 that empties all the boxes on the mail frame. Now my SimpleMailFrame_Reset()
37 will be called instead.
38 ]]
39 SimpleMail_SavedMailFrameReset = SendMailFrame_Reset;
40 SendMailFrame_Reset = SimpleMailFrame_Reset;
41  
42 --[[
43 registering the MAIL_SEND_INFO_UPDATE event, so I can update the subject line
44 whenever an item is attached.
45 ]]
46 this:RegisterEvent( "MAIL_SEND_INFO_UPDATE" );
47 this:RegisterEvent( "VARIABLES_LOADED" );
48 this:RegisterEvent( "MAIL_SHOW" );
49 this:RegisterEvent( "MAIL_SEND_SUCCESS" );
50  
51 --[[
52 register saved variable and initialize it if this is first use of addon.
53 ]]
54 -- RegisterForSave( "SimpleMailState" );
55  
56 --[[
57 tell the user the mod is loaded.
58 ]]
59 --SimpleMail_Print( format( TEXT_LOAD1, SIMPLEMAIL_VERSION ) );
60 end
61  
62 function SimpleMailFrame_Reset()
63 -- move the cursor to the subject box if we have text in the name box.
64 if ( SendMailNameEditBox:GetText() and SendMailNameEditBox:GetText() ~= "" ) then
65 SendMailSubjectEditBox:SetFocus();
66 else
67 SendMailNameEditBox:SetFocus();
68 end
69  
70 -- do everything SendMailFrame_Reset() does except empty name box.
71 SendMailSubjectEditBox:SetText("");
72 SendMailBodyEditBox:SetText("");
73 StationeryPopupFrame.selectedIndex = nil;
74 SendMailFrame_Update();
75 StationeryPopupButton_OnClick(1);
76 MoneyInputFrame_ResetMoney(SendMailMoney);
77 SendMailRadioButton_OnClick(1);
78 end
79  
80 function SimpleMail_OnEvent()
81 if ( event == "MAIL_SEND_INFO_UPDATE" ) then
82 local itemName, itemTexture, stackCount, quality = GetSendMailItem();
83 if ( itemName ) then
84 local subject = SendMailSubjectEditBox:GetText();
85 if ( not(subject) or subject == "" ) then
86 if (stackCount and stackCount > 1) then
87 SendMailSubjectEditBox:SetText(stackCount.."x "..itemName);
88 else
89 SendMailSubjectEditBox:SetText(itemName);
90 end
91 end
92 end
93 elseif event == "VARIABLES_LOADED" then
94 --[[
95 initialize SimpleMailState if this is first use of SimpleMail
96 ]]
97 if not SimpleMailState then
98 SimpleMailState = { LastRecipient = nil };
99 end
100 --if SimpleMailState.LastRecipient then
101 --SimpleMail_Print( "simplemail : onload : last recipient is "..SimpleMailState.LastRecipient );
102 --end
103 elseif event == "MAIL_SHOW" then
104 --SimpleMail_Print( "simplemail : onevent : mail show called." );
105 if SimpleMailState.LastRecipient then
106 SendMailNameEditBox:SetText( SimpleMailState.LastRecipient );
107 end
108 elseif event == "MAIL_SEND_SUCCESS" then
109 --SimpleMail_Print( "simplemail : onevent : mail send success called." );
110 SimpleMail_UpdateState();
111 end
112 end
113  
114 function SimpleMail_UpdateState ()
115 local txt = SendMailNameEditBox:GetText();
116 if txt == "" then
117 -- don't do anything
118 else
119 --SimpleMail_Print( "simplemail : updatestate : name is "..txt.."." );
120 SimpleMailState.LastRecipient = txt;
121 end
122 end
123  
124 function SimpleMail_Print( msg )
125 if DEFAULT_CHAT_FRAME then
126 DEFAULT_CHAT_FRAME:AddMessage( msg );
127 end
128 end