vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Guild Event Manager by Kiki of European Cho'gall
3 New event - By Alexandre Flament and Kiki
4 ]]
5  
6 local newEventDate;
7 local GEM_ModifyEventId = nil;
8 local _GEMNew_FirstShow = true;
9 local GEMNewAutoMembers_PList = {};
10 local GEMNewAutoMembers_RList = {};
11  
12 --
13 function GEMNewSorting_EventOnHover()
14 local plugin_name = getglobal("GEMNewSortingListDropDown").name;
15 GameTooltip:SetOwner(this, "ANCHOR_CURSOR");
16 GameTooltip:ClearLines();
17 GameTooltip:AddLine("1");
18 GameTooltipTextLeft1:SetText("|cff" .. "00AAFF" .. plugin_name .. "|r");
19 local help = nil;
20 for name,plugin in GEM_SUB_Plugins do
21 if(name == plugin_name)
22 then
23 help = plugin.Help;
24 break;
25 end
26 end
27 if(help)
28 then
29 GameTooltip:AddLine("2");
30 GameTooltipTextLeft2:SetText("|cff" .. "FFFFFF" .. help .. "|r");
31 end
32 GameTooltip:Show();
33 end
34 function GEMNewSortingListDropDown_OnShow(sortname)
35 if(getglobal("GEMNewSortingListDropDown").name == nil)
36 then
37 getglobal("GEMNewSortingListDropDown").name = "";
38 end
39 if(sortname)
40 then
41 getglobal("GEMNewSortingListDropDown").name = sortname;
42 end
43 UIDropDownMenu_Initialize(GEMNewSortingListDropDown, GEMNewSortingListDropDown_Init);
44 UIDropDownMenu_SetText(getglobal("GEMNewSortingListDropDown").name, GEMNewSortingListDropDown);
45 end
46  
47 local function _GEMNewSorting_IsDefault(name,plugin)
48 local selected = GEM_GetSelectedReroll();
49 if(selected == nil or selected == "")
50 then
51 selected = GEM_PlayerName;
52 end
53 if(GEM_Events.realms[GEM_Realm].my_names[selected].default_plugin)
54 then
55 return GEM_Events.realms[GEM_Realm].my_names[selected].default_plugin == name;
56 end
57 return (plugin.Default ~= nil and plugin.Default == true);
58 end
59  
60 function GEMNewSortingListDropDown_OnClick()
61 getglobal("GEMNewSortingListDropDown").name = this.value;
62 UIDropDownMenu_SetText(this.value,GEMNewSortingListDropDown);
63 GEMNewSorting_Configure:Disable();
64 local plugin = GEM_SUB_Plugins[this.value];
65 if(plugin ~= nil and plugin.Configure ~= nil)
66 then
67 GEMNewSorting_Configure:Enable();
68 end
69  
70 GEMNewSorting_Default:SetChecked(_GEMNewSorting_IsDefault(this.value,plugin));
71 end
72  
73 function GEMNewSorting_Default_OnClick()
74 local selected = GEM_GetSelectedReroll();
75 if(selected == nil or selected == "")
76 then
77 selected = GEM_PlayerName;
78 end
79  
80 if(GEMNewSorting_Default:GetChecked()) -- Default checked
81 then
82 GEM_Events.realms[GEM_Realm].my_names[selected].default_plugin = getglobal("GEMNewSortingListDropDown").name;
83 else -- Default unchecked
84 GEM_Events.realms[GEM_Realm].my_names[selected].default_plugin = nil;
85 end
86 end
87  
88 function GEMNewSortingListDropDown_Init()
89 GEMNewSorting_Configure:Disable();
90 for name,plugin in GEM_SUB_Plugins do
91 local info = { };
92 info.text = name;
93 info.value = name;
94 info.func = GEMNewSortingListDropDown_OnClick;
95 UIDropDownMenu_AddButton(info);
96 if(_GEMNewSorting_IsDefault(name,plugin))
97 then
98 getglobal("GEMNewSortingListDropDown").name = name;
99 getglobal("GEMNewSortingListDropDown").help = plugin.Help;
100 UIDropDownMenu_SetText(name,GEMNewSortingListDropDown);
101 if(plugin.Configure ~= nil)
102 then
103 GEMNewSorting_Configure:Enable();
104 end
105 GEMNewSorting_Default:SetChecked(1);
106 end
107 end
108 end
109  
110 --
111 function GEMNewTemplateListDropDown_OnShow()
112 if(getglobal("GEMNewTemplateListDropDown").name == nil)
113 then
114 getglobal("GEMNewTemplateListDropDown").name = "";
115 end
116 UIDropDownMenu_Initialize(GEMNewTemplateListDropDown, GEMNewTemplateListDropDown_Init);
117 UIDropDownMenu_SetText(getglobal("GEMNewTemplateListDropDown").name, GEMNewTemplateListDropDown);
118 end
119  
120 function GEMNewTemplateListDropDown_OnClick()
121 getglobal("GEMNewTemplateListDropDown").name = this.value;
122 UIDropDownMenu_SetText(this.value,GEMNewTemplateListDropDown);
123 GEMNewTemplate_Load:Enable();
124 GEMNewTemplate_Delete:Enable();
125 end
126  
127 function GEMNewTemplateListDropDown_Init()
128 for name,tab in GEM_Templates do
129 local info = { };
130 info.text = name;
131 info.value = name;
132 info.func = GEMNewTemplateListDropDown_OnClick;
133 UIDropDownMenu_AddButton(info);
134 end
135 end
136  
137 --
138 function GEMNewChannelDropDown_OnShow(ch_name)
139 if(getglobal("GEMNewChannelDropDown").name == nil or not GEM_IsChannelInList(getglobal("GEMNewChannelDropDown").name))
140 then
141 getglobal("GEMNewChannelDropDown").name = GEM_DefaultSendChannel;
142 end
143 if(ch_name)
144 then
145 getglobal("GEMNewChannelDropDown").name = ch_name;
146 end
147 UIDropDownMenu_Initialize(GEMNewChannelDropDown, GEMNewChannelDropDown_Init);
148 UIDropDownMenu_SetText(getglobal("GEMNewChannelDropDown").name, GEMNewChannelDropDown);
149 UIDropDownMenu_SetWidth(120, GEMNewChannelDropDown);
150 end
151  
152 function GEMNewChannelDropDown_OnClick()
153 getglobal("GEMNewChannelDropDown").name = this.value;
154 UIDropDownMenu_SetText(this.value,GEMNewChannelDropDown);
155 end
156  
157 function GEMNewChannelDropDown_Init()
158 for name,tab in GEM_COM_Channels do
159 local info = { };
160 info.text = name;
161 info.value = name;
162 if(tab.id == 0)
163 then
164 info.disabled = 1;
165 end
166 info.func = GEMNewChannelDropDown_OnClick;
167 UIDropDownMenu_AddButton(info);
168 end
169 end
170  
171 function GEM_GetSelectedChannel()
172 local name = getglobal("GEMNewChannelDropDown").name;
173 if(name == nil)
174 then
175 name = GEM_DefaultSendChannel;
176 end
177 return strlower(name);
178 end
179  
180 --
181 function GEMNewRerollDropDown_OnShow(pl_name)
182 if(getglobal("GEMNewRerollDropDown").name == nil)
183 then
184 getglobal("GEMNewRerollDropDown").name = GEM_PlayerName;
185 end
186 if(pl_name)
187 then
188 getglobal("GEMNewRerollDropDown").name = pl_name;
189 end
190 UIDropDownMenu_Initialize(GEMNewRerollDropDown, GEMNewRerollDropDown_Init);
191 UIDropDownMenu_SetText(getglobal("GEMNewRerollDropDown").name, GEMNewRerollDropDown);
192 UIDropDownMenu_SetWidth(80, GEMNewRerollDropDown);
193 end
194  
195 function GEMNewRerollDropDown_OnClick()
196 getglobal("GEMNewRerollDropDown").name = this.value;
197 getglobal("GEMListFrameRerollDropDown").name = this.value;
198 UIDropDownMenu_SetText(this.value,GEMNewRerollDropDown);
199 end
200  
201 function GEMNewRerollDropDown_OnClickBadValue()
202 GEM_ChatPrint(GEM_TEXT_REROLL_ERR_SELECT);
203 end
204  
205 function GEMNewRerollDropDown_Init()
206 for name,tab in GEM_Events.realms[GEM_Realm].my_names do
207 local info = { };
208 info.text = name;
209 info.value = name;
210 if(not GEM_IsChannelInRerollList(name,GEM_GetSelectedChannel()))
211 then
212 info.disabled = 1;
213 info.func = GEMNewRerollDropDown_OnClickBadValue;
214 else
215 info.func = GEMNewRerollDropDown_OnClick;
216 end
217 UIDropDownMenu_AddButton(info);
218 end
219 end
220 --
221  
222  
223 function GEMNew_Event_ZoneDropDown_OnShow()
224 UIDropDownMenu_Initialize(GEMNew_Event_ZoneDropDown, GEMNew_Event_ZoneDropDown_Init);
225 UIDropDownMenu_SetText("", GEMNew_Event_ZoneDropDown);
226 UIDropDownMenu_SetWidth(80, GEMNew_Event_ZoneDropDown);
227 end
228  
229 function GEMNew_Event_ZoneDropDown_OnClick()
230 GEMNew_Where:SetText(this.value);
231 end
232  
233 function GEMNew_Event_ZoneDropDown_Init()
234 for k,instance in GEM_INSTANCES do
235 local info = { };
236 info.text = instance;
237 info.value = instance;
238 info.func = GEMNew_Event_ZoneDropDown_OnClick;
239 UIDropDownMenu_AddButton(info);
240 end
241 end
242  
243 function GEMNew_Date_OnClick()
244 GEMCalendar_PickupDate(GEMNew_Date_PickedUp, nil);
245 end
246  
247 function GEMNew_Date_PickedUp(sel_date, user_data)
248 GEMNew_Date_Set(sel_date - GEM_ComputeHourOffset());
249 end
250  
251 function GEMNew_Date_Set(sel_date)
252 if(GEM_ServerOffset == 666)
253 then
254 GEM_ComputeServerOffset();
255 end
256  
257 GEMNew_DateValueServer:SetText(GEM_HEADER_DATE_SERVER..date(GEM_HOUR_FORMAT,sel_date+(GEM_ServerOffset * 60 * 60)));
258 GEMNew_DateValue:SetText(GEM_ConvertDateFormat(date(GEM_Events.DateFormat,sel_date)));
259  
260 newEventDate = sel_date;
261 end
262  
263 local function GEMNew_GetClass(name)
264 local wgt_name = "GEMNew_Limit_"..name;
265 local mini,maxi;
266 mini = tonumber(getglobal(wgt_name.."_Min"):GetText(),10);
267 maxi = tonumber(getglobal(wgt_name.."_Max"):GetText(),10);
268  
269 local sub = {};
270 sub.min = -1;
271 sub.max = -1;
272 sub.tit_count = 0;
273 sub.sub_count = 0;
274 sub.repl_count = 0;
275 if(mini)
276 then
277 sub.min = mini;
278 end
279 if(maxi)
280 then
281 sub.max = maxi;
282 end
283 return sub;
284 end
285  
286 local function GEMNew_SetClass(name,class)
287 local wgt_name = "GEMNew_Limit_"..name;
288 local mini,maxi;
289  
290 if(class.min)
291 then
292 getglobal(wgt_name.."_Min"):SetText(class.min);
293 end
294 if(class.min)
295 then
296 getglobal(wgt_name.."_Max"):SetText(class.max);
297 end
298 end
299  
300 local function GEMNew_ResetAllClasses()
301 GEMNew_Limit_Warrior_Min:SetText("");
302 GEMNew_Limit_Warrior_Max:SetText("");
303  
304 GEMNew_Limit_Paladin_Min:SetText("");
305 GEMNew_Limit_Paladin_Max:SetText("");
306  
307 GEMNew_Limit_Shaman_Min:SetText("");
308 GEMNew_Limit_Shaman_Max:SetText("");
309  
310 GEMNew_Limit_Rogue_Min:SetText("");
311 GEMNew_Limit_Rogue_Max:SetText("");
312  
313 GEMNew_Limit_Mage_Min:SetText("");
314 GEMNew_Limit_Mage_Max:SetText("");
315  
316 GEMNew_Limit_Warlock_Min:SetText("");
317 GEMNew_Limit_Warlock_Max:SetText("");
318  
319 GEMNew_Limit_Hunter_Min:SetText("");
320 GEMNew_Limit_Hunter_Max:SetText("");
321  
322 GEMNew_Limit_Druid_Min:SetText("");
323 GEMNew_Limit_Druid_Max:SetText("");
324  
325 GEMNew_Limit_Priest_Min:SetText("");
326 GEMNew_Limit_Priest_Max:SetText("");
327  
328 end
329  
330 local function GEMNew_GetClasses()
331 local clas = {};
332  
333 clas["WARRIOR"] = GEMNew_GetClass("Warrior");
334 clas["PALADIN"] = GEMNew_GetClass("Paladin");
335 clas["SHAMAN"] = GEMNew_GetClass("Shaman");
336 clas["ROGUE"] = GEMNew_GetClass("Rogue");
337 clas["MAGE"] = GEMNew_GetClass("Mage");
338 clas["WARLOCK"] = GEMNew_GetClass("Warlock");
339 clas["HUNTER"] = GEMNew_GetClass("Hunter");
340 clas["DRUID"] = GEMNew_GetClass("Druid");
341 clas["PRIEST"] = GEMNew_GetClass("Priest");
342 return clas;
343 end
344  
345 local function GEMNew_SetClasses(classes)
346 GEMNew_ResetAllClasses();
347 GEMNew_SetClass("Warrior",classes["WARRIOR"]);
348 GEMNew_SetClass("Paladin",classes["PALADIN"]);
349 GEMNew_SetClass("Shaman",classes["SHAMAN"]);
350 GEMNew_SetClass("Rogue",classes["ROGUE"]);
351 GEMNew_SetClass("Mage",classes["MAGE"]);
352 GEMNew_SetClass("Warlock",classes["WARLOCK"]);
353 GEMNew_SetClass("Hunter",classes["HUNTER"]);
354 GEMNew_SetClass("Druid",classes["DRUID"]);
355 GEMNew_SetClass("Priest",classes["PRIEST"]);
356 end
357  
358 function GEMNew_CheckResetEdit()
359 if(GEMNew_Create:GetText() == GEM_TEXT_MODIFY) -- Edit mode canceled
360 then
361 GEMNew_Create:SetText(GEM_TEXT_CREATE);
362 GEMNew_Reset();
363 GEMNew_ResetAllClasses();
364 end
365 end
366  
367 function GEMNew_Create_OnClick()
368 if(GEMNew_Create:GetText() == GEM_TEXT_MODIFY) -- Edit mode
369 then
370 local where, count, min_lvl, max_lvl;
371 local clas = GEMNew_GetClasses();
372 where = GEMNew_Where:GetText();
373 if(where == "")
374 then
375 GEM_ChatPrint(GEM_TEXT_ERR_NO_WHERE);
376 GEMNew_Where:SetFocus();
377 return;
378 end
379 comment = string.gsub(GEMNew_Comment:GetText(),"[%c]"," ");
380 count = GEMNew_Count:GetNumber();
381 min_lvl = GEMNew_MinLevel:GetNumber();
382 max_lvl = GEMNew_MaxLevel:GetNumber();
383 -- Update event
384 GEM_Events.realms[GEM_Realm].events[GEM_ModifyEventId].leader = GEM_GetSelectedReroll();
385 GEM_Events.realms[GEM_Realm].events[GEM_ModifyEventId].update_time = time();
386 GEM_Events.realms[GEM_Realm].events[GEM_ModifyEventId].ev_date = newEventDate;
387 GEM_Events.realms[GEM_Realm].events[GEM_ModifyEventId].ev_place = where;
388 GEM_Events.realms[GEM_Realm].events[GEM_ModifyEventId].ev_comment = comment;
389 GEM_Events.realms[GEM_Realm].events[GEM_ModifyEventId].max_count = count;
390 GEM_Events.realms[GEM_Realm].events[GEM_ModifyEventId].min_lvl = min_lvl;
391 GEM_Events.realms[GEM_Realm].events[GEM_ModifyEventId].max_lvl = max_lvl;
392 for name,tab in clas do
393 GEM_Events.realms[GEM_Realm].events[GEM_ModifyEventId].classes[name].min = tab.min
394 GEM_Events.realms[GEM_Realm].events[GEM_ModifyEventId].classes[name].max = tab.max;
395 end
396 local sorttype = GEM_SUB_GetSortType(getglobal("GEMNewSortingListDropDown").name);
397 if(sorttype == nil)
398 then
399 GEM_ChatWarning("GEMNew_Create_OnClick : Failed to update SortType for '"..getglobal("GEMNewSortingListDropDown").name.."'");
400 return;
401 end
402 GEM_Events.realms[GEM_Realm].events[GEM_ModifyEventId].sorttype = sorttype;
403  
404 GEM_ChatDebug(GEM_DEBUG_GUI,"EditEvent : Updated EventId "..GEM_ModifyEventId.." Leader="..GEM_GetSelectedReroll().." Date="..date("%c",newEventDate).." Place="..where.." Comment="..comment.." Count="..count.." Min="..min_lvl.." Max="..max_lvl);
405  
406 -- Check players's level
407 GEM_SUB_CheckPlayersLevel(GEM_ModifyEventId);
408  
409 -- Re order players
410 GEM_SUB_SortPlayers(GEM_ModifyEventId);
411  
412 -- Notify
413 GEM_COM_NotifyEventUpdate(GEM_ModifyEventId);
414  
415 GEMNew_Create:SetText(GEM_TEXT_CREATE);
416 GEMNew_Reset();
417 GEMNew_ResetAllClasses();
418 GEMMain_SelectTab(1);
419 else
420 local where, count, min_lvl, max_lvl, sorttype;
421 local clas = GEMNew_GetClasses();
422 where = GEMNew_Where:GetText();
423 if(where == "")
424 then
425 GEM_ChatPrint(GEM_TEXT_ERR_NO_WHERE);
426 GEMNew_Where:SetFocus();
427 return;
428 end
429 comment = string.gsub(GEMNew_Comment:GetText(),"[%c]"," ");
430 count = GEMNew_Count:GetNumber();
431 min_lvl = GEMNew_MinLevel:GetNumber();
432 max_lvl = GEMNew_MaxLevel:GetNumber();
433 sorttype = GEM_SUB_GetSortType(getglobal("GEMNewSortingListDropDown").name);
434 if(sorttype == nil)
435 then
436 GEM_ChatWarning("GEMNew_Create_OnClick : Failed to find SortType for '"..getglobal("GEMNewSortingListDropDown").name.."'");
437 return;
438 end
439 local ev_id = GEM_COM_CreateNewEvent(GEM_GetSelectedChannel(),newEventDate, where,comment, count, min_lvl, max_lvl,clas,sorttype);
440 GEMNew_CheckAutoMembers(ev_id);
441 GEMNew_Reset();
442 GEMNew_ResetAllClasses();
443 GEMMain_SelectTab(1);
444 end
445 end
446  
447 function GEMNew_Reset()
448 GEMNew_AutoMembers:Enable();
449 GEMNewAutoMembers_PList = {};
450 GEMNewAutoMembers_RList = {};
451 GEMNew_Where:SetText("");
452 GEMNew_Comment:SetText("");
453 GEMNew_Count:SetText("5");
454 GEMNew_MinLevel:SetText("1");
455 GEMNew_MaxLevel:SetText("60");
456 local d = floor(time() / 900) * 900;
457 GEMNew_Date_Set(d);
458 end
459  
460 function GEMNew_OnShow()
461 if(_GEMNew_FirstShow)
462 then
463 GEMNew_Reset();
464 GEMNew_ResetAllClasses();
465 GEMNewTemplate_Load:Disable();
466 GEMNewTemplate_Delete:Disable();
467 _GEMNew_FirstShow = false;
468 end
469 end
470  
471 --
472 function GEMNewTemplate_Save_OnClick()
473 local name = GEMNewTemplate_Name:GetText();
474 if(name == "")
475 then
476 GEM_ChatPrint(GEM_TEXT_ERR_NO_TEMPLATE);
477 GEMNewTemplate_Name:SetFocus();
478 return;
479 end
480  
481 GEM_Templates[name] = {};
482  
483 GEM_Templates[name].classes = GEMNew_GetClasses();
484 GEM_Templates[name].where = GEMNew_Where:GetText();
485 GEM_Templates[name].comment = GEMNew_Comment:GetText();
486 GEM_Templates[name].count = GEMNew_Count:GetNumber();
487 GEM_Templates[name].min_lvl = GEMNew_MinLevel:GetNumber();
488 GEM_Templates[name].max_lvl = GEMNew_MaxLevel:GetNumber();
489 GEM_Templates[name].AutoMembers_PList = GEMNewAutoMembers_PList;
490 GEM_Templates[name].AutoMembers_RList = GEMNewAutoMembers_RList;
491  
492 GEM_ChatPrint(GEM_TEXT_TEMPLATE_SAVED);
493 GEMNewTemplate_Name:SetText("");
494 GEMNewTemplateListDropDown_OnShow();
495 end
496  
497 function GEMNewTemplate_Load_OnClick()
498 local name = getglobal("GEMNewTemplateListDropDown").name;
499 GEMNew_Where:SetText(GEM_Templates[name].where);
500 GEMNew_Comment:SetText(GEM_Templates[name].comment);
501 GEMNew_Count:SetText(GEM_Templates[name].count);
502 GEMNew_MinLevel:SetText(GEM_Templates[name].min_lvl);
503 GEMNew_MaxLevel:SetText(GEM_Templates[name].max_lvl);
504 GEMNew_SetClasses(GEM_Templates[name].classes);
505 GEMNewAutoMembers_PList = GEM_Templates[name].AutoMembers_PList;
506 GEMNewAutoMembers_RList = GEM_Templates[name].AutoMembers_RList;
507 if(GEMNewAutoMembers_PList == nil) then GEMNewAutoMembers_PList = {}; end;
508 if(GEMNewAutoMembers_RList == nil) then GEMNewAutoMembers_RList = {}; end;
509 end
510  
511 StaticPopupDialogs["GEM_CONFIRM_ERASE_TEMPLATE"] = {
512 text = TEXT(GEM_TEXT_NEW_CLOSE_CONFIRM),
513 button1 = TEXT(OKAY),
514 button2 = TEXT(CANCEL),
515 OnAccept = function()
516 local name = this:GetParent().data;
517 GEM_Templates[name] = nil;
518 getglobal("GEMNewTemplateListDropDown").name = nil;
519 GEMNewTemplateListDropDown_OnShow();
520 GEMNewTemplate_Load:Disable();
521 GEMNewTemplate_Delete:Disable();
522 end,
523 timeout = 0
524 };
525  
526 function GEMNewTemplate_Delete_OnClick()
527 local dialogFrame = StaticPopup_Show("GEM_CONFIRM_ERASE_TEMPLATE");
528 if(dialogFrame)
529 then
530 dialogFrame.data = getglobal("GEMNewTemplateListDropDown").name;
531 end
532 end
533  
534 function GEMNew_LoadEvent(event)
535 GEMNew_Where:SetText(event.ev_place);
536 GEMNew_Comment:SetText(event.ev_comment);
537 GEMNew_Count:SetText(event.max_count);
538 GEMNew_MinLevel:SetText(event.min_lvl);
539 GEMNew_MaxLevel:SetText(event.max_lvl);
540 GEMNew_SetClasses(event.classes);
541 GEM_ModifyEventId = event.id;
542 GEMNewRerollDropDown_OnShow(event.leader);
543 GEMNewChannelDropDown_OnShow(event.channel);
544 GEMNewSortingListDropDown_OnShow(GEM_SUB_GetSortType(event.sorttype));
545 GEMNew_Date_Set(event.ev_date);
546 end
547  
548 --
549 function GEMNewSorting_Configure_OnClick()
550 local name = getglobal("GEMNewSortingListDropDown").name;
551 local plugin = GEM_SUB_Plugins[name];
552 if(plugin ~= nil and plugin.Configure ~= nil)
553 then
554 plugin.Configure();
555 end
556 end
557  
558 --
559 --[[
560 Auto members Functions
561 ]]
562  
563 local MAXDISPLAY_AUTOMEMBERS = 8;
564 local selectPItem = nil;
565 local selectRItem = nil;
566  
567 local function GEMNewAutoMembers_GetPList()
568 local plist = {};
569  
570 for i,tab in GEMNewAutoMembers_PList
571 do
572 table.insert(plist,{ Place=i; infos=tab; });
573 end
574  
575 return plist;
576 end
577  
578 function GEMNewAutoMembers_UpdatePList()
579 if(not GEMNewAutoMembersFrame:IsVisible()) then
580 return;
581 end
582 local list = GEMNewAutoMembers_GetPList();
583 local size = table.getn(list);
584  
585 local offset = FauxScrollFrame_GetOffset(GEMNewAutoMembersFramePItemScrollFrame);
586  
587 numButtons = MAXDISPLAY_AUTOMEMBERS;
588 i = 1;
589  
590 while (i <= numButtons) do
591 local j = i + offset
592 local prefix = "GEMNewAutoMembersFramePItem"..i;
593 local button = getglobal(prefix);
594  
595 if (j <= size) then
596 local infos = list[j].infos;
597 button.pl_name = infos.Name;
598 getglobal(prefix.."Place"):SetText("P"..list[j].Place);
599 getglobal(prefix.."Name"):SetText(infos.Name);
600 getglobal(prefix.."Guild"):SetText(infos.Guild);
601 getglobal(prefix.."Class"):SetText(GEM_Classes[infos.Class]);
602 getglobal(prefix.."Level"):SetText(infos.Level);
603 button:Show();
604  
605 -- selected
606 if (selectPItem == infos.Name) then
607 button:LockHighlight();
608 else
609 button:UnlockHighlight();
610 end
611 else
612 button.pl_name = nil;
613 button:Hide();
614 end
615  
616 i = i + 1;
617 end
618  
619 FauxScrollFrame_Update(GEMNewAutoMembersFramePItemScrollFrame, size, MAXDISPLAY_AUTOMEMBERS, 17);
620 end
621  
622 local function GEMNewAutoMembers_GetRList()
623 local plist = {};
624  
625 for i,tab in GEMNewAutoMembers_RList
626 do
627 table.insert(plist,{ Place=i; infos=tab; });
628 end
629  
630 return plist;
631 end
632  
633 function GEMNewAutoMembers_UpdateRList()
634 if(not GEMNewAutoMembersFrame:IsVisible()) then
635 return;
636 end
637 local list = GEMNewAutoMembers_GetRList();
638 local size = table.getn(list);
639  
640 local offset = FauxScrollFrame_GetOffset(GEMNewAutoMembersFrameRItemScrollFrame);
641  
642 numButtons = MAXDISPLAY_AUTOMEMBERS;
643 i = 1;
644  
645 while (i <= numButtons) do
646 local j = i + offset
647 local prefix = "GEMNewAutoMembersFrameRItem"..i;
648 local button = getglobal(prefix);
649  
650 if (j <= size) then
651 local infos = list[j].infos;
652 button.pl_name = infos.Name;
653 getglobal(prefix.."Place"):SetText("R"..list[j].Place);
654 getglobal(prefix.."Name"):SetText(infos.Name);
655 getglobal(prefix.."Guild"):SetText(infos.Guild);
656 getglobal(prefix.."Class"):SetText(GEM_Classes[infos.Class]);
657 getglobal(prefix.."Level"):SetText(infos.Level);
658 button:Show();
659  
660 -- selected
661 if (selectRItem == infos.Name) then
662 button:LockHighlight();
663 else
664 button:UnlockHighlight();
665 end
666 else
667 button.pl_name = nil;
668 button:Hide();
669 end
670  
671 i = i + 1;
672 end
673  
674 FauxScrollFrame_Update(GEMNewAutoMembersFrameRItemScrollFrame, size, MAXDISPLAY_AUTOMEMBERS, 17);
675 end
676  
677 function GEMNewAutoMembers_SortBy()
678 end
679  
680 function GEMNewAutoMembers_OnClick()
681 if(this:GetID() == 1)
682 then
683 selectPItem = this.pl_name;
684 GEMNewAutoMembers_UpdatePList();
685 elseif(this:GetID() == 2)
686 then
687 selectRItem = this.pl_name;
688 GEMNewAutoMembers_UpdateRList();
689 end
690 end
691  
692 function GEMNewAutoMembers_OnShow()
693 GEMNewAutoMembers_UpdatePList();
694 GEMNewAutoMembers_UpdateRList();
695 end
696  
697 function GEMNewAutoMembers_PInfosSet(infos)
698 table.insert(GEMNewAutoMembers_PList,{ Name=infos.name; Guild=infos.guild; Class=infos.class; Level=infos.level });
699 GEMNewAutoMembers_UpdatePList();
700 end
701  
702 function GEMNewAutoMembers_RInfosSet(infos)
703 table.insert(GEMNewAutoMembers_RList,{ Name=infos.name; Guild=infos.guild; Class=infos.class; Level=infos.level });
704 GEMNewAutoMembers_UpdateRList();
705 end
706  
707 function GEMNew_AutoMembers_OnClick()
708 if(GEMNewAutoMembersFrame:IsVisible())
709 then
710 GEMNewAutoMembersFrame:Hide();
711 else
712 -- Show the window
713 GEMNewAutoMembersFrame:Show();
714 end
715 end
716  
717 function GEMNew_CheckAutoMembers(ev_id)
718 local added = false;
719 local creat_time = time();
720  
721 for i,infos in GEMNewAutoMembers_PList
722 do
723 GEM_SUB_CreateSubscriber(ev_id,creat_time,infos.Name,infos.Class,infos.Guild,infos.Level,"",0,infos.ForceTit);
724 added = true;
725 end
726 for i,infos in GEMNewAutoMembers_RList
727 do
728 GEM_SUB_CreateSubscriber(ev_id,creat_time,infos.Name,infos.Class,infos.Guild,infos.Level,"",1,0);
729 added = true;
730 end
731 if(added)
732 then
733 GEM_NotifyGUI(GEM_NOTIFY_NEW_EVENT,ev_id);
734 end
735 end