vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Guild Event Manager by Kiki of European Cho'gall (Alliance) |
||
3 | Events list - By Alexandre Flament & Kiki |
||
4 | ]] |
||
5 | |||
6 | GEM_SORTBY_DATE = "date"; |
||
7 | GEM_SORTBY_WHERE = "where"; |
||
8 | GEM_SORTBY_LEADER = "leader"; |
||
9 | GEM_SORTBY_COUNT = "count"; |
||
10 | GEM_SORTBY_MINMAX = "minmax"; |
||
11 | |||
12 | local MAXDISPLAY_EVENT = 12; |
||
13 | local sortType = GEM_SORTBY_DATE; |
||
14 | local sortDir = true; |
||
15 | local UIEvents = nil; |
||
16 | local UIEventsRefresh = true; |
||
17 | local selectEvent = nil; |
||
18 | local GEMList_PreviousTab = 1; |
||
19 | |||
20 | GEM_Classes = {}; |
||
21 | GEM_Classes["WARRIOR"] = GEM_TEXT_CLASS_WARRIOR; |
||
22 | GEM_Classes["PALADIN"] = GEM_TEXT_CLASS_PALADIN; |
||
23 | GEM_Classes["SHAMAN"] = GEM_TEXT_CLASS_SHAMAN; |
||
24 | GEM_Classes["ROGUE"] = GEM_TEXT_CLASS_ROGUE; |
||
25 | GEM_Classes["MAGE"] = GEM_TEXT_CLASS_MAGE; |
||
26 | GEM_Classes["WARLOCK"] = GEM_TEXT_CLASS_WARLOCK; |
||
27 | GEM_Classes["HUNTER"] = GEM_TEXT_CLASS_HUNTER; |
||
28 | GEM_Classes["DRUID"] = GEM_TEXT_CLASS_DRUID; |
||
29 | GEM_Classes["PRIEST"] = GEM_TEXT_CLASS_PRIEST; |
||
30 | GEMList_CurrentGroupIDMustReset = false; |
||
31 | GEMList_CurrentGroupID = nil; |
||
32 | GEMList_CurrentGroupIsRaid = false; |
||
33 | GEMList_MustConvertToRaid = false; |
||
34 | GEM_NewEvents = {}; |
||
35 | |||
36 | function GEMList_GetCursorWidgetPosition() |
||
37 | local abs_x,abs_y = GetCursorPosition(); |
||
38 | local x = this:GetLeft(); |
||
39 | local y = this:GetTop(); |
||
40 | |||
41 | return abs_x-x,abs_y-y; |
||
42 | end |
||
43 | |||
44 | --[[ |
||
45 | Tabs handling function |
||
46 | ]] |
||
47 | function GEMList_SelectTab(tab) |
||
48 | PanelTemplates_SetTab(GEMListMiddleFrame, tab); |
||
49 | local TabFrames = { |
||
50 | [1] = "GEMListDetailsFrame", |
||
51 | [2] = "GEMListLimitationsFrame", |
||
52 | [3] = "GEMListAdminFrame" |
||
53 | }; |
||
54 | for id, name in TabFrames do |
||
55 | if (id == tab) then |
||
56 | getglobal(name):Show(); |
||
57 | else |
||
58 | getglobal(name):Hide(); |
||
59 | end |
||
60 | end |
||
61 | GEMList_PreviousTab = tab; |
||
62 | end |
||
63 | |||
64 | local function GEMList_Middle_ShowFrame() |
||
65 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
66 | |||
67 | if(event ~= nil) |
||
68 | then |
||
69 | --[[ if(GEM_IsMyReroll(event.leader)) |
||
70 | then |
||
71 | GEMListMiddleFrameTab3:Show(); |
||
72 | else |
||
73 | GEMListMiddleFrameTab3:Hide(); |
||
74 | if(GEMList_PreviousTab == 3) |
||
75 | then |
||
76 | GEMList_PreviousTab = 1; |
||
77 | end |
||
78 | end]] |
||
79 | PanelTemplates_SetNumTabs(GEMListMiddleFrame,3); |
||
80 | GEMList_SelectTab(GEMList_PreviousTab); |
||
81 | GEMListMiddleFrame:Show(); |
||
82 | else |
||
83 | GEMListMiddleFrame:Hide(); |
||
84 | end |
||
85 | end |
||
86 | |||
87 | |||
88 | --[[ |
||
89 | Details Tab functions |
||
90 | ]] |
||
91 | function GEMListDetails_OnShow() |
||
92 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
93 | if(event ~= nil) |
||
94 | then |
||
95 | GEMListDetailsFrame_Descr_Value:SetText(event.ev_comment); |
||
96 | local plugin = GEM_SUB_GetPlugin(event.sorttype); |
||
97 | if(plugin == nil) |
||
98 | then |
||
99 | GEMListDetailsFrame_SortType_Value:SetText(GEM_TEXT_DETAILS_UNKNOWN.." ("..event.sorttype..")"); |
||
100 | else |
||
101 | if(plugin.Help) |
||
102 | then |
||
103 | GEMListDetailsFrame_SortType_Value:SetText(plugin.Name.." : "..plugin.Help); |
||
104 | else |
||
105 | GEMListDetailsFrame_SortType_Value:SetText(plugin.Name); |
||
106 | end |
||
107 | end |
||
108 | end |
||
109 | end |
||
110 | |||
111 | |||
112 | --[[ |
||
113 | Limitations Tab functions |
||
114 | ]] |
||
115 | local function GEMListLimit_GetRangeValue(tab,name,range) |
||
116 | if(tab[name] == nil) |
||
117 | then |
||
118 | return -1; |
||
119 | end |
||
120 | if(tab[name][range] == nil) |
||
121 | then |
||
122 | return -1; |
||
123 | end |
||
124 | return tab[name][range]; |
||
125 | end |
||
126 | |||
127 | local function GEMListLimit_SetClassValues(name) |
||
128 | local wgt_name = "GEMListLimitItem_"..name; |
||
129 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
130 | if(event ~= nil) |
||
131 | then |
||
132 | local min,max,titular,substitute,replacement; |
||
133 | |||
134 | min = GEMListLimit_GetRangeValue(event.classes,name,"min"); |
||
135 | max = GEMListLimit_GetRangeValue(event.classes,name,"max"); |
||
136 | titular = GEMListLimit_GetRangeValue(event.classes,name,"tit_count"); |
||
137 | substitute = GEMListLimit_GetRangeValue(event.classes,name,"sub_count"); |
||
138 | replacement = GEMListLimit_GetRangeValue(event.classes,name,"repl_count"); |
||
139 | |||
140 | getglobal(wgt_name.."Class"):SetText(GEM_Classes[name]); |
||
141 | if(min == -1) |
||
142 | then |
||
143 | getglobal(wgt_name.."Min"):SetText("-"); |
||
144 | getglobal(wgt_name.."Min"):SetTextColor(1,1,1); |
||
145 | getglobal(wgt_name.."Titular"):SetTextColor(1,1,1); |
||
146 | else |
||
147 | getglobal(wgt_name.."Min"):SetText(min); |
||
148 | if(titular < min) |
||
149 | then |
||
150 | getglobal(wgt_name.."Min"):SetTextColor(1,0,0); |
||
151 | getglobal(wgt_name.."Titular"):SetTextColor(1,0,0); |
||
152 | else |
||
153 | getglobal(wgt_name.."Min"):SetTextColor(0,1,0); |
||
154 | getglobal(wgt_name.."Titular"):SetTextColor(0,1,0); |
||
155 | end |
||
156 | end |
||
157 | if(max == -1) |
||
158 | then |
||
159 | getglobal(wgt_name.."Max"):SetText("-"); |
||
160 | getglobal(wgt_name.."Max"):SetTextColor(1,1,1); |
||
161 | getglobal(wgt_name.."Substitute"):SetTextColor(1,1,1); |
||
162 | else |
||
163 | getglobal(wgt_name.."Max"):SetText(max); |
||
164 | if(substitute > 0) |
||
165 | then |
||
166 | getglobal(wgt_name.."Max"):SetTextColor(0.2,0.2,1); |
||
167 | getglobal(wgt_name.."Substitute"):SetTextColor(0.2,0.2,1); |
||
168 | else |
||
169 | getglobal(wgt_name.."Max"):SetTextColor(1,1,1); |
||
170 | getglobal(wgt_name.."Substitute"):SetTextColor(1,1,1); |
||
171 | end |
||
172 | end |
||
173 | if(titular == -1) |
||
174 | then |
||
175 | getglobal(wgt_name.."Titular"):SetText("n/a"); |
||
176 | else |
||
177 | getglobal(wgt_name.."Titular"):SetText(titular); |
||
178 | end |
||
179 | if(substitute == -1) |
||
180 | then |
||
181 | getglobal(wgt_name.."Substitute"):SetText("n/a"); |
||
182 | else |
||
183 | getglobal(wgt_name.."Substitute"):SetText(substitute); |
||
184 | end |
||
185 | getglobal(wgt_name.."Replacement"):SetText(replacement); |
||
186 | end |
||
187 | end |
||
188 | |||
189 | function GEMListLimitations_OnShow() |
||
190 | if(not GEMListLimitationsFrame:IsVisible()) then |
||
191 | return; |
||
192 | end |
||
193 | GEMListLimit_SetClassValues("WARRIOR"); |
||
194 | GEMListLimit_SetClassValues("PALADIN"); |
||
195 | GEMListLimit_SetClassValues("SHAMAN"); |
||
196 | GEMListLimit_SetClassValues("ROGUE"); |
||
197 | GEMListLimit_SetClassValues("MAGE"); |
||
198 | GEMListLimit_SetClassValues("WARLOCK"); |
||
199 | GEMListLimit_SetClassValues("HUNTER"); |
||
200 | GEMListLimit_SetClassValues("DRUID"); |
||
201 | GEMListLimit_SetClassValues("PRIEST"); |
||
202 | end |
||
203 | |||
204 | |||
205 | --[[ |
||
206 | Admin Tab functions |
||
207 | ]] |
||
208 | |||
209 | GEMADMIN_SORTBY_PLACE = "place"; |
||
210 | GEMADMIN_SORTBY_NAME = "name"; |
||
211 | GEMADMIN_SORTBY_GUILD = "guild"; |
||
212 | GEMADMIN_SORTBY_CLASS = "class"; |
||
213 | GEMADMIN_SORTBY_LEVEL = "level"; |
||
214 | |||
215 | local MAXDISPLAY_LIST = 10; |
||
216 | local sortTypeAdmin = GEMADMIN_SORTBY_PLACE; |
||
217 | local sortDirAdmin = true; |
||
218 | local UIList = nil; |
||
219 | local UIListAdminRefresh = true; |
||
220 | local selectAdminItem = nil; |
||
221 | |||
222 | function GEMListAdmin_EventOnClick(button) |
||
223 | selectAdminItem = this.pl_name; |
||
224 | GEMListAdmin_UpdatePlayersList(); |
||
225 | if(button == "RightButton") |
||
226 | then |
||
227 | ToggleDropDownMenu(1,nil,GEMListAdminMenu,"cursor"); |
||
228 | end |
||
229 | end |
||
230 | |||
231 | function GEMListAdmin_EventOnHover() |
||
232 | if (selectEvent ~= nil and GEM_Events.realms[GEM_Realm].events[selectEvent] ~= nil) then |
||
233 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
234 | local pl_name = getglobal(this:GetName().."Name"):GetText(); |
||
235 | if(pl_name and event.players[pl_name] ~= nil and event.players[pl_name].comment ~= nil and event.players[pl_name].comment ~= "") |
||
236 | then |
||
237 | GameTooltip:SetOwner(this, "ANCHOR_CURSOR"); |
||
238 | GameTooltip:ClearLines(); |
||
239 | local lines = 0; |
||
240 | lines = GEMList_AddTooltipText("|cff" .. "00AAFF" .. GEM_TEXT_ADMIN_COMMENT .. "|r",lines); |
||
241 | lines = GEMList_AddTooltipText("|cff" .. "FFFFFF" .. event.players[pl_name].comment .. "|r",lines,"FFFFFF"); |
||
242 | GameTooltip:Show(); |
||
243 | end |
||
244 | end |
||
245 | end |
||
246 | |||
247 | function GEMListAdmin_GetList() |
||
248 | if (UIListAdminRefresh) then |
||
249 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
250 | UIList = {}; |
||
251 | |||
252 | if(event ~= nil and event.closed_comment == nil) |
||
253 | then |
||
254 | GEM_CheckEventHasChannel(event); |
||
255 | local players = GEM_Players[GEM_Realm][event.channel]; |
||
256 | if(players == nil) then players = {}; end; |
||
257 | |||
258 | for pos,tab in event.titulars do |
||
259 | if(tab.guild == GEM_NA_FORMAT and players[tab.name]) then tab.guild = players[tab.name].guild; end; |
||
260 | tinsert(UIList, {place = "P"..pos; name = tab.name; guild=tab.guild; class=tab.class; level=tab.level}); |
||
261 | end |
||
262 | |||
263 | for pos,tab in event.substitutes do |
||
264 | if(tab.guild == GEM_NA_FORMAT and players[tab.name]) then tab.guild = players[tab.name].guild; end; |
||
265 | tinsert(UIList, {place = "S"..pos; name = tab.name; guild=tab.guild; class=tab.class; level=tab.level}); |
||
266 | end |
||
267 | |||
268 | for pos,tab in event.replacements do |
||
269 | if(tab.guild == GEM_NA_FORMAT and players[tab.name]) then tab.guild = players[tab.name].guild; end; |
||
270 | tinsert(UIList, {place = "R"..pos; name = tab.name; guild=tab.guild; class=tab.class; level=tab.level}); |
||
271 | end |
||
272 | |||
273 | -- If leader is not online, add speculative list |
||
274 | if(not GEM_IsPlayerConnected(event.channel,event.leader) and GEM_Events.realms[GEM_Realm].commands[selectEvent]) |
||
275 | then |
||
276 | for cmdid,cmdtab in GEM_Events.realms[GEM_Realm].commands[selectEvent].cmds |
||
277 | do |
||
278 | if(cmdtab.cmd == GEM_CMD_CMD_SUBSCRIBE and cmdtab.acked == 0) -- A subscribe not acked ? |
||
279 | then |
||
280 | tinsert(UIList, {place = "NA"; name = cmdtab.params[5]; guild=cmdtab.params[7]; class=cmdtab.params[6]; level=tonumber(cmdtab.params[8],10); stamp=cmdtab.stamp}); |
||
281 | end |
||
282 | end |
||
283 | end |
||
284 | |||
285 | table.sort(UIList, GEMListAdmin_Predicate); |
||
286 | if(not sortDirAdmin) |
||
287 | then |
||
288 | UIList = GEMList_InvertList(UIList); |
||
289 | end |
||
290 | end |
||
291 | UIListAdminRefresh = false; |
||
292 | end |
||
293 | |||
294 | return UIList; |
||
295 | end |
||
296 | |||
297 | function GEMListAdmin_UpdatePlayersList() |
||
298 | if(not GEMListAdminFrame:IsVisible()) then |
||
299 | return; |
||
300 | end |
||
301 | local list = GEMListAdmin_GetList(); |
||
302 | local size = table.getn(list); |
||
303 | |||
304 | local offset = FauxScrollFrame_GetOffset(GEMListAdminItemScrollFrame); |
||
305 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
306 | local iamassistant = false; |
||
307 | if(event == nil) |
||
308 | then |
||
309 | UIEventsRefresh = true; |
||
310 | GEMList_UpdateEventList(); |
||
311 | return; |
||
312 | end |
||
313 | numButtons = MAXDISPLAY_LIST; |
||
314 | i = 1; |
||
315 | |||
316 | if(GEM_IsMyReroll(event.leader) and GEM_IsChannelJoined(event.channel)) -- If I'm leader of this event AND my toon has joined the channel |
||
317 | then |
||
318 | GEMListAdminFrameClose:Enable(); |
||
319 | GEMListAdminFrameEdit:Enable(); |
||
320 | GEMListAdminFrameGroup:Enable(); |
||
321 | GEMListAdminFrameAddExt:Enable(); |
||
322 | GEMListAdminFrameIgnore:Disable(); |
||
323 | GEMListAdminFrameBanned:Enable(); |
||
324 | iamassistant = true; |
||
325 | else |
||
326 | GEMListAdminFrameClose:Disable(); |
||
327 | GEMListAdminFrameEdit:Disable(); |
||
328 | GEMListAdminFrameAddExt:Disable(); |
||
329 | if(not GEM_IsMyReroll(event.leader)) |
||
330 | then |
||
331 | GEMListAdminFrameIgnore:Enable(); |
||
332 | end |
||
333 | GEMListAdminFrameBanned:Disable(); |
||
334 | if(GEM_Events.realms[GEM_Realm].assistant[event.id] and GEM_IsChannelJoined(event.channel)) -- If I'm assistant AND my toon has joined the channel |
||
335 | then |
||
336 | GEMListAdminFrameGroup:Enable(); |
||
337 | iamassistant = true; |
||
338 | else |
||
339 | GEMListAdminFrameGroup:Disable(); |
||
340 | end |
||
341 | end |
||
342 | while (i <= numButtons) do |
||
343 | local j = i + offset |
||
344 | local prefix = "GEMListAdminItem"..i; |
||
345 | local button = getglobal(prefix); |
||
346 | |||
347 | if (j <= size) then |
||
348 | button.pl_name = list[j].name; |
||
349 | if((GEM_IsMyReroll(list[j].name) and iamassistant) or -- Myself and I'm assistant (assistant is set if I'm the leader) |
||
350 | (list[j].name == event.leader) or -- This is the leader |
||
351 | (GEM_IsMyReroll(event.leader) and event.assistants ~= nil and event.assistants[list[j].name])) -- I'm the leader, and there is an assistants list, and this subscriber is assistant |
||
352 | then |
||
353 | getglobal(prefix.."Place"):SetTextColor(0,1,0); |
||
354 | else |
||
355 | getglobal(prefix.."Place"):SetTextColor(1,1,1); |
||
356 | end |
||
357 | getglobal(prefix.."Place"):SetText(list[j].place); |
||
358 | if(GEM_IsPlayerConnected(event.channel,list[j].name)) |
||
359 | then |
||
360 | if(GEM_IsMyReroll(list[j].name) or GEM_IsPlayerInGroup(list[j].name)) |
||
361 | then |
||
362 | getglobal(prefix.."Name"):SetTextColor(0,1,0); -- Green |
||
363 | else |
||
364 | getglobal(prefix.."Name"):SetTextColor(0.4,0.4,1); -- blue |
||
365 | end |
||
366 | else |
||
367 | getglobal(prefix.."Name"):SetTextColor(1,1,1); -- White |
||
368 | end |
||
369 | getglobal(prefix.."Name"):SetText(list[j].name); |
||
370 | getglobal(prefix.."Guild"):SetText(list[j].guild); |
||
371 | getglobal(prefix.."Class"):SetText(GEM_Classes[list[j].class]); |
||
372 | getglobal(prefix.."Level"):SetText(list[j].level); |
||
373 | button:Show(); |
||
374 | |||
375 | -- selected |
||
376 | if (GEM_IsMyReroll(event.leader) and selectAdminItem == list[j].name and not GEM_IsMyReroll(list[j].name)) then |
||
377 | button:LockHighlight(); |
||
378 | else |
||
379 | button:UnlockHighlight(); |
||
380 | end |
||
381 | else |
||
382 | button.pl_name = nil; |
||
383 | button:Hide(); |
||
384 | end |
||
385 | |||
386 | i = i + 1; |
||
387 | end |
||
388 | |||
389 | FauxScrollFrame_Update(GEMListAdminItemScrollFrame, size, MAXDISPLAY_LIST, 17); |
||
390 | |||
391 | end |
||
392 | |||
393 | _GEMList_PlaceConvert = {}; |
||
394 | _GEMList_PlaceConvert["P"] = 100; |
||
395 | _GEMList_PlaceConvert["S"] = 200; |
||
396 | _GEMList_PlaceConvert["R"] = 300; |
||
397 | _GEMList_PlaceConvert["NA"] = 400; |
||
398 | |||
399 | function GEMListAdmin_PredicatePlace(a, b) |
||
400 | local _,_,type1,num1 = string.find(a.place,"([^%d]+)(%d*)"); |
||
401 | local _,_,type2,num2 = string.find(b.place,"([^%d]+)(%d*)"); |
||
402 | |||
403 | if(type1 == nil or type2 == nil) |
||
404 | then |
||
405 | if (a.place < b.place) then |
||
406 | return true; |
||
407 | elseif (a.place > b.place) then |
||
408 | return false; |
||
409 | end |
||
410 | else |
||
411 | if(num1 == "") then num1 = a.stamp; end; |
||
412 | if(num2 == "") then num2 = b.stamp; end; |
||
413 | local v1 = _GEMList_PlaceConvert[type1] + tonumber(num1,10); |
||
414 | local v2 = _GEMList_PlaceConvert[type2] + tonumber(num2,10); |
||
415 | if(v1 < v2) then |
||
416 | return true; |
||
417 | elseif(v1 > v2) then |
||
418 | return false; |
||
419 | end |
||
420 | end |
||
421 | |||
422 | return GEMListAdmin_PredicateName(a, b); |
||
423 | end |
||
424 | |||
425 | function GEMListAdmin_PredicateName(a, b) |
||
426 | if (a.name < b.name) then |
||
427 | return true; |
||
428 | elseif (a.name > b.name) then |
||
429 | return false; |
||
430 | end |
||
431 | |||
432 | return GEMListAdmin_PredicateGuild(a, b); |
||
433 | end |
||
434 | |||
435 | function GEMListAdmin_PredicateGuild(a, b) |
||
436 | if (a.guild == nil or b.guild == nil) then |
||
437 | if(a.guild == nil and b.guild == nil) then |
||
438 | return GEMListAdmin_PredicateClass(a, b); |
||
439 | elseif(a.guild == nil) then |
||
440 | return false; |
||
441 | else |
||
442 | return true; |
||
443 | end |
||
444 | end |
||
445 | if (a.guild < b.guild) then |
||
446 | return true; |
||
447 | elseif (a.guild > b.guild) then |
||
448 | return false; |
||
449 | end |
||
450 | |||
451 | return GEMListAdmin_PredicateClass(a, b); |
||
452 | end |
||
453 | |||
454 | function GEMListAdmin_PredicateClass(a, b) |
||
455 | if (a.class < b.class) then |
||
456 | return true; |
||
457 | elseif (a.class > b.class) then |
||
458 | return false; |
||
459 | end |
||
460 | |||
461 | return GEMListAdmin_PredicateLevel(a, b); |
||
462 | end |
||
463 | |||
464 | function GEMListAdmin_PredicateLevel(a, b) |
||
465 | if (a.level < b.level) then |
||
466 | return true; |
||
467 | elseif (a.level > b.level) then |
||
468 | return false; |
||
469 | end |
||
470 | |||
471 | return false; |
||
472 | end |
||
473 | |||
474 | function GEMListAdmin_Predicate(a, b) |
||
475 | -- a ou b est nil |
||
476 | if (a == nil) then |
||
477 | if (b == nil) then |
||
478 | return false; |
||
479 | else |
||
480 | return true; |
||
481 | end |
||
482 | elseif (b == nil) then |
||
483 | return false; |
||
484 | end |
||
485 | |||
486 | GEMADMIN_SORTBY = { |
||
487 | [GEMADMIN_SORTBY_PLACE] = GEMListAdmin_PredicatePlace, |
||
488 | [GEMADMIN_SORTBY_NAME] = GEMListAdmin_PredicateName, |
||
489 | [GEMADMIN_SORTBY_GUILD] = GEMListAdmin_PredicateGuild, |
||
490 | [GEMADMIN_SORTBY_CLASS] = GEMListAdmin_PredicateClass, |
||
491 | [GEMADMIN_SORTBY_LEVEL] = GEMListAdmin_PredicateLevel |
||
492 | }; |
||
493 | |||
494 | predicate = GEMADMIN_SORTBY[sortTypeAdmin]; |
||
495 | return predicate(a,b); |
||
496 | end |
||
497 | |||
498 | function GEMListAdmin_SortBy(aSortType, aSortDir) |
||
499 | sortTypeAdmin = aSortType; |
||
500 | sortDirAdmin = aSortDir; |
||
501 | UIListAdminRefresh = true; |
||
502 | GEMListAdmin_UpdatePlayersList(); |
||
503 | end |
||
504 | |||
505 | function GEMListAdmin_OnShow() |
||
506 | UIListAdminRefresh = true; |
||
507 | GEMListAdmin_UpdatePlayersList(); |
||
508 | end |
||
509 | |||
510 | StaticPopupDialogs["GEM_CONFIRM_CLOSE"] = { |
||
511 | text = TEXT(GEM_TEXT_ADMIN_CLOSE_CONFIRM), |
||
512 | button1 = TEXT(OKAY), |
||
513 | button2 = TEXT(CANCEL), |
||
514 | hasEditBox = 1, |
||
515 | maxLetters = 100, |
||
516 | OnAccept = function() |
||
517 | local text = getglobal(this:GetParent():GetName().."EditBox"):GetText(); |
||
518 | GEM_EVT_CloseEvent(this:GetParent().data,text); |
||
519 | end, |
||
520 | EditBoxOnEnterPressed = function() |
||
521 | local text = getglobal(this:GetParent():GetName().."EditBox"):GetText(); |
||
522 | GEM_EVT_CloseEvent(this:GetParent().data,text); |
||
523 | end, |
||
524 | OnShow = function() |
||
525 | getglobal(this:GetName().."EditBox"):SetFocus(); |
||
526 | end, |
||
527 | OnHide = function() |
||
528 | if ( ChatFrameEditBox:IsVisible() ) then |
||
529 | ChatFrameEditBox:SetFocus(); |
||
530 | end |
||
531 | getglobal(this:GetName().."EditBox"):SetText(""); |
||
532 | end, |
||
533 | timeout = 0, |
||
534 | exclusive = 1 |
||
535 | }; |
||
536 | |||
537 | function GEMListAdmin_CloseOnClick() |
||
538 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
539 | if(event ~= nil) |
||
540 | then |
||
541 | local dialogFrame = StaticPopup_Show("GEM_CONFIRM_CLOSE"); |
||
542 | if(dialogFrame) |
||
543 | then |
||
544 | dialogFrame.data = event.id; |
||
545 | end |
||
546 | end |
||
547 | end |
||
548 | |||
549 | function GEMListAdmin_EditOnClick() |
||
550 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
551 | if(event ~= nil) |
||
552 | then |
||
553 | GEMNew_Create:SetText(GEM_TEXT_MODIFY); |
||
554 | GEMNew_AutoMembers:Disable(); |
||
555 | if(GEMNewAutoMembersFrame:IsVisible()) |
||
556 | then |
||
557 | GEMNewAutoMembersFrame:Hide(); |
||
558 | end |
||
559 | GEMMain_SelectTab(2); |
||
560 | GEMNew_LoadEvent(event); |
||
561 | end |
||
562 | end |
||
563 | |||
564 | function GEMListAdmin_External_Set(infos, user_data) |
||
565 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
566 | if(event ~= nil) |
||
567 | then |
||
568 | if(infos.level < event.min_lvl or infos.level > event.max_lvl) |
||
569 | then |
||
570 | GEM_ChatPrint(GEM_TEXT_EXTERNAL_ERR_LEVEL); |
||
571 | return; |
||
572 | end |
||
573 | GEM_SUB_CreateSubscriber(event.id,time(),infos.name,infos.class,infos.guild,infos.level,infos.comment,infos.forcesub,infos.forcetit); |
||
574 | end |
||
575 | end |
||
576 | |||
577 | function GEM_IsPlayerInGroup(pl_name) |
||
578 | if(GEMList_CurrentGroupIsRaid) |
||
579 | then |
||
580 | for i = 1, 40 do |
||
581 | local name = GetRaidRosterInfo(i); |
||
582 | if(name and name == pl_name) |
||
583 | then |
||
584 | return true; |
||
585 | end |
||
586 | end |
||
587 | else |
||
588 | for i = 1,4 do |
||
589 | local name = UnitName("party"..i); |
||
590 | if(name and name == pl_name) |
||
591 | then |
||
592 | return true; |
||
593 | end |
||
594 | end |
||
595 | end |
||
596 | return false; |
||
597 | end |
||
598 | |||
599 | function GEMListAdmin_GroupOnClick() |
||
600 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
601 | if(event ~= nil) |
||
602 | then |
||
603 | if(GEMList_CurrentGroupIDMustReset) |
||
604 | then |
||
605 | GEMList_CurrentGroupIDMustReset = false; |
||
606 | GEMList_CurrentGroupID = nil; |
||
607 | GEMList_CurrentGroupIsRaid = false; |
||
608 | GEMList_MustConvertToRaid = false; |
||
609 | end |
||
610 | if(GEMList_CurrentGroupID ~= nil) -- Check current group and raid |
||
611 | then |
||
612 | if(GEMList_CurrentGroupID ~= event.id) |
||
613 | then |
||
614 | GEM_ChatPrint(GEM_TEXT_ADMIN_ERR_LEAVE_GROUP); |
||
615 | return; |
||
616 | end |
||
617 | else -- Check if already grouped |
||
618 | GEMList_CurrentGroupID = event.id; |
||
619 | if(GetNumPartyMembers() ~= 0 or UnitInRaid("player")) |
||
620 | then |
||
621 | GEM_ChatPrint(GEM_TEXT_ADMIN_ERR_ALREADY_GROUP); |
||
622 | if(GetNumRaidMembers() ~= 0) |
||
623 | then |
||
624 | GEMList_CurrentGroupIsRaid = true; |
||
625 | GEM_ChatDebug(GEM_DEBUG_GLOBAL,"I'm in a raid !"); |
||
626 | end |
||
627 | end |
||
628 | end |
||
629 | -- Ok let's group titulars |
||
630 | for i,tab in event.titulars |
||
631 | do |
||
632 | if(GEMList_MustConvertToRaid == true) |
||
633 | then |
||
634 | ConvertToRaid(); |
||
635 | GEMList_CurrentGroupIsRaid = true; |
||
636 | GEM_ChatDebug(GEM_DEBUG_GLOBAL,"Converted to raid !"); |
||
637 | GEMList_MustConvertToRaid = false; |
||
638 | end |
||
639 | GEM_ChatDebug(GEM_DEBUG_GLOBAL,"Group : Checking "..tab.name); |
||
640 | if(tab.name ~= GEM_PlayerName and not GEM_IsPlayerInGroup(tab.name)) |
||
641 | then |
||
642 | GEM_ChatDebug(GEM_DEBUG_GLOBAL,"Group : "..tab.name.." not in group, inviting"); |
||
643 | InviteByName(tab.name); |
||
644 | end |
||
645 | end |
||
646 | end |
||
647 | end |
||
648 | |||
649 | function GEMListAdmin_AddExtOnClick() |
||
650 | GEMExternal_Choose(GEMListAdmin_External_Set,GEM_TEXT_EXTERNAL_HEADER,{true,true}); |
||
651 | end |
||
652 | |||
653 | StaticPopupDialogs["GEM_CONFIRM_IGNORE"] = { |
||
654 | text = TEXT(GEM_TEXT_ADMIN_IGNORE_CONFIRM), |
||
655 | button1 = TEXT(OKAY), |
||
656 | button2 = TEXT(CANCEL), |
||
657 | OnAccept = function() |
||
658 | local event = GEM_Events.realms[GEM_Realm].events[this:GetParent().data.ev_id]; |
||
659 | if(event ~= nil) |
||
660 | then |
||
661 | GEM_Events.realms[GEM_Realm].ignore[event.id] = 1; |
||
662 | GEM_EVT_ClearEvent(event.id,"Ignored",true); |
||
663 | GEM_NotifyGUI(GEM_NOTIFY_EVENT_UPDATE,event.id); |
||
664 | end |
||
665 | end, |
||
666 | timeout = 0 |
||
667 | }; |
||
668 | |||
669 | function GEMListAdmin_IgnoreOnClick() |
||
670 | if (selectEvent and not GEM_EVT_CheckExpiredEvent(selectEvent)) then |
||
671 | local dialogFrame = StaticPopup_Show("GEM_CONFIRM_IGNORE"); |
||
672 | if(dialogFrame) |
||
673 | then |
||
674 | dialogFrame.data = { ev_id=selectEvent }; |
||
675 | end |
||
676 | end |
||
677 | end |
||
678 | |||
679 | function GEMListAdmin_BannedOnClick() |
||
680 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
681 | if(GEMListBannedFrame:IsVisible() or event == nil) |
||
682 | then |
||
683 | return; |
||
684 | end |
||
685 | GEMListBannedFrame.Event = selectEvent; |
||
686 | GEMListBannedFrame:Show(); |
||
687 | end |
||
688 | |||
689 | |||
690 | function GEMListAdminMenu_OnLoad() |
||
691 | HideDropDownMenu(1); |
||
692 | GEMListAdminMenu.initialize = GEMListAdminMenu_Initialize; |
||
693 | GEMListAdminMenu.displayMode = "MENU"; |
||
694 | GEMListAdminMenu.name = "Titre"; |
||
695 | end |
||
696 | |||
697 | function GEMListAdminMenu_Initialize() |
||
698 | info = { }; |
||
699 | info.text = selectAdminItem; |
||
700 | info.isTitle = true; |
||
701 | info.notCheckable = 1; |
||
702 | UIDropDownMenu_AddButton(info,1); |
||
703 | |||
704 | info = { }; |
||
705 | info.text = WHISPER_MESSAGE; |
||
706 | info.notCheckable = 1; |
||
707 | info.value = selectAdminItem; |
||
708 | info.func = GEMListAdminMenu_Whisper_OnClick; |
||
709 | if(GEM_IsMyReroll(selectAdminItem)) |
||
710 | then |
||
711 | info.disabled = 1; |
||
712 | end |
||
713 | UIDropDownMenu_AddButton(info,1); |
||
714 | |||
715 | info = { }; |
||
716 | info.text = GROUP_INVITE; |
||
717 | info.notCheckable = 1; |
||
718 | info.value = selectAdminItem; |
||
719 | info.func = GEMListAdminMenu_GroupInvite_OnClick; |
||
720 | if(GEM_IsMyReroll(selectAdminItem) or GEM_IsPlayerInGroup(selectAdminItem)) |
||
721 | then |
||
722 | info.disabled = 1; |
||
723 | end |
||
724 | UIDropDownMenu_AddButton(info,1); |
||
725 | |||
726 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
727 | if(event ~= nil and selectAdminItem ~= nil and selectAdminItem ~= "" and GEM_IsMyReroll(event.leader)) |
||
728 | then |
||
729 | info = { }; |
||
730 | info.text = GEM_TEXT_ADMIN_ASSISTANT; |
||
731 | info.notCheckable = 1; |
||
732 | info.value = selectAdminItem; |
||
733 | info.func = GEMListAdminMenu_Assistant_OnClick; |
||
734 | if(event.assistants == nil or event.assistants[selectAdminItem] or GEM_IsMyReroll(selectAdminItem)) |
||
735 | then |
||
736 | info.disabled = 1; |
||
737 | end |
||
738 | UIDropDownMenu_AddButton(info,1); |
||
739 | |||
740 | info = { }; |
||
741 | info.text = GEM_TEXT_ADMIN_KICK; |
||
742 | info.notCheckable = 1; |
||
743 | info.value = selectAdminItem; |
||
744 | info.disabled = GEM_IsMyReroll(selectAdminItem); |
||
745 | info.func = GEMListAdminMenu_Kick_OnClick; |
||
746 | UIDropDownMenu_AddButton(info,1); |
||
747 | |||
748 | info = { }; |
||
749 | info.text = GEM_TEXT_ADMIN_BAN; |
||
750 | info.notCheckable = 1; |
||
751 | info.value = selectAdminItem; |
||
752 | info.disabled = GEM_IsMyReroll(selectAdminItem); |
||
753 | info.func = GEMListAdminMenu_Ban_OnClick; |
||
754 | UIDropDownMenu_AddButton(info,1); |
||
755 | |||
756 | info = { }; |
||
757 | info.text = GEM_TEXT_FORCETIT; |
||
758 | info.value = selectAdminItem; |
||
759 | info.func = GEMListAdminMenu_Forcetit_OnClick; |
||
760 | info.checked = event.players[selectAdminItem].forcetit == 1; |
||
761 | UIDropDownMenu_AddButton(info,1); |
||
762 | |||
763 | info = { }; |
||
764 | info.text = GEM_TEXT_FORCESUB; |
||
765 | info.value = selectAdminItem; |
||
766 | info.func = GEMListAdminMenu_Forcesub_OnClick; |
||
767 | info.checked = event.players[selectAdminItem].forcesub == 1; |
||
768 | UIDropDownMenu_AddButton(info,1); |
||
769 | |||
770 | info = { }; |
||
771 | info.text = GEM_TEXT_SETLEADER; |
||
772 | info.notCheckable = 1; |
||
773 | info.value = selectAdminItem; |
||
774 | info.disabled = GEM_IsMyReroll(selectAdminItem); |
||
775 | info.func = GEMListAdminMenu_SetLeader_OnClick; |
||
776 | UIDropDownMenu_AddButton(info,1); |
||
777 | |||
778 | end |
||
779 | |||
780 | info = { }; |
||
781 | info.text = CANCEL; |
||
782 | info.notCheckable = 1; |
||
783 | info.func = GEMListAdminMenu_Cancel_OnClick; |
||
784 | UIDropDownMenu_AddButton(info,1); |
||
785 | end |
||
786 | |||
787 | function GEMListAdminMenu_Cancel_OnClick() |
||
788 | HideDropDownMenu(1); |
||
789 | end |
||
790 | |||
791 | function GEMListAdminMenu_Whisper_OnClick() |
||
792 | local pl_name = this.value; |
||
793 | if(pl_name) |
||
794 | then |
||
795 | if(not ChatFrameEditBox:IsVisible()) |
||
796 | then |
||
797 | ChatFrame_OpenChat("/w "..pl_name.." "); |
||
798 | else |
||
799 | ChatFrameEditBox:SetText("/w "..pl_name.." "); |
||
800 | end |
||
801 | ChatEdit_ParseText(ChatFrame1.editBox,0); |
||
802 | end |
||
803 | end |
||
804 | |||
805 | function GEMListAdminMenu_GroupInvite_OnClick() |
||
806 | local pl_name = this.value; |
||
807 | if(pl_name) |
||
808 | then |
||
809 | InviteByName(pl_name); |
||
810 | end |
||
811 | end |
||
812 | |||
813 | StaticPopupDialogs["GEM_KICK_DIALOG"] = { |
||
814 | text = TEXT(GEM_TEXT_ADMIN_KICK), |
||
815 | button1 = TEXT(ACCEPT), |
||
816 | button2 = TEXT(CANCEL), |
||
817 | hasEditBox = 1, |
||
818 | maxLetters = 100, |
||
819 | OnAccept = function() |
||
820 | local text = getglobal(this:GetParent():GetName().."EditBox"):GetText(); |
||
821 | GEM_COM_KickPlayer(this:GetParent().data.ev_id,this:GetParent().data.pl_name,text); |
||
822 | end, |
||
823 | EditBoxOnEnterPressed = function() |
||
824 | local text = getglobal(this:GetParent():GetName().."EditBox"):GetText(); |
||
825 | GEM_COM_KickPlayer(this:GetParent().data.ev_id,this:GetParent().data.pl_name,text); |
||
826 | end, |
||
827 | OnShow = function() |
||
828 | getglobal(this:GetName().."EditBox"):SetFocus(); |
||
829 | end, |
||
830 | OnHide = function() |
||
831 | if ( ChatFrameEditBox:IsVisible() ) then |
||
832 | ChatFrameEditBox:SetFocus(); |
||
833 | end |
||
834 | getglobal(this:GetName().."EditBox"):SetText(""); |
||
835 | end, |
||
836 | timeout = 0, |
||
837 | exclusive = 1 |
||
838 | }; |
||
839 | |||
840 | function GEMListAdminMenu_Assistant_OnClick() |
||
841 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
842 | if(event ~= nil and selectAdminItem ~= nil and selectAdminItem ~= "") |
||
843 | then |
||
844 | GEM_COM_AddAssistant(event.id,selectAdminItem); |
||
845 | GEM_NotifyGUI(GEM_NOTIFY_MY_SUBSCRIPTION,selectEvent); |
||
846 | end |
||
847 | end |
||
848 | |||
849 | function GEMListAdminMenu_Kick_OnClick() |
||
850 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
851 | if(event ~= nil and selectAdminItem ~= nil and selectAdminItem ~= "") |
||
852 | then |
||
853 | local dialogFrame = StaticPopup_Show("GEM_KICK_DIALOG"); |
||
854 | if(dialogFrame) |
||
855 | then |
||
856 | dialogFrame.data = { ev_id=event.id, pl_name=selectAdminItem }; |
||
857 | end |
||
858 | end |
||
859 | end |
||
860 | |||
861 | StaticPopupDialogs["GEM_BAN_DIALOG"] = { |
||
862 | text = TEXT(GEM_TEXT_ADMIN_BAN), |
||
863 | button1 = TEXT(ACCEPT), |
||
864 | button2 = TEXT(CANCEL), |
||
865 | hasEditBox = 1, |
||
866 | maxLetters = 100, |
||
867 | OnAccept = function() |
||
868 | local text = getglobal(this:GetParent():GetName().."EditBox"):GetText(); |
||
869 | GEM_COM_BanPlayer(this:GetParent().data.ev_id,this:GetParent().data.pl_name,text); |
||
870 | end, |
||
871 | EditBoxOnEnterPressed = function() |
||
872 | local text = getglobal(this:GetParent():GetName().."EditBox"):GetText(); |
||
873 | GEM_COM_BanPlayer(this:GetParent().data.ev_id,this:GetParent().data.pl_name,text); |
||
874 | end, |
||
875 | OnShow = function() |
||
876 | getglobal(this:GetName().."EditBox"):SetFocus(); |
||
877 | end, |
||
878 | OnHide = function() |
||
879 | if ( ChatFrameEditBox:IsVisible() ) then |
||
880 | ChatFrameEditBox:SetFocus(); |
||
881 | end |
||
882 | getglobal(this:GetName().."EditBox"):SetText(""); |
||
883 | end, |
||
884 | timeout = 0, |
||
885 | exclusive = 1 |
||
886 | }; |
||
887 | |||
888 | function GEMListAdminMenu_Ban_OnClick() |
||
889 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
890 | if(event ~= nil and selectAdminItem ~= nil and selectAdminItem ~= "") |
||
891 | then |
||
892 | local dialogFrame = StaticPopup_Show("GEM_BAN_DIALOG"); |
||
893 | if(dialogFrame) |
||
894 | then |
||
895 | dialogFrame.data = { ev_id=event.id, pl_name=selectAdminItem }; |
||
896 | end |
||
897 | end |
||
898 | end |
||
899 | |||
900 | function GEMListAdminMenu_Forcetit_OnClick() |
||
901 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
902 | if(event ~= nil and selectAdminItem ~= nil and selectAdminItem ~= "") |
||
903 | then |
||
904 | if(GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].forcesub == 1) -- Was in replacement |
||
905 | then |
||
906 | GEM_SUB_RemoveFromReplacementList(event.id,selectAdminItem,GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].class); |
||
907 | GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].forcesub = 0; |
||
908 | GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].forcetit = 1; |
||
909 | elseif(GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].forcetit == 1) -- Was forced titular |
||
910 | then |
||
911 | GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].forcetit = 0; |
||
912 | elseif(GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].forcetit == 0) -- Was not forced titular |
||
913 | then |
||
914 | GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].forcetit = 1; |
||
915 | end |
||
916 | GEM_SUB_SortPlayers(event.id); -- Sort players |
||
917 | GEM_NotifyGUI(GEM_NOTIFY_EVENT_UPDATE,event.id); -- Redraw |
||
918 | end |
||
919 | end |
||
920 | |||
921 | function GEMListAdminMenu_Forcesub_OnClick() |
||
922 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
923 | if(event ~= nil and selectAdminItem ~= nil and selectAdminItem ~= "") |
||
924 | then |
||
925 | GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].forcetit = 0; -- Clear forcetit status |
||
926 | if(GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].forcesub == 1) -- Was in replacement |
||
927 | then |
||
928 | GEM_SUB_RemoveFromReplacementList(event.id,selectAdminItem,GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].class); |
||
929 | GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].forcesub = 0; |
||
930 | else -- Move to replacement |
||
931 | GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].forcesub = 1; |
||
932 | GEM_SUB_AddToReplacementList(event.id,selectAdminItem,GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].guild,GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].class,GEM_Events.realms[GEM_Realm].events[event.id].players[selectAdminItem].level); |
||
933 | end |
||
934 | GEM_SUB_SortPlayers(event.id); -- Sort players |
||
935 | GEM_NotifyGUI(GEM_NOTIFY_EVENT_UPDATE,event.id); -- Redraw |
||
936 | end |
||
937 | end |
||
938 | |||
939 | StaticPopupDialogs["GEM_CONFIRM_SETLEADER"] = { |
||
940 | text = TEXT(GEM_TEXT_ADMIN_SETLEADER_CONFIRM), |
||
941 | button1 = TEXT(OKAY), |
||
942 | button2 = TEXT(CANCEL), |
||
943 | OnAccept = function() |
||
944 | GEM_COM_ChangeLeader(this:GetParent().data.ev_id,this:GetParent().data.pl_name); |
||
945 | end, |
||
946 | timeout = 0 |
||
947 | }; |
||
948 | |||
949 | function GEMListAdminMenu_SetLeader_OnClick() |
||
950 | local event = GEM_Events.realms[GEM_Realm].events[selectEvent]; |
||
951 | if(event ~= nil and selectAdminItem ~= nil and selectAdminItem ~= "") |
||
952 | then |
||
953 | local dialogFrame = StaticPopup_Show("GEM_CONFIRM_SETLEADER"); |
||
954 | if(dialogFrame) |
||
955 | then |
||
956 | dialogFrame.data = { ev_id=event.id, pl_name=selectAdminItem }; |
||
957 | end |
||
958 | end |
||
959 | end |
||
960 | |||
961 | |||
962 | --[[ |
||
963 | List Functions |
||
964 | ]] |
||
965 | |||
966 | function GEMList_InvertList(list) |
||
967 | local newlist = {}; |
||
968 | local count = table.getn(list); |
||
969 | for i=1,count |
||
970 | do |
||
971 | table.insert(newlist,list[count+1-i]); |
||
972 | end |
||
973 | return newlist; |
||
974 | end |
||
975 | |||
976 | function GEMSetColumnWidth( width, frame ) |
||
977 | if ( not frame ) then |
||
978 | frame = this; |
||
979 | end |
||
980 | frame:SetWidth(width); |
||
981 | getglobal(frame:GetName().."Middle"):SetWidth(width - 9); |
||
982 | end |
||
983 | |||
984 | function _GEMList_AddBanKickTooltip(event,lines) |
||
985 | if(GEM_Events.realms[GEM_Realm].banned[event.id] ~= nil) |
||
986 | then |
||
987 | return GEMList_AddTooltipText("|cff" .. "FF0000" .. GEM_TEXT_TOOLTIP_BANNED .. GEM_Events.realms[GEM_Realm].banned[event.id] .. "|r",lines,"FF0000"); |
||
988 | elseif(GEM_Events.realms[GEM_Realm].kicked[event.id] ~= nil) |
||
989 | then |
||
990 | return GEMList_AddTooltipText("|cff" .. "800000" .. GEM_TEXT_TOOLTIP_KICKED .. GEM_Events.realms[GEM_Realm].kicked[event.id] .. "|r",lines,"800000"); |
||
991 | end |
||
992 | return lines; |
||
993 | end |
||
994 | |||
995 | function _GEMList_AddClosedTooltip(event,lines) |
||
996 | if(GEM_Events.realms[GEM_Realm].events[event.id].closed_comment ~= nil) |
||
997 | then |
||
998 | return GEMList_AddTooltipText("|cff" .. "A0A0A0" .. GEM_TEXT_TOOLTIP_CLOSED .. GEM_Events.realms[GEM_Realm].events[event.id].closed_comment .. "|r",lines,"A0A0A0"); |
||
999 | end |
||
1000 | return lines; |
||
1001 | end |
||
1002 | |||
1003 | local function _GEMList_AddTooltipLine(text,lines) |
||
1004 | lines = lines + 1; |
||
1005 | local tooltip = getglobal("GameTooltipTextLeft"..lines); |
||
1006 | GameTooltip:AddLine("."); |
||
1007 | tooltip:SetText(text); |
||
1008 | return lines; |
||
1009 | end |
||
1010 | |||
1011 | function GEMList_AddTooltipText(text,lines,multi_line_color) |
||
1012 | local _GEM_MAX_TT_LINE_LENGTH = 100; |
||
1013 | local added = false; |
||
1014 | while(string.len(text) > _GEM_MAX_TT_LINE_LENGTH) |
||
1015 | do |
||
1016 | local add = 0; |
||
1017 | while(string.byte(text,_GEM_MAX_TT_LINE_LENGTH+add) and string.byte(text,_GEM_MAX_TT_LINE_LENGTH+add) ~= 32) |
||
1018 | do |
||
1019 | add = add + 1; |
||
1020 | end |
||
1021 | if(string.byte(text,_GEM_MAX_TT_LINE_LENGTH+add) == nil) -- Don't create new line if we reach eol |
||
1022 | then |
||
1023 | break; |
||
1024 | end |
||
1025 | local submsg = string.sub(text,1,_GEM_MAX_TT_LINE_LENGTH+add); |
||
1026 | if(added and multi_line_color) |
||
1027 | then |
||
1028 | submsg = "|cff"..multi_line_color..submsg; |
||
1029 | end |
||
1030 | lines = _GEMList_AddTooltipLine(submsg,lines); |
||
1031 | added = true; |
||
1032 | text = string.sub(text,_GEM_MAX_TT_LINE_LENGTH+add+1); |
||
1033 | end |
||
1034 | if(added and multi_line_color) |
||
1035 | then |
||
1036 | text = "|cff"..multi_line_color..text; |
||
1037 | end |
||
1038 | lines = _GEMList_AddTooltipLine(text,lines); |
||
1039 | |||
1040 | return lines; |
||
1041 | end |
||
1042 | |||
1043 | function GEMList_EventOnHover() |
||
1044 | local ev_id = this.eventid; |
||
1045 | if (ev_id ~= nil and GEM_Events.realms[GEM_Realm].events[ev_id] ~= nil) then |
||
1046 | local event = GEM_Events.realms[GEM_Realm].events[ev_id]; |
||
1047 | GameTooltip:SetOwner(this, "ANCHOR_CURSOR"); |
||
1048 | GameTooltip:ClearLines(); |
||
1049 | local color = "E0C010"; |
||
1050 | local color1 = "00AAFF"; |
||
1051 | local color2 = "E0C010"; |
||
1052 | local color3 = "FFFFFF"; |
||
1053 | if(event.closed_comment) |
||
1054 | then |
||
1055 | color = "706005"; |
||
1056 | color1 = "005588"; |
||
1057 | color2 = "706005"; |
||
1058 | color3 = "888888"; |
||
1059 | end |
||
1060 | local lines = 0; |
||
1061 | |||
1062 | local alias = event.channel; |
||
1063 | if(GEM_COM_Channels[event.channel] and GEM_COM_Channels[event.channel].alias and GEM_COM_Channels[event.channel].alias ~= "") |
||
1064 | then |
||
1065 | alias = GEM_COM_Channels[event.channel].alias; |
||
1066 | end |
||
1067 | lines = GEMList_AddTooltipText("|cff" .. color1 .. event.ev_place .. " |cff"..color3.."(" .. string.format(GEM_TEXT_EVT_CHANNEL,alias) .. ")|r",lines,color3); |
||
1068 | lines = GEMList_AddTooltipText("|cff" .. color2 .. event.leader .. "|r (" .. GEM_ConvertDateFormat(date(GEM_Events.DateFormat,event.ev_date + GEM_ComputeHourOffset()))..")",lines); |
||
1069 | if(event.ev_comment ~= "") |
||
1070 | then |
||
1071 | lines = GEMList_AddTooltipText("|cff" .. color3 .. GEM_TEXT_COMMENT .. " : "..event.ev_comment.."|r",lines,color3); |
||
1072 | end |
||
1073 | lines = _GEMList_AddBanKickTooltip(event,lines); |
||
1074 | lines = _GEMList_AddClosedTooltip(event,lines); |
||
1075 | GameTooltip:Show(); |
||
1076 | end |
||
1077 | end |
||
1078 | |||
1079 | function GEMList_EventOnClick() |
||
1080 | selectEvent = this.eventid; |
||
1081 | GEMList_UpdateEventList(); |
||
1082 | if(GEMList_PreviousTab == 1) -- Details |
||
1083 | then |
||
1084 | GEMListDetails_OnShow(); |
||
1085 | elseif(GEMList_PreviousTab == 2) -- Limits |
||
1086 | then |
||
1087 | GEMListLimitations_OnShow(); |
||
1088 | elseif(GEMList_PreviousTab == 3) -- Admin |
||
1089 | then |
||
1090 | UIListAdminRefresh = true; |
||
1091 | GEMListAdmin_UpdatePlayersList() |
||
1092 | end |
||
1093 | end |
||
1094 | |||
1095 | function GEMList_PredicateDate(a, b) |
||
1096 | if (a.event.ev_date < b.event.ev_date) then |
||
1097 | return true; |
||
1098 | elseif (a.event.ev_date > b.event.ev_date) then |
||
1099 | return false; |
||
1100 | end |
||
1101 | |||
1102 | return GEMList_PredicateWhere(a, b); |
||
1103 | end |
||
1104 | |||
1105 | function GEMList_PredicateWhere(a, b) |
||
1106 | if (a.event.ev_place < b.event.ev_place) then |
||
1107 | return true; |
||
1108 | elseif (a.event.ev_place > b.event.ev_place) then |
||
1109 | return false; |
||
1110 | end |
||
1111 | |||
1112 | return GEMList_PredicateLeader(a, b); |
||
1113 | end |
||
1114 | |||
1115 | function GEMList_PredicateLeader(a, b) |
||
1116 | if (a.event.leader < b.event.leader) then |
||
1117 | return true; |
||
1118 | elseif (a.event.leader > b.event.leader) then |
||
1119 | return false; |
||
1120 | end |
||
1121 | |||
1122 | return GEMList_PredicateCount(a, b); |
||
1123 | end |
||
1124 | |||
1125 | function GEMList_PredicateCount(a, b) |
||
1126 | if (a.event.titular_count < b.event.titular_count) then |
||
1127 | return true; |
||
1128 | elseif (a.event.titular_count > b.event.titular_count) then |
||
1129 | return false; |
||
1130 | end |
||
1131 | |||
1132 | return GEMList_PredicateMinMax(a, b); |
||
1133 | end |
||
1134 | |||
1135 | function GEMList_PredicateMinMax(a, b) |
||
1136 | if (a.event.max_lvl < b.event.max_lvl) then |
||
1137 | return true; |
||
1138 | elseif (a.event.max_lvl > b.event.max_lvl) then |
||
1139 | return false; |
||
1140 | end |
||
1141 | |||
1142 | return false; |
||
1143 | end |
||
1144 | |||
1145 | function GEMList_Predicate(a, b) |
||
1146 | -- a ou b est nil |
||
1147 | if (a == nil) then |
||
1148 | if (b == nil) then |
||
1149 | return false; |
||
1150 | else |
||
1151 | return true; |
||
1152 | end |
||
1153 | elseif (b == nil) then |
||
1154 | return false; |
||
1155 | end |
||
1156 | |||
1157 | GEM_SORTBY = { |
||
1158 | [GEM_SORTBY_DATE] = GEMList_PredicateDate, |
||
1159 | [GEM_SORTBY_WHERE] = GEMList_PredicateWhere, |
||
1160 | [GEM_SORTBY_LEADER] = GEMList_PredicateLeader, |
||
1161 | [GEM_SORTBY_COUNT] = GEMList_PredicateCount, |
||
1162 | [GEM_SORTBY_MINMAX] = GEMList_PredicateMinMax |
||
1163 | }; |
||
1164 | |||
1165 | predicate = GEM_SORTBY[sortType]; |
||
1166 | return predicate(a,b); |
||
1167 | end |
||
1168 | |||
1169 | function GEMList_SortBy(aSortType, aSortDir) |
||
1170 | sortType = aSortType; |
||
1171 | sortDir = aSortDir; |
||
1172 | UIEventsRefresh = true; |
||
1173 | GEMList_UpdateEventList(); |
||
1174 | end |
||
1175 | |||
1176 | function GEMList_GetEvent() |
||
1177 | if(UIEventsRefresh) |
||
1178 | then |
||
1179 | UIEvents = {}; |
||
1180 | local selected = GEM_GetSelectedReroll(); |
||
1181 | local infos = GEM_Events.realms[GEM_Realm].my_names[selected]; |
||
1182 | for ev_id,event in GEM_Events.realms[GEM_Realm].events |
||
1183 | do |
||
1184 | if((GEM_Events.realms[GEM_Realm].ignore[event.id] == nil) and -- Not in ignore list |
||
1185 | (GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].FilterEvents == nil or GEM_IsMyReroll(event.leader) or (infos.level >= event.min_lvl and infos.level <= event.max_lvl))) -- And level is ok |
||
1186 | then |
||
1187 | tinsert(UIEvents, {id = ev_id; event = event}); |
||
1188 | end |
||
1189 | end |
||
1190 | table.sort(UIEvents, GEMList_Predicate); |
||
1191 | if(not sortDir) |
||
1192 | then |
||
1193 | UIEvents = GEMList_InvertList(UIEvents); |
||
1194 | end |
||
1195 | UIEventsRefresh = false; |
||
1196 | end |
||
1197 | |||
1198 | return UIEvents; |
||
1199 | end |
||
1200 | |||
1201 | function GEM_ConvertDateFormat(df) |
||
1202 | for src,dest in GEM_DATE_CONVERT |
||
1203 | do |
||
1204 | df = string.gsub(df,src,dest); |
||
1205 | end |
||
1206 | return df; |
||
1207 | end |
||
1208 | |||
1209 | function GEM_IsNewEvent(id) |
||
1210 | for _,n in GEM_NewEvents |
||
1211 | do |
||
1212 | if(n == id) then return true; end |
||
1213 | end |
||
1214 | return false; |
||
1215 | end |
||
1216 | |||
1217 | function GEM_RemoveNewEvent(id) |
||
1218 | for i,n in GEM_NewEvents |
||
1219 | do |
||
1220 | if(n == id) then tremove(GEM_NewEvents,i); return; end |
||
1221 | end |
||
1222 | end |
||
1223 | |||
1224 | function GEMList_UpdateEventList() |
||
1225 | if(not GEMListFrame:IsVisible()) then |
||
1226 | return; |
||
1227 | end |
||
1228 | local events = GEMList_GetEvent(); |
||
1229 | local size = table.getn(events); |
||
1230 | local enable_subscribe = false; |
||
1231 | local enable_unsubscribe = false; |
||
1232 | local sel_event = nil; |
||
1233 | |||
1234 | local enableEventActions = false; |
||
1235 | local enableClosedActions = false; |
||
1236 | local offset = FauxScrollFrame_GetOffset(GEMEventItemScrollFrame); |
||
1237 | numButtons = MAXDISPLAY_EVENT; |
||
1238 | i = 1; |
||
1239 | |||
1240 | local selected = GEM_GetSelectedReroll(); |
||
1241 | local infos = GEM_Events.realms[GEM_Realm].my_names[selected]; |
||
1242 | while (i <= numButtons) do |
||
1243 | local j = i + offset |
||
1244 | local prefix = "GEMEventItem"..i; |
||
1245 | local button = getglobal(prefix); |
||
1246 | |||
1247 | if (j <= size) then |
||
1248 | local id = events[j].id; |
||
1249 | local event = events[j].event; |
||
1250 | local banned = GEM_Events.realms[GEM_Realm].banned[event.id] ~= nil; |
||
1251 | local kicked = GEM_Events.realms[GEM_Realm].kicked[event.id] ~= nil; |
||
1252 | local level_ok = infos.level >= event.min_lvl and infos.level <= event.max_lvl; |
||
1253 | if(infos.level == 0) -- No level, set as OK |
||
1254 | then |
||
1255 | level_ok = true; |
||
1256 | end |
||
1257 | |||
1258 | button.eventid = id; |
||
1259 | getglobal(prefix.."Date"):SetText(GEM_ConvertDateFormat(date(GEM_Events.DateFormat,event.ev_date + GEM_ComputeHourOffset()))); |
||
1260 | getglobal(prefix.."Where"):SetText(event.ev_place); |
||
1261 | getglobal(prefix.."Leader"):SetText(event.leader); |
||
1262 | getglobal(prefix.."Date"):SetTextColor(0.9,0.8,0.10); |
||
1263 | getglobal(prefix.."RangeLevel"):SetTextColor(1,1,1); |
||
1264 | |||
1265 | if(GEM_IsNewEvent(id)) |
||
1266 | then |
||
1267 | getglobal(prefix.."Where"):SetTextColor(0,1,0); |
||
1268 | else |
||
1269 | getglobal(prefix.."Where"):SetTextColor(1,1,1); |
||
1270 | end |
||
1271 | if(GEM_IsPlayerConnected(event.channel,event.leader)) |
||
1272 | then |
||
1273 | getglobal(prefix.."Leader"):SetTextColor(0,1,0); |
||
1274 | else |
||
1275 | getglobal(prefix.."Leader"):SetTextColor(1,1,1); |
||
1276 | end |
||
1277 | if(GEM_Events.realms[GEM_Realm].subscribed[event.id] ~= nil) -- I subscribed for this event |
||
1278 | then |
||
1279 | if(selectEvent == id) -- This event is the selected one |
||
1280 | then |
||
1281 | enable_unsubscribe = true; |
||
1282 | getglobal("GEMListFrameForcesub"):Disable(); |
||
1283 | getglobal("GEMListFrameComment"):EnableKeyboard(0); |
||
1284 | getglobal("GEMListFrameComment"):EnableMouse(0); |
||
1285 | getglobal("GEMListFrameComment"):SetTextColor(0.5,0.5,0.5); |
||
1286 | getglobal("GEMListFrameComment"):SetText(GEM_Events.realms[GEM_Realm].subscribed[event.id].comment); |
||
1287 | if(GEM_Events.realms[GEM_Realm].subscribed[event.id].forcesub == 1) |
||
1288 | then |
||
1289 | getglobal("GEMListFrameForcesub"):SetChecked(1); |
||
1290 | else |
||
1291 | getglobal("GEMListFrameForcesub"):SetChecked(0); |
||
1292 | end |
||
1293 | getglobal("GEMListFrameCommentString"):SetTextColor(0.4,0.4,0.4); |
||
1294 | getglobal("GEMListFrameForcesubString"):SetTextColor(0.4,0.4,0.4); |
||
1295 | GEM_SetSelectedReroll(GEM_Events.realms[GEM_Realm].subscribed[event.id].name); |
||
1296 | end |
||
1297 | if(GEM_Events.realms[GEM_Realm].subscribed[event.id].state == "1") -- Titular |
||
1298 | then |
||
1299 | getglobal(prefix.."Count"):SetTextColor(0,1,0); -- Green |
||
1300 | elseif(GEM_Events.realms[GEM_Realm].subscribed[event.id].state == "2") -- Substitute |
||
1301 | then |
||
1302 | getglobal(prefix.."Count"):SetTextColor(0.2,0.2,1); -- Blue |
||
1303 | elseif(GEM_Events.realms[GEM_Realm].subscribed[event.id].state == "3") -- Replacement |
||
1304 | then |
||
1305 | getglobal(prefix.."Count"):SetTextColor(0.8,0.8,0); -- Yellow |
||
1306 | else -- Not Acked |
||
1307 | getglobal(prefix.."Count"):SetTextColor(0.3,0.3,0.3); -- Dark Grey |
||
1308 | end |
||
1309 | elseif(GEM_IsMyReroll(event.leader)) -- I'm the leader |
||
1310 | then |
||
1311 | getglobal(prefix.."Count"):SetTextColor(0,1,0); |
||
1312 | if(selectEvent == id) -- This event is the selected one |
||
1313 | then |
||
1314 | getglobal("GEMListFrameForcesub"):Disable(); |
||
1315 | getglobal("GEMListFrameComment"):EnableKeyboard(0); |
||
1316 | getglobal("GEMListFrameComment"):EnableMouse(0); |
||
1317 | getglobal("GEMListFrameComment"):SetTextColor(0.6,0.6,0.6); |
||
1318 | getglobal("GEMListFrameComment"):SetText(""); |
||
1319 | getglobal("GEMListFrameForcesub"):SetChecked(0); |
||
1320 | getglobal("GEMListFrameCommentString"):SetTextColor(0.4,0.4,0.4); |
||
1321 | getglobal("GEMListFrameForcesubString"):SetTextColor(0.4,0.4,0.4); |
||
1322 | end |
||
1323 | else -- Not subscribed |
||
1324 | if(selectEvent == id) -- This event is the selected one |
||
1325 | then |
||
1326 | if(not banned and level_ok) -- Not banned, and level range is ok |
||
1327 | then |
||
1328 | enable_subscribe = true; |
||
1329 | end |
||
1330 | getglobal("GEMListFrameForcesub"):Enable(); |
||
1331 | getglobal("GEMListFrameComment"):EnableKeyboard(1); |
||
1332 | getglobal("GEMListFrameComment"):EnableMouse(1); |
||
1333 | getglobal("GEMListFrameComment"):SetTextColor(1,1,1); |
||
1334 | getglobal("GEMListFrameComment"):SetText(""); |
||
1335 | getglobal("GEMListFrameForcesub"):SetChecked(0); |
||
1336 | getglobal("GEMListFrameCommentString"):SetTextColor(0.90,0.75,0); |
||
1337 | getglobal("GEMListFrameForcesubString"):SetTextColor(0.90,0.75,0); |
||
1338 | end |
||
1339 | if(banned) |
||
1340 | then |
||
1341 | getglobal(prefix.."Count"):SetTextColor(1,0,0); |
||
1342 | elseif(kicked) |
||
1343 | then |
||
1344 | getglobal(prefix.."Count"):SetTextColor(0.5,0,0); |
||
1345 | elseif(not level_ok) |
||
1346 | then |
||
1347 | getglobal(prefix.."Count"):SetTextColor(0.7,0,0.8); |
||
1348 | else |
||
1349 | getglobal(prefix.."Count"):SetTextColor(1,1,1); |
||
1350 | end |
||
1351 | end |
||
1352 | local subs = table.getn(event.substitutes); |
||
1353 | if(subs ~= 0) |
||
1354 | then |
||
1355 | getglobal(prefix.."Count"):SetText(event.titular_count.."/"..event.max_count.." ("..subs..")"); |
||
1356 | else |
||
1357 | getglobal(prefix.."Count"):SetText(event.titular_count.."/"..event.max_count); |
||
1358 | end |
||
1359 | getglobal(prefix.."RangeLevel"):SetText(event.min_lvl.." - "..event.max_lvl); |
||
1360 | button:Show(); |
||
1361 | |||
1362 | if(event.closed_comment) |
||
1363 | then |
||
1364 | getglobal(prefix.."Date"):SetTextColor(0.5,0.5,0.5); |
||
1365 | getglobal(prefix.."Where"):SetTextColor(0.5,0.5,0.5); |
||
1366 | getglobal(prefix.."Leader"):SetTextColor(0.5,0.5,0.5); |
||
1367 | getglobal(prefix.."Count"):SetTextColor(0.5,0.5,0.5); |
||
1368 | getglobal(prefix.."RangeLevel"):SetTextColor(0.5,0.5,0.5); |
||
1369 | end |
||
1370 | -- selected |
||
1371 | if (selectEvent == id) then |
||
1372 | button:LockHighlight(); |
||
1373 | sel_event = event; |
||
1374 | if(event.closed_comment) then |
||
1375 | enableClosedActions = true; |
||
1376 | else |
||
1377 | enableEventActions = true; |
||
1378 | end |
||
1379 | else |
||
1380 | button:UnlockHighlight(); |
||
1381 | end |
||
1382 | else |
||
1383 | button.eventid = nil; |
||
1384 | button:Hide(); |
||
1385 | end |
||
1386 | |||
1387 | i = i + 1; |
||
1388 | end |
||
1389 | |||
1390 | FauxScrollFrame_Update(GEMEventItemScrollFrame, size, MAXDISPLAY_EVENT, 17); |
||
1391 | |||
1392 | if (enableEventActions) then |
||
1393 | GEMListFrameCommentString:Show(); |
||
1394 | GEMListFrameForcesubString:Show(); |
||
1395 | GEMListFrameComment:Show(); |
||
1396 | GEMListFrameForcesub:Show(); |
||
1397 | GEMList_Middle_ShowFrame(); |
||
1398 | GEMListFrameSubscribe:Show(); |
||
1399 | GEMListFrameUnsubscribe:Show(); |
||
1400 | GEMListFrameRerollDropDown:Show(); |
||
1401 | GEMListFrameUnclose:Hide(); |
||
1402 | GEMListFrameEventIgnore:Hide(); |
||
1403 | GEMListFrameDelete:Hide(); |
||
1404 | GEMListFrameRecover:Hide(); |
||
1405 | GEMListFrameUnsubscribe:Disable(); |
||
1406 | GEMListFrameSubscribe:Disable(); |
||
1407 | if(enable_subscribe) then |
||
1408 | GEMListFrameSubscribe:Enable(); |
||
1409 | end |
||
1410 | if(enable_unsubscribe) then |
||
1411 | GEMListFrameUnsubscribe:Enable(); |
||
1412 | end |
||
1413 | else |
||
1414 | GEMListFrameCommentString:Hide(); |
||
1415 | GEMListFrameForcesubString:Hide(); |
||
1416 | GEMListFrameComment:Hide(); |
||
1417 | GEMListFrameForcesub:Hide(); |
||
1418 | GEMListMiddleFrame:Hide(); |
||
1419 | GEMListFrameSubscribe:Hide(); |
||
1420 | GEMListFrameUnsubscribe:Hide(); |
||
1421 | GEMListFrameRerollDropDown:Hide(); |
||
1422 | GEMListFrameUnclose:Hide(); |
||
1423 | GEMListFrameEventIgnore:Hide(); |
||
1424 | GEMListFrameDelete:Hide(); |
||
1425 | GEMListFrameRecover:Hide(); |
||
1426 | if(enableClosedActions) then |
||
1427 | if(sel_event.crashed) then |
||
1428 | if(not GEM_EVT_CheckExpiredEvent(sel_event.id) and GEM_IsChannelJoined(sel_event.channel)) then |
||
1429 | GEMListFrameRecover:Show(); |
||
1430 | end |
||
1431 | elseif(GEM_IsMyReroll(sel_event.leader) and not GEM_EVT_CheckExpiredEvent(sel_event.id) and GEM_IsChannelJoined(sel_event.channel)) then |
||
1432 | GEMListFrameUnclose:Show(); |
||
1433 | GEMListFrameDelete:Show(); |
||
1434 | else |
||
1435 | GEMListFrameEventIgnore:Show(); |
||
1436 | end |
||
1437 | else |
||
1438 | GEMListFrameUnclose:Hide(); |
||
1439 | GEMListFrameEventIgnore:Hide(); |
||
1440 | GEMListFrameDelete:Hide(); |
||
1441 | GEMListFrameRecover:Hide(); |
||
1442 | end |
||
1443 | end |
||
1444 | GEM_NewEvents = {}; |
||
1445 | end |
||
1446 | |||
1447 | function GEMList_SubscribeOnClick() |
||
1448 | if (selectEvent and not GEM_EVT_CheckExpiredEvent(selectEvent)) then |
||
1449 | local forcesub = GEMListFrameForcesub:GetChecked(); |
||
1450 | if(forcesub == nil) then forcesub = 0; end; |
||
1451 | GEM_COM_Subscribe(selectEvent,forcesub,string.gsub(GEMListFrameComment:GetText(),"[%c]"," ")); |
||
1452 | end |
||
1453 | end |
||
1454 | |||
1455 | function GEMList_UnsubscribeOnClick() |
||
1456 | if (selectEvent and not GEM_EVT_CheckExpiredEvent(selectEvent)) then |
||
1457 | GEM_COM_Unsubscribe(selectEvent,"Test unsubscribe comment"); |
||
1458 | end |
||
1459 | end |
||
1460 | |||
1461 | function GEMList_UncloseOnClick() |
||
1462 | if (selectEvent and not GEM_EVT_CheckExpiredEvent(selectEvent)) then |
||
1463 | GEM_EVT_UnCloseEvent(selectEvent); |
||
1464 | GEM_NotifyGUI(GEM_NOTIFY_EVENT_UPDATE,selectEvent); |
||
1465 | end |
||
1466 | end |
||
1467 | |||
1468 | StaticPopupDialogs["GEM_CONFIRM_DELETEEVENT"] = { |
||
1469 | text = TEXT(GEM_TEXT_DELETE_CONFIRM), |
||
1470 | button1 = TEXT(OKAY), |
||
1471 | button2 = TEXT(CANCEL), |
||
1472 | OnAccept = function() |
||
1473 | local event = GEM_Events.realms[GEM_Realm].events[this:GetParent().data.ev_id]; |
||
1474 | if(event ~= nil) |
||
1475 | then |
||
1476 | event.ev_date = time() - GEM_ExpirationTimeSelf * 2; |
||
1477 | event.update_time = time(); |
||
1478 | GEM_COM_BroadcastEvent(event); -- Force brodcast (or it will be deleted before update) |
||
1479 | GEM_NotifyGUI(GEM_NOTIFY_EVENT_UPDATE,event.id); |
||
1480 | end |
||
1481 | end, |
||
1482 | timeout = 0 |
||
1483 | }; |
||
1484 | |||
1485 | function GEMList_DeleteOnClick() |
||
1486 | if (selectEvent and not GEM_EVT_CheckExpiredEvent(selectEvent)) then |
||
1487 | local dialogFrame = StaticPopup_Show("GEM_CONFIRM_DELETEEVENT"); |
||
1488 | if(dialogFrame) |
||
1489 | then |
||
1490 | dialogFrame.data = { ev_id=selectEvent }; |
||
1491 | end |
||
1492 | end |
||
1493 | end |
||
1494 | |||
1495 | function GEMList_RecoverOnClick() |
||
1496 | if (selectEvent and not GEM_EVT_CheckExpiredEvent(selectEvent)) then |
||
1497 | if(GEM_SUB_RecoverSubscribers(selectEvent)) then |
||
1498 | GEM_EVT_UnCloseEvent(selectEvent); |
||
1499 | GEM_NotifyGUI(GEM_NOTIFY_EVENT_UPDATE,selectEvent); |
||
1500 | GEM_ChatPrint("Event recovered using known informations !"); |
||
1501 | else |
||
1502 | GEM_ChatPrint("Failed to recover the event !"); |
||
1503 | end |
||
1504 | end |
||
1505 | end |
||
1506 | |||
1507 | -- |
||
1508 | function GEM_SetSelectedReroll(pl_name) |
||
1509 | if(GEM_Events.realms[GEM_Realm].my_names[pl_name] == nil) |
||
1510 | then |
||
1511 | return; |
||
1512 | end |
||
1513 | getglobal("GEMListFrameRerollDropDown").name = pl_name; |
||
1514 | getglobal("GEMNewRerollDropDown").name = pl_name; |
||
1515 | UIDropDownMenu_SetText(pl_name,GEMListFrameRerollDropDown); |
||
1516 | end |
||
1517 | |||
1518 | function GEM_GetSelectedReroll() |
||
1519 | local name; |
||
1520 | if(GEMNewRerollDropDown:IsVisible()) |
||
1521 | then |
||
1522 | name = getglobal("GEMNewRerollDropDown").name; |
||
1523 | else |
||
1524 | name = getglobal("GEMListFrameRerollDropDown").name; |
||
1525 | end |
||
1526 | if(name == nil) |
||
1527 | then |
||
1528 | name = GEM_PlayerName; |
||
1529 | end |
||
1530 | if(GEM_Events.realms[GEM_Realm].my_names[name] == nil) |
||
1531 | then |
||
1532 | GEM_ChatPrint("GEM_GetSelectedReroll : WARNING : my_names not initialized for "..name); |
||
1533 | return nil; |
||
1534 | end |
||
1535 | if(GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].guild == nil or GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].guild == "") |
||
1536 | then |
||
1537 | GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].guild = GetGuildInfo("player"); |
||
1538 | GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].level = UnitLevel("player"); |
||
1539 | end |
||
1540 | return name; |
||
1541 | end |
||
1542 | |||
1543 | function GEMListFrameRerollDropDown_OnShow() |
||
1544 | if(getglobal("GEMListFrameRerollDropDown").name == nil) |
||
1545 | then |
||
1546 | getglobal("GEMListFrameRerollDropDown").name = GEM_PlayerName; |
||
1547 | end |
||
1548 | UIDropDownMenu_Initialize(GEMListFrameRerollDropDown, GEMListFrameRerollDropDown_Init); |
||
1549 | UIDropDownMenu_SetText(getglobal("GEMListFrameRerollDropDown").name, GEMListFrameRerollDropDown); |
||
1550 | UIDropDownMenu_SetWidth(80, GEMListFrameRerollDropDown); |
||
1551 | end |
||
1552 | |||
1553 | function GEMListFrameRerollDropDown_OnClick() |
||
1554 | getglobal("GEMListFrameRerollDropDown").name = this.value; |
||
1555 | getglobal("GEMNewRerollDropDown").name = this.value; |
||
1556 | UIDropDownMenu_SetText(this.value,GEMListFrameRerollDropDown); |
||
1557 | GEMList_Notify(GEM_NOTIFY_MY_SUBSCRIPTION,""); -- Force update of the list |
||
1558 | end |
||
1559 | |||
1560 | function GEMListFrameRerollDropDown_OnClickBadValue() |
||
1561 | GEM_ChatPrint(GEM_TEXT_REROLL_ERR_SELECT); |
||
1562 | end |
||
1563 | |||
1564 | function GEMListFrameRerollDropDown_Init() |
||
1565 | for name,tab in GEM_Events.realms[GEM_Realm].my_names do |
||
1566 | local info = { }; |
||
1567 | info.text = name; |
||
1568 | info.value = name; |
||
1569 | if(not GEM_IsChannelInRerollList(name,GEM_GetSelectedChannel())) |
||
1570 | then |
||
1571 | info.disabled = 1; |
||
1572 | info.func = GEMListFrameRerollDropDown_OnClickBadValue; |
||
1573 | else |
||
1574 | info.func = GEMListFrameRerollDropDown_OnClick; |
||
1575 | end |
||
1576 | UIDropDownMenu_AddButton(info); |
||
1577 | end |
||
1578 | end |
||
1579 | |||
1580 | function GEMList_OnShow() |
||
1581 | GEM_EVT_CheckExpiredEvents(); |
||
1582 | GEMList_UpdateEventList(); |
||
1583 | end |
||
1584 | |||
1585 | function GEMList_OnLoad() |
||
1586 | GEM_SetNotifyCallback(GEMList_Notify); |
||
1587 | end |
||
1588 | |||
1589 | local function _GEMList_RefreshLists(ev_id) |
||
1590 | if(ev_id == nil or ev_id == "") |
||
1591 | then |
||
1592 | ev_id = selectEvent; |
||
1593 | end |
||
1594 | if(ev_id ~= nil and GEM_Events.realms[GEM_Realm].events[ev_id] == nil) -- id no longer exists |
||
1595 | then |
||
1596 | selectEvent = nil; |
||
1597 | end |
||
1598 | UIEventsRefresh = true; |
||
1599 | GEMList_UpdateEventList(); |
||
1600 | if(ev_id == selectEvent) -- Event selected |
||
1601 | then |
||
1602 | if(GEMList_PreviousTab == 1) -- Details |
||
1603 | then |
||
1604 | GEMListDetails_OnShow(); |
||
1605 | elseif(GEMList_PreviousTab == 2) -- Limits |
||
1606 | then |
||
1607 | GEMListLimitations_OnShow(); |
||
1608 | elseif(GEMList_PreviousTab == 3) -- Admin |
||
1609 | then |
||
1610 | UIListAdminRefresh = true; |
||
1611 | GEMListAdmin_UpdatePlayersList() |
||
1612 | end |
||
1613 | end |
||
1614 | end |
||
1615 | |||
1616 | local _GEMList_Blink = true; |
||
1617 | function GEMList_NotifyNewEvent() |
||
1618 | if(table.getn(GEM_NewEvents) == 0) -- Reset texture |
||
1619 | then |
||
1620 | GEMMinimapButtonText:SetText(""); |
||
1621 | GEMMinimapButtonTexture:SetAlpha(1); |
||
1622 | return; |
||
1623 | end |
||
1624 | |||
1625 | GEMMinimapButtonText:SetText("N"); |
||
1626 | if(_GEMList_Blink) |
||
1627 | then |
||
1628 | _GEMList_Blink = false; |
||
1629 | GEMMinimapButtonTexture:SetAlpha(0.7); |
||
1630 | else |
||
1631 | _GEMList_Blink = true; |
||
1632 | GEMMinimapButtonTexture:SetAlpha(1); |
||
1633 | end |
||
1634 | GEMSystem_Schedule(1,GEMList_NotifyNewEvent); |
||
1635 | end |
||
1636 | |||
1637 | function GEMList_Notify(cmd,...) |
||
1638 | if(cmd == GEM_NOTIFY_NEW_EVENT) then |
||
1639 | UIEventsRefresh = true; |
||
1640 | GEMList_UpdateEventList(); |
||
1641 | GEM_ChatDebug(GEM_DEBUG_GUI,"GEMList_Notify : New Event : "..arg[1]); |
||
1642 | if(not GEMMainFrame:IsVisible()) then |
||
1643 | if(not GEM_IsNewEvent(arg[1])) |
||
1644 | then |
||
1645 | tinsert(GEM_NewEvents,arg[1]); |
||
1646 | if(table.getn(GEM_NewEvents) == 1) -- Start schedule if first new event |
||
1647 | then |
||
1648 | GEMSystem_Schedule(1,GEMList_NotifyNewEvent); |
||
1649 | _GEMList_Blink = true; |
||
1650 | end |
||
1651 | end |
||
1652 | end |
||
1653 | elseif(cmd == GEM_NOTIFY_CLOSE_EVENT) then |
||
1654 | UIEventsRefresh = true; |
||
1655 | GEMList_UpdateEventList(); |
||
1656 | GEM_ChatDebug(GEM_DEBUG_GUI,"GEMList_Notify : Close Event : "..arg[1]); |
||
1657 | elseif(cmd == GEM_NOTIFY_EVENT_UPDATE) then |
||
1658 | GEM_ChatDebug(GEM_DEBUG_GUI,"GEMList_Notify : Update Event : "..arg[1]); |
||
1659 | _GEMList_RefreshLists(arg[1]); |
||
1660 | elseif(cmd == GEM_NOTIFY_SUBSCRIBER) then |
||
1661 | GEM_ChatDebug(GEM_DEBUG_GUI,"GEMList_Notify : My subscription changed for "..arg[1]); |
||
1662 | _GEMList_RefreshLists(arg[1]); |
||
1663 | elseif(cmd == GEM_NOTIFY_UNSUBSCRIBER) then |
||
1664 | GEM_ChatDebug(GEM_DEBUG_GUI,"GEMList_Notify : My subscription changed for "..arg[1]); |
||
1665 | _GEMList_RefreshLists(arg[1]); |
||
1666 | elseif(cmd == GEM_NOTIFY_MY_SUBSCRIPTION) then |
||
1667 | GEM_ChatDebug(GEM_DEBUG_GUI,"GEMList_Notify : My subscription changed for "..arg[1]); |
||
1668 | _GEMList_RefreshLists(arg[1]); |
||
1669 | elseif(cmd == GEM_NOTIFY_PLAYER_INFOS) then |
||
1670 | if(GEMPlayersFrame:IsVisible()) -- Players list |
||
1671 | then |
||
1672 | GEMPlayers_UpdatePlayersList(); |
||
1673 | end |
||
1674 | end |
||
1675 | end |
||
1676 | |||
1677 | |||
1678 | --[[ |
||
1679 | Banned list Functions |
||
1680 | ]] |
||
1681 | |||
1682 | local MAXDISPLAY_BANS = 10; |
||
1683 | local selectBannedItem = nil; |
||
1684 | |||
1685 | local function GEMListBanned_GetList() |
||
1686 | local bans = {}; |
||
1687 | |||
1688 | for name,reason in GEM_Events.realms[GEM_Realm].events[GEMListBannedFrame.Event].banned do |
||
1689 | table.insert(bans,{Name=name, Reason=reason }); |
||
1690 | end |
||
1691 | |||
1692 | return bans; |
||
1693 | end |
||
1694 | |||
1695 | function GEMListBanned_UpdatePlayersList() |
||
1696 | if(not GEMListBannedFrame:IsVisible()) then |
||
1697 | return; |
||
1698 | end |
||
1699 | local list = GEMListBanned_GetList(); |
||
1700 | local size = table.getn(list); |
||
1701 | |||
1702 | local offset = FauxScrollFrame_GetOffset(GEMListBannedItemScrollFrame); |
||
1703 | |||
1704 | numButtons = MAXDISPLAY_BANS; |
||
1705 | i = 1; |
||
1706 | GEMListBanned_UnBan:Disable(); |
||
1707 | |||
1708 | while (i <= numButtons) do |
||
1709 | local j = i + offset |
||
1710 | local prefix = "GEMListBannedItem"..i; |
||
1711 | local button = getglobal(prefix); |
||
1712 | |||
1713 | if (j <= size) then |
||
1714 | button.pl_name = list[j].Name; |
||
1715 | getglobal(prefix.."Name"):SetText(list[j].Name); |
||
1716 | getglobal(prefix.."Reason"):SetText(list[j].Reason); |
||
1717 | button:Show(); |
||
1718 | |||
1719 | -- selected |
||
1720 | if (selectBannedItem == list[j].Name) then |
||
1721 | button:LockHighlight(); |
||
1722 | if(GEM_IsMyReroll(GEM_Events.realms[GEM_Realm].events[GEMListBannedFrame.Event].leader)) then |
||
1723 | GEMListBanned_UnBan:Enable(); |
||
1724 | end |
||
1725 | else |
||
1726 | button:UnlockHighlight(); |
||
1727 | end |
||
1728 | else |
||
1729 | button.pl_name = nil; |
||
1730 | button:Hide(); |
||
1731 | end |
||
1732 | |||
1733 | i = i + 1; |
||
1734 | end |
||
1735 | |||
1736 | FauxScrollFrame_Update(GEMListBannedItemScrollFrame, size, MAXDISPLAY_BANS, 17); |
||
1737 | end |
||
1738 | |||
1739 | |||
1740 | function GEMListBannedUnBan_OnClick() |
||
1741 | if(selectBannedItem ~= nil and selectBannedItem ~= "") |
||
1742 | then |
||
1743 | GEM_COM_UnBanPlayer(GEMListBannedFrame.Event,selectBannedItem); |
||
1744 | GEMListBanned_UpdatePlayersList(); |
||
1745 | end |
||
1746 | end |
||
1747 | |||
1748 | function GEMListBanned_EventOnClick() |
||
1749 | selectBannedItem = this.pl_name; |
||
1750 | GEMListBanned_UpdatePlayersList(); |
||
1751 | end |
||
1752 | |||
1753 | function GEMListBanned_OnShow() |
||
1754 | GEMListBanned_UpdatePlayersList(); |
||
1755 | end |
||
1756 | |||
1757 | ----------------------------- CALENDAR --------------------------- |
||
1758 | local _GEMEventCalendar_CurrentMonth = nil; |
||
1759 | local _GEMEventCalendar_CurrentYear = nil; |
||
1760 | local _GEMEventCalendar_CurrentReset = 0; |
||
1761 | |||
1762 | function GEMEventCalendarResetsDropDown_OnShow() |
||
1763 | UIDropDownMenu_Initialize(GEMListFrameCalViewResetsDropDown, GEMEventCalendarResetsDropDown_Init); |
||
1764 | UIDropDownMenu_SetText(GEM_EVENT_CALENDAR_Resets[_GEMEventCalendar_CurrentReset].name, GEMListFrameCalViewResetsDropDown); |
||
1765 | UIDropDownMenu_SetWidth(80, GEMListFrameCalViewResetsDropDown); |
||
1766 | end |
||
1767 | |||
1768 | function GEMEventCalendarResetsDropDown_OnClick() |
||
1769 | _GEMEventCalendar_CurrentReset = this.value; |
||
1770 | if(this.value == 0) |
||
1771 | then |
||
1772 | UIDropDownMenu_SetText(GEM_EVENT_CALENDAR_INSTANCE_NONE_NAME, GEMListFrameCalViewResetsDropDown); |
||
1773 | else |
||
1774 | UIDropDownMenu_SetText(GEM_EVENT_CALENDAR_Resets[_GEMEventCalendar_CurrentReset].name,GEMListFrameCalViewResetsDropDown); |
||
1775 | end |
||
1776 | GEMEventCalendar_OnShow(getglobal("GEMListFrameCalViewCal")); |
||
1777 | end |
||
1778 | |||
1779 | function GEMEventCalendarResetsDropDown_Init() |
||
1780 | local info = { }; |
||
1781 | info.text = GEM_EVENT_CALENDAR_INSTANCE_NONE_NAME; |
||
1782 | info.value = 0; |
||
1783 | info.func = GEMEventCalendarResetsDropDown_OnClick; |
||
1784 | UIDropDownMenu_AddButton(info); |
||
1785 | |||
1786 | for i,tab in GEM_EVENT_CALENDAR_Resets do |
||
1787 | local info = { }; |
||
1788 | info.text = tab.name; |
||
1789 | info.value = i; |
||
1790 | info.func = GEMEventCalendarResetsDropDown_OnClick; |
||
1791 | UIDropDownMenu_AddButton(info); |
||
1792 | end |
||
1793 | end |
||
1794 | |||
1795 | function GEMListCalendarCheckBox_OnClick() |
||
1796 | if(GEMListCalendarCheckBox:GetChecked()) -- Calendar view |
||
1797 | then |
||
1798 | GEMListFrameListView:Hide(); |
||
1799 | GEMListFrameCalView:Show(); |
||
1800 | else |
||
1801 | GEMListFrameCalView:Hide(); |
||
1802 | GEMListFrameListView:Show(); |
||
1803 | end |
||
1804 | end |
||
1805 | |||
1806 | function GEMEventCalendar_OnShow(parent) |
||
1807 | local tab = date("*t"); |
||
1808 | |||
1809 | if(_GEMEventCalendar_CurrentMonth == nil) |
||
1810 | then |
||
1811 | _GEMEventCalendar_CurrentMonth = tab.month; |
||
1812 | _GEMEventCalendar_CurrentYear = tab.year; |
||
1813 | _GEMEventCalendar_CurrentReset = 0; |
||
1814 | end |
||
1815 | |||
1816 | tab.month = _GEMEventCalendar_CurrentMonth; |
||
1817 | tab.year = _GEMEventCalendar_CurrentYear; |
||
1818 | |||
1819 | GEMListFrameCalViewMonthYear:SetText(GEMCalendar_Month[tab.month].." ".._GEMEventCalendar_CurrentYear); |
||
1820 | GEMEventCalendar_DrawDays(parent,time(tab),_GEMEventCalendar_CurrentReset); |
||
1821 | end |
||
1822 | |||
1823 | function GEMEventCalendar_PreviousMonth() |
||
1824 | _GEMEventCalendar_CurrentMonth = _GEMEventCalendar_CurrentMonth - 1; |
||
1825 | if(_GEMEventCalendar_CurrentMonth == 0) |
||
1826 | then |
||
1827 | _GEMEventCalendar_CurrentYear = _GEMEventCalendar_CurrentYear - 1; |
||
1828 | _GEMEventCalendar_CurrentMonth = 12; |
||
1829 | end |
||
1830 | GEMEventCalendar_OnShow(getglobal("GEMListFrameCalViewCal")); |
||
1831 | end |
||
1832 | |||
1833 | function GEMEventCalendar_NextMonth() |
||
1834 | _GEMEventCalendar_CurrentMonth = _GEMEventCalendar_CurrentMonth + 1; |
||
1835 | if(_GEMEventCalendar_CurrentMonth == 13) |
||
1836 | then |
||
1837 | _GEMEventCalendar_CurrentYear = _GEMEventCalendar_CurrentYear + 1; |
||
1838 | _GEMEventCalendar_CurrentMonth = 1; |
||
1839 | end |
||
1840 | GEMEventCalendar_OnShow(getglobal("GEMListFrameCalViewCal")); |
||
1841 | end |
||
1842 |