vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 GuildRaidSnapShot_SnapShots = {};
2 GuildRaidSnapShot_Loot = {};
3 GuildRaidSnapShot_Notes = {};
4 GuildRaidSnapShot_Adj = {};
5 GRSS_Calendar = {};
6 GRSS_Alts = {};
7 GRSS_MainOnly = {};
8 GRSS_Divide = {};
9 GRSS_Systems = {};
10 GRSS_Full_DKP = {};
11 GRSS_Bosses = {"Lucifron","Magmadar","Gehennas","Garr","Baron Geddon","Shazzrah","Sulfuron Harbinger","Golemagg the Incinerator","Ragnaros","Doom Lord Kazzak","Azuregos","Lethon","Emeriss","Onyxia","Taerar","Ysondre","Razorgore the Untamed","Vaelastrasz the Corrupt","Flamegor","Ebonroc","Firemaw","Chromaggus","Broodlord Lashlayer","Nefarian","Prophet Skeram","Lord Kri","Battleguard Sartura","Princess Huhuran","Fankriss the Unyielding","Viscidus","Ouro","C'Thun","Emperor Vek'nilash","Emperor Vek'lor","Anub'Rekhan","Grand Widow Faerlina","Maexxna","Feugen","Gluth","Gothik the Harvester","Grobbulus","Heigan the Unclean","Highlord Mograine","Instructor Razuvious","Lady Blaumeux","Loatheb","Noth the Plaguebringer","Patchwerk","Sapphiron","Sir Zeliek","Stalagg","Thaddius","Thane Korth'azz","Ossirian the Unscarred","Moam","Kurinnaxx","General Rajaxx","Buru the Gorger","Ayamiss the Hunter","Bloodlord Mandokir","Gahz'ranka","Gri'lek","Hakkar","Hazza'rah","High Priest Thekal","High Priest Venoxis","High Priestess Arlokk","High Priestess Jeklik","High Priestess Mar'li","Jin'do the Hexxer","Renataki","Wushoolay","The Crone","Hyakiss the Lurker","Julianne","Maiden of Virtue","Moroes","Netherspite","Nightbane","Prince Malchezaar","Rokad the Ravager","Romulo","Shade of Aran","Shadikith the Glider","Terestian Illhoof","The Big Bad Wolf","The Curator","Gruul the Dragonkiller","Magtheridon","High King Maulgar","Fathom-Lord Karathress","Hydross the Unstable","Lady Vashj","Leotheras the Blind","Morogrim Tidewalker","The Lurker Below","Al'ar","High Astromancer Solarian","Kael'thas Sunstrider","Void Reaver","Doomwalker","Attumen the Huntsman","Illidan Stormrage","Gathios the Shatterer","High Nethermancer Zerevor","Lady Malande","Veras Darkshadow","Essence of Anger","Gurtogg Bloodboil","Illidari Council","Teron Gorefiend","High Warlord Naj'entus","Mother Shahraz","Shade of Akama","Supremus","Anetheron","Archimonde","Azgalor","Kaz'rogal","Rage Winterchill","Nalorakk","Akil'zon","Jan'alai","Halazzi","Hex Lord Malacrass","Zul'jin","Kalecgos","Sathrovarr the Corruptor","Brutallus","Felmyst","Lady Sacrolash","Grand Warlock Alythess","M'uru","Entropius","Kil'jaeden","Kel'Thuzad","Sartharion","Archavon the Stone Watcher","Malygos","Flame Leviathan","Razorscale","XT-002 Deconstructor","Ignis the Furnace Master","Assembly of Iron","Kologarn","Auriaya","Mimiron","Hodir","Thorim","Freva","General Vezax","Yogg-Saron","Algalon the Observer"
12  
13 --[[uncomment for testing the mobs outside shattrath
14 ,"Dreadfang Lurker","Timber Worg","Ironspine Petrifier"
15 --]]
16  
17 };
18 GRSS_FastBossLookup = {}; --This gets initialized with the mod
19 GRSS_Ignore = {"Onyxian","Onyxia's Elite Guard","Maexxna Spiderling","Patchwerk Golem","Hakkari","Son of Hakkar"," slain by ","Nightbane .+",".+the Crone","Netherspite Infernal","Ember of Al'ar","Sartharion Twilight Whelp","Sartharion Twilight Egg"};
20 GRSS_Yells = {};
21 GRSS_LootIgnore = {"Hakkari Bijou","Alabaster Idol","Amber Idol","Azure Idol","Jasper Idol","Lambent Idol","Obsidian Idol","Onyx Idol","Vermillion Idol","Lava Core","Fiery Core","Large .+ Shard","Small .+ Shard","Nexus Crystal","Wartorn .+ Scrap","Badge of Justice","Cosmic Infuser","^Devastation$","Infinity Blade","Phaseshift Bulwark","Warp Slicer","Staff of Disintegration","Netherstrand Longbow","Nether Spike","Bundle of Nether Spikes","Emblem of Heroism","Emblem of Valor","Abyss Crystal","Emblem of Conquest"};
22 GRSS_Yells["Majordomo Executus"] = "Impossible!.+I submit!";
23 GRSS_Yells["Attumen the Huntsman"] = "Always knew.+the hunted";
24 GRSS_Yells["Freya"] = "His hold on me dissipates";
25 GRSS_Yells["Thorim"] = "Stay your arms!";
26 GRSS_Yells["Hodir"] = "I am released from his grasp";
27 GRSS_Yells["Mimiron"] = "I allowed my mind to be corrupted";
28 GRSS_BossEmote = {};
29 GRSS_BossEmote["Chess"] = "doors of the Gamesman's Hall";
30 GRSS_ZoneIgnore = {"Arathi Basin","Alterac Valley","Eye of the Storm","Warsong Gulch"};
31 GRSS_Auto = 1;
32 GRSS_LootCap = 1;
33 GRSS_Bidding = 0;
34 GRSS_Rolling = 0;
35 GRSS_BidRolls = nil;
36 GRSS_HighBid = 0;
37 GRSS_HighBidder = "";
38 GRSS_CurrentSort = "total";
39 GRSS_BidStyle = "Silent Auction";
40 GRSS_CurrentItem = "";
41 GRSS_ItemHistory = {};
42 GRSS_TakeScreenshots = 0;
43 GRSS_CurrentLootDate = "";
44 GRSS_CurrentLootIndex = 0;
45 GRSS_LastCommand = {};
46 GRSS_ItemPrices = {};
47 GRSS_RaidFilter = "All";
48 GRSS_ClassFilter = "All";
49 GRSS_ItemQueue = {};
50 GRSS_ItemBoxOpen = 0;
51 GRSS_WipeCauser = "Unknown";
52 GRSS_LastWipeTime = 0;
53 GRSS_LastSnapshot = 0;
54 GRSSNewVersionPrinted = nil;
55 GRSS_PopupPoints = 0;
56 GRSS_PopupLootDate = "";
57 GRSS_PopupLootIndex = "";
58 GRSS_WaitListRequest = {}; --This is functioning as a Queue of WaitingList requests
59 GRSS_WaitListRequestBoxOpen = 0;
60 GRSS_NumberedSystems = {};
61 GRSS_Loot = {};
62 GRSS_WaitingList = {};
63 GRSS_RaidSignups = {};
64 GRSS_InviteType = "Waiting List";
65 GRSS_RollNumber = 1000;
66 GRSS_RaidPointsPopup = 1;
67 GRSS_AutoWipe = 1;
68 GRSS_PendingSnapShotName = ""
69 GRSS_CurrentCalendarIndex = 1;
70 GRSS_LootPromptInCombat = 0;
71 GRSS_LastSnapShotName = "";
72 GRSS_Redistribute_SnapShot = "";
73 GRSS_Redistribute_SnapShot_ExpireTime = 0;
74  
75 GRSS_NextTime = nil;
76 GRSS_Period = 60;
77 GRSS_ReadyForTimer = false;
78  
79 GRSS_Prefix = "GRSS: ";
80  
81 GRSS_Guild = {};
82 GRSS_DKP = {};
83 GRSS_Bids = {};
84 GRSSCurrentSystem = "";
85 GRSSCurrentAction = "DKP Standings";
86 GRSSHelpMsg = {
87 "!help = This help menu",
88 "!dkp = Your current DKP",
89 "!dkp name [name2 name3...] = the DKP for the player 'name' (and name2 and name3) (i.e. !dkp Joe Fred)",
90 "!items = Your item history",
91 "!items name = Item history for player 'name' (i.e. !items Joe)",
92 "!bid X = Bid X points on the current item",
93 "!request = Put in a request for the item",
94 "!dkpclass class [class2 class3...] = the current standings for the 'class' (and 'class2' and 'class3') (i.e. !dkpclass mage warlock)",
95 "!dkpraid X = the current standings for DKP System X for current raid members (to get the list of appropriate Systems, just type !dkpraid)",
96 "!dkpall X = the current standings for DKP System X (to get the list of appropriate Systems, just type !dkpall)",
97 "!price itemname = the price of the item 'itemname' (parts of names work too, i.e. '!price felheart' will retrieve the prices of all items with 'felheart' in the name)",
98 "!waitlist = Add me to the Waiting List",
99 "!waitlistwho = Show a list of who's on the waiting list",
100 };
101  
102 local GRSSVersion = "2.012";
103 local GRSSUsage = {
104 "Type |c00ffff00/grss <snapshotname>|r to take a snapshot (ex: |c00ffff00/grss Kel'Thuzad|r)",
105 "|c00ffff00/grss loot|r to open a loot prompt to manually record an item being received",
106 "|c00ffff00/grss adj|r to record an adjustment",
107 "|c00ffff00/grss reset|r to delete all your snapshots",
108 "|c00ffff00/grss show|r to bring up the DKP standings/bidding/rolling screen",
109 "|c00ffff00/grss invite|r to bring up the Waiting List/Auto-Invite screen",
110 "|c00ffff00/grss starttimer|r start Periodic Snapshots",
111 "|c00ffff00/grss stoptimer|r to disable Periodic Snapshots",
112 "|c00ffff00/grss noauto|r to disable auto-snapshot",
113 "|c00ffff00/grss yesauto|r to enable auto-snapshot",
114 "|c00ffff00/grss nosnapshotpopup|r to disable snapshot points popup asking how many points a snapshot is worth",
115 "|c00ffff00/grss yessnapshotpopup|r to enable snapshots points popup asking how many points a snapshot is worth",
116 "|c00ffff00/grss yesscreenshot|r to make snapshots also take a screenshot",
117 "|c00ffff00/grss noscreenshot|r to make snapshots NOT take a screenshot",
118 "|c00ffff00/grss yesloot|r to make Loot received (Blue and better) prompt for points spent",
119 "|c00ffff00/grss noloot|r to disable the loot prompt when items are received",
120 "|c00ffff00/grss yeswipe|r to enable the snapshot prompt when a wipe occurs",
121 "|c00ffff00/grss nowipe|r to disable the snapshot prompt when a wipe occurs",
122 "|c00ffff00/grss yeslootcombat|r allows the loot prompt to pop up in combat",
123 "|c00ffff00/grss nolootcombat|r forces the loot prompt to wait until out of combat (recommended unless you're having problems)",
124 "==========================================",
125 "Members can also send you tells like the following for information (you can even send yourself a tell for this info, too)",
126 };
127  
128 local GRSS_Colors={
129 --[[
130 ["ff9d9d9d"] = "grey",
131 ["ffffffff"] = "white",
132 ["ff00ff00"] = "green",
133 ["ff0070dd"] = "rare",--]]
134 ["ffa335ee"] = "epic",
135 ["ffff8000"] = "legendary"
136 };
137  
138 local GRSS_ChatFrame_OnEvent_Original = nil;
139  
140 function GRSS_IsWhisperGRSSWhisper(e,t,w)
141 if string.find(w,"^!dkp") or string.find(w,"^!items") or string.find(w,"^!info") or string.find(w,"^!commands") or string.find(w,"^!price") or string.find(w,"^!waitlist") then
142 return true;
143 else
144 return false;
145 end
146 end
147  
148  
149 function GRSS_IsOutgoingWhisperGRSSWhisper(e,t,w)
150 if string.find(w,"^"..GRSS_Prefix) then
151 return true;
152 else
153 return false;
154 end
155 end
156  
157  
158 function GRSS_SetItemRef(link,text,button)
159 if GRSSCurrentAction ~= "DKP Standings" and GRSS_Bidding~=1 and GRSS_Rolling~=1 then
160 GRSSItemName:SetText(text);
161 end
162 end
163  
164 function GuildRaidSnapShot_OnLoad()
165  
166 --GRSSChangeSystem(0);
167 SlashCmdList["GuildRaidSnapShot"] = GuildRaidSnapShot_SlashHandler;
168 SLASH_GuildRaidSnapShot1 = "/grss";
169 SLASH_GuildRaidSnapShot1 = "/GRSS";
170  
171 for i,v in pairs(GRSS_Bosses) do
172 GRSS_FastBossLookup[v] = v;
173 end
174  
175 this:RegisterEvent("PLAYER_REGEN_ENABLED");
176 this:RegisterEvent("PLAYER_REGEN_DISABLED");
177 this:RegisterEvent("PLAYER_DEAD");
178 this:RegisterEvent("CHAT_MSG_COMBAT_FRIENDLY_DEATH");
179 this:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH");
180 this:RegisterEvent("PLAYER_TARGET_CHANGED");
181 this:RegisterEvent("CHAT_MSG_LOOT");
182 this:RegisterEvent("CHAT_MSG_MONSTER_YELL");
183 this:RegisterEvent("CHAT_MSG_RAID_BOSS_EMOTE");
184 this:RegisterEvent("PLAYER_GUILD_UPDATE");
185 this:RegisterEvent("GUILD_ROSTER_UPDATE");
186 this:RegisterEvent("CHAT_MSG_WHISPER");
187 this:RegisterEvent("CHAT_MSG_SYSTEM");
188 this:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
189 this:RegisterEvent("LOOT_OPENED");
190 this:RegisterEvent("RAID_ROSTER_UPDATE");
191 this:RegisterEvent("VARIABLES_LOADED");
192 this:RegisterEvent("CALENDAR_OPEN_EVENT");
193 this:RegisterEvent("CALENDAR_UPDATE_EVENT");
194 this:RegisterEvent("CALENDAR_UPDATE_EVENT_LIST");
195 this:RegisterEvent("CALENDAR_NEW_EVENT");
196 this:RegisterEvent("ADDON_LOADED");
197 DEFAULT_CHAT_FRAME:AddMessage("GuildRaidSnapShot (By DKPSystem.com) Version "..GRSSVersion.." loaded. ");
198 DEFAULT_CHAT_FRAME:AddMessage("Type |c00ffff00/grss|r to get a list of options for GuildRaidSnapShot");
199  
200 --GRSS_ChatFrame_OnEvent_Original = ChatFrame_OnEvent;
201 --ChatFrame_OnEvent = GRSS_ChatFrame_OnEvent_Hook;
202 ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER",GRSS_IsWhisperGRSSWhisper); -- incoming whispers
203 ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER_INFORM",GRSS_IsOutgoingWhisperGRSSWhisper); --outgoing whispers
204  
205 hooksecurefunc("SetItemRef",GRSS_SetItemRef);
206  
207 StaticPopupDialogs["GRSS_ITEMPOINTS"] = {
208 text = "How many points did |c00ffff00%s|r spend on %s",
209 button1 = "OK",
210 button2 = "Cancel",
211 OnAccept = function()
212 points = getglobal(this:GetParent():GetName().."EditBox"):GetText();
213 GRSSRecordItemPointsOnly(points);
214 end,
215 EditBoxOnEnterPressed = function()
216 points = getglobal(this:GetParent():GetName().."EditBox"):GetText();
217 GRSSRecordItemPointsOnly(points);
218 this:GetParent():Hide();
219 end,
220 OnShow = function()
221 GRSS_ItemBoxOpen = 1;
222 getglobal(this:GetName().."EditBox"):SetText(GRSS_PopupPoints);
223 end,
224 OnHide = function()
225 if table.getn(GRSS_ItemQueue) > 0 then
226 GRSS_NextItemPopup();
227 else
228 GRSS_ItemBoxOpen = 0;
229 end
230 end,
231 timeout = 0,
232 whileDead = 1,
233 hideOnEscape = 1,
234 hasEditBox = 1,
235 };
236 StaticPopupDialogs["GRSS_RAIDPOINTS"] = {
237 text = "How many points should be awarded for the attendees in the snapshot called |c00ffff00%s|r?. Enter |c00ff0000zs|r if you want to award points based on the following loot (items awarded for the next 10 minutes)",
238 button1 = "OK",
239 button2 = "Cancel",
240 OnAccept = function()
241 points = getglobal(this:GetParent():GetName().."EditBox"):GetText();
242 GRSSSetSnapshotPoints(points);
243 end,
244 EditBoxOnEnterPressed = function()
245 points = getglobal(this:GetParent():GetName().."EditBox"):GetText();
246 GRSSSetSnapshotPoints(points);
247 this:GetParent():Hide();
248 end,
249 OnShow = function()
250 GRSS_SnapshotBoxOpen = 1;
251 getglobal(this:GetName().."EditBox"):SetText(GRSS_LastSnapShotPoints);
252 end,
253 OnHide = function()
254 end,
255 timeout = 0,
256 whileDead = 1,
257 hideOnEscape = 1,
258 hasEditBox = 1,
259 };
260 StaticPopupDialogs["GRSS_WAITINGLIST"] = {
261 text = "Name of person(s) to add to waiting list? If adding more than one, seperate by a space",
262 button1 = "OK",
263 button2 = "Cancel",
264 OnAccept = function()
265 name = getglobal(this:GetParent():GetName().."EditBox"):GetText();
266 GRSS_AddNameToWaitingList(name);
267  
268 end,
269 EditBoxOnEnterPressed = function()
270 name = getglobal(this:GetParent():GetName().."EditBox"):GetText();
271 GRSS_AddNameToWaitingList(name);
272 this:GetParent():Hide();
273 end,
274 OnShow = function()
275 getglobal(this:GetName().."EditBox"):SetText("");
276 end,
277 timeout = 0,
278 whileDead = 1,
279 hideOnEscape = 1,
280 hasEditBox = 1,
281 };
282 StaticPopupDialogs["GRSS_RAIDCHECK"] = {
283 text = "There are %s recorded right now. Would you like to keep this data (and apply any expenditures to the current standings) or would you like to purge all the data. You should ONLY purge if you've already uploaded your snapshots.",
284 button1 = "Purge",
285 button2 = "Keep",
286 OnAccept = function()
287 GuildRaidSnapShot_SnapShots = {};
288 GuildRaidSnapShot_Loot = {};
289 GuildRaidSnapShot_Adj = {};
290 GRSSPrint("Snapshots Purged");
291 end,
292 OnCancel = function()
293 GRSS_RecalcSpentLoot();
294 end,
295 timeout = 0,
296 whileDead = 1,
297 };
298  
299  
300 StaticPopupDialogs["GRSS_TIMERCHECK"] = {
301 text = "The timer is currently running to take snapshots. The next snapshot is set to be taken in |c00ffff00%s minutes|r. Continue the periodic snapshots, or Stop the Timer?",
302 button1 = "Continue",
303 button2 = "Stop Timer",
304 OnAccept = function()
305 GRSS_ReadyForTimer = true;
306 local mins = GRSS_NextTime - GetTime();
307 if mins > 0 then
308 mins = math.floor(mins / 60);
309 GRSSPrint("The next snapshot wlll be in "..mins.." minutes");
310 end
311 end,
312 OnCancel = function()
313 GRSS_NextTime = nil;
314 GRSS_ReadyForTimer = true;
315 GRSSPrint("Snapshot Timer Stopped");
316 end,
317 timeout};
318  
319 StaticPopupDialogs["GRSS_STARTTIMER"] = {
320 text = "How many minutes between snapshots?",
321 button1 = "OK",
322 button2 = "Cancel",
323 OnAccept = function()
324 mins = getglobal(this:GetParent():GetName().."EditBox"):GetText();
325 if tonumber(mins) == nil then
326 GRSSPrint(mins.." isn't exactly a number, is it?");
327 else
328 GRSS_StartTimer(mins);
329 end
330 end,
331 EditBoxOnEnterPressed = function()
332 mins = getglobal(this:GetParent():GetName().."EditBox"):GetText();
333 if tonumber(mins) == nil then
334 GRSSPrint(mins.." isn't exactly a number, is it?");
335 else
336 GRSS_StartTimer(mins);
337 end
338 this:GetParent():Hide();
339 end,
340 OnShow = function()
341 getglobal(this:GetName().."EditBox"):SetText(GRSS_Period);
342 end,
343 timeout = 0,
344 whileDead = 1,
345 hideOnEscape = 1,
346 hasEditBox = 1,
347 };
348  
349 StaticPopupDialogs["GRSS_WIPE"] = {
350 text = "Was this a wipe? If so, and if you want to take a snapshot, enter the name of the snapshot and click 'Record Wipe', otherwise, click Cancel",
351 button1 = "Record Wipe",
352 button2 = "Cancel",
353 OnAccept = function()
354 name = getglobal(this:GetParent():GetName().."EditBox"):GetText();
355 GRSS_TakeSnapShot(name);
356 end,
357 EditBoxOnEnterPressed = function()
358 name = getglobal(this:GetParent():GetName().."EditBox"):GetText();
359 GRSS_TakeSnapShot(name);
360 this:GetParent():Hide();
361 end,
362 OnShow = function()
363 getglobal(this:GetName().."EditBox"):SetText("Wipe on "..GRSS_WipeCauser);
364 end,
365 timeout = 0,
366 whileDead = 1,
367 hideOnEscape = 1,
368 hasEditBox = 1,
369 };
370  
371 StaticPopupDialogs["GRSS_AUTOWAITLIST"] = {
372 text = "|c00ffff00%s|r is requesting to be added to the Wait List. Accept or Deny?",
373 button1 = "Accept",
374 button2 = "Deny",
375 OnAccept = function()
376 local last = table.getn(GRSS_WaitListRequest);
377 local name = GRSS_WaitListRequest[last];
378 GRSS_AddNameToWaitingList(name);
379 GRSS_SendWhisper("You've been added to the waiting list","WHISPER",nil,name);
380 end,
381 OnCancel = function()
382 local last = table.getn(GRSS_WaitListRequest);
383 local name = GRSS_WaitListRequest[last];
384 GRSS_SendWhisper("Your request to be added to the waiting list has been denied","WHISPER",nil,name);
385 end,
386 OnHide = function()
387 table.remove(GRSS_WaitListRequest);
388 if table.getn(GRSS_WaitListRequest) > 0 then
389 GRSS_NextWaitListRequest();
390 else
391 GRSS_WaitListRequestBoxOpen = 0;
392 end
393 end,
394 onShow = function()
395 GRSS_WaitListRequestBoxOpen = 1;
396 end,
397 timeout = 0,
398 whileDead = 1,
399 };
400  
401 end
402  
403  
404  
405 function GRSS_GetCalendar()
406  
407 local curmonth,curyear;
408 _,curmonth,_,curyear = CalendarGetDate();
409 if(GRSS_Calendar == nil) then
410 GRSS_Calendar = {};
411 end
412  
413 local keepers = {}
414 for m = -1,1 do
415 for d=1,31 do
416 local numevents = CalendarGetNumDayEvents(0,d);
417 --GRSSPrint("Num Events:"..numevents);
418 if numevents > 0 then
419 for e=1,numevents do
420  
421 local title, hour, minute, caltype,_,eventtype = CalendarGetDayEvent(m,d,e);
422 if eventtype > 0 then
423 if caltype=="GUILD" or caltype=="PLAYER" then
424 month = curmonth + m;
425 year = curyear;
426 if(month < 0) then
427 year = year - 1;
428 month = 12;
429 elseif(month > 12) then
430 year = year + 1;
431 month = 1;
432 end
433  
434 local found = GRSS_FindEvent(title,year,month,d,hour,minute);
435 if found == nil then
436 local event = {
437 title = title,
438 monthoffset = m,
439 month = month,
440 year = year,
441 day = d,
442 eventindex = e,
443 hour = hour,
444 minute = minute,
445 eventtype = eventtype
446 }
447 table.insert(GRSS_Calendar,event);
448 found = table.getn(GRSS_Calendar);
449  
450 end
451 keepers[found] = found;
452 end
453 end
454  
455 end
456 end
457 end
458 end
459  
460 for i,v in pairs(GRSS_Calendar) do
461 if keepers[i]==nil then
462 GRSS_Calendar[i] = nil;
463 end
464 end
465 end
466  
467 function GRSS_FindEvent(title,year,month,day,hour,minute)
468 for i,e in pairs(GRSS_Calendar) do
469 if(e.title == title and e.month==month and e.day==day and e.hour==hour and e.minute==minute and e.year==year) then
470 return i;
471 end
472 end
473 return nil;
474 end
475  
476 function GRSS_StoreEventDetails()
477 local title, desc, creator,eventtype,_,maxsize,_,_,month,day,year,hour,minute = CalendarGetEventInfo();
478  
479 local i = GRSS_FindEvent(title,year,month,day,hour,minute);
480 if i ~= nil then
481 GRSS_Calendar[i].description = desc;
482 GRSS_Calendar[i].creator = creator;
483 GRSS_Calendar[i].maxsize = maxsize;
484 local numinvites = CalendarEventGetNumInvites();
485 local invites = {}
486 for ii = 1,numinvites do
487 local name,level,className,_,inviteStatus,modStatus = CalendarEventGetInvite(ii);
488 local inv = {
489 name = name,
490 level = level,
491 class = className,
492 status = inviteStatus
493 };
494 table.insert(invites,inv);
495 end
496  
497 GRSS_Calendar[i].invites = invites;
498 end
499 end
500  
501 function GRSS_StartTimer(mins)
502 GRSS_Period = mins;
503 GRSS_NextTime = GetTime() + (GRSS_Period*60);
504 GRSS_TakeSnapShot("Periodic Snapshot");
505 GRSSPrint("Periodic Snapshots Started. Next Snapshot will be in "..mins.." minutes");
506 end
507  
508 function GRSS_StopTimer()
509 GRSS_Period = nil;
510 GRSS_NextTime = nil;
511 GRSSPrint("Periodic Snapshots Halted");
512 end
513  
514 function GRSS_Timer_OnUpdate()
515 if GRSS_ReadyForTimer and GRSS_Period and GRSS_NextTime then
516 local now = GetTime();
517 if now > GRSS_NextTime then
518 GRSS_TakeSnapShot("Periodic Snapshot");
519 GRSSPrint("Next snapshot will be in "..GRSS_Period.." minutes");
520 GRSS_NextTime = GetTime() + (GRSS_Period*60);
521 --GRSS_TimerNotify = {};
522 end
523 end
524  
525  
526 --GRSSPrint("update");
527 if type(GRSS_GeneralTimer)=="function" then
528 local now = GetTime();
529 if now > GRSS_GeneralTimeout then
530 GRSSPrint("Timeout");
531 GRSS_GeneralTimer();
532  
533 GRSS_GeneralTimer = nil;
534 GRSS_GeneralTimeout = nil;
535 end
536 end
537 end
538  
539 function GRSS_StartGeneralTimer(seconds,fun)
540 GRSS_GeneralTimer = fun;
541 GRSS_GeneralTimeout = GetTime() + seconds;
542 end
543  
544  
545 function GRSS_NextItemPopup()
546 if table.getn(GRSS_ItemQueue) > 0 then
547 local i = table.getn(GRSS_ItemQueue);
548 local item, name, points;
549 GRSS_PopupLootDate = GRSS_ItemQueue[i].date;
550 GRSS_PopupLootIndex = GRSS_ItemQueue[i].index;
551 item = GRSS_ItemQueue[i].item;
552 name = GRSS_ItemQueue[i].name;
553 GRSS_PopupPoints = GRSS_ItemQueue[i].points;
554 table.remove(GRSS_ItemQueue,i);
555 StaticPopup_Show("GRSS_ITEMPOINTS",name,item);
556 end
557 end
558  
559 function GRSS_EnqueueItem(date,index,name,item,points)
560 local temp = {};
561 temp.date = date;
562 temp.index = index;
563 temp.name = name;
564 temp.item = item;
565 temp.points = points;
566 table.insert(GRSS_ItemQueue,1,temp);
567 end
568  
569 function GRSSLootSave()
570 local system = UIDropDownMenu_GetText(GRSSLootSystemDropDown);
571 local player = GRSSLootPlayer:GetText();
572 local points = GRSSLootPoints:GetText();
573 local item = GRSSLootItem:GetText();
574 GRSSLootClear();
575 GRSSRecordItem(system,player,item,points);
576 end
577  
578 function GRSSRecordItemPointsOnly(points)
579  
580 local lootrec = GuildRaidSnapShot_Loot[GRSS_PopupLootDate][GRSS_PopupLootIndex];
581 local playername = lootrec.player;
582 local sys = lootrec.system;
583 local hardpoints = GRSSPlayerPointCost(playername,sys,points);
584 GuildRaidSnapShot_Loot[GRSS_PopupLootDate][GRSS_PopupLootIndex].points = points;
585 GuildRaidSnapShot_Loot[GRSS_PopupLootDate][GRSS_PopupLootIndex].hardpoints = hardpoints;
586 GRSS_RecordCurrentPlayerReceivedItem(points);
587  
588 if GRSS_Redistributing() then
589 GRSSObamaPoints(hardpoints)
590 end
591 end
592  
593 function GRSSAdjSave()
594 local system = UIDropDownMenu_GetText(GRSSAdjSystemDropDown);
595 local player = GRSSAdjPlayer:GetText();
596 local points = GRSSAdjPoints:GetText();
597 local desc = GRSSAdjDesc:GetText();
598 local adjtype = "";
599 if GRSS_Divide[system] then
600 adjtype = GRSS_GetAdjType();
601 end
602 GRSSAdjClear();
603 GRSSRecordAdj(system,player,item,points,adjtype,desc);
604 end
605  
606 function GRSSRecordItem(system,player,item,points)
607 local lootdate = date("%Y-%m-%d");
608 if(GuildRaidSnapShot_Loot[lootdate] == nil) then
609 GuildRaidSnapShot_Loot[lootdate] = {};
610 end
611 local iteminfo = {};
612 iteminfo.player = player;
613 iteminfo.item = item;
614 iteminfo.RealmName = GetRealmName();
615 iteminfo.date = date("%Y-%m-%d %H:%M:%S");
616 iteminfo.system = system;
617 iteminfo.points = points;
618 iteminfo.hardpoints = GRSSPlayerPointCost(player,system,points);
619  
620 if GRSS_Redistributing() then
621 GRSSObamaPoints(iteminfo.hardpoints);
622 end
623  
624 table.insert(GuildRaidSnapShot_Loot[lootdate],iteminfo);
625 if points ~= nil then
626 GRSSAddPoints(player,system,"spent",iteminfo.hardpoints);
627 end
628 return lootdate;
629 end
630  
631 function GRSSRecordAdj(system,player,item,points,adjtype,desc)
632 local lootdate = date("%Y-%m-%d");
633 if(GuildRaidSnapShot_Adj[lootdate] == nil) then
634 GuildRaidSnapShot_Adj[lootdate] = {};
635 end
636 local adjinfo = {};
637 adjinfo.player = player;
638 adjinfo.item = item;
639 adjinfo.RealmName = GetRealmName();
640 adjinfo.date = date("%Y-%m-%d %H:%M:%S");
641 adjinfo.system = system;
642 adjinfo.points = points;
643 adjinfo.adjtype = adjtype;
644 adjinfo.description = desc;
645  
646 table.insert(GuildRaidSnapShot_Adj[lootdate],adjinfo);
647 if points ~= nil then
648 if GRSS_Divide[system] then
649 GRSSAddPoints(player,system,adjtype,points);
650 else
651 GRSSAddPoints(player,system,"adj",points);
652 end
653 end
654 return lootdate;
655 end
656  
657 function GRSSLootClear()
658 getglobal("GRSSLootPlayer"):SetText("");
659 getglobal("GRSSLootPoints"):SetText("");
660 getglobal("GRSSLootItem"):SetText("");
661 end
662  
663 function GRSSAdjClear()
664 getglobal("GRSSAdjPlayer"):SetText("");
665 getglobal("GRSSAdjPoints"):SetText("");
666 getglobal("GRSSAdjDesc"):SetText("");
667 end
668  
669 function GRSS_RecalcSpentLoot()
670 if GuildRaidSnapShot_Loot then
671 for ld,daytable in pairs(GuildRaidSnapShot_Loot) do
672 for lootindex,loottable in pairs(daytable) do
673 if loottable.system == nil or GRSS_Systems[loottable.system]==nil then
674 loottable.system = GRSSCurrentSystem
675 end
676 --points = GRSSPlayerPointCost(loottable.player,loottable.system,loottable.points);
677 points = loottable.hardpoints;
678 if tonumber(points) == nil then
679 points = loottable.points;
680 end
681 if tonumber(points) ~= nil then
682 GRSSAddPoints(loottable.player,loottable.system,"spent",points);
683 end
684 end
685 end
686 end
687  
688 if GuildRaidSnapShot_Adj then
689 for ld,daytable in pairs(GuildRaidSnapShot_Adj) do
690 if daytable then
691 for adjindex,adjtable in pairs(daytable) do
692 if adjtable.system == nil or GRSS_Systems[adjtable.system]==nil then
693 adjtable.system = GRSSCurrentSystem
694 end
695 points = adjtable.points;
696 if tonumber(points) ~= nil then
697 if GRSS_Divide[adjtable.system] then
698 adjtype = adjtable.adjtype;
699 else
700 adjtype = "adj";
701 end
702 GRSSAddPoints(adjtable.player,adjtable.system,adjtype,points);
703 end
704 end
705 end
706 end
707 end
708  
709 if GuildRaidSnapShot_SnapShots then
710 for snapshot in pairs(GuildRaidSnapShot_SnapShots) do
711 GRSSAddSnapshotPoints(snapshot);
712 end
713 GRSSChangeSystem(GRSSCurrentSystem);
714 end
715 end
716  
717 function GRSSSetSnapshotPoints(points)
718 if string.lower(points)=="zs" or string.lower(points)=="sz" then
719 GRSSPrint("All Items received for the next 15 minutes will get redistributed and associated with this snapshot");
720 GRSS_Redistribute_SnapShot = GRSS_LastSnapShotName;
721 GRSS_Redistribute_SnapShot_ExpireTime = GetTime() + 15*60; -- Expire in 15 minutes
722 GuildRaidSnapShot_SnapShots[GRSS_LastSnapShotName].redistribute = 1;
723 GuildRaidSnapShot_SnapShots[GRSS_LastSnapShotName].points = 0;
724 else
725 GuildRaidSnapShot_SnapShots[GRSS_LastSnapShotName].points = points;
726 end
727 GRSSAddSnapshotPoints(GRSS_LastSnapShotName);
728 end
729  
730 -- This works for the whole snapshot
731 function GRSSAddSnapshotPoints(snapshotname)
732 local points = GRSSNumNilZero(GuildRaidSnapShot_SnapShots[snapshotname].points);
733 local sys = GuildRaidSnapShot_SnapShots[snapshotname].system;
734 local players = GRSS_ParsePlayers(GuildRaidSnapShot_SnapShots[snapshotname].Raid);
735 if GuildRaidSnapShot_SnapShots[snapshotname].redistribute then
736 points = points/table.getn(players);
737 end
738 for _,mem in pairs(players) do
739 GRSSAddPoints(mem,sys,"earned",points);
740 end
741 end
742  
743 -- Obama = Redistribution, get it? OLZOLZOLZ
744 -- This works only for newly added items, to adjust the previous value of a snapshot when an item is received and redistributed
745 function GRSSObamaPoints(totalpoints)
746 local snapshotname = GRSS_Redistribute_SnapShot;
747 local curpoints = GuildRaidSnapShot_SnapShots[snapshotname].points;
748 local sys = GuildRaidSnapShot_SnapShots[snapshotname].system;
749 local players = GRSS_ParsePlayers(GuildRaidSnapShot_SnapShots[snapshotname].Raid);
750 local newpoints = curpoints + totalpoints;
751 GuildRaidSnapShot_SnapShots[snapshotname].points = newpoints;
752  
753 local toadd = totalpoints / table.getn(players);
754  
755 for _,mem in pairs(players) do
756 GRSSAddPoints(mem,sys,"earned",toadd);
757 end
758 end
759  
760 -- Returns the snapshot name if we are redistributing, else, returns nil
761 function GRSS_Redistributing()
762 if GRSS_Redistribute_SnapShot_ExpireTime > 0 and GetTime() < GRSS_Redistribute_SnapShot_ExpireTime then
763 return GRSS_Redistribute_SnapShot;
764 else
765 return nil;
766 end
767 end
768  
769 function GRSSTrim (s)
770 return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
771 end
772  
773  
774 function GRSS_ParsePlayers(str)
775 local retarr = {};
776 local pzarr = { strsplit(",",str) }; -- Players with Zones
777 for _,pz in pairs(pzarr) do
778 local p,z = strsplit(":",pz);
779 if(z~="Offline") then
780 table.insert(retarr,GRSSTrim(p));
781 end
782 end
783 return retarr;
784 end
785  
786 function GRSS_PendingSnapshotCheck()
787 local items = 0;
788 local snapshots = 0;
789 local adjustments = 0;
790  
791 for _ in pairs(GuildRaidSnapShot_SnapShots) do
792 snapshots = snapshots + 1;
793 end
794  
795 for i,v in pairs(GuildRaidSnapShot_Adj) do
796 adjustments = adjustments + table.getn(v);
797 end
798  
799 for i,v in pairs(GuildRaidSnapShot_Loot) do
800 items = items + table.getn(v);
801 end
802 if snapshots > 0 or items > 0 or adjustments > 0 then
803 local msg = items.." items, "..snapshots.." snapshots, and "..adjustments.." adjustments";
804 StaticPopup_Show("GRSS_RAIDCHECK",msg);
805 end
806 end
807  
808  
809 function GRSS_TimerRunningCheck()
810 if GRSS_NextTime then
811 local mins = math.floor((GRSS_NextTime - GetTime())/60);
812 if mins < 0 then
813 mins = 0
814 end
815 StaticPopup_Show("GRSS_TIMERCHECK",mins);
816 else
817 GRSS_ReadyForTimer = true;
818 end
819 end
820  
821  
822  
823 --
824 function GRSS_RecordCurrentPlayerReceivedItem(pointstr)
825 playername = string.lower(GuildRaidSnapShot_Loot[GRSS_PopupLootDate][GRSS_PopupLootIndex].player);
826 normalplayername = GuildRaidSnapShot_Loot[GRSS_PopupLootDate][GRSS_PopupLootIndex].player;
827 points = GRSSPlayerPointCost(playername,GRSSCurrentSystem,pointstr);
828  
829 if tonumber(points) ~= nil and tonumber(points) ~= 0 then
830 points = tonumber(points);
831 GRSSAddPoints(normalplayername,GRSSCurrentSystem,"spent",points);
832  
833 temp = "Today: "..normalplayername.." <-- "..GuildRaidSnapShot_Loot[GRSS_PopupLootDate][GRSS_PopupLootIndex].item.." for "..points;
834  
835 if GRSS_ItemHistory[string.upper(playername)] ~= nil then
836 table.insert(GRSS_ItemHistory[string.upper(playername)],temp);
837 else
838 GRSS_ItemHistory[string.upper(playername)] = {};
839 GRSS_ItemHistory[string.upper(playername)][0] = temp;
840 end
841 GRSSScrollBar_Update();
842 end
843 end
844  
845 function GRSS_GetItemPoints(item)
846 for i,v in pairs(GRSS_ItemPrices[GRSSCurrentSystem]) do
847 if string.lower(item)==string.lower(v.name) then
848 return v.points;
849 end
850 end
851 return "";
852 end
853  
854 --Sorts the Temp table GRSS_DKP
855 function GRSSSortBy(sort)
856 GRSS_CurrentSort = sort;
857  
858  
859 table.sort(GRSS_DKP,
860 function(a,b)
861 if sort=="spent" then
862 if GRSSCurrentAction == "DKP Standings" then
863 return GRSSNum(a.spent) > GRSSNum(b.spent);
864 elseif GRSSCurrentAction == "Rolls" or GRSSCurrentAction=="DKP+Roll" then
865 return GRSSNum(a.roll) > GRSSNum(b.roll);
866 elseif GRSSCurrentAction == "Bids" or GRSSCurrentAction == "Bid+Roll" then
867 return GRSSNum(a.bid) > GRSSNum(b.bid);
868 end
869 elseif sort=="bidroll" or (GRSSCurrentAction=="Bid+Roll" and sort=="adj") then
870 return GRSSNumNilZero(a.roll) + GRSSNumNilZero(a.bid) > GRSSNumNilZero(b.roll) + GRSSNumNilZero(b.bid);
871 elseif sort=="rankid" then
872 return GRSSNum(a.rankid) < GRSSNum(b.rankid);
873 elseif a[sort]==b[sort] then
874 return GRSSNum(a.total) > GRSSNum(b.total);
875 elseif sort=="name" or sort=="class" then
876 return (string.lower(a[sort]) < string.lower(b[sort]))
877 else
878 return (GRSSNum(a[sort]) > GRSSNum(b[sort]))
879 end
880 end
881 );
882 GRSSScrollBar_Update();
883 end
884  
885 --Sorts the Full table generated by the downloader: GRSS_Full_DKP
886 function GRSSSortByFull(sort,sys)
887 table.sort(GRSS_Full_DKP[sys],
888 function(a,b)
889 if sort=="spent" then
890 if GRSSCurrentAction == "DKP Standings" then
891 return GRSSNum(a.spent) > GRSSNum(b.spent);
892 elseif GRSSCurrentAction == "Rolls" then
893 return GRSSNum(a.roll) > GRSSNum(b.roll);
894 elseif GRSSCurrentAction == "Bids" then
895 return GRSSNum(a.bid) > GRSSNum(b.bid);
896 end
897 elseif a[sort]==b[sort] then
898 return GRSSNum(a.earned) + GRSSNum(a.adj) - GRSSNum(a.spent) > GRSSNum(b.earned) + GRSSNum(b.adj) - GRSSNum(b.spent);
899 elseif sort=="name" or sort=="class" then
900 return (string.lower(a[sort]) < string.lower(b[sort]))
901 else
902 return (GRSSNum(a[sort]) > GRSSNum(b[sort]))
903 end
904 end
905 );
906 end
907  
908 function GRSSChangeSystem(sys)
909 if sys ~= nil then
910 local inc = 1;
911 local i,v;
912 local top = table.getn(GRSS_Full_DKP[sys]);
913 GRSS_DKP = {};
914 local RaidTable = GRSS_RaidTable();
915  
916 if GRSS_RaidFilter == "Raid Only" and GRSS_MainOnly[sys] then
917 for name,v in pairs(RaidTable) do
918 if GRSS_Alts[string.lower(name)] then
919 RaidTable[string.upper(GRSS_Alts[string.lower(name)])] = 1;
920 end
921 end
922 end
923  
924 if(GRSS_RaidFilter == "" or GRSS_RaidFilter == nil) then
925 GRSS_RaidFilter = "All";
926 end
927 for i=1,top do
928 if GRSS_RaidFilter == "All" or RaidTable[string.upper(GRSS_Full_DKP[sys][i].name)]==1 then
929 if GRSS_ClassFilter == "All" or string.upper(GRSS_Full_DKP[sys][i].class) == string.upper(GRSS_ClassFilter) then
930 GRSS_DKP[inc] = {};
931 GRSS_DKP[inc].name = GRSS_Full_DKP[sys][i].name;
932 GRSS_DKP[inc].class = GRSS_Full_DKP[sys][i].class;
933 GRSS_DKP[inc].earned = GRSS_Full_DKP[sys][i].earned;
934 GRSS_DKP[inc].spent = GRSS_Full_DKP[sys][i].spent;
935 GRSS_DKP[inc].adj = GRSS_Full_DKP[sys][i].adj;
936 if GRSS_Divide and GRSS_Divide[sys] then
937 GRSS_DKP[inc].total = GRSS_DKP[inc].earned/GRSSNumNilOne(GRSS_DKP[inc].spent);
938 else
939 GRSS_DKP[inc].total = GRSS_DKP[inc].earned + GRSS_DKP[inc].adj - GRSS_DKP[inc].spent
940 end
941 GRSS_DKP[inc].bid = ""
942 GRSS_DKP[inc].roll = ""
943 GRSS_DKP[inc].rank = GRSS_Full_DKP[sys][i].rank;
944 GRSS_DKP[inc].rankid = GRSS_Full_DKP[sys][i].rankid;
945 inc = inc + 1;
946 end
947 end
948 end
949 GRSSScrollBar_Update();
950 GRSSSortBy("total");
951 GRSSScrollBar:Show();
952 if table.getn(GRSS_NumberedSystems)==0 then
953 for mysys in pairs(GRSS_Systems) do
954 table.insert(GRSS_NumberedSystems,mysys);
955 end
956 end
957 end
958 end
959  
960  
961 function GRSSGenerateBids()
962 GRSS_Bids = {};
963 local temp = {};
964 local n = 24;
965 local m = table.getn(GRSS_DKP);
966 for i=1,n do
967 temp = {};
968 temp.name = GRSS_DKP[math.random(m)].name;
969 temp.bid = math.random(1000);
970 table.insert(GRSS_Bids,temp);
971 end
972 GRSSBidsScrollBar_Update();
973 end
974  
975  
976 function GRSSNum(v)
977 v = tonumber(v);
978 if v == nil then
979 v = -9999999
980 end
981 return v;
982 end
983  
984  
985 function GRSSNumNilOne(v)
986 v = tonumber(v);
987 if v==nil or v==0 then
988 v = 1;
989 end
990 return v;
991 end
992  
993 function GRSSNumNilZero(v)
994 v = tonumber(v);
995 if v == nil then
996 v = 0
997 end
998 return v;
999 end
1000  
1001  
1002  
1003 function GRSSScrollBar_Update()
1004 local line; -- 1 through 10 of our window to scroll
1005 local lineplusoffset; -- an index into our data calculated from the scroll offset
1006 local earned,sent,adj;
1007 FauxScrollFrame_Update(GRSSScrollBar,table.getn(GRSS_DKP),10,16);
1008 for line=1,10 do
1009 lineplusoffset = line + FauxScrollFrame_GetOffset(GRSSScrollBar);
1010 if lineplusoffset <= table.getn(GRSS_DKP) then
1011 earned = "";
1012 spent = "";
1013 adj = "";
1014 total = GRSS_DKP[lineplusoffset].total; -- Default Val for that
1015 if GRSSCurrentAction == "DKP Standings" then
1016 spent = GRSS_DKP[lineplusoffset].spent;
1017 earned = GRSS_DKP[lineplusoffset].earned;
1018 adj = GRSS_DKP[lineplusoffset].adj;
1019 elseif GRSSCurrentAction == "Rolls" then
1020 spent = GRSS_DKP[lineplusoffset].roll;
1021 elseif GRSSCurrentAction == "Bids" then
1022 spent = GRSS_DKP[lineplusoffset].bid;
1023 elseif GRSSCurrentAction == "Bid+Roll" then
1024 earned = GRSS_DKP[lineplusoffset].roll;
1025 spent = GRSS_DKP[lineplusoffset].bid;
1026 adj = GRSSNumNilZero(earned) + GRSSNumNilZero(spent);
1027 if adj==0 then
1028 adj = "";
1029 end
1030 elseif GRSSCurrentAction == "DKP+Roll" then
1031 earned = GRSS_DKP[lineplusoffset].roll;
1032 if GRSSNumNilZero(earned) > 0 then
1033 adj = GRSSNumNilZero(earned) + total;
1034 end
1035 end
1036  
1037 getglobal("GRSSRow"..line.."FieldPlayer"):SetText(GRSS_DKP[lineplusoffset].name);
1038 getglobal("GRSSRow"..line.."FieldClass"):SetText(GRSS_DKP[lineplusoffset].class);
1039 getglobal("GRSSRow"..line.."FieldRank"):SetText(GRSS_DKP[lineplusoffset].rank);
1040 getglobal("GRSSRow"..line.."FieldEarned"):SetText(earned);
1041 getglobal("GRSSRow"..line.."FieldSpent"):SetText(spent);
1042 getglobal("GRSSRow"..line.."FieldAdj"):SetText(adj);
1043 if tonumber(GRSS_DKP[lineplusoffset].total) ~= nil then
1044 getglobal("GRSSRow"..line.."FieldDKP"):SetText(string.format("%.2f",GRSS_DKP[lineplusoffset].total));
1045 else
1046 getglobal("GRSSRow"..line.."FieldDKP"):SetText(GRSS_DKP[lineplusoffset].total);
1047 end
1048 getglobal("GRSSRow"..line.."FieldPlayer"):Show();
1049 getglobal("GRSSRow"..line.."FieldClass"):Show();
1050 getglobal("GRSSRow"..line.."FieldRank"):Show();
1051 getglobal("GRSSRow"..line.."FieldEarned"):Show();
1052 getglobal("GRSSRow"..line.."FieldSpent"):Show();
1053 getglobal("GRSSRow"..line.."FieldAdj"):Show();
1054 getglobal("GRSSRow"..line.."FieldDKP"):Show();
1055 getglobal("GRSSRow"..line.."FieldHighlight"):Show();
1056  
1057 else
1058 getglobal("GRSSRow"..line.."FieldPlayer"):Hide();
1059 getglobal("GRSSRow"..line.."FieldClass"):Hide();
1060 getglobal("GRSSRow"..line.."FieldRank"):Hide();
1061 getglobal("GRSSRow"..line.."FieldEarned"):Hide();
1062 getglobal("GRSSRow"..line.."FieldSpent"):Hide();
1063 getglobal("GRSSRow"..line.."FieldAdj"):Hide();
1064 getglobal("GRSSRow"..line.."FieldDKP"):Hide();
1065 getglobal("GRSSRow"..line.."FieldHighlight"):Hide();
1066  
1067 end
1068 end
1069 end
1070  
1071 function GRSSBidsScrollBar_Update()
1072 local line; -- 1 through 10 of our window to scroll
1073 local lineplusoffset; -- an index into our data calculated from the scroll offset
1074 local earned,sent,adj;
1075 FauxScrollFrame_Update(GRSSBidsScrollBar,table.getn(GRSS_Bids),23,16);
1076 for line=1,23 do
1077 lineplusoffset = line + FauxScrollFrame_GetOffset(GRSSBidsScrollBar);
1078 if lineplusoffset <= table.getn(GRSS_Bids) then
1079 getglobal("GRSSBidsRow"..line.."FieldPlayer"):SetText(GRSS_Bids[lineplusoffset].name);
1080 getglobal("GRSSBidsRow"..line.."FieldBid"):SetText(GRSS_Bids[lineplusoffset].bid);
1081 getglobal("GRSSBidsRow"..line.."FieldBidType"):SetText(GRSS_Bids[lineplusoffset].bidtype);
1082 getglobal("GRSSBidsRow"..line.."FieldPlayer"):Show();
1083 getglobal("GRSSBidsRow"..line.."FieldBid"):Show();
1084 getglobal("GRSSBidsRow"..line.."FieldBidType"):Show();
1085 getglobal("GRSSBidsRow"..line.."Delete"):Show();
1086 getglobal("GRSSBidsRow"..line.."FieldHighlight"):Show();
1087 else
1088 getglobal("GRSSBidsRow"..line.."FieldPlayer"):Hide();
1089 getglobal("GRSSBidsRow"..line.."FieldBid"):Hide();
1090 getglobal("GRSSBidsRow"..line.."FieldBidType"):Hide();
1091 getglobal("GRSSBidsRow"..line.."FieldHighlight"):Hide();
1092 getglobal("GRSSBidsRow"..line.."Delete"):Hide();
1093 end
1094 end
1095 end
1096  
1097 function nn(v)
1098 if v == nil then
1099 return "nil"
1100 else
1101 return v;
1102 end
1103 end
1104  
1105 function GuildRaidSnapShot_OnEvent(event,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
1106 if(event == "CHAT_MSG_MONSTER_YELL") then
1107 if GRSS_Auto==1 and GRSS_Yells[arg2] ~= nil then
1108 if string.find(arg1,GRSS_Yells[arg2]) ~= nil then
1109 if InCombatLockdown() then
1110 GRSS_PendingSnapShotName = arg2;
1111 else
1112 GRSS_TakeSnapShot(arg2);
1113 end
1114 end
1115 end
1116 elseif(event == "CHAT_MSG_RAID_BOSS_EMOTE") then
1117 if GRSS_Auto == 1 then
1118 for i,v in ipairs(GRSS_BossEmote) do
1119 if string.find(arg1,v) then
1120 if InCombatLockdown() then
1121 GRSS_PendingSnapShotName = i;
1122 else
1123 GRSS_TakeSnapShot(i);
1124 end
1125 end
1126 end
1127 end
1128 elseif(event == "PLAYER_REGEN_ENABLED") then
1129 if GRSS_PendingSnapShotName ~= "" then
1130 GRSS_TakeSnapShot(GRSS_PendingSnapShotName);
1131 GRSS_PendingSnapShotName = "";
1132 end
1133 if table.getn(GRSS_ItemQueue) > 0 then
1134 GRSS_NextItemPopup();
1135 end
1136 if table.getn(GRSS_WaitListRequest)>0 then
1137 GRSS_NextWaitListRequest()
1138 end
1139 elseif(event=="PLAYER_DEAD" or event=="CHAT_MSG_COMBAT_FRIENDLY_DEATH") then
1140 GRSS_WipeCheck();
1141 elseif(event=="COMBAT_LOG_EVENT_UNFILTERED") then
1142 if(arg2=="PARTY_KILL" or arg2=="UNIT_DIED") then
1143 if not IsActiveBattlefieldArena() then
1144 if GRSS_FastBossLookup[arg7] ~= nil and GRSS_Auto == 1 then
1145 if InCombatLockdown() then
1146 GRSS_PendingSnapShotName = arg7;
1147 else
1148 GRSS_TakeSnapShot(arg7);
1149 end
1150 end
1151 end
1152 end
1153 elseif(event=="PLAYER_TARGET_CHANGED") then
1154 local name = UnitName("target");
1155 if name ~= nil and GRSS_FastBossLookup[name]~= nil then
1156 GRSS_WipeCauser = name;
1157 end
1158 elseif(event == "PLAYER_GUILD_UPDATE") then
1159 GuildRoster();
1160 elseif(event == "VARIABLES_LOADED") then
1161 GRSSInviteScrollBar_Update();
1162 GRSS_PendingSnapshotCheck();
1163 GRSS_TimerRunningCheck();
1164 elseif(event == "CALENDAR_OPEN_EVENT" or event=="CALENDAR_UPDATE_EVENT" or event=="CALENDAR_UPDATE_EVENT_LIST" or event=="CALENDAR_NEW_EVENT") then
1165 GRSS_GetCalendar();
1166 GRSS_StoreEventDetails();
1167 elseif(event == "GUILD_ROSTER_UPDATE") then
1168 GRSS_TakeGuildOnly();
1169 elseif(event == "CHAT_MSG_LOOT") then
1170 GRSS_CaptureLoot(arg1);
1171 elseif(event == "RAID_ROSTER_UPDATE") then
1172 GRSS_RaidChange(arg1,arg2);
1173 elseif(event == "LOOT_OPENED") then
1174 GRSS_GetLoot();
1175 elseif(event == "CHAT_MSG_WHISPER") then
1176 GRSS_ProcessWhisper(arg2,arg1,this.language);
1177 elseif(event == "CHAT_MSG_SYSTEM") then
1178 if GRSS_Rolling==1 or GRSS_BidRolls then
1179 local name, roll;
1180 for name, roll in string.gmatch(arg1, "(.+) rolls (%d+) %(1%-"..GRSS_RollNumber.."%)") do
1181 GRSS_RecordRoll(name, roll);
1182 if GRSS_BidRolls==1 then
1183 GRSSSortBy("bidroll");
1184 else
1185 GRSSSortBy("roll");
1186 end
1187  
1188 end
1189 end
1190 elseif(event == "ADDON_LOADED") then
1191 UIDropDownMenu_SetText(GRSSRollNumberDropDown,"1-"..GRSSNumNilZero(GRSS_RollNumber));
1192 end
1193 end
1194  
1195 function GRSS_IsZoneIgnored()
1196 local zone = GetRealZoneText();
1197 for i,v in pairs(GRSS_ZoneIgnore) do
1198 if v == zone then
1199 return 1;
1200 end
1201 end
1202 return nil;
1203 end
1204  
1205 function GRSS_WipeCheck()
1206 if GRSS_Auto and GRSS_AutoWipe==1 and not IsActiveBattlefieldArena() and not GRSS_IsZoneIgnored() then
1207 local num = GetNumRaidMembers();
1208 local is_dead,online,dead,alive,name;
1209 dead = 0;
1210 if num>1 then
1211 for i = 1, num do
1212 name,_,_,_,_,_,_,online,is_dead = GetRaidRosterInfo(i);
1213 if is_dead or not online then
1214 dead = dead + 1
1215 end
1216 end
1217 end
1218 if (dead/num) >= 0.7 then
1219 if(GetTime() > GRSS_LastWipeTime+120) then
1220 GRSS_LastWipeTime = GetTime();
1221 StaticPopup_Show("GRSS_WIPE");
1222 end
1223 end
1224 end
1225 end
1226  
1227 function GRSS_RecordRoll(name,roll)
1228 local itemname = GRSSItemName:GetText()
1229 for i,v in pairs(GRSS_DKP) do
1230 if string.lower(v.name)==string.lower(name) or (GRSS_MainOnly[GRSSCurrentSystem] and GRSS_Alts[string.lower(name)]==string.lower(v.name)) then
1231 if GRSS_DKP[i].roll == "" or GRSS_DKP[i].roll == nil then
1232 GRSS_DKP[i].roll = roll;
1233 GRSS_SendWhisper("Your roll of "..roll.." for "..itemname.." has been recorded","WHISPER",nil,name);
1234 end
1235 return;
1236 end
1237 end
1238 temp = {};
1239 temp.name = name;
1240 temp.class = "?";
1241 temp.spent = "";
1242 temp.earned = "";
1243 temp.adj = "";
1244 temp.roll = roll;
1245 temp.total = "?";
1246 GRSS_SendWhisper("Your roll of "..roll.." for "..itemname.." has been recorded","WHISPER",nil,name);
1247 table.insert(GRSS_DKP,1,temp);
1248 --GRSSScrollBar_Update();
1249 end
1250  
1251  
1252 function GRSS_SendWhisper(msg,msgtype,lang,to)
1253 SendChatMessage(GRSS_Prefix..msg,msgtype,lang,to);
1254 end
1255  
1256 -- Will search S for the regular expressions and return the result of the first successful search, or nil if none is found
1257 -- Allows for a briefer way rather than doing if string.find, then return, elseif string.find....
1258 function GRSS_MultiRegex(s,...)
1259 for i,v in ipairs({...}) do
1260 if(string.find(s,v)) then
1261 return string.find(s,v);
1262 end
1263 end
1264 return nil;
1265 end
1266  
1267 function GRSS_ProcessWhisper(from,msg,lang)
1268 temp = {};
1269 if(string.find(msg,"^!waitlistwho") or string.find(msg,"^!whowaitlist")) then
1270 local _,waitlist = GRSS_WaitCommaList();
1271 GRSS_SendWhisper("Waiting List: "..waitlist,"WHISPER",lang,from);
1272 elseif(string.find(msg,"^!waitlist")) then
1273 if not GRSS_IsNameQueuedOnWaitList(from) then
1274 GRSS_QueueWaitListRequest(from)
1275 end
1276 if GRSS_IsNameOnWaitingList(from) then
1277 GRSS_SendWhisper("You're already on the waiting list","WHISPER",lang,from);
1278 elseif InCombatLockdown() then
1279 GRSS_SendWhisper("Your request to be added to the waiting list has been received, but I am currently in combat. When I am out of combat, I will be able to respond to your request","WHISPER",lang,from);
1280 elseif GRSS_WaitListRequestBoxOpen==0 then
1281 GRSS_NextWaitListRequest()
1282 end
1283 elseif(string.find(msg,"^!bid") or string.find(msg,"^!req")) then
1284 if GRSS_Bidding == 1 or GRSS_BidRolls==1 then
1285 local bidtype;
1286 local amtsrch = "%s+(%d*)";
1287 s,e,bidtype,amt = GRSS_MultiRegex(msg,
1288 "^!bid(main)"..amtsrch,
1289 "^!bid(off)"..amtsrch,
1290 "^!bid(alt)"..amtsrch,
1291 "^!(bid)"..amtsrch
1292 );
1293 if bidtype=="main" then
1294 bidtype = "Main";
1295 elseif bidtype=="off" then
1296 bidtype = "Offspec";
1297 elseif bidtype=="alt" then
1298 bidtype = "Alt";
1299 else
1300 bidtype = "";
1301 end
1302 temp.name = from;
1303 if GRSS_BidStyle=="Requests" and GRSS_BidRolls==nil then
1304 amt = "R";
1305 else
1306 if amt=="" then
1307 amt = "blank";
1308 else
1309 amt = GRSSNumNilZero(amt);
1310 end
1311 end
1312 temp.bid = amt;
1313 temp.bidtype = bidtype;
1314 table.insert(GRSS_Bids,temp);
1315 GRSSBidsScrollBar_Update();
1316  
1317 if GRSS_BidRolls==1 then
1318 GRSS_SendWhisper("Your bid of "..amt.." has been recorded. Remember to also /roll "..GRSS_RollNumber.." if you haven't yet","WHISPER",lang,from);
1319 elseif GRSS_BidStyle=="Silent Non-Auction" then
1320 GRSS_SendWhisper("Your bid of "..amt.." has been recorded","WHISPER",lang,from);
1321 elseif GRSS_BidStyle=="Requests" then
1322 GRSS_SendWhisper("Your request has been recorded","WHISPER",lang,from);
1323 elseif GRSS_BidStyle=="Silent Auction" or GRSS_BidStyle=="Open Auction" then
1324 if tonumber(amt)~=nil and tonumber(amt) > GRSS_HighBid then
1325 GRSS_SendWhisper("You are now the high bidder with "..amt,"WHISPER",lang,from);
1326 GRSS_HighBid = tonumber(amt);
1327 if GRSS_HighBidder ~= from and GRSS_HighBidder ~= "" then
1328 GRSS_SendWhisper("You are no longer the high bidder. The high bid is now "..GRSS_HighBid..".","WHISPER",nil,GRSS_HighBidder);
1329 end
1330 GRSS_HighBidder = from;
1331 if GRSS_BidStyle=="Silent Auction" then
1332 SendChatMessage("The high bid is now "..amt,"RAID");
1333 else
1334 SendChatMessage(GRSS_HighBidder.." is now the high bidder with "..amt,"RAID");
1335 end
1336 elseif tonumber(amt)~=nil and tonumber(amt) < GRSS_HighBid then
1337 GRSS_SendWhisper(amt.." is too low","WHISPER",lang,from);
1338 elseif tonumber(amt)~=nil and tonumber(amt) == GRSS_HighBid then
1339 GRSS_SendWhisper("Your bid of "..amt.." ties you with the high bidder", "WHISPER", lang, from);
1340 else
1341 GRSS_SendWhisper("Your bid was not understood. Please specify a number. (ie: !bid 365)","WHISPER",lang,from);
1342 end
1343 end
1344 local found=false;
1345 for i,v in pairs(GRSS_DKP) do
1346 if string.lower(v.name)==string.lower(from) or (GRSS_MainOnly[GRSSCurrentSystem] and GRSS_Alts[string.lower(from)]==string.lower(v.name)) then
1347 if tonumber(GRSS_DKP[i].bid)==nil or (tonumber(amt) ~= nil and tonumber(GRSS_DKP[i].bid) < tonumber(amt)) then
1348 GRSS_DKP[i].bid = amt;
1349 end
1350 found=true
1351 end
1352 end
1353 if found==false then
1354 temp = {};
1355 temp.name = from;
1356 temp.class = "?";
1357 temp.spent = "";
1358 temp.earned = "";
1359 temp.adj = "";
1360 temp.bid = amt;
1361 temp.total = "?";
1362 table.insert(GRSS_DKP,1,temp);
1363 end
1364 if GRSS_BidRolls==1 then
1365 GRSSSortBy("bidroll");
1366 else
1367 GRSSSortBy("bid");
1368 end
1369 GRSSScrollBar_Update();
1370 else
1371 GRSS_SendWhisper("Sorry, bids are not being received right now", "WHISPER", lang, from);
1372 end
1373 elseif(string.find(msg,"^!dkpclass")) then
1374 s,e,class = string.find(msg,"^!dkpclass%s+(.+)");
1375 if class==nil or class == "" then
1376 GRSS_SendWhisper("You need to specify a class (i.e. !dkpclass mage)", "WHISPER", lang, from);
1377 else
1378 found = false;
1379 local classes = {};
1380 for w in string.gmatch(string.upper(class),"(%a+)") do
1381 classes[w]=w;
1382 end
1383 if string.find(string.lower(class),"death%s*knight") then
1384 classes["DEATH KNIGHT"]="DEATH KNIGHT";
1385 end
1386 for sys in pairs(GRSS_Systems) do
1387 GRSSSortByFull("total",sys);
1388 for i,v in pairs(GRSS_Full_DKP[sys]) do
1389 if classes[string.upper(v.class)] then
1390 local total;
1391 if GRSS_Divide[sys] == nil then
1392 total = tonumber(v.earned) + tonumber(v.adj) - tonumber(v.spent)
1393 else
1394 total = GRSSNumNilZero(v.earned) / GRSSNumNilOne(v.spent);
1395 end
1396 GRSS_SendWhisper("("..sys..") "..v.name.."("..v.class.."): "..total,"WHISPER",lang,from);
1397 found=true;
1398 end
1399 end
1400 end
1401 if found==false then
1402 GRSS_SendWhisper("Sorry, no players were found with the class "..class,"WHISPER",lang,from);
1403 end
1404 end
1405 elseif(string.find(msg,"^!dkpraid")) then
1406 s,e,sysid = string.find(msg,"^!dkpraid%s+(.+)%s*");
1407 if sysid==nil or sys=="" or GRSS_NumberedSystems[GRSSNumNilZero(sysid)]==nil then
1408 GRSS_SendWhisper("You'll need to specify one of the following DKP Systems in the following form...","WHISPER",lang,from);
1409 for sysid,sys in pairs(GRSS_NumberedSystems) do
1410 GRSS_SendWhisper("For "..sys..": !dkpraid "..sysid,"WHISPER",lang,from);
1411 end
1412 else
1413 sys = GRSS_NumberedSystems[GRSSNumNilZero(sysid)];
1414 GRSSSortByFull("total",sys);
1415 RaidTable = GRSS_RaidTable();
1416 GRSS_SendWhisper("Sending DKP for "..sys.." (only showing Raid Members)","WHISPER",lang,from);
1417 for i,v in pairs(GRSS_Full_DKP[sys]) do
1418 if RaidTable[string.upper(v.name)]==1 then
1419 local total = GRSSNumNilZero(v.earned) + GRSSNumNilZero(v.adj) - GRSSNumNilZero(v.spent)
1420 GRSS_SendWhisper(v.name.."("..v.class.."): "..total,"WHISPER",lang,from);
1421 found=true;
1422 end
1423 end
1424 end
1425 elseif(string.find(msg,"^!dkpall")) then
1426 s,e,sysid = string.find(msg,"^!dkpall%s+(.+)%s*");
1427 if sysid==nil or sys=="" or GRSS_NumberedSystems[GRSSNumNilZero(sysid)]==nil then
1428 GRSS_SendWhisper("You'll need to specify one of the following DKP Systems in the following form...","WHISPER",lang,from);
1429 for sysid,sys in pairs(GRSS_NumberedSystems) do
1430 GRSS_SendWhisper("For "..sys..": !dkpall "..sysid,"WHISPER",lang,from);
1431 end
1432 else
1433 local count = 0;
1434 sys = GRSS_NumberedSystems[GRSSNumNilZero(sysid)];
1435 GRSSSortByFull("total",sys);
1436 GRSS_SendWhisper("Sending DKP for "..sys.." (Only showing top 40)","WHISPER",lang,from);
1437 for i,v in pairs(GRSS_Full_DKP[sys]) do
1438 if count < 40 then
1439 local total;
1440 if GRSS_Divide[sys] == nil then
1441 total = GRSSNumNilZero(v.earned) + GRSSNumNilZero(v.adj) - GRSSNumNilZero(v.spent)
1442 else
1443 total = GRSSNumNilZero(v.earned) / GRSSNumNilOne(v.spent);
1444 end
1445 --local total = GRSSNumNilZero(v.earned) + GRSSNumNilZero(v.adj) - GRSSNumNilZero(v.spent)
1446 GRSS_SendWhisper(v.name.."("..v.class.."): "..total,"WHISPER",lang,from);
1447 found=true;
1448 count = count + 1
1449 end
1450 end
1451 end
1452 elseif(string.find(msg,"^!dkp")) then
1453 s,e,name = string.find(msg,"^!dkp%s*(.*)");
1454 if name == "" then
1455 name = from;
1456 end
1457 tosend = GRSSGetPlayerDKP(name);
1458 for i,v in pairs(tosend) do
1459 GRSS_SendWhisper(v, "WHISPER", lang, from);
1460 end
1461 if table.getn(tosend)==0 then
1462 GRSS_SendWhisper("No player named "..name.." found", "WHISPER", lang, from);
1463 end
1464 elseif(string.find(msg,"^!items")) then
1465 s,e,name = string.find(msg,"^!items%s*(.*)%s*");
1466 if name == "" then
1467 playername = string.upper(from);
1468 else
1469 playername = string.upper(name);
1470 end
1471 if GRSS_ItemHistory[playername] ~= nil then
1472 for i,v in pairs(GRSS_ItemHistory[playername]) do
1473 GRSS_SendWhisper(v,"WHISPER",lang,from);
1474 end
1475 else
1476 GRSS_SendWhisper("There is no item history for "..playername,"WHISPER",lang,from);
1477 end
1478 elseif(string.find(msg,"^!price%s")) then
1479 s,e,itemraw = string.find(msg,"^!price%s+(.*)%s*");
1480 s,e,color,item = string.find(itemraw, "|c(%x+)|Hitem:%d+:%d+:%d+:%d+|h%[(.-)%]|h|r");
1481 if not s then
1482 item = itemraw
1483 end
1484 found = false;
1485 for sys in pairs(GRSS_Systems) do
1486 for i,v in pairs(GRSS_ItemPrices[sys]) do
1487 if string.find(string.lower(v.name),string.lower(item)) then
1488 if GRSSNumNilZero(v.points) > 0 then
1489 GRSS_SendWhisper("("..sys..") "..v.name..": "..v.points.." points","WHISPER",lang,from);
1490 found = true;
1491 end
1492 end
1493 end
1494 end
1495 if found == false then
1496 GRSS_SendWhisper("Sorry no item by the name of '"..item.." was found","WHISPER",lang,from);
1497 end
1498  
1499 elseif(string.find(msg,"^!help") or string.find(msg,"^!%?") or string.find(msg,"^!info") or string.find(msg,"^!commands")) then
1500 if string.upper(from) == string.upper(UnitName("player")) then
1501 for i,v in pairs(GRSSHelpMsg) do
1502 GRSSPrint(v);
1503 end
1504 else
1505 for i,v in pairs(GRSSHelpMsg) do
1506 GRSS_SendWhisper(v,"WHISPER",lang,from);
1507 end
1508 end
1509 end
1510 end
1511  
1512 function GRSSFindPlayerSystemIndex(playername,sys)
1513 playername = string.lower(playername);
1514  
1515 if GRSS_MainOnly[sys]==1 and GRSS_Alts[playername] then
1516 playername = GRSS_Alts[playername];
1517 end
1518  
1519 if GRSS_Full_DKP[sys]==nil then
1520 GRSS_Full_DKP[sys] = {};
1521 end
1522 for i,v in pairs(GRSS_Full_DKP[sys]) do
1523 if(string.lower(v.name)==playername) then
1524 return i;
1525 end
1526 end
1527 return -1;
1528 end
1529  
1530 function GRSSLookupPlayerDKP(playername,sys)
1531 local i = GRSSFindPlayerSystemIndex(playername,sys);
1532 if i == -1 then
1533 return 0;
1534 else
1535 local v = GRSS_Full_DKP[sys][i];
1536 if(string.lower(v.name)==playername) then
1537 local total;
1538 if(GRSS_Divide[sys] == nil) then
1539 total = GRSSNumNilZero(v.earned) + GRSSNumNilZero(v.adj) - GRSSNumNilZero(v.spent);
1540 else
1541 if(v.spent == 0) then
1542 v.spent = 1;
1543 end
1544 total = GRSSNumNilZero(v.earned) / GRSSNumNilZero(v.spent);
1545 end
1546 return total;
1547 end
1548 end
1549 end
1550  
1551 function GRSSAddPoints(playername,sys,pointtype,points)
1552 if sys==nil then
1553 sys = GRSSCurrentSystem
1554 end
1555 if sys==nil then
1556 return;
1557 end
1558 local i = GRSSFindPlayerSystemIndex(playername,sys);
1559 if i == -1 then
1560 local temp = {};
1561 temp.name = playername;
1562 temp.class = "?";
1563 temp.spent = 0;
1564 temp.earned = 0;
1565 temp.adj = 0;
1566 temp.rank = "?";
1567 temp.rankid = 0;
1568 table.insert(GRSS_Full_DKP[sys],temp);
1569 i = GRSSFindPlayerSystemIndex(playername,sys);
1570 end
1571 GRSS_Full_DKP[sys][i][pointtype] = GRSSNumNilZero(GRSS_Full_DKP[sys][i][pointtype]) + GRSSNumNilZero(points);
1572 if GRSSCurrentSystem == sys then
1573 GRSSChangeSystem(sys);
1574 end
1575 end
1576  
1577 function GRSSPlayerPointCost(playername,sys,pointstr)
1578 playername = string.lower(playername);
1579 if pointstr==nil then
1580 return 0;
1581 elseif tonumber(pointstr) then --if the points entered are a number, just return that number
1582 return tonumber(pointstr);
1583 else --if it's entered as a percentage, fetch the current DKP, and return the corresponding percentage
1584 local matches = {string.match(pointstr,"^([%d%.]+)%%$")};
1585 if matches then
1586 local percent = GRSSNumNilZero(matches[1])/100;
1587 local current = GRSSLookupPlayerDKP(playername,sys);
1588 return current * percent;
1589 else
1590 return 0;
1591 end
1592 end
1593 end
1594  
1595 function GRSSGetPlayerDKP(players)
1596 local dkp = {};
1597 for sys in pairs(GRSS_Systems) do
1598 for i,v in pairs(GRSS_Full_DKP[sys]) do
1599 for name in string.gmatch(players,"([%S,]+)") do
1600 if string.lower(v.name)==string.lower(name) then
1601 local total;
1602 if GRSS_Divide[sys] == nil then
1603 total = GRSSNumNilZero(v.earned) + GRSSNumNilZero(v.adj) - GRSSNumNilZero(v.spent)
1604 else
1605 total = GRSSNumNilZero(v.earned) / GRSSNumNilOne(v.spent);
1606 end
1607 --total = GRSSNumNilZero(v.earned) + GRSSNumNilZero(v.adj) - GRSSNumNilZero(v.spent);
1608 table.insert(dkp,"("..sys..") "..name.."("..v.class.."): "..total);
1609 end
1610 end
1611 end
1612 end
1613 return dkp;
1614 end
1615  
1616 function GRSS_CompareVersions()
1617 if not GRSSNewVersionPrinted then
1618 if GRSSNewestVersion then
1619 if GRSSNewestVersion~=GRSSVersion then
1620 GRSSNewVersionPrinted = true;
1621 GRSSPrint("|c00ff0000There is a newer version of the GuildRaidSnapShot mod ("..GRSSNewestVersion..") available. Please download the newest version from www.dkpsystem.com|r");
1622 end
1623 end
1624 end
1625 end
1626  
1627 function GuildRaidSnapShot_SlashHandler(msg)
1628 local newboss;
1629 msglower = string.lower(msg);
1630 if msglower=="" or msglower=="help" or msglower=="?" then
1631 for i,v in pairs(GRSSUsage) do
1632 DEFAULT_CHAT_FRAME:AddMessage(v);
1633 end
1634 for i,v in pairs(GRSSHelpMsg) do
1635 local tellcolor = "|c00ffff00";
1636 local endcolor = "|r";
1637 v = string.gsub(v,"^(.+) = (.+)",tellcolor.."%1"..endcolor.." = %2");
1638 DEFAULT_CHAT_FRAME:AddMessage(v);
1639 end
1640 elseif msglower=="reset" or msglower=="purge" then
1641 GuildRaidSnapShot_SnapShots = {};
1642 GuildRaidSnapShot_Loot = {};
1643 GuildRaidSnapShot_Adj = {};
1644 GRSSPrint("Snapshots Purged");
1645 elseif msglower == "noauto" then
1646 GRSS_Auto = 0;
1647 GRSSPrint("Auto Snapshots Disabled");
1648 elseif msglower == "yesauto" then
1649 GRSS_Auto = 1;
1650 GRSSPrint("Auto Snapshots Enabled");
1651 elseif msglower == "yesloot" then
1652 GRSS_LootCap = 1;
1653 GRSSPrint("Looting will now result in popups prompting for points");
1654 elseif msglower == "noloot" then
1655 GRSS_LootCap = 0;
1656 GRSSPrint("Looting will no longer result in popups prompting for points");
1657 elseif msglower == "yessnapshotpopup" or msglower == "yessnapshotpopups" or msglower == "yessnapshotpoints" then
1658 GRSS_RaidPointsPopup = 1;
1659 GRSSPrint("Raid snapshots will now now prompt for points");
1660 elseif msglower == "nosnapshotpopup" or msglower == "nosnapshotpopups" or msglower == "nosnapshotpoints" then
1661 GRSSPrint("Raid snapshots will no longer result in popups prompting for points");
1662 GRSS_RaidPointsPopup = 0;
1663 elseif msglower == "yeslootcombat" then
1664 GRSS_LootPromptInCombat = 1;
1665 GRSSPrint("Loot prompts will now pop up immediately");
1666 elseif msglower == "nolootcombat" then
1667 GRSS_LootPromptInCombat = 0;
1668 GRSSPrint("Loot prompts will now wait to pop once you're out of combat");
1669 elseif msglower == "show" then
1670 GRSS:Show();
1671 GRSS_CompareVersions();
1672 elseif msglower == "loot" or msglower == "item" then
1673 GRSSLoot:Show();
1674 elseif msglower=="adj" or msglower=="adjustment" then
1675 GRSSAdjShowHideType()
1676 GRSSAdj:Show();
1677 elseif msglower == "invite" or msglower=="waitlist" or msglower=="wait" then
1678 GRSSInvite:Show();
1679 elseif msglower == "starttimer" then
1680 StaticPopup_Show("GRSS_STARTTIMER");
1681 elseif msglower == "stoptimer" then
1682 GRSS_StopTimer();
1683 elseif msglower == "yesscreenshot" then
1684 GRSSPrint("Screenshots of the raid will be taken when snapshots are initiated");
1685 GRSS_TakeScreenshots = 1
1686 elseif msglower == "noscreenshot" then
1687 GRSS_TakeScreenshots = nil
1688 GRSSPrint("Screenshots of the raid will no longer be taken when snapshots are initiated");
1689 elseif msglower == "yeswipe" then
1690 GRSS_AutoWipe = 1;
1691 GRSSPrint("Wipe Detection enabled");
1692 elseif msglower == "nowipe" then
1693 GRSS_AutoWipe = 0;
1694 GRSSPrint("Wipe Detection disabled");
1695 elseif GetNumRaidMembers() > 0 or GetNumPartyMembers() > 0 then
1696 GRSS_TakeSnapShot(msg);
1697 else
1698 GRSSPrint("You're not in a raid");
1699 end
1700 end
1701  
1702 function GRSS_CaptureLoot(msg)
1703 if GetNumRaidMembers()>0 or GetNumPartyMembers()>0 then
1704 local s, e, player, link = string.find(msg, "([^%s]+) receives loot: (.+)%.");
1705 if(player == nil) then
1706 s, e, link = string.find(msg, "You receive loot: (.+)%.");
1707 if(link ~= nil) then
1708 player = UnitName("player");
1709 end
1710 end
1711 --GRSS_Auto = link;
1712 if(link and player) then
1713 local s, e, color, item = string.find(link, "|c(%x+)|Hitem[:%d%-]+|h%[(.-)%]|h|r");
1714 if(color and item and GRSS_Colors[color]) then
1715 -- Checking to see if the item listed is one we should ignore
1716 for i,v in pairs(GRSS_LootIgnore) do
1717 if string.find(item,v) then
1718 return;
1719 end
1720 end
1721 local lootdate = GRSSRecordItem(GRSSCurrentSystem,player,item,nil);
1722 --loot search
1723  
1724 if GRSS_LootCap == 1 then
1725 GRSS_CurrentLootDate = lootdate;
1726 lootindex = table.getn(GuildRaidSnapShot_Loot[lootdate]);
1727 if GRSS_HighBid==0 or GRSS_Highbid == nil then
1728 points = GRSS_GetItemPoints(GuildRaidSnapShot_Loot[lootdate][lootindex].item);
1729 else
1730 points = GRSS_HighBid;
1731 end
1732 GRSS_EnqueueItem(lootdate,lootindex,player,link,points);
1733 if GRSS_ItemBoxOpen==0 and (not(InCombatLockdown()) or GRSS_LootPromptInCombat==1) then
1734 GRSS_NextItemPopup();
1735 end
1736 end
1737 end
1738 end
1739 end
1740 end
1741  
1742  
1743 function GRSS_TakeSnapShot(name)
1744 local SnapShotName = name.." "..date("%Y-%m-%d %H:%M:%S");
1745 GRSS_LastSnapShotName = SnapShotName;
1746 if GRSS_LastSnapshot == nil then
1747 GRSS_LastSnapshot = 0
1748 end
1749 if GuildRaidSnapShot_SnapShots[SnapShotName]==nil and GetTime() > GRSS_LastSnapshot+4 then
1750 GRSS_LastSnapshot = GetTime();
1751 GuildRaidSnapShot_SnapShots[SnapShotName] = {};
1752 GuildRaidSnapShot_SnapShots[SnapShotName].RealmName = GetRealmName();
1753 GuildRaidSnapShot_SnapShots[SnapShotName].system = GRSSCurrentSystem;
1754 GuildRaidSnapShot_SnapShots[SnapShotName].points = 0;
1755  
1756 local OnlineRaid,RaidList = GRSS_RaidCommaList();
1757 GuildRaidSnapShot_SnapShots[SnapShotName]["Raid"] = RaidList;
1758  
1759 local OnlineGuild,GuildList = GRSS_GuildCommaList();
1760 GuildRaidSnapShot_SnapShots[SnapShotName]["Guild"] = GuildList;
1761  
1762 local OnlineWaitingList,WaitingList = GRSS_WaitCommaList();
1763 GuildRaidSnapShot_SnapShots[SnapShotName]["WaitList"] = WaitingList;
1764  
1765 GRSSPrint("SnapShot Taken: "..SnapShotName.." (Guild: "..OnlineGuild.." | Raid: "..OnlineRaid.." | Waiting List: "..OnlineWaitingList..")");
1766 if GRSS_TakeScreenshots==1 then
1767 Screenshot();
1768 end
1769  
1770 GRSS_LastSnapShotPoints = GRSS_BossPoints(name,GRSSCurrentSystem);
1771  
1772 if(GRSS_RaidPointsPopup==1) then
1773 StaticPopup_Show("GRSS_RAIDPOINTS",name);
1774 end
1775 end
1776 end
1777  
1778 function GRSS_BossPoints(bossname,sys)
1779 if GRSS_Dests then
1780 for i,b in pairs(GRSS_Dests) do
1781 if string.lower(b.boss)==string.lower(bossname) then
1782 return b.points;
1783 end
1784 end
1785 end
1786 return "";
1787 end
1788  
1789 function GRSS_PlayerRank(player)
1790  
1791 end
1792  
1793 function GRSS_BossRatio(bossname,sys,player)
1794 local rank = GRSS_PlayerRank(player);
1795 for i,b in pairs(GRSS_Dests) do
1796 if string.lower(b.boss)==string.lower(bossname) then
1797 if b.ratios[sys] then
1798 if b.ratios[sys][rank] then
1799 return b.ratios[sys][rank];
1800 end
1801 end
1802 end
1803 end
1804 return 1;
1805 end
1806  
1807 function GRSS_TakeGuildOnly()
1808 local members="", level,class,online,rank,notes;
1809 GRSS_Guild = {};
1810 local n = GetNumGuildMembers(true);
1811 local NumOnline = 0;
1812 for i = 1, n do
1813 MemName,rank,_,level,class,_,notes,_,_,online = GetGuildRosterInfo(i);
1814 if notes == nil then
1815 notes = "";
1816 end
1817 GRSS_Guild[MemName] = level .. ";" .. class..";"..rank..";;;"..notes;
1818 end
1819  
1820 end
1821  
1822 function GRSS_TakeGuildNotes()
1823 local members="", notes,num;
1824 num =0;
1825 GuildRoster();
1826 GRSS_Guild = {};
1827 local n = GetNumGuildMembers(true);
1828 local NumOnline = 0;
1829 GuildRaidSnapShot_Notes = {};
1830 for i = 1, n do
1831 MemName,_,_,_,_,_,notes = GetGuildRosterInfo(i);
1832 if notes ~= "" then
1833 num = num + 1;
1834 GuildRaidSnapShot_Notes[MemName] = notes;
1835 end
1836 end
1837 GRSSPrint("Guild notes Snapshot Taken: "..num.." Guild Notes Captured");
1838 end
1839  
1840  
1841 function GRSS_RaidCommaList()
1842 local members="";
1843 local NumOnline=0;
1844 local zone="";
1845 local con;
1846 local n = GetNumRaidMembers();
1847 if GetNumRaidMembers()>1 then
1848 for i = 1, n do
1849 MemName,_,_,_,_,_,zone,Online = GetRaidRosterInfo(i);
1850 if Online==1 then
1851 if zone==nil then
1852 zone = ""
1853 end
1854 else
1855 zone = "Offline";
1856 end
1857 members = members..MemName..":"..zone;
1858 if i ~= n then
1859 members = members .. ", "
1860 end
1861 NumOnline=NumOnline+1;
1862 end
1863 if GRSS_TakeScreenshots==1 then
1864 if InCombatLockdown() then
1865 GRSSPrint("You're currently in combat, so I can't open the raid window for this snapshot");
1866 else
1867 ToggleFriendsFrame(1);
1868 ToggleFriendsFrame(5);
1869 end
1870 end
1871 else
1872 n = GetNumPartyMembers();
1873 zone = "";
1874 for i = 1, n do
1875 MemName = UnitName("party"..i);
1876 if UnitIsConnected("party"..i) then
1877 con=1
1878 else
1879 con=0
1880 end
1881 if MemName ~= nil and con==1 then
1882 members = members..MemName..":"..zone..", ";
1883  
1884 NumOnline = NumOnline + 1
1885 end
1886 end
1887 members = members..UnitName("player")..":"..zone;
1888 NumOnline = NumOnline + 1;
1889 end
1890 return NumOnline,members
1891 end
1892  
1893 function GRSS_GuildCommaList()
1894 local members="";
1895 local online;
1896 local zone="";
1897 GuildRoster();
1898 local n = GetNumGuildMembers(false);
1899 local NumOnline = 0;
1900 for i = 1, n do
1901 MemName,_,_,_,_,zone,_,_,online = GetGuildRosterInfo(i);
1902 if zone==nil then
1903 zone = ""
1904 end
1905 if online==1 then
1906 members = members..MemName .. ":" .. zone;
1907 if i ~= n then
1908 members = members .. ", "
1909 end
1910 NumOnline = NumOnline + 1;
1911 end
1912 end
1913 return NumOnline,members;
1914 end
1915  
1916  
1917 function GRSS_WaitCommaList()
1918 local num = table.getn(GRSS_WaitingList);
1919 local waitlist = "";
1920 for i = 1, num do
1921 waitlist = waitlist..GRSS_WaitingList[i]
1922 if i<num then
1923 waitlist = waitlist..", ";
1924 end
1925 end
1926 return num,waitlist;
1927 end
1928  
1929  
1930 function GRSS_RaidTable()
1931 local members={};
1932 local NumOnline=0;
1933 local con;
1934 local n = GetNumRaidMembers();
1935 if GetNumRaidMembers()>1 then
1936 for i = 1, n do
1937 MemName,_,_,_,_,_,_,Online = GetRaidRosterInfo(i);
1938 if Online==1 then
1939 members[string.upper(MemName)]=1;
1940 end
1941 end
1942 else
1943 n = GetNumPartyMembers();
1944 zone = "";
1945 for i = 1, n do
1946 MemName = UnitName("party"..i);
1947 if UnitIsConnected("party"..i) then
1948 con=1
1949 else
1950 con=0
1951 end
1952 if MemName ~= nil and con==1 then
1953 members[string.upper(MemName)]=1;
1954 end
1955 end
1956 members[string.upper(UnitName("player"))]=1;
1957 end
1958 return members;
1959 end
1960  
1961 function GRSS_GuildTable()
1962 local members={};
1963 local online;
1964 GuildRoster();
1965 local n = GetNumGuildMembers(false);
1966 local NumOnline = 0;
1967 for i = 1, n do
1968 MemName,_,_,_,_,_,_,_,online = GetGuildRosterInfo(i);
1969 if online==1 then
1970 members[string.upper(MemName)]=1;
1971 end
1972 end
1973 return members;
1974 end
1975  
1976 function GRSSSystemDropDown_OnLoad()
1977 GRSS_Initialize_Data();
1978 GRSSChangeSystem(GRSSCurrentSystem);
1979 UIDropDownMenu_Initialize(this, GRSSSystemDropDown_Initialize);
1980 if GRSS_Systems[GRSSCurrentSystem]~=nil then
1981 UIDropDownMenu_SetText(GRSSSystemDropDown,GRSSCurrentSystem);
1982 else
1983 UIDropDownMenu_SetText(GRSSSystemDropDown,"Select System");
1984 end
1985 UIDropDownMenu_SetWidth(GRSSSystemDropDown,130);
1986 end
1987  
1988 function GRSSLootSystemDropDown_OnLoad()
1989 --GRSS_Initialize_Data();
1990 UIDropDownMenu_Initialize(this, GRSSLootSystemDropDown_Initialize);
1991 if GRSS_Systems[GRSSCurrentSystem]~=nil then
1992 UIDropDownMenu_SetText(GRSSLootSystemDropDown,GRSSCurrentSystem);
1993 else
1994 UIDropDownMenu_SetText(GRSSLootSystemDropDown,"Select System");
1995 end
1996 UIDropDownMenu_SetWidth(GRSSLootSystemDropDown,130);
1997 end
1998  
1999 function GRSSAdjSystemDropDown_OnLoad()
2000 --GRSS_Initialize_Data();
2001 UIDropDownMenu_Initialize(this, GRSSAdjSystemDropDown_Initialize);
2002 if GRSS_Systems[GRSSCurrentSystem]~=nil then
2003 UIDropDownMenu_SetText(GRSSAdjSystemDropDown,GRSSCurrentSystem);
2004 else
2005 UIDropDownMenu_SetText(GRSSAdjSystemDropDown,"Select System");
2006 end
2007 UIDropDownMenu_SetWidth(GRSSAdjSystemDropDown,130);
2008 end
2009  
2010  
2011 function GRSSActionDropDown_OnLoad()
2012 UIDropDownMenu_Initialize(this, GRSSActionDropDown_Initialize);
2013 UIDropDownMenu_SetText(GRSSActionDropDown,"DKP Standings");
2014 UIDropDownMenu_SetWidth(GRSSActionDropDown,110);
2015 end
2016  
2017 function GRSSBidStyleDropDown_OnLoad()
2018 UIDropDownMenu_Initialize(this, GRSSBidStyleDropDown_Initialize);
2019 if GRSS_BidStyle == "" then
2020 UIDropDownMenu_SetText(GRSSBidStyleDropDown,"Bidding Style");
2021 else
2022 UIDropDownMenu_SetText(GRSSBidStyleDropDown,GRSS_BidStyle);
2023 end
2024 UIDropDownMenu_SetWidth(GRSSBidStyleDropDown,110);
2025 end
2026  
2027 function GRSSBidStyleDropDown_Initialize()
2028 local Actions = {"Silent Auction","Silent Non-Auction","Open Auction","Requests"};
2029 local info = {};
2030  
2031 info.notCheckable = nil;
2032 info.keepShownOnClick = nil;
2033 info.func = GRSS_ChangeBidStyle;
2034 for i,v in pairs(Actions) do
2035 info.text = v;
2036 info.value = v;
2037 UIDropDownMenu_AddButton(info);
2038 end
2039 end
2040  
2041 function GRSS_ChangeBidStyle()
2042 UIDropDownMenu_SetText(GRSSBidStyleDropDown,this.value);
2043 GRSS_BidStyle = this.value;
2044 end
2045  
2046 function GRSSSpamDropDown_OnLoad()
2047 UIDropDownMenu_Initialize(this, GRSSSpamDropDown_Initialize);
2048 UIDropDownMenu_SetText(GRSSSpamDropDown,"Spam Chat");
2049 UIDropDownMenu_SetWidth(GRSSSpamDropDown,110);
2050 end
2051  
2052 function GRSSAdjTypeDropDown_OnLoad()
2053 UIDropDownMenu_Initialize(this, GRSSAdjTypeDropDown_Initialize);
2054 UIDropDownMenu_SetText(GRSSAdjTypeDropDown,"EP(Earned)");
2055 UIDropDownMenu_SetWidth(GRSSAdjTypeDropDown,90);
2056 end
2057  
2058 function GRSSSpamDropDown_Initialize()
2059 local Actions = {"RAID","PARTY","GUILD","SAY","OFFICER"};
2060 local info = {};
2061  
2062 info.notCheckable = nil;
2063 info.keepShownOnClick = nil;
2064 info.func = GRSS_ChangeSpam;
2065 for i,v in pairs(Actions) do
2066 info.text = v;
2067 info.value = v;
2068 UIDropDownMenu_AddButton(info);
2069 end
2070 end
2071  
2072 function GRSSAdjTypeDropDown_Initialize()
2073 local Actions = {"EP(Earned)","GP(Spent)"};
2074 local info = {};
2075  
2076 info.notCheckable = nil;
2077 info.keepShownOnClick = nil;
2078 info.func = GRSS_SetAdjType;
2079 for i,v in pairs(Actions) do
2080 info.text = v;
2081 info.value = v;
2082 UIDropDownMenu_AddButton(info);
2083 end
2084 end
2085  
2086 function GRSS_GetAdjType()
2087 local adjtype = UIDropDownMenu_GetText(GRSSAdjTypeDropDown);
2088 if string.find(adjtype,"EP") then
2089 adjtype = "earned";
2090 elseif string.find(adjtype,"GP") then
2091 adjtype = "spent";
2092 else
2093 adjtype = "adj";
2094 end
2095 return adjtype;
2096 end
2097  
2098 function GRSS_SetAdjType()
2099 UIDropDownMenu_SetText(GRSSAdjTypeDropDown,this.value);
2100 local s,e,adjtype = string.find(this.value,"^(%w+)%(");
2101 end
2102  
2103 function GRSS_ChangeSpam()
2104 local place = this.value;
2105 SendChatMessage("The following are for the DKP System: "..GRSSCurrentSystem,place);
2106 if table.getn(GRSS_DKP) > 40 then
2107 SendChatMessage("Only showing the top 40",place);
2108 end
2109 local count=0;
2110 for i,v in pairs(GRSS_DKP) do
2111 if count < 40 then
2112 GRSS_SendWhisper(v.name..": "..v.total,place);
2113 count = count + 1;
2114 end
2115 end
2116 end
2117  
2118  
2119 function GRSSRaidFilterDropDown_OnLoad()
2120 UIDropDownMenu_Initialize(this, GRSSRaidFilterDropDown_Initialize);
2121 if GRSS_Spam == "" then
2122 UIDropDownMenu_SetText(GRSSRaidFilterDropDown,"All");
2123 else
2124 UIDropDownMenu_SetText(GRSSRaidFilterDropDown,GRSS_RaidFilter);
2125 end
2126 UIDropDownMenu_SetWidth(GRSSRaidFilterDropDown,90);
2127 end
2128  
2129 function GRSSRaidFilterDropDown_Initialize()
2130 local Actions = {"All","Raid Only"};
2131 local info = {};
2132  
2133 info.notCheckable = nil;
2134 info.keepShownOnClick = nil;
2135 info.func = GRSS_ChangeRaidFilter;
2136 for i,v in pairs(Actions) do
2137 info.text = v;
2138 info.value = v;
2139 UIDropDownMenu_AddButton(info);
2140 end
2141 end
2142  
2143 function GRSS_ChangeRaidFilter()
2144 UIDropDownMenu_SetText(GRSSRaidFilterDropDown,this.value);
2145 GRSS_RaidFilter = this.value;
2146 GRSSChangeSystem(GRSSCurrentSystem);
2147 end
2148  
2149 function GRSSClassFilterDropDown_OnLoad()
2150 UIDropDownMenu_Initialize(this, GRSSClassFilterDropDown_Initialize);
2151 if GRSS_BidStyle == "" then
2152 UIDropDownMenu_SetText(GRSSClassFilterDropDown,"All");
2153 else
2154 UIDropDownMenu_SetText(GRSSClassFilterDropDown,GRSS_ClassFilter);
2155 end
2156 UIDropDownMenu_SetWidth(GRSSClassFilterDropDown,90);
2157 end
2158  
2159 function GRSSClassFilterDropDown_Initialize()
2160 local Actions = {"All","Druid","Hunter","Mage","Paladin","Priest","Rogue","Shaman","Warlock","Warrior","Death Knight"};
2161 local info = {};
2162  
2163 info.notCheckable = nil;
2164 info.keepShownOnClick = nil;
2165 info.func = GRSS_ChangeClassFilter;
2166 for i,v in pairs(Actions) do
2167 info.text = v;
2168 info.value = v;
2169 UIDropDownMenu_AddButton(info);
2170 end
2171 end
2172  
2173  
2174 function GRSS_ChangeClassFilter()
2175 UIDropDownMenu_SetText(GRSSClassFilterDropDown,this.value);
2176 GRSS_ClassFilter = this.value;
2177 GRSSChangeSystem(GRSSCurrentSystem);
2178 end
2179  
2180 function GRSSRollNumberDropDown_OnLoad()
2181  
2182 UIDropDownMenu_Initialize(this, GRSSRollNumberDropDown_Initialize);
2183 UIDropDownMenu_SetText(GRSSRollNumberDropDown,"1-"..GRSSNumNilZero(GRSS_RollNumber));
2184 UIDropDownMenu_SetWidth(GRSSRollNumberDropDown,110);
2185 end
2186  
2187 function GRSSRollNumberDropDown_Initialize()
2188 local Actions = {"1-100","1-1000","1-1337"};
2189 local info = {};
2190  
2191 info.notCheckable = nil;
2192 info.keepShownOnClick = nil;
2193 info.func = GRSS_ChangeRollNumber;
2194 for i,v in pairs(Actions) do
2195 info.text = v;
2196 info.value = v;
2197 UIDropDownMenu_AddButton(info);
2198 end
2199 end
2200  
2201 function GRSS_ChangeRollNumber()
2202 UIDropDownMenu_SetText(GRSSRollNumberDropDown,this.value);
2203 local s,e,num = string.find(this.value,"1%-(%d+)")
2204 GRSS_RollNumber = num;
2205 end
2206  
2207  
2208 function GRSSSystemDropDown_OnClick()
2209 GRSSCurrentSystem = this.value;
2210 UIDropDownMenu_SetText(GRSSSystemDropDown,this.value);
2211 this.isChecked=true;
2212 GRSSChangeSystem(GRSSCurrentSystem);
2213 end
2214  
2215 function GRSSLootSystemDropDown_OnClick()
2216 GRSSLootCurrentSystem = this.value;
2217 UIDropDownMenu_SetText(GRSSLootSystemDropDown,this.value);
2218 this.isChecked=true;
2219 end
2220  
2221 function GRSSAdjSystemDropDown_OnClick()
2222 UIDropDownMenu_SetText(GRSSAdjSystemDropDown,this.value);
2223 GRSSAdjShowHideType()
2224 this.isChecked=true;
2225 end
2226  
2227 function GRSSAdjShowHideType()
2228 local system = UIDropDownMenu_GetText(GRSSAdjSystemDropDown);
2229 if GRSS_Divide[system] then
2230 GRSSAdjTypeDropDown:Show();
2231 else
2232 GRSSAdjTypeDropDown:Hide();
2233 end
2234 end
2235  
2236  
2237 function GRSS_DeleteBid(line)
2238 lineplusoffset = line + FauxScrollFrame_GetOffset(GRSSBidsScrollBar);
2239 amount = GRSS_Bids[lineplusoffset].bid;
2240 name = GRSS_Bids[lineplusoffset].name;
2241 table.remove(GRSS_Bids,lineplusoffset);
2242 playerhigh = 0;
2243 totalhigh = 0;
2244 highbidder = "";
2245 for i,v in pairs(GRSS_Bids) do
2246 if string.lower(v.name)==string.lower(name) then
2247 if tonumber(v.bid)~=nil and tonumber(v.bid) > playerhigh then
2248 playerhigh = tonumber(v.bid);
2249 end
2250 end
2251 if tonumber(v.bid)~=nil and tonumber(v.bid) > totalhigh then
2252 totalhigh = tonumber(v.bid);
2253 highbidder = v.name;
2254 end
2255 end
2256 if GRSS_HighBid ~= totalhigh and GRSS_Bidding==1 then
2257 GRSS_HighBid = totalhigh;
2258 GRSS_HighBidder = highbidder;
2259 if GRSS_BidStyle=="Silent Auction" then
2260 SendChatMessage("The high bid has been changed to "..GRSS_HighBid,"RAID");
2261 elseif GRSS_BidStyle=="Open Auction" then
2262 SendChatMessage(highbidder.." is now the high bidder with "..totalhigh,"RAID");
2263 end
2264 end
2265  
2266 for i,v in pairs(GRSS_DKP) do
2267 if string.lower(v.name)==string.lower(name) then
2268 GRSS_DKP[i].bid = playerhigh;
2269 end
2270 end
2271 GRSSBidsScrollBar_Update();
2272 GRSSScrollBar_Update();
2273 end
2274  
2275 function GRSSActionDropDown_Initialize()
2276 local Actions = {"DKP Standings","Rolls","Bids","Bid+Roll","DKP+Roll"};
2277 local info = {};
2278  
2279 info.notCheckable = nil;
2280 info.keepShownOnClick = nil;
2281 info.func = GRSS_DoAction;
2282 for i,v in pairs(Actions) do
2283 info.text = v;
2284 info.value = v;
2285 UIDropDownMenu_AddButton(info);
2286 end
2287 end
2288  
2289 function GRSSSetHeaders(earned,spent,adj,total)
2290 GRSSHeaderEarnedText:SetText(earned);
2291 GRSSHeaderSpentText:SetText(spent);
2292 GRSSHeaderAdjText:SetText(adj);
2293 GRSSHeaderDKPText:SetText(total);
2294 end
2295  
2296 function GRSSShowHeaders(t)
2297 if t=="DKP Standings" then
2298 GRSSSetHeaders("Earned","Spent","Adj","Total");
2299 elseif t=="Bids" then
2300 GRSSSetHeaders("","Bid","","DKP");
2301 elseif t=="Rolls" then
2302 GRSSSetHeaders("","Roll","","DKP");
2303 elseif t=="Bid+Roll" then
2304 GRSSSetHeaders("Roll","Bid","Bid+Roll","DKP");
2305 elseif t=="DKP+Roll" then
2306 GRSSSetHeaders("Roll","","DKP+Roll","DKP");
2307 end
2308 end
2309  
2310  
2311  
2312 function GRSS_ActionShow(...)
2313 local hide = {"GRSSBids","GRSSToggleBids","GRSSClearBids","GRSSBidStyleDropDown","GRSSToggleRolls","GRSSClearRolls","GRSSRollNumberDropDown","GRSSRaidFilterDropDown","GRSSClassFilterDropDown","GRSSSpamDropDown","GRSSLootDropDown","GRSSItemName"};
2314 for i,v in pairs(hide) do
2315 getglobal(v):Hide();
2316 end
2317 for i,v in pairs({...}) do
2318 getglobal(v):Show();
2319 end
2320 end
2321  
2322 function GRSS_ToggleRolls()
2323 local itemname = GRSSItemName:GetText()
2324 if GRSS_Rolling == 1 then
2325 GRSSToggleRolls:SetText("Start Rolls");
2326 GRSSRollNumberDropDown:Show();
2327 GRSS_Rolling = 0;
2328 GRSS_EnableFunctionalButtons(1);
2329 SendChatMessage("Rolling Ended on "..itemname..". No more rolls will be recorded", "RAID");
2330 SendChatMessage("Rolling Ended on "..itemname..". No more rolls will be recorded", "RAID_WARNING");
2331 else
2332 GRSSToggleRolls:SetText("Stop Rolls");
2333 GRSSRollNumberDropDown:Hide();
2334 GRSS_Rolling = 1;
2335 GRSS_EnableFunctionalButtons(0);
2336 SendChatMessage("Rolling Started on "..itemname..". If you are interested /random "..GRSS_RollNumber..". Rolls with anything but "..GRSS_RollNumber.." will be ignored.", "RAID");
2337 SendChatMessage("Rolling Started on "..itemname..". If you are interested /random "..GRSS_RollNumber..".", "RAID_WARNING");
2338 end
2339 end
2340  
2341  
2342 function GRSS_EnableFunctionalButtons(tf)
2343 if tf == 1 then
2344 GRSSClearBids:Enable();
2345 GRSSClearRolls:Enable();
2346 GRSSSystemDropDown:Show();
2347 GRSSActionDropDown:Show();
2348 GRSSItemName:Show();
2349 GRSSLootDropDown:Show();
2350 else
2351 GRSSClearBids:Disable();
2352 GRSSClearRolls:Disable();
2353 GRSSBidStyleDropDown:Hide();
2354 GRSSSystemDropDown:Hide();
2355 GRSSActionDropDown:Hide();
2356 GRSSItemName:Hide();
2357 GRSSLootDropDown:Hide();
2358 end
2359 end
2360  
2361  
2362 function GRSS_ToggleBids()
2363 local player = UnitName("player");
2364 local itemname = GRSSItemName:GetText()
2365 if GRSS_Bidding == 1 then
2366 GRSSToggleBids:SetText("Start Bids");
2367 GRSS_Bidding = nil;
2368 GRSS_BidRolls = nil;
2369 GRSS_EnableFunctionalButtons(1);
2370  
2371 if GRSSCurrentAction == "Bid+Roll" then
2372 GRSSRollNumberDropDown:Show();
2373 else
2374 GRSSBidStyleDropDown:Show();
2375 end
2376 msg = "Bidding Ended for "..itemname..". No more bids will be recorded"
2377 else
2378 GRSSToggleBids:SetText("Stop Bids");
2379 GRSS_Bidding = 1;
2380 GRSS_EnableFunctionalButtons(0);
2381 GRSS_HighBid = 0;
2382  
2383 if GRSSCurrentAction == "Bid+Roll" then
2384 GRSS_BidRolls = 1;
2385 msg = "Bidding and Rolling started for "..itemname.."! Type /random "..GRSS_RollNumber.." to register your roll. Then to bid: '/w "..player.." !bid X' where X is the amount to bid.";
2386 GRSSRollNumberDropDown:Hide();
2387 else
2388 if GRSS_BidStyle=="Requests" then
2389 msg = "Taking requests for "..itemname..". To request item: /w "..player.." !req";
2390 else
2391 msg = "Bidding Started for "..itemname.."! To bid: '/w "..player.." !bid X' where X is the amount you wish to bid";
2392 end
2393 GRSSBidStyleDropDown:Hide();
2394 end
2395 end
2396 SendChatMessage(msg, "RAID");
2397 SendChatMessage(msg, "RAID_WARNING");
2398 end
2399  
2400  
2401 function GRSS_ClearBids()
2402 GRSS_Bids = {};
2403 for i,v in pairs(GRSS_DKP) do
2404 GRSS_DKP[i].bid = ""
2405 GRSS_DKP[i].roll = ""
2406  
2407 end
2408  
2409 GRSSBidsScrollBar_Update();
2410 GRSSScrollBar_Update();
2411 end
2412  
2413  
2414 function GRSS_ClearRolls()
2415 GRSS_ClearBids();
2416 end
2417  
2418  
2419 function GRSS_DoAction()
2420 GRSSCurrentAction = this.value;
2421 UIDropDownMenu_SetText(GRSSActionDropDown,this.value);
2422  
2423 if this.value == "DKP Standings" then
2424 GRSS_ActionShow("GRSSRaidFilterDropDown","GRSSClassFilterDropDown","GRSSSpamDropDown");
2425  
2426 elseif this.value == "Rolls" then
2427 GRSS_ActionShow("GRSSToggleRolls","GRSSClearRolls","GRSSRollNumberDropDown","GRSSItemName","GRSSLootDropDown");
2428  
2429 elseif this.value == "DKP+Roll" then
2430 GRSS_ActionShow("GRSSToggleRolls","GRSSClearRolls","GRSSRollNumberDropDown","GRSSItemName","GRSSLootDropDown");
2431  
2432 elseif this.value == "Bids" or this.value=="Requests" then
2433 GRSS_ActionShow("GRSSBids","GRSSToggleBids","GRSSClearBids","GRSSBidStyleDropDown","GRSSItemName","GRSSLootDropDown");
2434  
2435 elseif this.value == "Bid+Roll" then
2436 GRSS_ActionShow("GRSSBids","GRSSToggleBids","GRSSClearBids","GRSSRollNumberDropDown","GRSSItemName","GRSSLootDropDown");
2437  
2438 end
2439  
2440 GRSSShowHeaders(this.value);
2441  
2442 --[[
2443 if this.value == "DKP Standings" then
2444 DKP = true;
2445 elseif this.value == "Rolls" or this.value == "DKP+Roll" then
2446 Rolls = true;
2447 elseif this.value == "Bids" or this.value == "Bid+Roll" then
2448 Bids = true;
2449 end
2450 if Rolls or Bids then
2451 GRSSItemName:Show();
2452 else
2453 GRSSItemName:Hide();
2454 end
2455 GRSSShowHeaders(this.value);
2456  
2457 GRSSShowDKP(DKP);
2458 GRSSShowRolls(Rolls);
2459 GRSSShowBids(Bids);
2460  
2461 if this.value=="Bid+Roll" then
2462 GRSSRollNumberDropDown:Show();
2463 GRSSBidStyleDropDown:Hide();
2464 end
2465 --]]
2466 GRSSScrollBar_Update();
2467 end
2468  
2469 function GRSSSystemDropDown_Initialize()
2470 local info = {};
2471  
2472 if (not GRSS_Systems) then GRSS_Systems = {}; end;
2473  
2474 for index, sys in pairs(GRSS_Systems) do
2475 info.text = sys;
2476 info.value = sys;
2477 info.func = GRSSSystemDropDown_OnClick;
2478 info.notCheckable = nil;
2479 info.keepShownOnClick = nil;
2480 UIDropDownMenu_AddButton(info);
2481 end
2482 end
2483  
2484 function GRSSLootSystemDropDown_Initialize()
2485 local info = {};
2486  
2487 if (not GRSS_Systems) then GRSS_Systems = {}; end;
2488  
2489 for index, sys in pairs(GRSS_Systems) do
2490 info.text = sys;
2491 info.value = sys;
2492 info.func = GRSSLootSystemDropDown_OnClick;
2493 info.notCheckable = nil;
2494 info.keepShownOnClick = nil;
2495 UIDropDownMenu_AddButton(info);
2496 end
2497 end
2498  
2499 function GRSSAdjSystemDropDown_Initialize()
2500 local info = {};
2501  
2502 if (not GRSS_Systems) then GRSS_Systems = {}; end;
2503  
2504 for index, sys in pairs(GRSS_Systems) do
2505 info.text = sys;
2506 info.value = sys;
2507 info.func = GRSSAdjSystemDropDown_OnClick;
2508 info.notCheckable = nil;
2509 info.keepShownOnClick = nil;
2510 UIDropDownMenu_AddButton(info);
2511 end
2512 end
2513  
2514 function GRSSLootDropDown_OnLoad()
2515 UIDropDownMenu_Initialize(this, GRSSLootDropDown_Initialize);
2516 end
2517  
2518 function GRSSLootDropDown_Initialize()
2519 local info = {};
2520  
2521 if (not GRSS_Loot) then GRSS_Loot = {}; end;
2522  
2523 for link in pairs(GRSS_Loot) do
2524 info.text = link;
2525 info.value = link;
2526 info.func = GRSSLootDropDownSelect;
2527 info.notCheckable = nil;
2528 info.keepShownOnClick = nil;
2529 UIDropDownMenu_AddButton(info);
2530 end
2531 end
2532  
2533 function GRSSLootDropDown_OnClick()
2534 ToggleDropDownMenu(1, nil, GRSSLootDropDown, "GRSSItemName", 0, 0);
2535 end
2536  
2537 function GRSSLootDropDownSelect()
2538 GRSSItemName:SetText(this.value);
2539 end
2540  
2541 function GRSS_GetLoot()
2542 GRSS_Loot = {};
2543 for i = 1, GetNumLootItems() do
2544 if LootSlotIsItem(i) then
2545 local link = GetLootSlotLink(i);
2546 local s, e, color, item = string.find(link, "|c(%x+)|Hitem[:%d%-]+|h%[(.-)%]|h|r");
2547 if(color and item and GRSS_Colors[color]) then
2548 GRSS_Loot[link]=link;
2549 end
2550 end
2551 end
2552 UIDropDownMenu_Initialize(GRSSLootDropDown, GRSSLootDropDown_Initialize);
2553 end
2554  
2555  
2556  
2557  
2558  
2559  
2560  
2561  
2562 -- Begin the Waiting List/Invite Code
2563  
2564  
2565 function GRSSInviteDropDown_OnLoad()
2566 UIDropDownMenu_Initialize(this, GRSSInviteDropDown_Initialize);
2567 UIDropDownMenu_SetText(GRSSInviteDropDown,"Waiting List");
2568 UIDropDownMenu_SetWidth(GRSSInviteDropDown,110);
2569 end
2570  
2571 function GRSSInviteDropDown_Initialize()
2572 local Actions = {"Waiting List","Signup Invites"};
2573 local info = {};
2574  
2575 info.notCheckable = nil;
2576 info.keepShownOnClick = nil;
2577 info.func = GRSS_ChangeInvite;
2578 for i,v in pairs(Actions) do
2579 info.text = v;
2580 info.value = v;
2581 UIDropDownMenu_AddButton(info);
2582 end
2583 end
2584  
2585 function GRSS_ChangeInvite()
2586 UIDropDownMenu_SetText(GRSSInviteDropDown,this.value);
2587 GRSS_InviteType = this.value;
2588 if GRSS_InviteType == "Waiting List" then
2589 GRSSInviteWaitingList:Show();
2590 else
2591 GRSSInviteWaitingList:Hide();
2592 end
2593 GRSSInviteScrollBar_Update();
2594 end
2595  
2596 function GRSSInviteScrollBar_Update()
2597 local line; -- 1 through 10 of our window to scroll
2598 local lineplusoffset; -- an index into our data calculated from the scroll offset
2599 if GRSS_InviteType == "Waiting List" then
2600 FauxScrollFrame_Update(GRSSInviteScrollBar,table.getn(GRSS_WaitingList),10,16);
2601 for line=1,10 do
2602 lineplusoffset = line + FauxScrollFrame_GetOffset(GRSSInviteScrollBar);
2603 if lineplusoffset <= table.getn(GRSS_WaitingList) then
2604 getglobal("GRSSInviteRow"..line.."FieldItem"):SetText(GRSS_WaitingList[lineplusoffset]);
2605 getglobal("GRSSInviteRow"..line.."FieldItem"):Show();
2606 getglobal("GRSSInviteRow"..line.."Invite"):Show();
2607 getglobal("GRSSInviteRow"..line.."FieldHighlight"):Show();
2608 getglobal("GRSSInviteRow"..line.."Delete"):Show();
2609 else
2610 getglobal("GRSSInviteRow"..line.."FieldItem"):Hide();
2611 getglobal("GRSSInviteRow"..line.."FieldHighlight"):Hide();
2612 getglobal("GRSSInviteRow"..line.."Invite"):Hide();
2613 getglobal("GRSSInviteRow"..line.."Delete"):Hide();
2614 end
2615 end
2616 else
2617 FauxScrollFrame_Update(GRSSInviteScrollBar,table.getn(GRSS_RaidSignups),10,16);
2618 for line=1,10 do
2619 lineplusoffset = line + FauxScrollFrame_GetOffset(GRSSInviteScrollBar);
2620 if lineplusoffset <= table.getn(GRSS_RaidSignups) then
2621 getglobal("GRSSInviteRow"..line.."FieldItem"):SetText(GRSS_RaidSignups[lineplusoffset].name);
2622 getglobal("GRSSInviteRow"..line.."FieldItem"):Show();
2623 getglobal("GRSSInviteRow"..line.."Invite"):Show();
2624 getglobal("GRSSInviteRow"..line.."FieldHighlight"):Show();
2625 getglobal("GRSSInviteRow"..line.."Delete"):Hide();
2626 else
2627 getglobal("GRSSInviteRow"..line.."FieldItem"):Hide();
2628 getglobal("GRSSInviteRow"..line.."FieldHighlight"):Hide();
2629 getglobal("GRSSInviteRow"..line.."Invite"):Hide();
2630 getglobal("GRSSInviteRow"..line.."Delete"):Hide();
2631 end
2632 end
2633 end
2634 end
2635  
2636  
2637 function GRSS_InviteLine(n)
2638 if GRSS_InviteType == "Waiting List" then
2639 local lineplusoffset = n + FauxScrollFrame_GetOffset(GRSSInviteScrollBar);
2640 local name = GRSS_WaitingList[lineplusoffset];
2641 InviteUnit(name);
2642 else
2643 local RaidTable = GRSS_RaidTable();
2644 local lineplusoffset = n + FauxScrollFrame_GetOffset(GRSSInviteScrollBar);
2645 for i,v in pairs(GRSS_RaidSignups[lineplusoffset].waiting) do
2646 GRSS_AddNameToWaitingList(v);
2647 end
2648 for i,v in pairs(GRSS_RaidSignups[lineplusoffset].pending) do
2649 GRSS_AddNameToWaitingList(v);
2650 end
2651 for i,v in pairs(GRSS_RaidSignups[lineplusoffset].approved) do
2652 InviteUnit(v);
2653 end
2654 end
2655 end
2656  
2657 function GRSS_DeleteInviteLine(n)
2658 if GRSS_InviteType == "Waiting List" then
2659 local lineplusoffset = n + FauxScrollFrame_GetOffset(GRSSInviteScrollBar);
2660 local name = GRSS_WaitingList[lineplusoffset];
2661 GRSS_RemoveFromWaitingList(name);
2662 end
2663 end
2664  
2665  
2666 function GRSS_RaidChange(arg1,arg2)
2667 local i=1;
2668 local RaidTable = GRSS_RaidTable();
2669 while i <= table.getn(GRSS_WaitingList) do
2670 if RaidTable[string.upper(GRSS_WaitingList[i])]==1 then
2671 table.remove(GRSS_WaitingList,i)
2672 else
2673 i = i + 1
2674 end
2675 end
2676 GRSSInviteScrollBar_Update();
2677 end
2678  
2679  
2680 function GRSS_RemoveFromWaitingList(name)
2681 local i = 1;
2682 while i <= table.getn(GRSS_WaitingList) do
2683 v = GRSS_WaitingList[i];
2684 if string.upper(v)==string.upper(name) then
2685 table.remove(GRSS_WaitingList,i);
2686 else
2687 i = i + 1
2688 end
2689 end
2690 GRSSInviteScrollBar_Update();
2691 end
2692  
2693 function GRSS_IsNameOnWaitingList(name)
2694 for i,v in pairs(GRSS_WaitingList) do
2695 if string.upper(name)==string.upper(v) then
2696 return true;
2697 end
2698 end
2699 return false;
2700 end
2701  
2702 function GRSS_AddToWaitingList()
2703 StaticPopup_Show("GRSS_WAITINGLIST");
2704 end
2705  
2706 function GRSS_AddNameToWaitingList(name)
2707 for n in string.gmatch(name,"([^;,%s]+)") do
2708 if not GRSS_IsNameOnWaitingList(n) then
2709 table.insert(GRSS_WaitingList,n);
2710 end
2711 end
2712 GRSSInviteScrollBar_Update();
2713 end
2714  
2715 function GRSS_IsNameQueuedOnWaitList(name)
2716 for i,v in pairs(GRSS_WaitListRequest) do
2717 if string.upper(name)==string.upper(v) then
2718 return true;
2719 end
2720 end
2721 return false;
2722 end
2723  
2724 function GRSS_QueueWaitListRequest(name)
2725 table.insert(GRSS_WaitListRequest,1,name);
2726 end
2727  
2728 function GRSS_NextWaitListRequest()
2729 local n = table.getn(GRSS_WaitListRequest);
2730 if n > 0 then
2731 local name = GRSS_WaitListRequest[n];
2732 StaticPopup_Show("GRSS_AUTOWAITLIST",name);
2733 end
2734  
2735 end
2736  
2737  
2738 function GRSSPrint(msg)
2739 DEFAULT_CHAT_FRAME:AddMessage("GRSS: "..msg);
2740 end
2741  
2742