-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathMacros.Mail.lua
73 lines (61 loc) · 2.84 KB
/
Macros.Mail.lua
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
--This file is part of Game Master Genie.
--Copyright 2011-2014 Chocochaos
--Game Master Genie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
--Game Master Genie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
--You should have received a copy of the GNU General Public License along with Game Master Genie. If not, see <http://www.gnu.org/licenses/>.
GMGenie.Macros.Mail = {};
GMGenie.Macros.Mail.curMailMessage = '';
function GMGenie.Macros.Mail.run(name, title)
local text = GMGenie_SavedVars.mail[title].macro;
local text = string.gsub(text, "NAME", name);
local lines = { strsplit("\n", text) };
local subject = GMGenie_SavedVars.mail[title].subject;
for index, line in pairs(lines) do
local command = '.send mail ' .. name .. ' "' .. subject;
if #lines > 1 then
command = command .. ' ' .. index .. '/' .. (#lines);
end
local command = command .. '" "' .. line .. '"';
SendChatMessage(command, "GUILD");
end
end
function GMGenie.Macros.Mail.runFromSpy(self)
CloseDropDownMenus();
if GMGenie.Spy.currentRequest["name"] then
GMGenie.Macros.Mail.run(GMGenie.Spy.currentRequest["name"], self.value);
end
end
function GMGenie.Macros.Mail.addToUnitMenu()
UnitPopupMenus["GMGenie_Mail"] = {};
local MailTemp = GMGenie.pairsByKeys2(GMGenie_SavedVars.mail);
for _, name in pairs(MailTemp) do
table.insert(UnitPopupMenus["GMGenie_Mail"], "GMGenie_Mail_" .. name);
UnitPopupButtons["GMGenie_Mail_" .. name] = { text = name, dist = 0, };
end
table.insert(UnitPopupMenus["GMGenie_Mail"], "GMGenie_MailOptions");
UnitPopupButtons["GMGenie_MailOptions"] = { text = "Manage macros", dist = 0, };
end
function GMGenie.Macros.Mail.loadDropdown(_, level)
local info = UIDropDownMenu_CreateInfo();
info.hasArrow = false;
info.notCheckable = true;
info.isTitle = true;
info.text = "Mail Macros";
UIDropDownMenu_AddButton(info, level);
local MailTemp = GMGenie.pairsByKeys2(GMGenie_SavedVars.mail);
for _, name in pairs(MailTemp) do
local info = UIDropDownMenu_CreateInfo();
info.hasArrow = false;
info.notCheckable = true;
info.text = name;
info.func = GMGenie.Macros.Mail.runFromSpy;
info.value = name;
UIDropDownMenu_AddButton(info, level);
end
local info = UIDropDownMenu_CreateInfo();
info.hasArrow = false;
info.notCheckable = true;
info.text = "Manage Macros";
info.func = GMGenie.Macros.Mail.showOptions;
UIDropDownMenu_AddButton(info, level);
end