-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.lua
228 lines (213 loc) · 5.93 KB
/
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
local AddonName, NS = ...
local CopyTable = CopyTable
local next = next
local LibStub = LibStub
local IsInInstance = IsInInstance
local AceConfig = LibStub("AceConfig-3.0")
local AceConfigDialog = LibStub("AceConfigDialog-3.0")
local SharedMedia = LibStub("LibSharedMedia-3.0")
---@type HIR
local HIR = NS.HIR
local HIRFrame = NS.HIR.frame
local Options = {}
NS.Options = Options
NS.AceConfig = {
name = AddonName,
type = "group",
args = {
lock = {
name = "Lock the text into place",
type = "toggle",
width = "double",
order = 1,
set = function(_, val)
NS.db.global.lock = val
if val then
NS.Interface:Lock(NS.Interface.textFrame)
else
NS.Interface:Unlock(NS.Interface.textFrame)
end
end,
get = function(_)
return NS.db.global.lock
end,
},
test = {
name = "Toggle on to test settings (out of group)",
desc = "Only works outside of a group.",
type = "toggle",
width = "double",
order = 2,
set = function(_, val)
NS.db.global.test = val
if NS.isInGroup() == false then
if val then
NS.Interface.textFrame:Show()
NS.Interface.textFrame:SetAlpha(1)
else
NS.Interface.textFrame:SetAlpha(0)
end
end
end,
get = function(_)
return NS.db.global.test
end,
},
reverse = {
name = "Show Healer out of range instead",
type = "toggle",
width = "double",
order = 3,
set = function(_, val)
-- true = show out of range
-- false = show in range
NS.db.global.reverse = val
NS.UpdateText(NS.Interface.text, val)
if NS.isInGroup() then
local inRange = NS.isHealerInRange()
NS.ToggleVisibility(inRange, NS.db.global.reverse)
end
end,
get = function(_)
return NS.db.global.reverse
end,
},
healer = {
name = "Disable when spec'd into a healer role",
type = "toggle",
width = "double",
order = 4,
set = function(_, val)
NS.db.global.healer = val
if NS.isInGroup() then
local inRange = NS.isHealerInRange()
NS.ToggleVisibility(inRange, NS.db.global.reverse)
end
end,
get = function(_)
return NS.db.global.healer
end,
},
showOutside = {
name = "Show outside of instances",
type = "toggle",
width = "double",
order = 5,
set = function(_, val)
NS.db.global.showOutside = val
if not IsInInstance() then
if val then
NS.Interface.textFrame:Show()
NS.Interface.textFrame:SetAlpha(1)
local inRange = NS.isHealerInRange()
NS.ToggleVisibility(inRange, NS.db.global.reverse)
else
NS.Interface.textFrame:SetAlpha(0)
end
end
end,
get = function(_)
return NS.db.global.showOutside
end,
},
fontsize = {
type = "range",
name = "Font Size",
width = "double",
order = 6,
min = 2,
max = 64,
step = 1,
set = function(_, val)
NS.db.global.fontsize = val
NS.UpdateFont(NS.Interface.text)
NS.Interface.textFrame:SetWidth(NS.Interface.text:GetStringWidth())
NS.Interface.textFrame:SetHeight(NS.Interface.text:GetStringHeight())
end,
get = function(_)
return NS.db.global.fontsize
end,
},
font = {
type = "select",
name = "Font",
width = "double",
order = 7,
dialogControl = "LSM30_Font",
values = SharedMedia:HashTable("font"),
set = function(_, val)
NS.db.global.font = val
NS.UpdateFont(NS.Interface.text)
NS.Interface.textFrame:SetWidth(NS.Interface.text:GetStringWidth())
NS.Interface.textFrame:SetHeight(NS.Interface.text:GetStringHeight())
end,
get = function(_)
return NS.db.global.font
end,
},
color = {
type = "color",
name = "Color",
width = "full",
order = 8,
hasAlpha = true,
set = function(_, val1, val2, val3, val4)
NS.db.global.color.r = val1
NS.db.global.color.g = val2
NS.db.global.color.b = val3
NS.db.global.color.a = val4
NS.Interface.text:SetTextColor(val1, val2, val3, val4)
end,
get = function(_)
return NS.db.global.color.r, NS.db.global.color.g, NS.db.global.color.b, NS.db.global.color.a
end,
},
reset = {
name = "Reset Everything",
type = "execute",
width = "normal",
order = 100,
func = function()
HIRDB = CopyTable(NS.DefaultDatabase)
NS.db = CopyTable(NS.DefaultDatabase)
end,
},
},
}
function Options:SlashCommands(message)
if message == "toggle lock" then
if NS.db.global.lock == false then
NS.db.global.lock = true
NS.Interface:Lock(NS.Interface.textFrame)
else
NS.db.global.lock = false
NS.Interface:Unlock(NS.Interface.textFrame)
end
else
AceConfigDialog:Open(AddonName)
end
end
function Options:Setup()
AceConfig:RegisterOptionsTable(AddonName, NS.AceConfig)
AceConfigDialog:AddToBlizOptions(AddonName, AddonName)
SLASH_HIR1 = "/healerinrange"
SLASH_HIR2 = "/hir"
function SlashCmdList.HIR(message)
self:SlashCommands(message)
end
end
function HIR:ADDON_LOADED(addon)
if addon == AddonName then
HIRFrame:UnregisterEvent("ADDON_LOADED")
HIRDB = HIRDB and next(HIRDB) ~= nil and HIRDB or {}
-- Copy any settings from default if they don't exist in current profile
NS.CopyDefaults(NS.DefaultDatabase, HIRDB)
-- Reference to active db profile
-- Always use this directly or reference will be invalid
NS.db = HIRDB
-- Remove table values no longer found in default settings
NS.CleanupDB(HIRDB, NS.DefaultDatabase)
Options:Setup()
end
end
HIRFrame:RegisterEvent("ADDON_LOADED")