Repository navigation
Expand file tree
/
Copy pathDansSpellRange.lua
More file actions
598 lines (511 loc) · 22.4 KB
/
Copy pathDansSpellRange.lua
File metadata and controls
598 lines (511 loc) · 22.4 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
local addonName = ...
-- Default SavedVariables settings
local DEFAULT_SETTINGS = {
tintIcon = false, -- true: tint the entire spell icon red when out of range
thickFont = true, -- true: apply THICKOUTLINE to keybind numbers
showBackdrop = false, -- true: display dark rectangular backdrop box behind numbers
bgAlpha = 0.65, -- Opacity of the background box (0.0 to 1.0)
fontSize = 13, -- Font size for keybind numbers (8-22)
shadowSize = 1.5, -- Font shadow offset in pixels (0-4, 0 = no shadow)
outOfRangeColor = { r = 1.0, g = 0.15, b = 0.15 }, -- Vivid neon red
inRangeColor = { r = 1.0, g = 1.0, b = 1.0 }, -- Pure crisp white
}
-- List of standard action button prefixes to style
local BUTTON_PREFIXES = {
"ActionButton",
"MultiBarBottomLeftButton",
"MultiBarBottomRightButton",
"MultiBarRightButton",
"MultiBarLeftButton",
"BonusActionButton",
"StanceButton",
"PetActionButton",
}
-- Forward declarations
local optionsPanel
local RefreshAllButtons
local StyleAllButtons
local OpenOptions
-- Newer clients moved these into C_ActionBar
local IsActionInRange = IsActionInRange or (C_ActionBar and C_ActionBar.IsActionInRange)
local IsUsableAction = IsUsableAction or (C_ActionBar and C_ActionBar.IsUsableAction)
-- Buttons whose icon we tinted red, so only those get their color put back
local tintedButtons = {}
-- Helper to safely retrieve hotkey font string for any button
local function GetButtonHotKey(button)
if not button then return nil end
return button.HotKey or _G[button:GetName() and (button:GetName() .. "HotKey")]
end
-- Helper to safely retrieve icon texture for any button
local function GetButtonIcon(button)
if not button then return nil end
return button.icon or _G[button:GetName() and (button:GetName() .. "Icon")]
end
-- Update the size and visibility of the optional dark square/box behind the hotkey
local function UpdateButtonBackdrop(button)
local hotkey = GetButtonHotKey(button)
local bg = button.DansSpellRangeBG
if not bg or not hotkey then return end
if DansSpellRangeDB.showBackdrop and hotkey:IsShown() then
local text = hotkey:GetText()
if text and text ~= "" then
local strWidth = hotkey:GetStringWidth() or 0
local strHeight = hotkey:GetStringHeight() or 0
if strWidth > 0 then
local alpha = DansSpellRangeDB.bgAlpha or DEFAULT_SETTINGS.bgAlpha
bg:SetSize(math.max(strWidth + 4, 10), math.max(strHeight + 2, 10))
bg:SetColorTexture(0, 0, 0, alpha)
bg:Show()
return
end
end
end
bg:Hide()
end
-- Style a button's hotkey font with clean THICKOUTLINE, font shadow, and optional square box
local function StyleButton(button)
if not button then return end
local hotkey = GetButtonHotKey(button)
if not hotkey then return end
local fontFile = NumberFontNormal and NumberFontNormal:GetFont() or hotkey:GetFont()
local targetSize = DansSpellRangeDB.fontSize or DEFAULT_SETTINGS.fontSize
local fontFlags = (DansSpellRangeDB.thickFont ~= false) and "THICKOUTLINE" or ""
local shadow = DansSpellRangeDB.shadowSize or DEFAULT_SETTINGS.shadowSize
hotkey:SetFont(fontFile, targetSize, fontFlags)
hotkey:SetShadowColor(0, 0, 0, shadow > 0 and 1 or 0)
hotkey:SetShadowOffset(shadow, -shadow)
hotkey:SetDrawLayer("OVERLAY", 7)
-- Manage optional dark square box
if DansSpellRangeDB.showBackdrop then
if not button.DansSpellRangeBG then
local bg = button:CreateTexture(nil, "OVERLAY", nil, 0)
bg:SetPoint("TOPRIGHT", hotkey, "TOPRIGHT", 2, 1)
button.DansSpellRangeBG = bg
hooksecurefunc(hotkey, "Show", function()
UpdateButtonBackdrop(button)
end)
hooksecurefunc(hotkey, "Hide", function()
if button.DansSpellRangeBG then
button.DansSpellRangeBG:Hide()
end
end)
hooksecurefunc(hotkey, "SetText", function()
UpdateButtonBackdrop(button)
end)
end
UpdateButtonBackdrop(button)
else
if button.DansSpellRangeBG then
button.DansSpellRangeBG:Hide()
end
end
end
-- Apply styling to all standard action buttons
StyleAllButtons = function()
for _, prefix in ipairs(BUTTON_PREFIXES) do
for i = 1, 12 do
local btn = _G[prefix .. i]
if btn then
StyleButton(btn)
end
end
end
end
-- Determine whether an action is currently out of range
local function IsActionOutOfRange(button)
if not button or not button.action then
return false
end
-- If no target or dead target, action is NEVER considered out of range
if not UnitExists("target") or UnitIsDeadOrGhost("target") then
return false
end
-- IsActionInRange check:
-- 0 or false = out of range / no line of sight
-- 1 or true = in range
-- nil = action has no range check on this target
local inRange = IsActionInRange(button.action)
if inRange == 0 or inRange == false then
return true
end
return false
end
-- Tint the icon red while out of range (when enabled). Once it shouldn't be red anymore,
-- give the icons we tinted Blizzard's usable / out of mana / unusable color back.
local function UpdateIconTint(button, outOfRange)
local icon = GetButtonIcon(button)
if not icon then return end
if DansSpellRangeDB.tintIcon and outOfRange then
icon:SetVertexColor(1.0, 0.2, 0.2) -- Red icon when out of range
tintedButtons[button] = true
elseif tintedButtons[button] then
tintedButtons[button] = nil
local isUsable, notEnoughMana = true, false
if button.action and IsUsableAction then
isUsable, notEnoughMana = IsUsableAction(button.action)
end
if isUsable then
icon:SetVertexColor(1.0, 1.0, 1.0) -- Normal full color
elseif notEnoughMana then
icon:SetVertexColor(0.5, 0.5, 1.0) -- Out of mana
else
icon:SetVertexColor(0.4, 0.4, 0.4) -- Unusable
end
end
end
-- Update both hotkey text and icon vertex colors for a button
local function UpdateButtonVisuals(button)
if not button then return end
local hotkey = GetButtonHotKey(button)
local outOfRange = IsActionOutOfRange(button)
-- 1. HotKey coloring: vivid red if out of range, crisp white if in range or idle
if hotkey then
if outOfRange then
local c = DansSpellRangeDB.outOfRangeColor or DEFAULT_SETTINGS.outOfRangeColor
hotkey:SetVertexColor(c.r, c.g, c.b)
else
local c = DansSpellRangeDB.inRangeColor or DEFAULT_SETTINGS.inRangeColor
hotkey:SetVertexColor(c.r, c.g, c.b)
end
end
-- 2. Icon coloring: red when tinting is on and out of range, otherwise undo our tint
UpdateIconTint(button, outOfRange)
end
-- Blizzard just reset the icon color for usability (e.g. mana changed): tint it again if still out of range
local function OnUsableUpdated(button)
if not button then return end
tintedButtons[button] = nil
UpdateIconTint(button, IsActionOutOfRange(button))
end
-- Instantly refresh range status and icon states on all buttons
-- (hidden ones too, so a tint is never left behind when tinting is turned off)
RefreshAllButtons = function()
for _, prefix in ipairs(BUTTON_PREFIXES) do
for i = 1, 12 do
local btn = _G[prefix .. i]
if btn then
UpdateButtonVisuals(btn)
end
end
end
end
-- Newer clients (Classic Era 1.15+) replaced the global ActionButton_* functions with
-- methods that each button has its own copy of, so hook them on every button
local function HookButtonMethods()
for _, prefix in ipairs(BUTTON_PREFIXES) do
for i = 1, 12 do
local btn = _G[prefix .. i]
if btn then
if btn.UpdateUsable then hooksecurefunc(btn, "UpdateUsable", OnUsableUpdated) end
if btn.UpdateHotkeys then hooksecurefunc(btn, "UpdateHotkeys", StyleButton) end
if btn.Update then hooksecurefunc(btn, "Update", StyleButton) end
end
end
end
end
-- Initialize database and apply defaults
local function InitDB()
DansSpellRangeDB = DansSpellRangeDB or {}
for k, v in pairs(DEFAULT_SETTINGS) do
if DansSpellRangeDB[k] == nil then
DansSpellRangeDB[k] = v
end
end
end
-- Print helper for chat messages
local function PrintMessage(msg)
print("|cff00ccffDan's Spell Range:|r " .. msg)
end
-------------------------------------------------------------------------------
-- Blizzard Options Menu Panel Registration
-------------------------------------------------------------------------------
local function CreateOptionsPanel()
if optionsPanel then return optionsPanel end
local panel = CreateFrame("Frame", "DansSpellRangeOptionsPanel", UIParent)
panel.name = "Dan's Spell Range"
-- Title
local title = panel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 16, -16)
title:SetText("Dan's Spell Range")
-- Subtitle
local subHeader = panel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
subHeader:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
subHeader:SetPoint("RIGHT", panel, "RIGHT", -16, 0)
subHeader:SetJustifyH("LEFT")
subHeader:SetText("Enhances action bar range indicators with high-contrast keybinds, pure font shadows, and full icon tinting.")
-- Helper to build styled checkboxes
local function CreateCheckbox(name, labelText, subtextText, yOffset, onClick)
local cb = CreateFrame("CheckButton", "DansSpellRangeOpt_" .. name, panel, "UICheckButtonTemplate")
cb:SetPoint("TOPLEFT", panel, "TOPLEFT", 16, yOffset)
local text = _G[cb:GetName() .. "Text"]
text:SetText(labelText)
text:SetFontObject("GameFontNormal")
if subtextText then
local sub = panel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
sub:SetPoint("TOPLEFT", cb, "BOTTOMLEFT", 28, -2)
sub:SetPoint("RIGHT", panel, "RIGHT", -20, 0)
sub:SetJustifyH("LEFT")
sub:SetText(subtextText)
sub:SetTextColor(0.72, 0.72, 0.72)
cb.Subtext = sub
end
cb:SetScript("OnClick", function(self)
local checked = self:GetChecked()
if type(checked) == "number" then checked = (checked == 1) end
onClick(checked)
end)
return cb
end
-- Helper to build styled sliders
local function CreateSlider(name, labelText, minVal, maxVal, step, yOffset, formatVal, onValChanged)
local slider = CreateFrame("Slider", "DansSpellRangeOpt_" .. name, panel, "OptionsSliderTemplate")
slider:SetPoint("TOPLEFT", panel, "TOPLEFT", 24, yOffset)
slider:SetWidth(300)
slider:SetMinMaxValues(minVal, maxVal)
slider:SetValueStep(step)
slider:SetObeyStepOnDrag(true)
local t = _G[slider:GetName() .. "Text"]
t:SetFontObject("GameFontNormal")
t:SetText(labelText)
local low = _G[slider:GetName() .. "Low"]
low:SetText(tostring(minVal))
local high = _G[slider:GetName() .. "High"]
high:SetText(tostring(maxVal))
local valDisplay = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
valDisplay:SetPoint("LEFT", t, "RIGHT", 10, 0)
slider.ValDisplay = valDisplay
slider:SetScript("OnValueChanged", function(self, value)
onValChanged(value)
valDisplay:SetText(formatVal(value))
end)
return slider
end
-- 1. Checkbox: Whole icon tint
local cbTint = CreateCheckbox("TintIcon", "Tint whole spell icon red", "When an action is out of range, colors the entire button icon red instead of just the number.", -75,
function(checked)
DansSpellRangeDB.tintIcon = checked
RefreshAllButtons()
end
)
-- 2. Checkbox: Thick keybind font
local cbThick = CreateCheckbox("ThickFont", "Thick keybind numbers (THICKOUTLINE)", "Applies a bold font with a clean THICKOUTLINE to keybind numbers (1-9, etc.).", -140,
function(checked)
DansSpellRangeDB.thickFont = checked
StyleAllButtons()
RefreshAllButtons()
end
)
-- 3. Checkbox: Optional dark square box
local cbBackdrop = CreateCheckbox("Backdrop", "Dark background box behind numbers (Optional)", "Displays a subtle dark rectangular backing box behind keybind numbers for extra contrast on bright icons.", -205,
function(checked)
DansSpellRangeDB.showBackdrop = checked
StyleAllButtons()
end
)
-- 4. Slider: Font Size
local sliderSize = CreateSlider("FontSize", "Keybind Font Size", 8, 22, 1, -280,
function(val) return "|cffffd100" .. math.floor(val) .. " pt|r" end,
function(val)
DansSpellRangeDB.fontSize = math.floor(val)
StyleAllButtons()
end
)
-- 5. Slider: Shadow Size (offset in half pixels, 0 = no shadow)
local sliderShadow = CreateSlider("ShadowSize", "Keybind Shadow Size", 0, 4, 0.5, -335,
function(val) return "|cffffd100" .. (math.floor(val * 2 + 0.5) / 2) .. " px|r" end,
function(val)
DansSpellRangeDB.shadowSize = math.floor(val * 2 + 0.5) / 2
StyleAllButtons()
end
)
-- 6. Slider: Box Darkness (Opacity)
local sliderAlpha = CreateSlider("BoxAlpha", "Background Box Darkness", 0, 100, 5, -390,
function(val) return "|cffffd100" .. math.floor(val) .. "%|r" end,
function(val)
DansSpellRangeDB.bgAlpha = val / 100
StyleAllButtons()
end
)
-- 7. Button: Defaults
local btnDefaults = CreateFrame("Button", nil, panel, "UIPanelButtonTemplate")
btnDefaults:SetSize(120, 24)
btnDefaults:SetPoint("TOPLEFT", panel, "TOPLEFT", 16, -450)
btnDefaults:SetText("Defaults")
btnDefaults:SetScript("OnClick", function()
for k, v in pairs(DEFAULT_SETTINGS) do
DansSpellRangeDB[k] = v
end
if panel.refresh then panel.refresh() end
StyleAllButtons()
RefreshAllButtons()
PrintMessage("All settings reset to defaults.")
end)
-- Refresh panel controls from DB
panel.refresh = function()
cbTint:SetChecked(DansSpellRangeDB.tintIcon)
cbThick:SetChecked(DansSpellRangeDB.thickFont ~= false)
cbBackdrop:SetChecked(DansSpellRangeDB.showBackdrop == true)
local curSize = DansSpellRangeDB.fontSize or DEFAULT_SETTINGS.fontSize
sliderSize:SetValue(curSize)
sliderSize.ValDisplay:SetText("|cffffd100" .. curSize .. " pt|r")
local curShadow = DansSpellRangeDB.shadowSize or DEFAULT_SETTINGS.shadowSize
sliderShadow:SetValue(curShadow)
sliderShadow.ValDisplay:SetText("|cffffd100" .. curShadow .. " px|r")
local curAlpha = math.floor((DansSpellRangeDB.bgAlpha or DEFAULT_SETTINGS.bgAlpha) * 100)
sliderAlpha:SetValue(curAlpha)
sliderAlpha.ValDisplay:SetText("|cffffd100" .. curAlpha .. "%|r")
end
panel.default = function()
for k, v in pairs(DEFAULT_SETTINGS) do
DansSpellRangeDB[k] = v
end
if panel.refresh then panel.refresh() end
StyleAllButtons()
RefreshAllButtons()
end
-- Hook panel OnShow to sync controls
panel:SetScript("OnShow", function()
if panel.refresh then panel.refresh() end
end)
-- Register with Blizzard Settings / Interface Options
if Settings and Settings.RegisterCanvasLayoutCategory and Settings.RegisterAddOnCategory then
-- Modern Settings UI (WoW 10.0+, 11.0+, Classic Era 1.15+)
local category = Settings.RegisterCanvasLayoutCategory(panel, "Dan's Spell Range")
Settings.RegisterAddOnCategory(category)
panel.settingsCategory = category
elseif InterfaceOptions_AddCategory then
-- Classic / Legacy Interface Options
InterfaceOptions_AddCategory(panel)
end
optionsPanel = panel
return optionsPanel
end
-- Open options panel directly (opens Game Menu Settings to the Dan's Spell Range tab).
-- Addons aren't allowed to open the Options window in combat (ADDON_ACTION_BLOCKED,
-- which pcall can't catch), so say so instead.
OpenOptions = function()
if InCombatLockdown() then
PrintMessage("Can't open the options during combat. Try again when combat ends.")
return
end
local panel = CreateOptionsPanel()
if not panel then return end
if Settings and Settings.OpenToCategory and panel.settingsCategory and panel.settingsCategory.GetID then
Settings.OpenToCategory(panel.settingsCategory:GetID())
elseif InterfaceOptionsFrame_OpenToCategory then
InterfaceOptionsFrame_OpenToCategory(panel)
InterfaceOptionsFrame_OpenToCategory(panel) -- Workaround for Blizzard double-call quirk
end
end
-------------------------------------------------------------------------------
-- Slash Commands
-------------------------------------------------------------------------------
local function HandleSlashCommand(msg)
local cmd, arg = strsplit(" ", (msg or ""):trim():lower(), 2)
if not cmd or cmd == "" or cmd == "options" or cmd == "config" or cmd == "menu" or cmd == "ui" then
OpenOptions()
elseif cmd == "tint" then
if arg == "on" then
DansSpellRangeDB.tintIcon = true
elseif arg == "off" then
DansSpellRangeDB.tintIcon = false
else
DansSpellRangeDB.tintIcon = not DansSpellRangeDB.tintIcon
end
PrintMessage("Full icon tinting: " .. (DansSpellRangeDB.tintIcon and "|cff00ff00Enabled|r" or "|cffff0000Disabled|r"))
RefreshAllButtons()
elseif cmd == "box" or cmd == "bg" then
if arg == "on" then
DansSpellRangeDB.showBackdrop = true
elseif arg == "off" then
DansSpellRangeDB.showBackdrop = false
else
DansSpellRangeDB.showBackdrop = not DansSpellRangeDB.showBackdrop
end
StyleAllButtons()
PrintMessage("Background box: " .. (DansSpellRangeDB.showBackdrop and "|cff00ff00Enabled|r" or "|cffff0000Disabled|r"))
elseif cmd == "size" then
local size = tonumber(arg)
if size and size >= 8 and size <= 22 then
DansSpellRangeDB.fontSize = size
StyleAllButtons()
PrintMessage("Font size set to |cffffd100" .. size .. "|r.")
else
PrintMessage("Usage: |cffffd100/dsr size <8-22>|r (current: " .. (DansSpellRangeDB.fontSize or DEFAULT_SETTINGS.fontSize) .. ")")
end
elseif cmd == "shadow" then
local shadow = tonumber(arg)
if shadow and shadow >= 0 and shadow <= 4 then
DansSpellRangeDB.shadowSize = math.floor(shadow * 2 + 0.5) / 2
StyleAllButtons()
PrintMessage("Shadow size set to |cffffd100" .. DansSpellRangeDB.shadowSize .. "|r.")
else
PrintMessage("Usage: |cffffd100/dsr shadow <0-4>|r, 0 turns it off (current: " .. (DansSpellRangeDB.shadowSize or DEFAULT_SETTINGS.shadowSize) .. ")")
end
elseif cmd == "reset" then
for k, v in pairs(DEFAULT_SETTINGS) do
DansSpellRangeDB[k] = v
end
if optionsPanel and optionsPanel.refresh then
optionsPanel.refresh()
end
StyleAllButtons()
RefreshAllButtons()
PrintMessage("Settings reset to default.")
else
PrintMessage("Available commands:")
print(" |cffffd100/dsr|r (or |cffffd100/dansspellrange|r) - Open options menu")
print(" |cffffd100/dsr tint|r - Toggle full spell icon red tinting (current: " .. (DansSpellRangeDB.tintIcon and "on" or "off") .. ")")
print(" |cffffd100/dsr box|r - Toggle background box behind numbers (current: " .. (DansSpellRangeDB.showBackdrop and "on" or "off") .. ")")
print(" |cffffd100/dsr size <8-22>|r - Set font size (current: " .. DansSpellRangeDB.fontSize .. ")")
print(" |cffffd100/dsr shadow <0-4>|r - Set shadow size, 0 for none (current: " .. DansSpellRangeDB.shadowSize .. ")")
print(" |cffffd100/dsr reset|r - Reset all settings to defaults")
end
end
-------------------------------------------------------------------------------
-- Main Event Lifecycle & Hooks
-------------------------------------------------------------------------------
local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("PLAYER_LOGIN")
eventFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
eventFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
eventFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
eventFrame:SetScript("OnEvent", function(self, event, ...)
if event == "PLAYER_LOGIN" then
InitDB()
-- Hook range indicator updates
if ActionButton_UpdateRangeIndicator then
hooksecurefunc("ActionButton_UpdateRangeIndicator", function(button, checksRange, inRange)
UpdateButtonVisuals(button)
end)
end
-- Hook usability updates so out-of-range icon tint isn't prematurely cleared by mana updates
if ActionButton_UpdateUsable then
hooksecurefunc("ActionButton_UpdateUsable", OnUsableUpdated)
end
-- Re-style buttons whenever hotkeys or actions are updated
if ActionButton_UpdateHotkeys then
hooksecurefunc("ActionButton_UpdateHotkeys", function(button)
StyleButton(button)
end)
end
if ActionButton_Update then
hooksecurefunc("ActionButton_Update", function(button)
StyleButton(button)
end)
end
-- Same hooks for clients where these are per-button methods
HookButtonMethods()
-- Initial styling
StyleAllButtons()
-- Register options panel into Blizzard Settings / Interface Options menu
CreateOptionsPanel()
-- Register slash commands: /dsr, /dansspellrange
SLASH_DANSSPELLRANGE1 = "/dsr"
SLASH_DANSSPELLRANGE2 = "/dansspellrange"
SlashCmdList["DANSSPELLRANGE"] = HandleSlashCommand
elseif event == "PLAYER_TARGET_CHANGED" or event == "PLAYER_REGEN_ENABLED" or event == "PLAYER_REGEN_DISABLED" then
-- Refresh range colors instantly when targeting/untargeting or engaging combat
RefreshAllButtons()
end
end)