-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathButton.lua
290 lines (271 loc) · 12.3 KB
/
Button.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
function CEPGP_ListButton_OnClick(obj)
if strfind(obj, "CEPGP_guild_reset") then
CEPGP_context_popup_desc:SetPoint("TOP", CEPGP_context_popup_title, "BOTTOM", 0, -5);
else
CEPGP_context_popup_desc:SetPoint("TOP", CEPGP_context_popup_title, "BOTTOM", 0, -15);
end
if strfind(obj, "CEPGP_standby_ep_list_add") then
_G["CEPGP_context_reason"]:Hide();
_G["CEPGP_context_popup_reason"]:Hide();
else
_G["CEPGP_context_reason"]:Show();
_G["CEPGP_context_popup_reason"]:Show();
end
if strfind(obj, "Delete") then
local name = _G["CEPGP_overrideButton" .. _G[obj]:GetParent():GetID() .. "item"]:GetText();
OVERRIDE_INDEX[name] = nil;
CEPGP_print(name .. " removed from the GP override list");
CEPGP_UpdateOverrideScrollBar();
return;
end
if not CanEditOfficerNote() and not CEPGP_debugMode then
CEPGP_print("You don't have access to modify EPGP", 1);
return;
end
--[[ Distribution Menu ]]--
if strfind(obj, "LootDistButton") then --A player in the distribution menu is clicked
ShowUIPanel(CEPGP_distribute_popup);
CEPGP_distribute_popup_title:SetText(_G[_G[obj]:GetName() .. "Info"]:GetText());
CEPGP_distPlayer = _G[_G[obj]:GetName() .. "Info"]:GetText();
print(CEPGP_distPlayer);
CEPGP_distribute_popup:SetID(CEPGP_distribute:GetID()); --CEPGP_distribute:GetID gets the ID of the LOOT SLOT. Not the player.
--[[ Guild Menu ]]--
elseif strfind(obj, "GuildButton") then --A player from the guild menu is clicked (awards EP)
local name = _G[_G[obj]:GetName() .. "Info"]:GetText();
ShowUIPanel(CEPGP_context_popup);
ShowUIPanel(CEPGP_context_amount);
ShowUIPanel(CEPGP_context_popup_EP_check);
ShowUIPanel(CEPGP_context_popup_GP_check);
_G["CEPGP_context_popup_EP_check_text"]:Show();
_G["CEPGP_context_popup_GP_check_text"]:Show();
CEPGP_context_popup_EP_check:SetChecked(1);
CEPGP_context_popup_GP_check:SetChecked(nil);
CEPGP_context_popup_header:SetText("Guild Moderation");
CEPGP_context_popup_title:SetText("Add EP/GP to " .. name);
CEPGP_context_popup_desc:SetText("Adding EP");
CEPGP_context_amount:SetText("0");
CEPGP_context_popup_confirm:SetScript('OnClick', function()
if string.find(CEPGP_context_amount:GetText(), '[^0-9%-]') then
CEPGP_print("Enter a valid number", true);
else
PlaySound(799);
HideUIPanel(CEPGP_context_popup);
if CEPGP_context_popup_EP_check:GetChecked() then
CEPGP_addEP(name, tonumber(CEPGP_context_amount:GetText()), CEPGP_context_reason:GetText());
else
CEPGP_addGP(name, tonumber(CEPGP_context_amount:GetText()), false, _, CEPGP_context_reason:GetText());
end
end
end);
elseif strfind(obj, "CEPGP_guild_add_EP") then --Click the Add Guild EP button in the Guild menu
ShowUIPanel(CEPGP_context_popup);
ShowUIPanel(CEPGP_context_amount);
ShowUIPanel(CEPGP_context_popup_EP_check);
HideUIPanel(CEPGP_context_popup_GP_check);
_G["CEPGP_context_popup_EP_check_text"]:Show();
_G["CEPGP_context_popup_GP_check_text"]:Hide();
CEPGP_context_popup_EP_check:SetChecked(1);
CEPGP_context_popup_GP_check:SetChecked(nil);
CEPGP_context_popup_header:SetText("Guild Moderation");
CEPGP_context_popup_title:SetText("Add Guild EP");
CEPGP_context_popup_desc:SetText("Adds EP to all guild members");
CEPGP_context_amount:SetText("0");
CEPGP_context_popup_confirm:SetScript('OnClick', function()
if string.find(CEPGP_context_amount:GetText(), '[^0-9%-]') then
CEPGP_print("Enter a valid number", true);
else
PlaySound(799);
HideUIPanel(CEPGP_context_popup);
CEPGP_addGuildEP(tonumber(CEPGP_context_amount:GetText()), CEPGP_context_reason:GetText());
end
end);
elseif strfind(obj, "CEPGP_guild_decay") then --Click the Decay Guild EPGP button in the Guild menu
ShowUIPanel(CEPGP_context_popup);
ShowUIPanel(CEPGP_context_amount);
HideUIPanel(CEPGP_context_popup_EP_check);
HideUIPanel(CEPGP_context_popup_GP_check);
_G["CEPGP_context_popup_EP_check_text"]:Hide();
_G["CEPGP_context_popup_GP_check_text"]:Hide();
CEPGP_context_popup_EP_check:SetChecked(nil);
CEPGP_context_popup_GP_check:SetChecked(nil);
CEPGP_context_popup_header:SetText("Guild Moderation");
CEPGP_context_popup_title:SetText("Decay Guild EPGP");
CEPGP_context_popup_desc:SetText("Decays EPGP standings by a percentage");
CEPGP_context_amount:SetText("0");
CEPGP_context_popup_confirm:SetScript('OnClick', function()
if string.find(CEPGP_context_amount:GetText(), '[^0-9%-]') then
CEPGP_print("Enter a valid number", true);
else
PlaySound(799);
HideUIPanel(CEPGP_context_popup);
CEPGP_decay(tonumber(CEPGP_context_amount:GetText()), CEPGP_context_reason:GetText());
end
end);
elseif strfind(obj, "CEPGP_guild_reset") then --Click the Reset All EPGP Standings button in the Guild menu
ShowUIPanel(CEPGP_context_popup);
HideUIPanel(CEPGP_context_amount);
HideUIPanel(CEPGP_context_popup_EP_check);
HideUIPanel(CEPGP_context_popup_GP_check);
_G["CEPGP_context_popup_EP_check_text"]:Hide();
_G["CEPGP_context_popup_GP_check_text"]:Hide();
CEPGP_context_popup_EP_check:SetChecked(nil);
CEPGP_context_popup_GP_check:SetChecked(nil);
CEPGP_context_popup_header:SetText("Guild Moderation");
CEPGP_context_popup_title:SetText("Reset Guild EPGP");
CEPGP_context_popup_desc:SetText("Resets the Guild EPGP standings\n|c00FF0000Are you sure that is what you want to do?\nthis cannot be reversed!\nNote: this will report to Guild chat|r");
CEPGP_context_popup_confirm:SetScript('OnClick', function()
PlaySound(799);
HideUIPanel(CEPGP_context_popup);
CEPGP_resetAll(CEPGP_context_reason:GetText());
end)
--[[ Raid Menu ]]--
elseif strfind(obj, "RaidButton") then --A player from the raid menu is clicked (awards EP)
local name = _G[_G[obj]:GetName() .. "Info"]:GetText();
if not CEPGP_getGuildInfo(name) then
CEPGP_print(name .. " is not a guild member - Cannot award EP or GP", true);
return;
end
ShowUIPanel(CEPGP_context_popup);
ShowUIPanel(CEPGP_context_amount);
ShowUIPanel(CEPGP_context_popup_EP_check);
ShowUIPanel(CEPGP_context_popup_GP_check);
_G["CEPGP_context_popup_EP_check_text"]:Show();
_G["CEPGP_context_popup_GP_check_text"]:Show();
CEPGP_context_popup_EP_check:SetChecked(1);
CEPGP_context_popup_GP_check:SetChecked(nil);
CEPGP_context_popup_header:SetText("Raid Moderation");
CEPGP_context_popup_title:SetText("Add EP/GP to " .. name);
CEPGP_context_popup_desc:SetText("Adding EP");
CEPGP_context_amount:SetText("0");
CEPGP_context_popup_confirm:SetScript('OnClick', function()
if string.find(CEPGP_context_amount:GetText(), '[^0-9%-]') then
CEPGP_print("Enter a valid number", true);
else
PlaySound(799);
HideUIPanel(CEPGP_context_popup);
if CEPGP_context_popup_EP_check:GetChecked() then
CEPGP_addEP(name, tonumber(CEPGP_context_amount:GetText()), CEPGP_context_reason:GetText());
else
CEPGP_addGP(name, tonumber(CEPGP_context_amount:GetText()), _, _, CEPGP_context_reason:GetText());
end
end
end);
elseif strfind(obj, "CEPGP_raid_add_EP") then --Click the Add Raid EP button in the Raid menu
ShowUIPanel(CEPGP_context_popup);
ShowUIPanel(CEPGP_context_amount);
HideUIPanel(CEPGP_context_popup_EP_check);
HideUIPanel(CEPGP_context_popup_GP_check);
_G["CEPGP_context_popup_EP_check_text"]:Hide();
_G["CEPGP_context_popup_GP_check_text"]:Hide();
CEPGP_context_popup_EP_check:SetChecked(nil);
CEPGP_context_popup_GP_check:SetChecked(nil);
CEPGP_context_popup_header:SetText("Raid Moderation");
CEPGP_context_popup_title:SetText("Award Raid EP");
CEPGP_context_popup_desc:SetText("Adds an amount of EP to the entire raid");
CEPGP_context_amount:SetText("0");
CEPGP_context_popup_confirm:SetScript('OnClick', function()
if string.find(CEPGP_context_amount:GetText(), '[^0-9%-]') then
CEPGP_print("Enter a valid number", true);
else
PlaySound(799);
HideUIPanel(CEPGP_context_popup);
CEPGP_AddRaidEP(tonumber(CEPGP_context_amount:GetText()), CEPGP_context_reason:GetText());
end
end);
elseif strfind(obj, "CEPGP_standby_ep_list_add") then
CEPGP_context_popup_EP_check:Hide();
CEPGP_context_popup_GP_check:Hide();
_G["CEPGP_context_popup_EP_check_text"]:Hide();
_G["CEPGP_context_popup_GP_check_text"]:Hide();
CEPGP_context_popup_header:SetText("Add to Standby");
CEPGP_context_popup_title:Hide();
CEPGP_context_popup_desc:SetText("Add a guild member to the standby list");
CEPGP_context_amount:SetText("");
CEPGP_context_popup_confirm:SetScript('OnClick', function()
PlaySound(799);
HideUIPanel(CEPGP_context_popup);
CEPGP_addToStandby(CEPGP_context_amount:GetText());
end);
elseif strfind(obj, "CEPGP_StandbyButton") then
local name = _G[_G[_G[obj]:GetName()]:GetParent():GetName() .. "Info"]:GetText();
for i = 1, CEPGP_ntgetn(CEPGP_standbyRoster) do
if CEPGP_standbyRoster[i] == name then
table.remove(CEPGP_standbyRoster, i);
end
end
CEPGP_UpdateStandbyScrollBar();
end
end
function CEPGP_setOverrideLink(frame, event)
if event == "enter" then
local _, link = GetItemInfo(frame:GetText());
GameTooltip:SetOwner(frame, "ANCHOR_TOPLEFT");
GameTooltip:SetHyperlink(link);
GameTooltip:Show()
else
GameTooltip:Hide();
end
end
function CEPGP_distribute_popup_give()
for i = 1, 40 do
if GetMasterLootCandidate(CEPGP_lootSlot, i) == CEPGP_distPlayer then
GiveMasterLoot(CEPGP_lootSlot, i);
return;
end
end
CEPGP_print(CEPGP_distPlayer .. " is not on the candidate list for loot", true);
end
function CEPGP_distribute_popup_OnEvent(event, msg, name)
if CEPGP_distributing then
if event == "UI_ERROR_MESSAGE" and arg1 == "Inventory is full." and CEPGP_distPlayer ~= "" then
CEPGP_print(CEPGP_distPlayer .. "'s inventory is full", 1);
CEPGP_distribute_popup:Hide();
elseif event == "UI_ERROR_MESSAGE" and arg1 == "You can't carry any more of those items." and CEPGP_distPlayer ~= "" then
CEPGP_print(CEPGP_distPlayer .. " can't carry any more of this unique item", 1);
CEPGP_distribute_popup:Hide();
end
end
end
function CEPGP_initRestoreDropdown(frame, level, menuList)
for k, _ in pairs(RECORDS) do
local info = {text = k, func = CEPGP_restoreDropdownOnClick};
local entry = UIDropDownMenu_AddButton(info);
end
end
function CEPGP_syncRankDropdown(frame, level, menuList)
for i = 1, 10, 1 do
if GuildControlGetRankName(i) ~= "" then
local info = {text = GuildControlGetRankName(i), value = i, func = CEPGP_syncRankChange}; --Value is used as the guild rank index as ranks can have identical names
local entry = UIDropDownMenu_AddButton(info);
end
end
UIDropDownMenu_SetSelectedName(CEPGP_sync_rank, GuildControlGetRankName(CEPGP_force_sync_rank));
UIDropDownMenu_SetSelectedValue(CEPGP_sync_rank, CEPGP_force_sync_rank);
end
function CEPGP_attendanceDropdown(frame, level, menuList)
local info = {text = "All Records", value = 0, func = CEPGP_attendanceChange};
local entry = UIDropDownMenu_AddButton(info);
for i = 1, CEPGP_ntgetn(CEPGP_raid_logs) do
local info = {text = date("%d/%m/%Y %H:%M", CEPGP_raid_logs[i][1]), value = i, func = CEPGP_attendanceChange};
local entry = UIDropDownMenu_AddButton(info);
end
end
function CEPGP_attendanceChange(self, arg1, arg2, checked)
if (not checked) then
UIDropDownMenu_SetSelectedName(CEPGP_attendance_dropdown, self:GetText());
UIDropDownMenu_SetSelectedValue(CEPGP_attendance_dropdown, self.value);
end
end
function CEPGP_syncRankChange(self, arg1, arg2, checked)
if (not checked) then
UIDropDownMenu_SetSelectedName(CEPGP_sync_rank, self:GetText());
UIDropDownMenu_SetSelectedValue(CEPGP_sync_rank, self.value);
CEPGP_force_sync_rank = self.value;
CEPGP_print("Updated forced synchronisation rank");
end
end
function CEPGP_restoreDropdownOnClick(self, arg1, arg2, checked)
if (not checked) then
UIDropDownMenu_SetSelectedName(CEPGP_restoreDropdown, self:GetText());
end
end