forked from jpxthu/EPGP-Classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopups.lua
388 lines (376 loc) · 9.71 KB
/
popups.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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
local L = LibStub("AceLocale-3.0"):GetLocale("EPGP")
local GP = LibStub("LibGearPoints-1.3")
local DLG = LibStub("LibDialog-1.0")
DLG:Register("EPGP_CONFIRM_GP_CREDIT", {
text = "Unknown Item",
icon = [[Interface\DialogFrame\UI-Dialog-Icon-AlertNew]],
buttons = {
{
text = _G.ACCEPT,
on_click = function(self, data, reason)
local gp = tonumber(self.editboxes[1]:GetText())
EPGP:IncGPBy(data.name, data.item, gp)
end,
},
{
text = _G.CANCEL,
},
{
text = _G.GUILD_BANK,
on_click = function(self, data, reason)
EPGP:BankItem(data.item)
end,
},
},
editboxes = {
{
auto_focus = true,
},
},
on_show = function(self, data)
local text = ("\n"..L["Credit GP to %s"].."\n"):format(data.item)
local edit = ""
self.icon:SetTexture(data.icon)
local gp1, c1, gp2, c2, gp3, c3 = GP:GetValue(data.item)
if gp1 then
text = text .. ("\nGP1: %d (%s)"):format(gp1, c1)
edit = tostring(gp1)
end
if gp2 then
text = text .. ("\nGP2: %d (%s)"):format(gp2, c2)
edit = edit .. (" or %d"):format(gp2)
end
if gp3 then
text = text .. ("\nGP3: %d (%s)"):format(gp3, c3)
edit = edit .. (" or %d"):format(gp3)
end
self.text:SetFormattedText(text)
self.editboxes[1]:SetText(edit)
self.editboxes[1]:HighlightText()
if not self.icon_frame then
local icon_frame = CreateFrame("Frame", nil, self)
icon_frame:ClearAllPoints()
icon_frame:SetAllPoints(self.icon)
icon_frame:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT", - 3, icon_frame:GetHeight() + 6)
GameTooltip:SetHyperlink(self:GetParent().data.item)
end)
icon_frame:SetScript("OnLeave", function(self)
GameTooltip:FadeOut()
end)
self.icon_frame = icon_frame
end
if self.icon_frame then
self.icon_frame:EnableMouse(true)
self.icon_frame:Show()
end
end,
on_hide = function(self, data)
if ChatEdit_GetActiveWindow() then
ChatEdit_FocusActiveWindow()
end
if self.icon_frame then
self.icon_frame:EnableMouse(false)
self.icon_frame:Hide()
end
end,
on_update = function(self, elapsed)
local gp = tonumber(self.editboxes[1]:GetText())
if EPGP:CanIncGPBy(self.data.item, gp) then
self.buttons[1]:Enable()
else
self.buttons[1]:Disable()
end
end,
hide_on_escape = true,
show_while_dead = true,
})
DLG:Register("EPGP_DECAY_EPGP", {
buttons = {
{
text = _G.ACCEPT,
on_click = function(self, data, reason)
EPGP:DecayEPGP()
end,
},
{
text = _G.CANCEL,
},
},
on_show = function(self, data)
local t = L["Decay EP and GP by %d%%?"]
local vars = EPGP.db.profile
if not vars.manageRankAll then
for i = 1, GuildControlGetNumRanks() do
if vars.manageRank[i] then
t = t .. "\n" .. GuildControlGetRankName(i)
end
end
end
self.text:SetFormattedText(t, data)
end,
on_update = function(self, elapsed)
if EPGP:CanDecayEPGP() then
self.buttons[1]:Enable()
else
self.buttons[1]:Disable()
end
end,
hide_on_escape = true,
show_while_dead = true,
})
DLG:Register("EPGP_RESET_EPGP", {
text = L["Reset all main toons' EP and GP to 0?"],
buttons = {
{
text = _G.ACCEPT,
on_click = function(self, data, reason)
EPGP:ResetEPGP()
end,
},
{
text = _G.CANCEL,
},
},
on_update = function(self, elapsed)
if EPGP:CanResetEPGP() then
self.buttons[1]:Enable()
else
self.buttons[1]:Disable()
end
end,
hide_on_escape = true,
show_while_dead = true,
})
DLG:Register("EPGP_RESET_GP", {
text = L["Reset all main toons' GP to 0?"],
buttons = {
{
text = _G.ACCEPT,
on_click = function(self, data, reason)
EPGP:ResetGP()
end,
},
{
text = _G.CANCEL,
},
},
on_update = function(self, elapsed)
if EPGP:CanResetEPGP() then
self.buttons[1]:Enable()
else
self.buttons[1]:Disable()
end
end,
hide_on_escape = true,
show_while_dead = true,
})
DLG:Register("EPGP_RESCALE_GP", {
buttons = {
{
text = _G.ACCEPT,
on_click = function(self, data, reason)
EPGP:RescaleGP(data)
end,
},
{
text = _G.CANCEL,
},
},
on_show = function(self, data)
self.text:SetFormattedText(L["Re-scale all main toons' GP to current tier?"] .. " (+%d)", data)
end,
on_update = function(self, elapsed)
if EPGP:CanResetEPGP() then
self.buttons[1]:Enable()
else
self.buttons[1]:Disable()
end
end,
hide_on_escape = true,
show_while_dead = true,
})
DLG:Register("EPGP_MASS_ADJUST_GP", {
buttons = {
{
text = _G.ACCEPT,
on_click = function(self, data, reason)
EPGP:AdjustGP(data)
end,
},
{
text = _G.CANCEL,
},
},
on_show = function(self, data)
self.text:SetFormattedText(L["Adjust all main toons' GP?"] .. " (%d)", data)
end,
on_update = function(self, elapsed)
if EPGP:CanResetEPGP() then
self.buttons[1]:Enable()
else
self.buttons[1]:Disable()
end
end,
hide_on_escape = true,
show_while_dead = true,
})
DLG:Register("EPGP_BOSS_DEAD", {
buttons = {
{
text = _G.ACCEPT,
on_click = function(self, data, reason)
local ep = tonumber(self.editboxes[1]:GetText())
EPGP:IncMassEPBy(data, ep)
end,
},
{
text = _G.CANCEL,
},
},
editboxes = {
{
auto_focus = true,
},
},
on_show = function(self, data)
self.text:SetFormattedText(L["%s is dead. Award EP?"], data)
self.editboxes[1]:SetText("")
end,
on_hide = function(self, data)
if ChatEdit_GetActiveWindow() then
ChatEdit_FocusActiveWindow()
end
end,
on_update = function(self, elapsed)
local ep = tonumber(self.editboxes[1]:GetText())
if EPGP:CanIncEPBy(self.data, ep) then
self.buttons[1]:Enable()
else
self.buttons[1]:Disable()
end
end,
show_while_dead = true,
})
DLG:Register("EPGP_BOSS_ATTEMPT", {
buttons = {
{
text = _G.ACCEPT,
on_click = function(self, data, reason)
local ep = tonumber(self.editboxes[1]:GetText())
EPGP:IncMassEPBy(data .. " (attempt)", ep)
end,
},
{
text = _G.CANCEL,
},
},
editboxes = {
{
-- on_escape_pressed = function(editbox, data)
-- end,
-- on_text_changed = function(editbox, data)
-- end,
-- on_enter_pressed = function(editbox, data)
-- end,
auto_focus = true,
},
},
on_show = function(self, data)
self.text:SetFormattedText(L["Wiped on %s. Award EP?"], data)
self.editboxes[1]:SetText("")
end,
on_hide = function(self, data)
if ChatEdit_GetActiveWindow() then
ChatEdit_FocusActiveWindow()
end
end,
on_update = function(self, elapsed)
local ep = tonumber(self.editboxes[1]:GetText())
if EPGP:CanIncEPBy(self.data, ep) then
self.buttons[1]:Enable()
else
self.buttons[1]:Disable()
end
end,
show_while_dead = true,
})
DLG:Register("EPGP_LOOTMASTER_ASK_TRACKING", {
text = "You are the Loot Master, would you like to use EPGP Lootmaster to distribute loot?\r\n\r\n(You will be asked again next time. Use the configuration panel to change this behaviour)",
icon = [[Interface\DialogFrame\UI-Dialog-Icon-AlertNew]],
buttons = {
{
text = _G.YES,
on_click = function(self)
EPGP:GetModule("lootmaster"):EnableTracking()
EPGP:Print('You have enabled loot tracking for this raid')
end,
},
{
text = _G.NO,
on_click = function(self)
EPGP:GetModule("lootmaster"):DisableTracking()
EPGP:Print('You have disabled loot tracking for this raid')
end,
},
},
hide_on_escape = true,
show_while_dead = true,
})
DLG:Register("EPGP_NEW_VERSION", {
text = "|cFFFFFF00EPGP " .. EPGP.version .. "|r\n" ..
L["You can now check your epgp standings and loot on the web: http://www.epgpweb.com"] .. "\n\n" ..
L["%s %s"]:format(L["[%s] is comming!"]:format(L["Blackwing Lair"]), L["You should probably: increase standard_ilvl, reset or rescale GP."]) .. "\n" ..
string.format("(%s -> %s -> EPGP -> %s / %s)", _G.UIOPTIONS_MENU, _G.ADDONS, L["Gear Points"], L["Rescale GP"]), -- /script EPGP.db.profile.last_version = nil
icon = [[Interface\DialogFrame\UI-Dialog-Icon-AlertNew]],
buttons = {
{
text = _G.OKAY,
},
},
hide_on_escape = true,
show_while_dead = true,
})
DLG:Register("EPGP_NEW_TIER", {
text = "|cFFFFFF00EPGP " .. EPGP.version .. "|r\n" ..
L["%s %s"]:format(L["A new tier is here!"], L["You should probably: increase standard_ilvl, reset or rescale GP."]) .. "\n" ..
string.format("(%s -> %s -> EPGP -> %s / %s)", _G.UIOPTIONS_MENU, _G.ADDONS, L["Gear Points"], L["Rescale GP"]), -- /script EPGP.db.profile.last_tier = nil
icon = [[Interface\DialogFrame\UI-Dialog-Icon-AlertNew]],
buttons = {
{
text = _G.OKAY,
},
},
hide_on_escape = true,
show_while_dead = true,
})
DLG:Register("EPGP_SETTINGS_RECEIVED", {
on_show = function(self, data)
local t = L["SETTINGS_RECEIVED_POPUP_TEXT"]
t = format(t, data, L["Trust"], data)
self.text:SetText(t)
end,
buttons = {
{
text = _G.ACCEPT,
on_click = function(self, data)
local mod = EPGP:GetModule("sync")
local name = data
print(name)
print(type(name))
mod:AcceptSettings(name)
end,
},
{
text = L["Trust"],
on_click = function(self, data)
local mod = EPGP:GetModule("sync")
mod:AcceptSettings(data)
mod:AddTrustList(data)
end,
},
{
text = _G.CANCEL,
},
}
})