-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.lua
More file actions
140 lines (128 loc) · 4.78 KB
/
Config.lua
File metadata and controls
140 lines (128 loc) · 4.78 KB
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
local addonName = ...;
---@class (partial) InviteOnWhisper
local IOW = LibStub("AceAddon-3.0"):GetAddon(addonName);
if not IOW then return; end
local Config = {};
IOW.Config = Config;
Config.version = C_AddOns.GetAddOnMetadata(addonName, "Version") or ""
Config.name = "Invite On Whisper";
function Config:GetOptions()
local increment = CreateCounter();
local options = {
type = 'group',
get = function(info) return self:GetConfig(info[#info]); end,
set = function(info, value) return self:SetConfig(info[#info], value); end,
args = {
version = {
order = increment(),
type = "description",
name = "Version: " .. self.version,
},
confirm = {
order = increment(),
name = "Confirmation",
desc = "Asks for confirmation for group invites",
descStyle = 'inline',
width = "full",
type = "toggle",
},
triggerOutgoingGInv = {
order = increment(),
name = "Trigger on outgoing whispers for Guild invites",
descStyle = 'inline',
width = "full",
type = "toggle",
},
triggerOutgoingInv = {
order = increment(),
name = "Trigger on outgoing whispers for Group invites",
descStyle = 'inline',
width = "full",
type = "toggle",
},
keywordMatchMiddle = {
order = increment(),
name = "Toggle Smart Match",
desc = "Smart Match will search your received whispers for an invite keyword. If any invite keyword is found in the whisper, it will trigger an invite. For example, the 'invite' keyword would then be triggered from \"Invite please?\"",
width = "full",
type = "toggle",
},
addGuildInviteTrigger = {
order = increment(),
type = "input",
name = "Add Guild invite trigger phrase",
set = function(_, phrase)
IOW.DB.ginv[phrase:lower()] = true;
end,
},
removeGuildInviteTrigger = {
order = increment(),
type = "select",
style = "dropdown",
name = "Remove Guild invite trigger phrase",
desc = "Select a Guild invite trigger phrase to remove it",
width = "double",
values = function()
local tempTable = {};
for phrase, _ in pairs(IOW.DB.ginv) do
tempTable[phrase] = phrase;
end
return tempTable;
end,
get = function() return false; end,
set = function(_, phrase)
IOW.DB.ginv[phrase] = nil;
end,
},
addGroupInviteTrigger = {
order = increment(),
type = "input",
name = "Add Group invite trigger phrase",
set = function(_, phrase)
IOW.DB.inv[phrase:lower()] = true;
end,
},
removeGroupInviteTrigger = {
order = increment(),
type = "select",
style = "dropdown",
name = "Remove Group invite trigger phrase",
desc = "Select a Group invite trigger phrase to remove it",
width = "double",
values = function()
local tempTable = {};
for phrase, _ in pairs(IOW.DB.inv) do
tempTable[phrase] = phrase;
end
return tempTable;
end,
get = function() return false end,
set = function(_, phrase, ...)
IOW.DB.inv[phrase] = nil;
end,
},
},
};
return options;
end
function Config:Initialize()
self:RegisterOptions();
local _, categoryID = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(self.name, self.name);
self.categoryID = categoryID;
end
function Config:RegisterOptions()
LibStub("AceConfig-3.0"):RegisterOptionsTable(self.name, self:GetOptions());
end
function Config:OpenConfig()
if C_SettingsUtil and C_SettingsUtil.OpenSettingsPanel and InCombatLockdown() then
LibStub("AceConfigDialog-3.0"):Open(self.name);
return;
end
Settings.OpenToCategory(self.categoryID);
end
function Config:GetConfig(property)
return IOW.DB[property];
end
function Config:SetConfig(property, value)
IOW.DB[property] = value;
end