-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dialogs.lua
107 lines (99 loc) · 3.29 KB
/
Dialogs.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
--[[
* Copyright (c) 2011-2020 by Adam Hellberg.
*
* This file is part of KillTrack.
*
* KillTrack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* KillTrack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with KillTrack. If not, see <http://www.gnu.org/licenses/>.
--]]
---@class KillTrack
local KT = select(2, ...)
StaticPopupDialogs.KILLTRACK_FINISH = {
text = "%s entries removed.",
button1 = "Okay",
timeout = 10,
enterClicksFirstButton = true,
whileDead = true,
hideOnEscape = true
}
StaticPopupDialogs.KILLTRACK_DELETE = {
text = "Delete %s with ID %s?",
button1 = "Delete all",
button2 = "CANCEL",
button3 = "Character Only",
OnAccept = function() KT:Delete(KT.Temp.DeleteId) KT.MobList:UpdateMobs() KT.MobList:UpdateEntries() end,
OnAlt = function() KT:Delete(KT.Temp.DeleteId, true) KT.MobList:UpdateMobs() KT.MobList:UpdateEntries() end,
showAlert = true,
timeout = 10,
whileDead = true,
hideOnEscape = true
}
StaticPopupDialogs.KILLTRACK_PURGE = {
text = "Remove all mob entries with their kill count below this threshold:",
button1 = "Purge",
button2 = "Cancel",
hasEditBox = true,
OnAccept = function(self)
KT:Purge(tonumber(self.editBox:GetText()) --[[@as integer]]) KT.MobList:UpdateMobs() KT.MobList:UpdateEntries()
end,
OnCancel = function() KT.Temp.Threshold = nil end,
OnShow = function(self)
if tonumber(KT.Temp.Threshold) then
self.editBox:SetText(tostring(KT.Temp.Threshold))
else
self.button1:Disable()
end
end,
EditBoxOnTextChanged = function(self)
if tonumber(self:GetText()) then
self:GetParent().button1:Enable()
else
self:GetParent().button1:Disable()
end
end,
showAlert = true,
enterClicksFirstButton = true,
timeout = 0,
whileDead = true,
hideOnEscape = true
}
StaticPopupDialogs.KILLTRACK_RESET = {
text = "Remove all mob entries from the database? THIS CANNOT BE REVERSED.",
button1 = "Yes",
button2 = "No",
OnAccept = function() KT:Reset() KT.MobList:UpdateMobs() KT.MobList:UpdateEntries() end,
showAlert = true,
enterClicksFirstButton = true,
timeout = 0,
whileDead = true,
hideOnEscape = true
}
---@param id integer|string
---@param name string
function KT:ShowDelete(id, name)
id = tonumber(id) --[[@as integer]]
name = tostring(name)
if not id then error("'id' must be a number.") end
self.Temp.DeleteId = id
StaticPopup_Show("KILLTRACK_DELETE", name, id)
end
---@param threshold integer?
function KT:ShowPurge(threshold)
if tonumber(threshold) then
self.Temp.Threshold = tonumber(threshold)
end
StaticPopup_Show("KILLTRACK_PURGE")
end
function KT:ShowReset()
StaticPopup_Show("KILLTRACK_RESET")
end