-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettings.lua
More file actions
657 lines (575 loc) · 29.3 KB
/
Copy pathSettings.lua
File metadata and controls
657 lines (575 loc) · 29.3 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
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
local _, WE = ...
local function DefaultAtPath(path)
local value = WE.DEFAULT_PROFILE
for segment in string.gmatch(path, "[^.]+") do
value = value[segment]
end
return value
end
local function VariableForPath(path)
return "WE_" .. string.upper((path:gsub("[^%w]", "_")))
end
local function RefreshAfterChange()
local db = WE.GetDB()
if db.enabled then
WE.ApplyAll()
else
WE.RestoreBlizzardLikeStyle()
end
if WE.previewFrame then
WE.UpdatePreview()
end
end
local layoutRefreshOptions = {
["icon.enabled"] = true,
["icon.tintEnabled"] = true,
["icon.glowEnabled"] = true,
["icon.shadowEnabled"] = true,
["text.enabled"] = true,
["text.shadowEnabled"] = true,
["text.colorByDistance"] = true,
["text.backgroundEnabled"] = true,
["text.compact"] = true,
["text.uppercase"] = true,
["arrow.enabled"] = true,
["arrow.tintEnabled"] = true,
["arrow.glowEnabled"] = true,
["background.enabled"] = true,
["visibility.hideNearEnabled"] = true,
}
function WE.RefreshSettingsLayout()
C_Timer.After(0, function()
if SettingsInbound and SettingsInbound.RepairDisplay then
SettingsInbound.RepairDisplay()
elseif SettingsPanel and SettingsPanel.RepairDisplay then
SettingsPanel:RepairDisplay()
end
end)
end
function WE.SetOption(path, value, visual)
WE.SetPath(path, value)
local db = WE.GetDB()
if path == "text.compact" and value then
db.text.uppercase = false
elseif path == "text.uppercase" and value then
db.text.compact = false
elseif path == "preview.locked" then
WE.SetPreviewLocked(value)
end
WE.ValidateCurrentProfile()
if visual then
WE.MarkCustom()
end
WE.InvalidateHotState()
RefreshAfterChange()
if layoutRefreshOptions[path] then
WE.RefreshSettingsLayout()
end
end
local function RegisterProxy(category, path, varType, label, defaultValue, setter)
local setting = Settings.RegisterProxySetting(
category,
VariableForPath(path),
varType,
label,
defaultValue,
function() return WE.GetPath(path) end,
setter or function(value) WE.SetOption(path, value, true) end
)
WE.settingsByPath[path] = setting
return setting
end
local function AddCheckbox(category, path, label, tooltip, visual)
local setting = RegisterProxy(category, path, Settings.VarType.Boolean, label, DefaultAtPath(path),
function(value) WE.SetOption(path, value, visual ~= false) end)
return Settings.CreateCheckbox(category, setting, tooltip)
end
local function NumberFormatter(step)
if step >= 1 then
return function(value) return tostring(WE.Round(value)) end
end
local precision = step < 0.1 and 2 or 1
local formatString = "%." .. precision .. "f"
return function(value) return string.format(formatString, tonumber(value) or 0) end
end
local function FormatYards(value)
return string.format("%d yd", WE.Round(value))
end
local function AddSlider(category, path, label, minimum, maximum, step, tooltip, visual, formatter)
local setting = RegisterProxy(category, path, Settings.VarType.Number, label, DefaultAtPath(path),
function(value) WE.SetOption(path, value, visual ~= false) end)
local options = Settings.CreateSliderOptions(minimum, maximum, step)
if options.SetLabelFormatter and MinimalSliderWithSteppersMixin then
options:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right, formatter or NumberFormatter(step))
end
return Settings.CreateSlider(category, setting, options, tooltip)
end
local function AddDropdown(category, path, label, values, tooltip, visual, customSetter)
local setting = RegisterProxy(category, path, Settings.VarType.String, label, DefaultAtPath(path),
customSetter or function(value) WE.SetOption(path, value, visual ~= false) end)
local function GetOptions()
local container = Settings.CreateControlTextContainer()
local entries = type(values) == "function" and values() or values
for _, entry in ipairs(entries) do
container:Add(entry.value, entry.label)
end
return container:GetData()
end
return Settings.CreateDropdown(category, setting, GetOptions, tooltip)
end
local function ColorToHex(color)
return CreateColor(color[1], color[2], color[3], color[4] or 1):GenerateHexColor()
end
local function AddColor(category, path, label, tooltip, visual)
local default = DefaultAtPath(path)
local setting = Settings.RegisterProxySetting(
category,
VariableForPath(path),
Settings.VarType.String,
label,
ColorToHex(default),
function() return ColorToHex(WE.GetPath(path)) end,
function(value)
local color = CreateColorFromHexString(value)
if color then
local r, g, b, a = color:GetRGBA()
WE.SetOption(path, { r, g, b, a }, visual ~= false)
end
end
)
WE.settingsByPath[path] = setting
return Settings.CreateColorSwatch(category, setting, tooltip)
end
local function AddButton(layout, label, buttonText, callback, tooltip)
layout:AddInitializer(CreateSettingsButtonInitializer(label, buttonText, callback, tooltip, true))
end
local function AddSection(layout, label, tooltip)
if layout and CreateSettingsListSectionHeaderInitializer then
return layout:AddInitializer(CreateSettingsListSectionHeaderInitializer(label, tooltip))
end
end
local function GetGlowShapeValues()
local values = {}
for _, key in ipairs(WE.GLOW_SHAPE_ORDER) do
values[#values + 1] = { value = key, label = WE.GLOW_SHAPES[key].label }
end
return values
end
local WOW_FONT_VALUES = {
{ value = "Fonts\\FRIZQT__.TTF", label = "Friz Quadrata" },
{ value = "Fonts\\ARIALN.TTF", label = "Arial Narrow" },
{ value = "Fonts\\MORPHEUS.TTF", label = "Morpheus" },
{ value = "Fonts\\SKURRI.TTF", label = "Skurri" },
}
local function GetLibSharedMedia()
local libStub = _G.LibStub
if not libStub or type(libStub.GetLibrary) ~= "function" then
return nil
end
return libStub:GetLibrary("LibSharedMedia-3.0", true)
end
local function GetFontValues()
local values = {}
local seen = {}
local function AddFont(path, label)
if type(path) ~= "string" or path == "" then
return
end
local normalized = string.lower(path)
if seen[normalized] then
return
end
seen[normalized] = true
values[#values + 1] = { value = path, label = label }
end
for _, font in ipairs(WOW_FONT_VALUES) do
AddFont(font.value, font.label)
end
local sharedMedia = GetLibSharedMedia()
if sharedMedia and type(sharedMedia.List) == "function" and type(sharedMedia.Fetch) == "function" then
local sharedFonts = {}
for _, name in ipairs(sharedMedia:List("font") or {}) do
local path = sharedMedia:Fetch("font", name, true)
if type(path) == "string" and path ~= "" and not seen[string.lower(path)] then
sharedFonts[#sharedFonts + 1] = { value = path, label = name }
end
end
table.sort(sharedFonts, function(left, right)
return string.lower(left.label) < string.lower(right.label)
end)
for _, font in ipairs(sharedFonts) do
AddFont(font.value, font.label)
end
end
local selected = WE.GetPath("text.font")
if type(selected) == "string" and selected ~= "" and not seen[string.lower(selected)] then
AddFont(selected, "Unavailable font (using Friz Quadrata)")
end
return values
end
local function TrackSettingsCategory(category)
if not category then
return
end
WE.settingsCategories[category] = true
WE.settingsCategoryIDs[category:GetID()] = true
end
local function IsWaypointEnhancerCategory(category)
if not category then
return false
end
return WE.settingsCategories[category]
or (category.GetID and WE.settingsCategoryIDs[category:GetID()])
end
local function GetDefaultsButton()
return SettingsPanel
and SettingsPanel.Container
and SettingsPanel.Container.SettingsList
and SettingsPanel.Container.SettingsList.Header
and SettingsPanel.Container.SettingsList.Header.DefaultsButton
end
local function UpdateDefaultsButton(category)
local button = GetDefaultsButton()
if not button then
return
end
if IsWaypointEnhancerCategory(category) then
if not button.__hiddenByWaypointEnhancer then
button.__hiddenByWaypointEnhancer = true
button:Hide()
end
elseif button.__hiddenByWaypointEnhancer then
button.__hiddenByWaypointEnhancer = nil
if not button.__hidden_by then
button:Show()
end
end
end
local function InstallDefaultsButtonGuard()
if WE.defaultsButtonGuardInstalled then
return
end
WE.defaultsButtonGuardInstalled = true
EventRegistry:RegisterCallback("Settings.CategoryChanged", function(_, category)
UpdateDefaultsButton(category)
end)
if SettingsPanel and SettingsPanel.SearchBox then
SettingsPanel.SearchBox:HookScript("OnTextChanged", function()
UpdateDefaultsButton(SettingsPanel:GetCurrentCategory())
end)
end
if SettingsPanel then
SettingsPanel:HookScript("OnShow", function()
UpdateDefaultsButton(SettingsPanel:GetCurrentCategory())
end)
end
end
local function ShowWhen(initializer, predicate)
if initializer and initializer.AddShownPredicate then
initializer:AddShownPredicate(predicate)
end
return initializer
end
local function WhenAll(...)
local paths = { ... }
return function()
for _, path in ipairs(paths) do
if not WE.GetPath(path) then
return false
end
end
return true
end
end
local function ReopenSettings()
if SettingsPanel and SettingsPanel:IsShown() then
HideUIPanel(SettingsPanel)
C_Timer.After(0, function() WE.OpenSettings() end)
end
end
function WE.ApplyReset()
WE.ResetAllSettings()
WE.InitializeDB()
WE.InvalidateHotState()
WE.ResetPreviewPosition()
WE.SetPreviewLocked(WE.GetDB().preview.locked)
RefreshAfterChange()
ReopenSettings()
end
StaticPopupDialogs.WAYPOINT_ENHANCER_RESET_ALL = {
text = "Reset all Waypoint Enhancer settings?",
button1 = YES,
button2 = NO,
OnAccept = function() WE.ApplyReset() end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3,
}
local function CreateCompatibilityPanel()
local panel = CreateFrame("Frame")
panel.name = "Compatibility"
local title = panel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 24, -24)
title:SetText("Compatibility")
local safe = CreateFrame("CheckButton", nil, panel, "UICheckButtonTemplate")
safe:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -20)
safe:SetScript("OnClick", function(self)
WE.SetOption("compatibility.safeMode", self:GetChecked(), false)
end)
panel.SafeMode = safe
local safeLabel = panel:CreateFontString(nil, "ARTWORK", "GameFontNormal")
safeLabel:SetPoint("LEFT", safe, "RIGHT", 4, 0)
safeLabel:SetText("Safe mode")
local safeHelp = panel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
safeHelp:SetPoint("TOPLEFT", safe, "BOTTOMLEFT", 4, -8)
safeHelp:SetWidth(620)
safeHelp:SetJustifyH("LEFT")
safeHelp:SetText("Only scale, icon size, text size and text outline are applied in safe mode.")
local detectedTitle = panel:CreateFontString(nil, "ARTWORK", "GameFontNormal")
detectedTitle:SetPoint("TOPLEFT", safeHelp, "BOTTOMLEFT", -4, -24)
detectedTitle:SetText("Detected addons")
local detectedText = panel:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
detectedText:SetPoint("TOPLEFT", detectedTitle, "BOTTOMLEFT", 0, -8)
detectedText:SetWidth(620)
detectedText:SetJustifyH("LEFT")
panel.DetectedText = detectedText
local warningText = panel:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
warningText:SetPoint("TOPLEFT", detectedText, "BOTTOMLEFT", 0, -20)
warningText:SetWidth(620)
warningText:SetJustifyH("LEFT")
warningText:SetJustifyV("TOP")
panel.WarningText = warningText
panel:SetScript("OnShow", function() WE.UpdateCompatibilityPanel() end)
WE.compatibilityPanel = panel
return panel
end
function WE.UpdateCompatibilityPanel()
local panel = WE.compatibilityPanel
if not panel then
return
end
local detected, warning = WE.GetCompatibilitySummary()
panel.SafeMode:SetChecked(WE.GetDB().compatibility.safeMode)
panel.DetectedText:SetText(detected)
panel.WarningText:SetText(warning)
end
local function CreateAboutPanel()
local panel = CreateFrame("Frame")
panel.name = "About"
local title = panel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 24, -24)
title:SetText("Waypoint Enhancer")
local version = panel:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
version:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -10)
version:SetText("Version " .. (C_AddOns.GetAddOnMetadata(WE.ADDON_NAME, "Version") or "Unknown"))
local description = panel:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
description:SetPoint("TOPLEFT", version, "BOTTOMLEFT", 0, -24)
description:SetWidth(620)
description:SetJustifyH("LEFT")
description:SetText("Improves Blizzard's native SuperTrackedFrame without replacing the navigation system.\n\nRetail 12.0.7 only. No navigation engine, map pins or /way parser are included.")
return panel
end
function WE.RegisterSettings()
if WE.settingsRegistered or not Settings or not Settings.RegisterVerticalLayoutCategory then
return
end
WE.settingsRegistered = true
WE.settingsByPath = {}
WE.settingsCategories = {}
WE.settingsCategoryIDs = {}
local general, generalLayout = Settings.RegisterVerticalLayoutCategory(WE.DISPLAY_NAME)
WE.settingsCategory = general
TrackSettingsCategory(general)
AddSection(generalLayout, "Addon")
AddCheckbox(general, "enabled", "Enable Waypoint Enhancer", "Restore Blizzard's native appearance when disabled.", false)
AddSection(generalLayout, "Preset & Frame")
local presetValues = {}
for _, preset in ipairs(WE.PRESET_ORDER) do
presetValues[#presetValues + 1] = { value = preset.key, label = preset.label }
end
AddDropdown(general, "preset", "Preset", presetValues, nil, false, function(value)
if value == "CUSTOM" then
WE.GetDB().preset = "CUSTOM"
else
WE.ApplyPreset(value)
end
end)
AddSlider(general, "frame.scale", "Global scale", 0.75, 2.0, 0.05,
"Scales the complete Blizzard waypoint frame, including its icon, text and off-screen arrow.")
AddDropdown(general, "frame.strata", "Frame strata", {
{ value = "MEDIUM", label = "Medium" },
{ value = "HIGH", label = "High" },
{ value = "DIALOG", label = "Dialog" },
}, "Controls whether the waypoint is drawn above or below other UI elements. High is recommended.")
AddSection(generalLayout, "Transparency & Clamp")
AddSlider(general, "frame.alphaNormal", "Normal alpha", 0, 1, 0.05,
"Opacity while the waypoint is on screen and visible.")
AddSlider(general, "frame.alphaOccluded", "Occluded alpha", 0, 1, 0.05,
"Opacity when Blizzard reports that the destination is hidden behind world geometry.")
AddSlider(general, "frame.alphaClamped", "Clamped alpha", 0, 1, 0.05,
"Opacity while the destination is off screen and Blizzard shows the edge arrow.")
AddSlider(general, "frame.clampRadiusX", "Horizontal clamp radius", 200, 900, 10,
"How far the off-screen arrow may move horizontally from the screen center. Larger values place it closer to the screen edge.")
AddSlider(general, "frame.clampRadiusY", "Vertical clamp radius", 100, 500, 10,
"How far the off-screen arrow may move vertically from the screen center. Larger values place it closer to the screen edge.")
AddSection(generalLayout, "Preview & Reset")
AddCheckbox(general, "preview.locked", "Lock preview", "Unlock to drag the preview with the left mouse button.", false)
AddButton(generalLayout, "Preview", "Toggle Preview", function() WE.TogglePreview() end,
"Shows a movable sample that does not require an active waypoint.")
AddButton(generalLayout, "All settings", "Reset All", function()
StaticPopup_Show("WAYPOINT_ENHANCER_RESET_ALL")
end, "Restores every Waypoint Enhancer option to its default value.")
local icon, iconLayout = Settings.RegisterVerticalLayoutSubcategory(general, "Icon")
TrackSettingsCategory(icon)
AddSection(iconLayout, "Appearance")
AddCheckbox(icon, "icon.enabled", "Enable icon styling")
ShowWhen(AddSlider(icon, "icon.size", "Icon size", 24, 96, 1), WhenAll("icon.enabled"))
ShowWhen(AddCheckbox(icon, "icon.desaturate", "Desaturate icon",
"Removes the original color from Blizzard's waypoint icon."), WhenAll("icon.enabled"))
ShowWhen(AddSection(iconLayout, "Tint"), WhenAll("icon.enabled"))
ShowWhen(AddCheckbox(icon, "icon.tintEnabled", "Tint icon",
"Applies the selected color over the waypoint icon."), WhenAll("icon.enabled"))
ShowWhen(AddColor(icon, "icon.tintColor", "Icon tint"), WhenAll("icon.enabled", "icon.tintEnabled"))
ShowWhen(AddSection(iconLayout, "Glow"), WhenAll("icon.enabled"))
ShowWhen(AddCheckbox(icon, "icon.glowEnabled", "Enable icon glow",
"Adds a colored effect behind the waypoint icon."), WhenAll("icon.enabled"))
ShowWhen(AddDropdown(icon, "icon.glowShape", "Icon glow shape", GetGlowShapeValues,
"Selects the Blizzard texture used for the icon glow."), WhenAll("icon.enabled", "icon.glowEnabled"))
ShowWhen(AddSlider(icon, "icon.glowSize", "Icon glow size", 24, 160, 1,
"Controls the width and height of the glow behind the icon."), WhenAll("icon.enabled", "icon.glowEnabled"))
ShowWhen(AddColor(icon, "icon.glowColor", "Icon glow color"), WhenAll("icon.enabled", "icon.glowEnabled"))
ShowWhen(AddSlider(icon, "icon.glowAlpha", "Icon glow alpha", 0, 1, 0.05,
"Controls the opacity of the icon glow."), WhenAll("icon.enabled", "icon.glowEnabled"))
ShowWhen(AddCheckbox(icon, "icon.pulseOnChange", "Pulse on waypoint change",
"Briefly brightens the icon glow when Blizzard changes the tracked destination."), WhenAll("icon.enabled", "icon.glowEnabled"))
ShowWhen(AddSection(iconLayout, "Shadow"), WhenAll("icon.enabled"))
ShowWhen(AddCheckbox(icon, "icon.shadowEnabled", "Enable icon shadow",
"Adds a dark copy of the icon behind the original icon."), WhenAll("icon.enabled"))
ShowWhen(AddColor(icon, "icon.shadowColor", "Icon shadow color"), WhenAll("icon.enabled", "icon.shadowEnabled"))
ShowWhen(AddSlider(icon, "icon.shadowOffsetX", "Shadow horizontal offset", -50, 50, 1,
"Moves the shadow left or right relative to the icon."), WhenAll("icon.enabled", "icon.shadowEnabled"))
ShowWhen(AddSlider(icon, "icon.shadowOffsetY", "Shadow vertical offset", -50, 50, 1,
"Moves the shadow up or down relative to the icon."), WhenAll("icon.enabled", "icon.shadowEnabled"))
local text, textLayout = Settings.RegisterVerticalLayoutSubcategory(general, "Distance Text")
TrackSettingsCategory(text)
AddSection(textLayout, "Typography")
AddCheckbox(text, "text.enabled", "Show distance text")
ShowWhen(AddDropdown(text, "text.font", "Font", GetFontValues,
"Lists built-in WoW fonts and fonts registered by LibSharedMedia. If a selected font becomes unavailable, Friz Quadrata is used instead."), WhenAll("text.enabled"))
ShowWhen(AddSlider(text, "text.size", "Font size", 10, 32, 1), WhenAll("text.enabled"))
ShowWhen(AddDropdown(text, "text.outline", "Font outline", {
{ value = "", label = "None" },
{ value = "OUTLINE", label = "Outline" },
{ value = "THICKOUTLINE", label = "Thick outline" },
}, "Adds a dark edge around the distance text to improve contrast."), WhenAll("text.enabled"))
ShowWhen(AddColor(text, "text.color", "Text color"), WhenAll("text.enabled"))
ShowWhen(AddCheckbox(text, "text.shadowEnabled", "Enable text shadow",
"Adds a configurable shadow behind the distance text."), WhenAll("text.enabled"))
ShowWhen(AddColor(text, "text.shadowColor", "Text shadow color"), WhenAll("text.enabled", "text.shadowEnabled"))
ShowWhen(AddSlider(text, "text.shadowOffsetX", "Shadow horizontal offset", -10, 10, 1), WhenAll("text.enabled", "text.shadowEnabled"))
ShowWhen(AddSlider(text, "text.shadowOffsetY", "Shadow vertical offset", -10, 10, 1), WhenAll("text.enabled", "text.shadowEnabled"))
ShowWhen(AddSection(textLayout, "Position"), WhenAll("text.enabled"))
ShowWhen(AddSlider(text, "text.offsetX", "Horizontal offset", -50, 50, 1), WhenAll("text.enabled"))
ShowWhen(AddSlider(text, "text.offsetY", "Vertical offset", -50, 50, 1), WhenAll("text.enabled"))
ShowWhen(AddSection(textLayout, "Format"), WhenAll("text.enabled"))
ShowWhen(AddCheckbox(text, "text.compact", "Compact format",
"Shows only the distance number, for example 37 instead of 37 yds."), WhenAll("text.enabled"))
local uppercase = ShowWhen(AddCheckbox(text, "text.uppercase", "Uppercase format",
"Displays the distance unit in uppercase. This option is unavailable in Compact format."), WhenAll("text.enabled"))
if uppercase and uppercase.AddModifyPredicate then
uppercase:AddModifyPredicate(function() return not WE.GetPath("text.compact") end)
end
ShowWhen(AddSection(textLayout, "Distance Colors"), WhenAll("text.enabled"))
ShowWhen(AddCheckbox(text, "text.colorByDistance", "Color by distance",
"Blends smoothly from the near color to the far color as the distance increases."), WhenAll("text.enabled"))
ShowWhen(AddSlider(text, "text.nearDistance", "Near distance (0-200 yd)", 0, 200, 1,
"Distance at or below which the near color is used.", true, FormatYards), WhenAll("text.enabled", "text.colorByDistance"))
ShowWhen(AddColor(text, "text.nearColor", "Near color"), WhenAll("text.enabled", "text.colorByDistance"))
ShowWhen(AddSlider(text, "text.farDistance", "Far distance (31-5000 yd)", 31, 5000, 10,
"Distance at or above which the far color is used.", true, FormatYards), WhenAll("text.enabled", "text.colorByDistance"))
ShowWhen(AddColor(text, "text.farColor", "Far color"), WhenAll("text.enabled", "text.colorByDistance"))
ShowWhen(AddSection(textLayout, "Text Background"), WhenAll("text.enabled"))
ShowWhen(AddCheckbox(text, "text.backgroundEnabled", "Enable text background",
"Adds a solid background behind the distance text. This is separate from the icon background category."), WhenAll("text.enabled"))
ShowWhen(AddColor(text, "text.backgroundColor", "Text background color"), WhenAll("text.enabled", "text.backgroundEnabled"))
ShowWhen(AddSlider(text, "text.backgroundAlpha", "Text background alpha", 0, 1, 0.05), WhenAll("text.enabled", "text.backgroundEnabled"))
ShowWhen(AddSlider(text, "text.backgroundPaddingX", "Horizontal background padding", 0, 30, 1,
"Adds empty space to the left and right of the text."), WhenAll("text.enabled", "text.backgroundEnabled"))
ShowWhen(AddSlider(text, "text.backgroundPaddingY", "Vertical background padding", 0, 20, 1,
"Adds empty space above and below the text."), WhenAll("text.enabled", "text.backgroundEnabled"))
local arrow, arrowLayout = Settings.RegisterVerticalLayoutSubcategory(general, "Arrow")
TrackSettingsCategory(arrow)
AddSection(arrowLayout, "Appearance")
AddCheckbox(arrow, "arrow.enabled", "Enable arrow styling",
"Styles Blizzard's native arrow when the tracked destination is off screen.")
ShowWhen(AddSlider(arrow, "arrow.scale", "Arrow scale", 0.5, 2.5, 0.05,
"Changes the size of Blizzard's off-screen arrow without changing its direction or position."), WhenAll("arrow.enabled"))
ShowWhen(AddCheckbox(arrow, "arrow.desaturate", "Desaturate arrow",
"Removes the original color from Blizzard's off-screen arrow."), WhenAll("arrow.enabled"))
ShowWhen(AddSection(arrowLayout, "Tint"), WhenAll("arrow.enabled"))
ShowWhen(AddCheckbox(arrow, "arrow.tintEnabled", "Tint arrow",
"Applies the selected color over Blizzard's off-screen arrow."), WhenAll("arrow.enabled"))
ShowWhen(AddColor(arrow, "arrow.tintColor", "Arrow and glow color"), function()
return WE.GetPath("arrow.enabled")
and (WE.GetPath("arrow.tintEnabled") or WE.GetPath("arrow.glowEnabled"))
end)
ShowWhen(AddSection(arrowLayout, "Glow"), WhenAll("arrow.enabled"))
ShowWhen(AddCheckbox(arrow, "arrow.glowEnabled", "Enable arrow glow",
"Adds a colored effect behind Blizzard's off-screen arrow."), WhenAll("arrow.enabled"))
ShowWhen(AddDropdown(arrow, "arrow.glowShape", "Arrow glow shape", GetGlowShapeValues,
"Selects the Blizzard texture used for the arrow glow."), WhenAll("arrow.enabled", "arrow.glowEnabled"))
ShowWhen(AddSlider(arrow, "arrow.glowSize", "Arrow glow size", 16, 128, 1,
"Controls the width and height of the glow behind the arrow."), WhenAll("arrow.enabled", "arrow.glowEnabled"))
ShowWhen(AddSlider(arrow, "arrow.glowAlpha", "Arrow glow alpha", 0, 1, 0.05,
"Controls the opacity of the arrow glow."), WhenAll("arrow.enabled", "arrow.glowEnabled"))
ShowWhen(AddCheckbox(arrow, "arrow.pulseWhenClamped", "Pulse when clamped",
"Briefly brightens the arrow glow when the destination first moves off screen."), WhenAll("arrow.enabled", "arrow.glowEnabled"))
local background, backgroundLayout = Settings.RegisterVerticalLayoutSubcategory(general, "Background")
TrackSettingsCategory(background)
ShowWhen(AddSection(backgroundLayout, "Icon Background"), WhenAll("icon.enabled"))
ShowWhen(AddCheckbox(background, "background.enabled", "Enable icon background",
"Adds a colored rectangle behind the waypoint icon. Presets keep this option disabled."), WhenAll("icon.enabled"))
ShowWhen(AddSlider(background, "background.width", "Background width", 40, 180, 1), WhenAll("icon.enabled", "background.enabled"))
ShowWhen(AddSlider(background, "background.height", "Background height", 40, 180, 1), WhenAll("icon.enabled", "background.enabled"))
ShowWhen(AddColor(background, "background.color", "Background color"), WhenAll("icon.enabled", "background.enabled"))
ShowWhen(AddSlider(background, "background.alpha", "Background alpha", 0, 1, 0.05,
"Controls the opacity of the icon background."), WhenAll("icon.enabled", "background.enabled"))
local visibility, visibilityLayout = Settings.RegisterVerticalLayoutSubcategory(general, "Visibility")
TrackSettingsCategory(visibility)
AddSection(visibilityLayout, "Situational Hiding")
AddCheckbox(visibility, "visibility.hideInCombat", "Hide in combat",
"Makes the waypoint fully transparent while you are in combat.", false)
AddCheckbox(visibility, "visibility.hideInInstances", "Hide in dungeons, raids and scenarios",
"Hides the waypoint in party instances, raids and scenarios.", false)
AddCheckbox(visibility, "visibility.hideInArena", "Hide in arenas", nil, false)
AddCheckbox(visibility, "visibility.hideInBattleground", "Hide in battlegrounds", nil, false)
AddCheckbox(visibility, "visibility.hideWhileMounted", "Hide while mounted", nil, false)
AddSection(visibilityLayout, "Near Destination")
AddCheckbox(visibility, "visibility.hideNearEnabled", "Hide near destination",
"Hides an on-screen waypoint after you move within the selected distance. Off-screen arrows are not hidden by this rule.", false)
ShowWhen(AddSlider(visibility, "visibility.hideNearDistance", "Hide distance (1-100 yd)", 1, 100, 1,
"Hide the waypoint at or below this distance.", false, FormatYards), WhenAll("visibility.hideNearEnabled"))
AddSection(visibilityLayout, "Visibility Overrides")
AddCheckbox(visibility, "visibility.forceVisibleWhenClamped", "Force visible when clamped",
"Uses the configured Clamped alpha while the destination is off screen and Blizzard shows the edge arrow.", false)
AddCheckbox(visibility, "visibility.forceVisibleWhenOccluded", "Force visible when occluded",
"Uses the configured Occluded alpha when Blizzard reports that the destination is hidden behind world geometry.", false)
local compatibilityPanel = CreateCompatibilityPanel()
local compatibilityCategory, compatibilityLayout = Settings.RegisterCanvasLayoutSubcategory(general, compatibilityPanel, "Compatibility")
TrackSettingsCategory(compatibilityCategory)
compatibilityLayout:AddAnchorPoint("TOPLEFT", 0, 0)
compatibilityLayout:AddAnchorPoint("BOTTOMRIGHT", 0, 0)
local aboutPanel = CreateAboutPanel()
local aboutCategory, aboutLayout = Settings.RegisterCanvasLayoutSubcategory(general, aboutPanel, "About")
TrackSettingsCategory(aboutCategory)
aboutLayout:AddAnchorPoint("TOPLEFT", 0, 0)
aboutLayout:AddAnchorPoint("BOTTOMRIGHT", 0, 0)
Settings.RegisterAddOnCategory(general)
InstallDefaultsButtonGuard()
end
function WE.OpenSettings()
if WE.settingsCategory then
Settings.OpenToCategory(WE.settingsCategory:GetID())
end
end