-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPantheonDKP.lua
350 lines (276 loc) · 10.7 KB
/
PantheonDKP.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
local _, core = ...;
local _G = _G;
local L = core.L;
local DKP = core.DKP;
local GUI = core.GUI;
local Item = core.Item;
local Util = core.Util;
local PDKP = core.PDKP;
local Guild = core.Guild;
local Shroud = core.Shroud;
local Defaults = core.defaults;
local Invites = core.Invites;
local Raid = core.Raid;
local Comms = core.Comms;
local Setup = core.Setup;
local Import = core.Import;
local PlaySound = PlaySound
--[[
KNOWN BUGS:
]]
--[[
FEATURE REQUESTS:
- Show MS > OS > Roll for pdkp shrouding.
- Display what classes / specs are allowed to roll on certain items.
- When an item is linked for distribution, throw a RW out for people to see.
]]
PDKP.data = {} -- All of the data that is supposed to be shown.
PDKP.raidData = {}
GUI.selected = {}
core.initialized = false
core.filterOffline = nil
-- Generic event handler that handles all of the game events & directs them.
-- This is the FIRST function to run on load triggered registered events at bottom of file
local function PDKP_OnEvent(self, event, arg1, ...)
if event == "ADDON_LOADED" then
Util:Debug('Addon loaded')
PDKP:OnInitialize(event, arg1)
UnregisterEvent(self, event)
return
elseif event == "PLAYER_ENTERING_WORLD" then
local arg1, arg2, arg3, arg4,arg5, _, _,_, _, _, _, _ = ...;
-- print(arg1, arg2)
-- print(event, ...)
-- UnregisterEvent(self, event)
return
elseif event == "GUILD_ROSTER_UPDATE" then
-- Guild:GetGuildData();
-- DKP:SyncWithGuild();
return;
elseif event == "GROUP_ROSTER_UPDATE" then
Raid:GetRaidInfo()
return
elseif event == "ENCOUNTER_START" then return -- for testing purposes
elseif event == "COMBAT_LOG_EVENT_UNFILTERED" then return -- NPC kill event
elseif event == "LOOT_OPENED" then return -- when the loot bag is opened.
elseif event == "OPEN_MASTER_LOOT_LIST" then return -- when the master loot list is opened.
elseif event == "CHAT_MSG_RAID" then
local msg = arg1;
local _, name, _, _,_, _, _ _, _ ,_, _, _ = ...;
Shroud:ShroudingSent(msg, name);
elseif event == "CHAT_MSG_RAID_LEADER" then return
elseif event == "CHAT_MSG_WHISPER" then
-- local msg = arg1;
local _, _, _, arg4,_, _, _,_, _, _, _, _ = ...;
local text = arg1;
local name = arg4;
Shroud:ShroudingSent(text, name);
return
elseif event == "CHAT_MSG_GUILD" then return
elseif event == "ZONE_CHANGED_NEW_AREA" then return
elseif event == "BOSS_KILL" then
-- PDKP:Print(self, event, arg1); -- TABLE, BOSS_KILL, EVENTID
-- Raid:BossKill(event, arg1);
return
end
end
-- event function that happens when the addon is initialized.
function PDKP:OnInitialize(event, name)
if (name ~= "PantheonDKP") then return end
PDKP:Print("Welcome,", Util:GetMyName(), "to:", core.defaults.addon_name)
-----------------------------
-- Register Slash Commands --
-----------------------------
self:RegisterChatCommand("pdkp", "HandleSlashCommands")
self:RegisterChatCommand("shroud", "HandleShroudCommands")
-----------------------------
-- Register PDKP Databases --
-----------------------------
PDKP:InitializeDatabases();
-----------------------------
-- Initialize Addon Data --
-----------------------------
Guild:GetGuildData(false);
DKP:SyncWithGuild();
PDKP:BuildAllData();
-----------------------------
-- Register Communications --
-----------------------------
Comms:RegisterCommCommands()
end
-- Initializes the PDKP Databases.
function PDKP:InitializeDatabases()
Guild:InitGuildDB()
DKP:InitDKPDB()
-- DKP:ImportMonolithData()
end
function PDKP:HandleShroudCommands(item)
-- Normal shrouding command send by a non officer, bidding on an item.
if item == nil or string.len(item) == 0 then
return Shroud:ShroudingSent('shroud', Util:GetMyName());
-- Item linked by the officer.
elseif core.canEdit then -- NEED TO CHECK IF THEY ARE THE ML AS WELL.
-- Check to see if the GUI is open or not.
if not GUI.shown then PDKP:Show() end
GUI:UpdateShroudItemLink(Item:GetItemByName(item));
end
end
-- Generic function that handles all the slash commands.
function PDKP:HandleSlashCommands(msg, item)
-- Commands:
-- pdkp - Opens / closes the GUI
-- pdkp show - Opens the GUI
-- pdkp hide - Hides the GUI
if string.len(msg) == 0 then
if GUI.shown then
return GUI:Hide()
else PDKP:Show()
end
elseif msg == 'show' then
return PDKP:Show()
elseif msg == 'hide' then
return GUI:Hide()
end
if msg == 'shroud' then
return Shroud:ShroudingSent('shroud', Util:GetMyName());
end
-- OFFICER ONLY COMMANDS
if not core.canEdit then return end;
if msg == 'item' and item then
return Item:LinkItem();
end
if msg == 'invite' then
return Invites:Show();
-- local tempInvites = {'Sparklenips', 'Annaliese'}
-- for i=1, #tempInvites do
-- InviteUnit(tempInvites[i]);
-- end
end
if msg == 'bossKill' then
return Raid:BossKill(663, 'Lucifron');
end
if msg == 'classes' then
return Guild:GetClassBreakdown();
end
if msg == 'timer' then
return GUI:CreateTimer()
end
if msg == 'pdkp_reset_all_db' and core.defaults.debug then
DKP:ResetDB()
end
if msg == 'test_boss' then
Raid:GetCurrentRaid()
end
if msg == 'pdkp_testing_com' then
Comms:pdkp_send_comm()
end
if msg == 'pdkp_getTime' then
print(Util:Format12HrDateTime(GetServerTime()))
end
if msg == 'importDKP' then
DKP:ImportMonolithData()
end
if msg == 'TestImportData' then
Import:AcceptData()
end
end
function PDKP:BuildAllData()
-- Pug Data -- Need to think of clever solution for this!
local dkpEntries = DKP:GetMembers();
local gMembers = Guild:GetMembers();
PDKP.data = {};
local errorText;
for i=1, #gMembers do
local gMember = gMembers[i];
-- Check for weird gMember bug where shit is missing?
if gMember.name then
local dkpEntry = dkpEntries[gMember.name];
if gMember and dkpEntry then
gMember.dkpTotal = dkpEntry.dkpTotal;
table.insert(PDKP.data, gMember);
elseif gMember.name then
errorText = 'BuildAllData...Member was not found' .. gMember.name;
else
errorText = 'BuildAllData Initilization... Index: ' .. i
end
else
errorText = 'BuildAllData...Improperly created member ' .. i;
end
if errorText then Util:ThrowError(errorText); end
errorText = nil;
end
end
function PDKP:GetAllTableData()
return PDKP.data;
end
function PDKP:GetDataCount()
return table.getn(PDKP.data);
end
-----------------------------
-- UI FUNCTIONS --
-----------------------------
function PDKP:GetCharName()
return UnitName("PLAYER")
end
-- Shows the PDKP UI
function PDKP:Show()
if GUI.shown then return end -- Don't open more than one instance of PDKP
PlaySound(826)
-- print('PDKP_UID: ', core.defaults.pdkp_is_in_guild)
Setup:MainUI()
pdkp_init_scrollbar()
-- Displays the current character's dkp at the top for accessability.
GUI:UpdateEasyStats()
-- Automatically update the online status regardless of whether it's checked, when the app is reopened.
GUI:UpdateOnlineStatus(core.filterOffline)
GUI.pdkp_frame:Show()
GUI.shown = true;
GUI.HistoryCheck.frame:Show()
if GUI.reasonDropdown then GUI.reasonDropdown.frame:Show() end;
if GUI.raidDropdown then GUI.raidDropdown.frame:Show() end;
end
-----------------------------
-- GLOBAL FUNCTIONS --
-----------------------------
-- General handler for template object clicks.
function pdkp_template_function_call(funcName, object, clickType, buttonName)
if funcName == "Hide" then return GUI:Hide() end
if funcName == "pdkp_entry_clicked" then return GUI:EntryClicked(object, clickType, buttonName) end;
if funcName == 'pdkp_entry_control_clicked' then return GUI:EntryControlClicked(object, clickType, buttonName) end;
if funcName == 'pdkp_entry_shift_clicked' then return GUI:EntryShiftClicked(object, clickType, buttonName) end;
if funcName == "pdkp_dkp_table_sort" then return GUI:pdkp_dkp_table_sort(object) end;
if funcName == "pdkp_dkp_scrollbar_Update" then return GUI:pdkp_dkp_scrollbar_Update() end;
if funcName == "pdkp_dkp_table_filter_class" then return GUI:pdkp_dkp_table_filter_class(object) end;
if funcName == 'pdkp_change_table_view' then return GUI:pdkp_change_view(object) end;
if funcName == 'pdkp_toggle_online' then return GUI:UpdateOnlineStatus(object) end;
if funcName == 'pdkp_in_raid_checkbox' then return GUI:ToggleInRaid(object) end;
if funcName == 'pdkp_dkp_table_filter' then return pdkp_dkp_table_filter() end;
if funcName == 'pdkp_toggle_selected' then return GUI:pdkp_toggle_selected() end;
if funcName == 'GetSelectedFilterStatus' then return GUI:GetSelectedFilterStatus() end;
if funcName == 'SearchInputUpdated' then return GUI:SearchInputUpdated(object) end
if funcName == 'pdkp_dkp_update' then return DKP:ConfirmChange() end;
if funcName == 'pdkp_boss_kill_dkp' then return Raid:AcceptDKPUpdate(object) end;
if funcName == 'pdkp_quick_shroud' then return GUI:QuickCalculate('shroud') end;
if funcName == 'pdkp_quick_roll' then return GUI:QuickCalculate('roll') end;
if funcName == 'toggleSubmitButton' then return GUI:ToggleSubmitButton() end;
if funcName == 'pdkp_select_all_classes' then return GUI:ToggleAllClasses(object) end;
end
function UnregisterEvent(self, event)
self:UnregisterEvent(event);
end
local events = CreateFrame("Frame", "EventsFrame");
events:RegisterEvent("ADDON_LOADED");
events:RegisterEvent("GUILD_ROSTER_UPDATE");
events:RegisterEvent("GROUP_ROSTER_UPDATE");
events:RegisterEvent("ENCOUNTER_START"); -- FOR TESTING PURPOSES.
events:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED"); -- NPC kill event
events:RegisterEvent("LOOT_OPENED");
events:RegisterEvent("CHAT_MSG_RAID");
events:RegisterEvent("CHAT_MSG_RAID_LEADER");
events:RegisterEvent("CHAT_MSG_WHISPER");
events:RegisterEvent("CHAT_MSG_GUILD");
events:RegisterEvent("CHAT_MSG_LOOT"); -- someone selects need, greed, passes, rolls, receives
events:RegisterEvent("PLAYER_ENTERING_WORLD");
events:RegisterEvent("ZONE_CHANGED_NEW_AREA");
events:RegisterEvent("BOSS_KILL");
events:SetScript("OnEvent", PDKP_OnEvent); -- calls the above MonDKP_OnEvent function to determine what to do with the event