vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 AcePlayerMenu = AceAddon:new({
2 name = AcePlayerMenuLocals.NAME,
3 description = AcePlayerMenuLocals.DESCRIPTION,
4 version = "0.3",
5 releaseDate = "06-27-2006",
6 aceCompatible = "103",
7 author = "hshh",
8 email = "hunreal@gmail.com",
9 website = "http://www.hshh.org",
10 category = "interface",
11 cmd = AceChatCmd:new(AcePlayerMenuLocals.COMMANDS, AcePlayerMenuLocals.CMD_OPTIONS),
12 db = AceDatabase:new("apm"),
13 })
14  
15  
16 function AcePlayerMenu:Initialize()
17 self.UnitPopupButtons={};
18 self.UnitPopupMenus={};
19 for k,v in UnitPopupButtons do
20 self.UnitPopupButtons[k]=v;
21 end
22 for k,v in UnitPopupMenus do
23 self.UnitPopupMenus[k]=v;
24 end
25  
26 if (not self.db:get("toggle")) then
27 self.db:set("toggle", "on");
28 end
29 if (not self.db:get("left")) then
30 self.db:set("left", "off");
31 end
32 end
33  
34 function AcePlayerMenu:Enable()
35 if (self.db:get("toggle")~="on") then
36 return
37 end
38  
39 self:Hook("UnitPopup_OnClick");
40 self:Hook("UnitPopup_HideButtons");
41 if (self.db:get("left")=="on") then
42 self:Hook("SetItemRef");
43 end
44  
45 UnitPopupButtons["ADD_FRIEND"] = { text = TEXT(ADD_FRIEND), dist = 0 };
46 UnitPopupButtons["GUILD_INVITE"] = { text = TEXT(AcePlayerMenuLocals.TEXT.GUILD_INVITE), dist = 0 };
47 UnitPopupButtons["IGNORE"] = { text = TEXT(IGNORE), dist = 0 };
48 UnitPopupButtons["GET_NAME"] = { text = TEXT(AcePlayerMenuLocals.TEXT.GET_NAME), dist = 0 };
49 UnitPopupButtons["WHO"] = { text = TEXT(WHO), dist = 0 };
50  
51 UnitPopupMenus["FRIEND"] = { "WHISPER", "INVITE", "TARGET", "GUILD_PROMOTE", "GUILD_LEAVE", "ADD_FRIEND", "GUILD_INVITE", "IGNORE", "GET_NAME", "WHO", "CANCEL" };
52 end
53  
54 function AcePlayerMenu:Disable()
55 for k,v in self.UnitPopupButtons do
56 UnitPopupButtons[k]=v;
57 end
58 for k,v in self.UnitPopupMenus do
59 UnitPopupMenus[k]=v;
60 end
61  
62 self:Unhook("UnitPopup_OnClick");
63 self:Unhook("UnitPopup_HideButtons");
64 self:Unhook("SetItemRef");
65 end
66  
67 function AcePlayerMenu:UnitPopup_HideButtons()
68 self:CallHook("UnitPopup_HideButtons");
69 local dropdownMenu = getglobal(UIDROPDOWNMENU_INIT_MENU);
70 for index, value in UnitPopupMenus[dropdownMenu.which] do
71 if ( value == "GUILD_INVITE" ) then
72 if ( not CanGuildInvite() or dropdownMenu.name == UnitName("player") ) then
73 UnitPopupShown[index] = 0;
74 else
75 UnitPopupShown[index] = 1;
76 end
77 elseif ( value == "ADD_FRIEND" or value == "IGNORE" or value == "WHO" or value == "GET_NAME") then
78 if (dropdownMenu.name == UnitName("player")) then
79 UnitPopupShown[index] = 0;
80 else
81 UnitPopupShown[index] = 1;
82 end
83 end
84 end
85 end
86  
87 function AcePlayerMenu:UnitPopup_OnClick()
88 local dropdownFrame = getglobal(UIDROPDOWNMENU_INIT_MENU);
89 local button = this.value;
90 local unit = dropdownFrame.unit;
91 local name = dropdownFrame.name;
92  
93 if (button == "ADD_FRIEND") then
94 AddFriend(name);
95 elseif (button == "GUILD_INVITE") then
96 GuildInviteByName(name);
97 elseif (button == "IGNORE") then
98 AddIgnore(name);
99 elseif (button == "GET_NAME") then
100 ChatFrameEditBox:Show();
101 ChatFrameEditBox:Insert(name);
102 elseif (button == "WHO") then
103 SendWho(name);
104 else
105 return self:CallHook("UnitPopup_OnClick");
106 end
107 PlaySound("UChatScrollButton");
108 end
109  
110 function AcePlayerMenu:SetItemRef(link, text, button)
111 if ( strsub(link, 1, 6) == "player" ) then
112 local name = strsub(link, 8);
113 if ( name and (strlen(name) > 0) ) then
114 name = gsub(name, "([^%s]*)%s+([^%s]*)%s+([^%s]*)", "%3");
115 name = gsub(name, "([^%s]*)%s+([^%s]*)", "%2");
116 if ( IsShiftKeyDown() ) then
117 local staticPopup;
118 staticPopup = StaticPopup_Visible("ADD_IGNORE");
119 if ( staticPopup ) then
120 -- If add ignore dialog is up then enter the name into the editbox
121 getglobal(staticPopup.."EditBox"):SetText(name);
122 return;
123 end
124 staticPopup = StaticPopup_Visible("ADD_FRIEND");
125 if ( staticPopup ) then
126 -- If add ignore dialog is up then enter the name into the editbox
127 getglobal(staticPopup.."EditBox"):SetText(name);
128 return;
129 end
130 staticPopup = StaticPopup_Visible("ADD_GUILDMEMBER");
131 if ( staticPopup ) then
132 -- If add ignore dialog is up then enter the name into the editbox
133 getglobal(staticPopup.."EditBox"):SetText(name);
134 return;
135 end
136 staticPopup = StaticPopup_Visible("ADD_RAIDMEMBER");
137 if ( staticPopup ) then
138 -- If add ignore dialog is up then enter the name into the editbox
139 getglobal(staticPopup.."EditBox"):SetText(name);
140 return;
141 end
142 if ( ChatFrameEditBox:IsVisible() ) then
143 ChatFrameEditBox:Insert(name);
144 else
145 SendWho("n-"..name);
146 end
147  
148 else
149 FriendsFrame_ShowDropdown(name, 1);
150 end
151 end
152 return;
153 end
154  
155 return self:CallHook("SetItemRef", link, text, button);
156 end
157  
158 function AcePlayerMenu:Toggle()
159 local toggle = self.db:get("toggle");
160 if ( not toggle or toggle ~= "on" ) then
161 self.db:set("toggle", "on");
162 self.cmd:msg(AcePlayerMenuLocals.MSG.APM_ON)
163 self:Reload();
164 else
165 self.db:set("toggle", "off");
166 self.cmd:msg(AcePlayerMenuLocals.MSG.APM_OFF)
167 self:Reload();
168 end
169 end
170  
171 function AcePlayerMenu:Left()
172 local toggle = self.db:get("left");
173 if ( not toggle or toggle ~= "off" ) then
174 self.db:set("left", "off");
175 self.cmd:msg(AcePlayerMenuLocals.MSG.LEFT_OFF)
176 self:Reload();
177 else
178 self.db:set("left", "on");
179 self.cmd:msg(AcePlayerMenuLocals.MSG.LEFT_ON)
180 self:Reload();
181 end
182 end
183  
184 function AcePlayerMenu:Reload()
185 self:Disable();
186 self:Enable();
187 end
188 AcePlayerMenu:RegisterForLoad()