vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 function GuildAdsConfigFrame_OnShow()
2  
3 local realmName = GetCVar("realmName");
4  
5 local playerName = UnitName("player");
6  
7  
8  
9 if (GuildAds.Config.PublishMyAds) then
10  
11 GuildAds_PublishMyAdsCheckButton:SetChecked(1);
12  
13 else
14  
15 GuildAds_PublishMyAdsCheckButton:SetChecked(0);
16  
17 end
18  
19 if (GuildAds.Config.ShowOfflinePlayer) then
20  
21 GuildAds_ShowOfflinePlayerCheckButton:SetChecked(1);
22  
23 else
24  
25 GuildAds_ShowOfflinePlayerCheckButton:SetChecked(0);
26  
27 end
28  
29 if (GuildAds.Config.ShowMyAds) then
30  
31 GuildAds_ShowMyAdsCheckButton:SetChecked(1);
32  
33 else
34  
35 GuildAds_ShowMyAdsCheckButton:SetChecked(0);
36  
37 end
38  
39  
40  
41 if (GuildAds.Config.Mine[realmName] == nil) then
42  
43 GuildAds.Config.Mine[realmName] = {};
44  
45 end
46  
47  
48  
49 if (GuildAdsConfig_GetProfileValue("ShowNewAsk")) then
50  
51 GuildAds_ChatShowNewAskCheckButton:SetChecked(1);
52  
53 else
54  
55 GuildAds_ChatShowNewAskCheckButton:SetChecked(0);
56  
57 end
58  
59  
60  
61 if (GuildAdsConfig_GetProfileValue("ShowNewHave")) then
62  
63 GuildAds_ChatShowNewHaveCheckButton:SetChecked(1);
64  
65 else
66  
67 GuildAds_ChatShowNewHaveCheckButton:SetChecked(0);
68  
69 end
70  
71  
72  
73 local channelName = nil;
74  
75 if (GuildAds.Config.Mine[realmName][playerName]) then
76  
77 if (GuildAds.Config.Mine[realmName][playerName].ChannelName) then
78  
79 channelName=GuildAds.Config.Mine[realmName][playerName].ChannelName;
80  
81 end
82  
83 end
84  
85 if (channelName) then
86  
87 GuildAds_ChatUseThisCheckButton:SetChecked(1);
88  
89 GuildAds_ChannelEditBox:Show();
90  
91 GuildAds_ChannelPasswordEditBox:Show();
92  
93 GuildAds_ChannelEditBox:SetText(channelName);
94  
95 password = GuildAds.Config.Mine[realmName][playerName].ChannelPassword;
96  
97 if (password == nil) then
98  
99 password = "";
100  
101 end
102  
103 GuildAds_ChannelPasswordEditBox:SetText(password);
104  
105 else
106  
107 GuildAds_ChatUseThisCheckButton:SetChecked(0);
108  
109 GuildAds_ChannelEditBox:Hide();
110  
111 GuildAds_ChannelPasswordEditBox:Hide();
112  
113 end
114  
115  
116  
117 local channelCommand, channelAlias = GuildAdsConfig_GetChannelAlias();
118  
119 GuildAds_ChannelAliasEditBox:SetText(channelAlias);
120  
121 GuildAds_ChannelCommandEditBox:SetText(channelCommand);
122  
123  
124  
125 GuildAds_MinimapArcSlider:SetValue(GuildAds.Config.MinimapArcOffset);
126  
127 GuildAds_MinimapRadiusSlider:SetValue(GuildAds.Config.MinimapRadiusOffset);
128  
129 end
130  
131  
132  
133 function GuildAdsConfigFrame_OnHide()
134  
135 if ( GuildAds_ChatUseThisCheckButton:GetChecked() ) then
136  
137 local name = GuildAds_ChannelEditBox:GetText();
138  
139 local password = GuildAds_ChannelPasswordEditBox:GetText();
140  
141 if (name == "") then
142  
143 name = nil;
144  
145 password = nil;
146  
147 else
148  
149 if (password == "") then
150  
151 password = nil;
152  
153 end
154  
155 end
156  
157 GuildAdsConfig_SetChannel(name, password);
158  
159 else
160  
161 GuildAdsConfig_SetChannel(nil, nil);
162  
163 end
164  
165  
166  
167 local channelCommand = GuildAds_ChannelCommandEditBox:GetText();
168  
169 local channelAlias = GuildAds_ChannelAliasEditBox:GetText();
170  
171 GuildAdsConfig_SetChannelAlias(channelCommand, channelAlias);
172  
173  
174  
175 end
176  
177  
178  
179 function GuildAdsConfig_GetProfileValue(key, defaultValue)
180  
181 local realmName = GetCVar("realmName");
182  
183 local playerName = UnitName("player");
184  
185 if (GuildAds.Config.Mine[realmName]) then
186  
187 if (GuildAds.Config.Mine[realmName][playerName]) then
188  
189 if (GuildAds.Config.Mine[realmName][playerName][key]) then
190  
191 return GuildAds.Config.Mine[realmName][playerName][key];
192  
193 end
194  
195 end
196  
197 end
198  
199 return defaultValue;
200  
201 end
202  
203  
204  
205 function GuildAdsConfig_SetProfileValue(key, value)
206  
207 local realmName = GetCVar("realmName");
208  
209 local playerName = UnitName("player");
210  
211 if (not GuildAds.Config.Mine[realmName]) then
212  
213 GuildAds.Config.Mine[realmName] = { };
214  
215 end
216  
217 if (not GuildAds.Config.Mine[realmName][playerName]) then
218  
219 GuildAds.Config.Mine[realmName][playerName] = { };
220  
221 end
222  
223 GuildAds.Config.Mine[realmName][playerName][key] = value;
224  
225 end
226  
227  
228  
229 function GuildAdsConfig_SetUseThisChannel(state)
230  
231 if (state) then
232  
233 GuildAds_ChatUseThisCheckButton:SetChecked(1);
234  
235 GuildAds_ChannelEditBox:Show();
236  
237 GuildAds_ChannelPasswordEditBox:Show();
238  
239 else
240  
241 GuildAds_ChatUseThisCheckButton:SetChecked(0);
242  
243 GuildAds_ChannelEditBox:Hide();
244  
245 GuildAds_ChannelPasswordEditBox:Hide();
246  
247 end
248  
249 end
250  
251  
252  
253 function GuildAdsConfig_GetChannelName()
254  
255 local realmName = GetCVar("realmName");
256  
257 local playerName = UnitName("player");
258  
259 if (GuildAds.Config.Mine[realmName]) then
260  
261 if (GuildAds.Config.Mine[realmName][playerName]) then
262  
263 if (GuildAds.Config.Mine[realmName][playerName].ChannelName) then
264  
265 return GuildAds.Config.Mine[realmName][playerName].ChannelName;
266  
267 end
268  
269 end
270  
271 end
272  
273  
274  
275 local go_guildName, go_GuildRankName, go_guildRankIndex = GetGuildInfo("player");
276  
277 if (go_guildName) then
278  
279 name = "GuildAds";
280  
281 for word in string.gfind(go_guildName,"[^ ]+") do
282  
283 name = name..word;
284  
285 end
286  
287 if (strlen(name) > 31) then
288  
289 name = string.sub(name, 0, 31);
290  
291 end
292  
293 return name;
294  
295 else
296  
297 return "GuildAds"..UnitName("player");
298  
299 end
300  
301 end
302  
303  
304  
305 function GuildAdsConfig_GetChannelPassword()
306  
307 local realmName = GetCVar("realmName");
308  
309 local playerName = UnitName("player");
310  
311 if (GuildAds.Config.Mine[realmName]) then
312  
313 if (GuildAds.Config.Mine[realmName][playerName]) then
314  
315 return GuildAds.Config.Mine[realmName][playerName].ChannelPassword;
316  
317 end
318  
319 end
320  
321 return nil;
322  
323 end
324  
325  
326  
327 function GuildAdsConfig_SetChannel(name, password)
328  
329 local realmName = GetCVar("realmName");
330  
331 local playerName = UnitName("player");
332  
333 local reinit = false;
334  
335  
336  
337 if (GuildAds.Config.Mine[realmName] == nil) then
338  
339 GuildAds.Config.Mine[realmName] = {};
340  
341 end
342  
343  
344  
345 if (name ~= nil) then
346  
347 if (password~=nil and string.len(password) == 0) then
348  
349 password = nil;
350  
351 end
352  
353  
354  
355 local current = GuildAds.Config.Mine[realmName][playerName];
356  
357 if not(current and current.ChannelName == name and current.ChannelPassword == password) then
358  
359 if (GuildAds.Config.Mine[realmName][playerName] == nil) then
360  
361 GuildAds.Config.Mine[realmName][playerName] = { };
362  
363 end
364  
365 if (GuildAds.Config.Mine[realmName][playerName].ChannelName ~= name) or (GuildAds.Config.Mine[realmName][playerName].ChannelPassword ~= password) then
366  
367 GuildAds.Config.Mine[realmName][playerName].ChannelName = name;
368  
369 GuildAds.Config.Mine[realmName][playerName].ChannelPassword = password;
370  
371 reinit = true;
372  
373 end
374  
375 end
376  
377 else
378  
379 if (GuildAds.Config.Mine[realmName][playerName]) then
380  
381 if (GuildAds.Config.Mine[realmName][playerName].ChannelName) or (GuildAds.Config.Mine[realmName][playerName].ChannelPassword) then
382  
383 GuildAds.Config.Mine[realmName][playerName].ChannelName = nil;
384  
385 GuildAds.Config.Mine[realmName][playerName].ChannelPassword = nil;
386  
387 reinit = true;
388  
389 end
390  
391 end
392  
393 end
394  
395  
396  
397 if (reinit) then
398  
399 GuildAds_Reinit();
400  
401 end
402  
403 end
404  
405  
406  
407 function GuildAdsConfig_GetChannelAlias()
408  
409 local realmName = GetCVar("realmName");
410  
411 local playerName = UnitName("player");
412  
413  
414  
415 if (GuildAds.Config.Mine[realmName]) then
416  
417 if (GuildAds.Config.Mine[realmName][playerName]) then
418  
419 local current = GuildAds.Config.Mine[realmName][playerName];
420  
421 if (current.ChannelCommand and current.ChannelAlias) then
422  
423 return current.ChannelCommand, current.ChannelAlias;
424  
425 end
426  
427 end
428  
429 end
430  
431  
432  
433 return "ga", "GuildAds";
434  
435 end
436  
437  
438  
439 function GuildAdsConfig_SetChannelAlias(command, alias)
440  
441 local realmName = GetCVar("realmName");
442  
443 local playerName = UnitName("player");
444  
445 local reinit = false;
446  
447  
448  
449 if (GuildAds.Config.Mine[realmName] == nil) then
450  
451 GuildAds.Config.Mine[realmName] = {};
452  
453 end
454  
455  
456  
457 if (GuildAds.Config.Mine[realmName][playerName] == nil) then
458  
459 GuildAds.Config.Mine[realmName][playerName] = {};
460  
461 end
462  
463  
464  
465 local current = GuildAds.Config.Mine[realmName][playerName];
466  
467 if (current.ChannelCommand~=command or current.ChannelAlias~=alias) then
468  
469 current.ChannelCommand = command;
470  
471 current.ChannelAlias = alias;
472  
473 reinit = true;
474  
475 end
476  
477  
478  
479 if (reinit) then
480  
481 SimpleComm_InitAlias(current.ChannelCommand, current.ChannelAlias);
482  
483 end
484  
485 end
486  
487  
488  
489 function GuildAdsConfig_Toggle()
490  
491 if (GuildAdsConfigFrame:IsVisible()) then
492  
493 GuildAdsConfigFrame:Hide()
494  
495 else
496  
497 GuildAdsConfigFrame:Show();
498  
499 end
500  
501 end