forked from jpxthu/EPGP-Classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepgp_options.lua
207 lines (197 loc) · 6.83 KB
/
epgp_options.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
local L = LibStub("AceLocale-3.0"):GetLocale("EPGP")
local GP = LibStub("LibGearPoints-1.3")
local Debug = LibStub("LibDebug-1.0")
local DLG = LibStub("LibDialog-1.0")
local LLN = LibStub("LibLootNotify-1.0")
function EPGP:SetupOptions()
self.firstOpen = true
local options = {
name = "EPGP",
type = "group",
childGroups = "tab",
handler = self,
args = {
help = {
order = 1,
type = "description",
name = L["EPGP is an in game, relational loot distribution system"],
fontSize = "medium",
},
hint = {
order = 2,
type = "description",
name = L["Hint: You can open these options by typing /epgp config"],
fontSize = "medium",
},
list_errors = {
order = 1000,
type = "execute",
name = L["List errors"],
desc = L["Lists errors during officer note parsing to the default chat frame. Examples are members with an invalid officer note."],
func = function()
outputFunc = function(s) DEFAULT_CHAT_FRAME:AddMessage(s) end
EPGP:ReportErrors(outputFunc)
end,
},
reset = {
order = 1001,
type = "execute",
name = L["Reset EPGP"],
desc = L["Resets EP and GP of all members of the guild. This will set all main toons' EP and GP to 0. Use with care!"],
func = function() DLG:Spawn("EPGP_RESET_EPGP") end,
},
reset_gp = {
order = 1002,
type = "execute",
name = L["Reset only GP"],
desc = L["Resets GP (not EP!) of all members of the guild. This will set all main toons' GP to 0. Use with care!"],
func = function() DLG:Spawn("EPGP_RESET_GP") end,
},
allow_negative_ep = {
order = 2000,
type = "toggle",
name = L["ALLOW_NEGATIVE_EP_NAME"],
desc = L["ALLOW_NEGATIVE_EP_DESC"],
width = 30,
get = function() return self.db.profile.allow_negative_ep end,
set = function(info, v) self.db.profile.allow_negative_ep = v end,
},
remind_enable_combatlog = {
order = 2001,
type = "toggle",
name = L["COMBATLOG_REMIND_ENABLE_NAME"],
desc = L["COMBATLOG_REMIND_ENABLE_DESC"],
width = 30,
get = function() return self.db.profile.remind_enable_combatlog end,
set = function(info, v) self.db.profile.remind_enable_combatlog = v end,
},
},
}
local registry = LibStub("AceConfigRegistry-3.0")
registry:RegisterOptionsTable("EPGP Options", options)
local dialog = LibStub("AceConfigDialog-3.0")
dialog:AddToBlizOptions("EPGP Options", "EPGP")
-- Setup options for each module that defines them.
for name, m in self:IterateModules() do
if m.optionsArgs then
-- Set all options under this module as disabled when the module
-- is disabled.
for n, o in pairs(m.optionsArgs) do
if o.disabled then
local old_disabled = o.disabled
o.disabled = function(i)
return old_disabled(i) or m:IsDisabled()
end
else
o.disabled = "IsDisabled"
end
end
-- Add the enable/disable option.
m.optionsArgs.enabled = {
order = 0,
type = "toggle",
width = "full",
name = ENABLE,
get = "IsEnabled",
set = "SetEnabled",
}
end
if m.optionsName then
registry:RegisterOptionsTable("EPGP " .. name, {
handler = m,
order = 100,
type = "group",
name = m.optionsName,
desc = m.optionsDesc,
args = m.optionsArgs,
get = "GetDBVar",
set = "SetDBVar",
})
dialog:AddToBlizOptions("EPGP " .. name, m.optionsName, "EPGP")
end
end
EPGP:RegisterChatCommand("epgp", "ProcessCommand")
end
function EPGP:ProcessCommand(str)
str = str:gsub("%%t", UnitName("target") or "notarget")
local command, nextpos = self:GetArgs(str, 1)
if command == "config" then
if self.firstOpen then
-- long standing WOW interface bug where the config does not open the first time you execute it
self.firstOpen = false
InterfaceOptionsFrame_OpenToCategory("EPGP")
end
InterfaceOptionsFrame_OpenToCategory("EPGP")
elseif command == "debug" then
Debug:Toggle()
elseif command == "massep" then
local reason, amount = self:GetArgs(str, 2, nextpos)
amount = tonumber(amount)
if self:CanIncEPBy(reason, amount) then
self:IncMassEPBy(reason, amount)
end
elseif command == "ep" then
local member, reason, amount = self:GetArgs(str, 3, nextpos)
amount = tonumber(amount)
if self:CanIncEPBy(reason, amount) then
self:IncEPBy(self:GetFullCharacterName(member), reason, amount)
end
elseif command == "gp" then
local member, itemlink, amount = self:GetArgs(str, 3, nextpos)
self:Print(member, itemlink, amount)
if amount then
amount = tonumber(amount)
else
local gp1, _, gp2 = GP:GetValue(itemlink)
self:Print(gp1, gp2)
-- Only automatically fill amount if we have a single GP value.
if gp1 and not gp2 then
amount = gp1
end
end
if self:CanIncGPBy(itemlink, amount) then
self:IncGPBy(self:GetFullCharacterName(member), itemlink, amount)
end
elseif command == "decay" then
if EPGP:CanDecayEPGP() then
DLG:Spawn("EPGP_DECAY_EPGP", EPGP:GetDecayPercent())
end
elseif command == "coins" or command == "coin" then
local num, show_gold = self:GetArgs(str, 2, nextpos)
if num then
num = tonumber(num)
else
num = 10
end
EPGP:PrintCoinLog(num, show_gold)
elseif command == "fakecoin" then
local item = self:GetArgs(str, 1, nextpos)
EPGP:FakeCoinEvent(item)
elseif command == "help" then
local help = {
self.version,
" config - "..L["Open the configuration options"],
" debug - "..L["Open the debug window"],
" massep <reason> <amount> - "..L["Mass EP Award"],
" ep <name> <reason> <amount> - "..L["Award EP"],
" gp <name> <itemlink> [<amount>] - "..L["Credit GP"],
" decay - "..L["Decay of EP/GP by %d%%"]:format(EPGP:GetDecayPercent()),
}
EPGP:Print(table.concat(help, "\n"))
else
EPGP:ToggleUI()
end
end
function EPGP:FakeCoinEvent(item)
LLN.BonusMessageReceiver(nil, string.format("BONUS_LOOT_RESULT^%s^%s^%s^%s", "item", item, 32, 776),
nil, UnitName("player"))
end
function EPGP:ToggleUI()
if EPGPFrame and IsInGuild() then
if EPGPFrame:IsShown() then
HideUIPanel(EPGPFrame)
else
ShowUIPanel(EPGPFrame)
end
end
end