-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.lua
More file actions
90 lines (79 loc) · 2.87 KB
/
config.lua
File metadata and controls
90 lines (79 loc) · 2.87 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
local addonName, ns = ...;
--- @type TalentLoadoutBroker
local TLB = ns.TLB;
ns.Config = ns.Config or {};
local Config = ns.Config;
Config.version = C_AddOns.GetAddOnMetadata(addonName, "Version") or "";
function Config:GetOptions()
local orderCount = CreateCounter(1);
local defaultFormat = TLB.defaults.textFormat;
local options = {
type = 'group',
get = function(info) return self:GetConfig(info[#info]); end,
set = function(info, value) self:SetConfig(info[#info], value); end,
args = {
version = {
order = orderCount(),
type = "description",
name = "Version: " .. self.version,
},
textFormat = {
order = orderCount(),
type = "input",
name = "Text Format",
desc = "The format of the text to display on the broker bar.",
descStyle = "inline",
width = "full",
},
textFormatDescription = {
order = orderCount(),
type = "description",
name = [[
The following placeholders are available:
- %loadoutName%: The name of the current loadout.
- %specIcon%: The icon of the current spec.
- %specName%: The name of the current spec.
- %lootspecIcon%: The icon of the current loot spec.
- %lootspecName%: The name of the current loot spec.
- %lootspecIcon2%: The icon of the current loot spec (but hidden if lootspec = current spec).
- %lootspecName2%: The name of the current loot spec (but hidden if lootspec = current spec).
- %switching%: When switching spec or loadout, contains "switching ".
]],
},
resetTextFormat = {
order = orderCount(),
type = "execute",
name = "Reset Text Format",
desc = "Reset the text format to the default.",
descStyle = "inline",
width = "full",
func = function() self:SetConfig("textFormat", defaultFormat); end,
},
},
}
return options
end
function Config:Initialize()
self:RegisterOptions();
local _, categoryID = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(addonName, addonName);
self.categoryID = categoryID;
end
function Config:RegisterOptions()
LibStub("AceConfig-3.0"):RegisterOptionsTable(addonName, self:GetOptions());
end
function Config:OpenConfig()
if C_SettingsUtil and C_SettingsUtil.OpenSettingsPanel and InCombatLockdown() then
LibStub("AceConfigDialog-3.0"):Open(addonName);
return;
end
Settings.OpenToCategory(self.categoryID);
end
function Config:GetConfig(property)
return TLB.db[property];
end
function Config:SetConfig(property, value)
TLB.db[property] = value;
if property == "textFormat" then
TLB:SetText();
end
end