vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | WP_Registered = nil; |
2 | |||
3 | function myWhoPinged_OnLoad() |
||
4 | if(not whopinged_cfg) then |
||
5 | whopinged_cfg = {}; |
||
6 | whopinged_cfg["zone"] = 1; |
||
7 | whopinged_cfg["IGNORE"] = {}; |
||
8 | end |
||
9 | wpversion = "0.3"; |
||
10 | theypinged = nil; |
||
11 | theypinged2 = nil; |
||
12 | whospinging = nil; |
||
13 | |||
14 | this:RegisterEvent("MINIMAP_PING"); |
||
15 | this:RegisterEvent("VARIABLES_LOADED"); |
||
16 | |||
17 | SlashCmdList["WHOPINGED"] = myWhoPinged_SlashHandler; |
||
18 | SLASH_WHOPINGED1 = "/wp"; |
||
19 | |||
20 | WP_Registered = 0; |
||
21 | -- hook minimap ping event to show who pinged |
||
22 | myWhoPinged_original_Minimap_OnEvent = Minimap_OnEvent; |
||
23 | Minimap_OnEvent = myWhoPinged_Minimap_OnEvent; |
||
24 | |||
25 | -- hook sound event to assist in ignoring pings |
||
26 | myWhoPinged_original_PlaySound = PlaySound; |
||
27 | PlaySound = myWhoPinged_PlaySound; |
||
28 | |||
29 | -- DEFAULT_CHAT_FRAME:AddMessage("WhoPinged " .. wpversion .. " loaded. type /wp help to see a list of commands."); |
||
30 | end |
||
31 | |||
32 | function myWhoPinged_PlaySound(argument1) |
||
33 | if(argument1 == "MapPing" and event == "MINIMAP_PING" and arg1 ~= nil) then |
||
34 | if(myWhoPinged_IsInList(string.lower(UnitName(arg1)))) then |
||
35 | return; |
||
36 | end |
||
37 | end |
||
38 | myWhoPinged_original_PlaySound(argument1); |
||
39 | end |
||
40 | |||
41 | function myWhoPinged_SlashHandler(cmd) |
||
42 | if(cmd ~= nil) then |
||
43 | cmd = string.lower(cmd); |
||
44 | end |
||
45 | if(string.find(cmd, " ")) then |
||
46 | local sep = string.find(cmd, " "); |
||
47 | local wparg1 = string.sub(cmd, 1, (sep -1)); |
||
48 | sep = (sep + 1); |
||
49 | wparg2 = string.sub(cmd, sep); |
||
50 | cmd = wparg1; |
||
51 | end |
||
52 | if(cmd == "last") then |
||
53 | myWhoPinged_WhoPinged() |
||
54 | elseif(cmd == "") then |
||
55 | myWhoPinged_WhosPinging() |
||
56 | elseif(cmd == "ignore") then |
||
57 | myWhoPinged_IgnorePing(wparg2); |
||
58 | elseif(cmd == "unignore") then |
||
59 | myWhoPinged_UnIgnorePing(wparg2); |
||
60 | elseif(cmd == "list") then |
||
61 | myWhoPinged_ListIgnored(); |
||
62 | elseif(cmd == "zone") then |
||
63 | myWhoPinged_ZoneToggle(); |
||
64 | else |
||
65 | myWhoPinged_ShowHelp(); |
||
66 | end |
||
67 | wparg2 = nil; |
||
68 | end |
||
69 | |||
70 | function myWhoPinged_ZoneToggle() |
||
71 | if(whopinged_cfg["zone"] == 1) then |
||
72 | DEFAULT_CHAT_FRAME:AddMessage("|cffffff00DISABLED display of pinging player's name in zone field|r"); |
||
73 | whopinged_cfg["zone"] = 0; |
||
74 | MinimapZoneText:SetText(GetMinimapZoneText()); |
||
75 | else |
||
76 | DEFAULT_CHAT_FRAME:AddMessage("|cffffff00ENABLED display of pinging player's name in zone field|r"); |
||
77 | whopinged_cfg["zone"] = 1; |
||
78 | end |
||
79 | end |
||
80 | |||
81 | function myWhoPinged_ListIgnored() |
||
82 | if(whopinged_cfg["IGNORE"] ~= nil and table.getn(whopinged_cfg["IGNORE"]) > 0) then |
||
83 | DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Minimap pings ignored from players:|r"); |
||
84 | table.foreach(whopinged_cfg["IGNORE"], function(k,v) DEFAULT_CHAT_FRAME:AddMessage("-" .. v) end); |
||
85 | else |
||
86 | DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Ignore list is empty.|r"); |
||
87 | end |
||
88 | end |
||
89 | |||
90 | function myWhoPinged_ShowHelp() |
||
91 | DEFAULT_CHAT_FRAME:AddMessage("|cffffff00WhoPinged " .. wpversion .. " Help:|r"); |
||
92 | DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00/wp|r: toggles on/off automatic ping identifying. can create lots of spam"); |
||
93 | DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00/wp last|r: shows the last two players to ping the map"); |
||
94 | DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00/wp ignore <player>|r: ignores a player's minimap pings"); |
||
95 | DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00/wp unignore|r <player>|r: removes a player from your minimap ping ignore list"); |
||
96 | DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00/wp list|r: lists players whose pings you're ignoring"); |
||
97 | DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00/wp zone|r: toggle to show the pinging player's name in the zone field above the minimap"); |
||
98 | DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00/wp help|r: shows this list of commands"); |
||
99 | end |
||
100 | |||
101 | function myWhoPinged_UnIgnorePing(ipname) |
||
102 | if(ipname ~= nil) then |
||
103 | if(myWhoPinged_RemoveFromList(ipname)) then |
||
104 | DEFAULT_CHAT_FRAME:AddMessage("|cffffff00No longer ignoring " .. ipname .. "'s pings.|r"); |
||
105 | else |
||
106 | DEFAULT_CHAT_FRAME:AddMessage("|cffffff00" .. ipname .. " not found in ignore list.|r"); |
||
107 | end |
||
108 | else |
||
109 | myWhoPinged_ShowHelp(); |
||
110 | end |
||
111 | end |
||
112 | |||
113 | function myWhoPinged_IgnorePing(ipname) |
||
114 | if(ipname ~= nil) then |
||
115 | if(not myWhoPinged_AddToList(ipname)) then |
||
116 | DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Already ignoring " .. ipname .. "'s pings.|r"); |
||
117 | else |
||
118 | DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Now ignoring " .. ipname .. "'s pings.|r"); |
||
119 | end |
||
120 | else |
||
121 | myWhoPinged_ListIgnored(); |
||
122 | end |
||
123 | end |
||
124 | |||
125 | function myWhoPinged_WhoPinged() |
||
126 | if(theypinged ~= nil) then |
||
127 | if(theypinged2 ~= nil) then |
||
128 | DEFAULT_CHAT_FRAME:AddMessage(theypinged .. " and " .. theypinged2 .. " last pinged the minimap."); |
||
129 | else |
||
130 | DEFAULT_CHAT_FRAME:AddMessage(theypinged .. " last pinged the minimap."); |
||
131 | end |
||
132 | else |
||
133 | DEFAULT_CHAT_FRAME:AddMessage("no recorded minimap pings."); |
||
134 | end |
||
135 | end |
||
136 | |||
137 | function myWhoPinged_IsInList(ipname) |
||
138 | ipname = string.lower(ipname); |
||
139 | if(whopinged_cfg["IGNORE"] ~= nil) then |
||
140 | for i, v in whopinged_cfg["IGNORE"] do |
||
141 | if(v == ipname) then |
||
142 | return i; |
||
143 | end |
||
144 | end |
||
145 | return false; |
||
146 | else |
||
147 | return false; |
||
148 | end |
||
149 | end |
||
150 | |||
151 | function myWhoPinged_AddToList(ipname) |
||
152 | ipname = string.lower(ipname); |
||
153 | if(not myWhoPinged_IsInList(ipname)) then |
||
154 | table.insert(whopinged_cfg.IGNORE, ipname) |
||
155 | return true; |
||
156 | else |
||
157 | return false; |
||
158 | end |
||
159 | end |
||
160 | |||
161 | function myWhoPinged_RemoveFromList(ipname) |
||
162 | ipname = string.lower(ipname); |
||
163 | tempo = myWhoPinged_IsInList(ipname); |
||
164 | if(tempo) then |
||
165 | table.remove(whopinged_cfg.IGNORE, tempo); |
||
166 | return true; |
||
167 | else |
||
168 | return false; |
||
169 | end |
||
170 | tempo = nil; |
||
171 | end |
||
172 | |||
173 | function WP_RegisterUltimateUI() |
||
174 | UltimateUI_RegisterConfiguration( |
||
175 | "UUI_WHOPINGED", |
||
176 | "SECTION", |
||
177 | "WhoPinged", |
||
178 | "Find out who pinged the minimap!" |
||
179 | ); |
||
180 | UltimateUI_RegisterConfiguration( |
||
181 | "UUI_WHOPINGED_SEPARATOR", |
||
182 | "SEPARATOR", |
||
183 | "WhoPinged", |
||
184 | "Find out who pinged the minimap!" |
||
185 | ); |
||
186 | UltimateUI_RegisterConfiguration( |
||
187 | "UUI_SELFCAST_ENABLE", |
||
188 | "CHECKBOX", |
||
189 | "Enable SelfCast", |
||
190 | "Check this box to enable WhoPinged.", |
||
191 | myWhoPinged_WhosPinging, |
||
192 | |||
193 | ); |
||
194 | UltimateUI_RegisterConfiguration( |
||
195 | "UUI_SELFCAST_ZONE", |
||
196 | "CHECKBOX", |
||
197 | "Zone output", |
||
198 | "Will show who pinged in the minimap zone text area.", |
||
199 | myWhoPinged_ZoneToggle, |
||
200 | |||
201 | ); |
||
202 | UltimateUI_RegisterConfiguration( |
||
203 | "UUI_SELFCAST_LISTIGNORED", |
||
204 | "BUTTON", |
||
205 | "", |
||
206 | "", |
||
207 | myWhoPinged_ListIgnored, |
||
208 | 0, |
||
209 | 0, |
||
210 | 0, |
||
211 | 0, |
||
212 | "List Ignored" |
||
213 | ); |
||
214 | UltimateUI_RegisterConfiguration( |
||
215 | "UUI_SELFCAST_COMMANDS", |
||
216 | "BUTTON", |
||
217 | "", |
||
218 | "", |
||
219 | myWhoPinged_ShowHelp, |
||
220 | 0, |
||
221 | 0, |
||
222 | 0, |
||
223 | 0, |
||
224 | "Command List" |
||
225 | ); |
||
226 | WP_Registered = 1; |
||
227 | end |
||
228 | |||
229 | function myWhoPinged_Minimap_OnEvent() |
||
230 | --if(event == "VARIABLES_LOADED" ) then |
||
231 | if( WP_Registered == 0 ) then |
||
232 | if ( UltimateUI_RegisterButton ) then |
||
233 | WP_RegisterUltimateUI(); |
||
234 | end |
||
235 | end |
||
236 | --end |
||
237 | if(event == "MINIMAP_PING" and arg1 ~= nil) then |
||
238 | if(myWhoPinged_IsInList(string.lower(UnitName(arg1)))) then |
||
239 | return; |
||
240 | end |
||
241 | end |
||
242 | myWhoPinged_original_Minimap_OnEvent(); |
||
243 | if(event == "MINIMAP_PING" and arg1 ~= nil) then |
||
244 | if(whopinged_cfg["zone"] == 1) then |
||
245 | MinimapZoneText:SetText(UnitName(arg1)); |
||
246 | end |
||
247 | if(theypinged ~= nil and theypinged ~= UnitName(arg1)) then |
||
248 | theypinged2 = theypinged; |
||
249 | theypinged = UnitName(arg1); |
||
250 | if(whospinging == 1) then |
||
251 | DEFAULT_CHAT_FRAME:AddMessage(theypinged .. " pinged the minimap!"); |
||
252 | end |
||
253 | else |
||
254 | theypinged = UnitName(arg1); |
||
255 | if(whospinging == 1) then |
||
256 | DEFAULT_CHAT_FRAME:AddMessage(theypinged .. " pinged the minimap!"); |
||
257 | end |
||
258 | end |
||
259 | end |
||
260 | end |
||
261 | |||
262 | function myWhoPinged_WhosPinging() |
||
263 | if(whospinging == nil) then |
||
264 | whospinging = 1; |
||
265 | DEFAULT_CHAT_FRAME:AddMessage("|cffffff00ENABLED minimap ping identifying. type /wp to disable|r"); |
||
266 | else |
||
267 | whospinging = nil; |
||
268 | DEFAULT_CHAT_FRAME:AddMessage("|cffffff00DISABLED minimap ping identifying. type /wp to enable|r"); |
||
269 | end |
||
270 | end |