Skip to content

Commit 9989b5e

Browse files
committed
Added support for respeccing in Retail's Specializations UI
Various Retail-only settings no longer show up in Classic
1 parent 697d186 commit 9989b5e

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

main.lua

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ end
4444

4545
--- @type Button[]
4646
DialogKey.playerChoiceButtons = {}
47+
--- @type Button[]
48+
DialogKey.specButtons = {}
4749
DialogKey.activeOverrideBindings = {}
4850

51+
DialogKey.dummyButton = CreateFrame("Button")
52+
4953
function DialogKey:OnInitialize()
5054
DialogKeyNumyDB = DialogKeyNumyDB or {}
5155
--- @type DialogKeyDB
@@ -86,6 +90,9 @@ function DialogKey:ADDON_LOADED(_, addon)
8690
if addon == 'Blizzard_PlayerChoice' then
8791
self:SecureHook(PlayerChoiceFrame, "TryShow", "OnPlayerChoiceShow")
8892
self:SecureHookScript(PlayerChoiceFrame, "OnHide", "OnPlayerChoiceHide")
93+
elseif addon == 'Blizzard_PlayerSpells' then
94+
self:SecureHookScript(PlayerSpellsFrame.SpecFrame, "OnShow", "OnSpecFrameShow")
95+
self:SecureHookScript(PlayerSpellsFrame.SpecFrame, "OnHide", "OnSpecFrameHide")
8996
end
9097
end
9198

@@ -186,6 +193,24 @@ function DialogKey:OnPlayerChoiceHide()
186193
self.playerChoiceButtons = {}
187194
end
188195

196+
function DialogKey:OnSpecFrameShow()
197+
--- @type FramePool<Frame, ClassSpecContentFrameTemplate>
198+
local framePool = PlayerSpellsFrame.SpecFrame.SpecContentFramePool
199+
200+
self.specButtons = {}
201+
for specContentFrame in framePool:EnumerateActive() do
202+
--- @type ClassSpecContentFrameTemplate
203+
local specContentFrame = specContentFrame
204+
self.specButtons[specContentFrame.specIndex] = specContentFrame.ActivateButton
205+
local text = self.db.handleSpecFrame and (specContentFrame.specIndex .. ' ' .. TALENT_SPEC_ACTIVATE) or TALENT_SPEC_ACTIVATE
206+
specContentFrame.ActivateButton:SetText(text)
207+
end
208+
end
209+
210+
function DialogKey:OnSpecFrameHide()
211+
self.specButtons = {}
212+
end
213+
189214
--- @param GossipFrame GossipFrame
190215
function DialogKey:OnGossipFrameUpdate(GossipFrame)
191216
local scrollbox = GossipFrame.GreetingPanel.ScrollBox
@@ -369,6 +394,8 @@ function DialogKey:ShouldIgnoreInput()
369394
and not self:GetFirstVisibleCustomFrame()
370395
-- Ignore input if no player choice buttons are visible
371396
and not next(self.playerChoiceButtons)
397+
-- Ignore input if no spec buttons are visible
398+
and not next (self.specButtons)
372399
then
373400
return true
374401
end
@@ -495,6 +522,17 @@ function DialogKey:HandleKey(key)
495522
end
496523
end
497524

525+
-- Spec Frame
526+
if self.db.handleSpecFrame and next(self.specButtons) then
527+
local button = self.specButtons[keynum]
528+
if button then
529+
-- blocks keybind for currently selected spec index
530+
if not button:IsVisible() then button = self.dummyButton end
531+
self:SetClickbuttonBinding(button, key)
532+
return
533+
end
534+
end
535+
498536
-- GossipFrame
499537
if (doAction or self.db.numKeysForGossip) and GossipFrame.GreetingPanel:IsVisible() then
500538
while keynum and keynum > 0 and keynum <= #self.frames do

options.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ ns.defaultOptions = {
2828
handleCraftingOrders = true,
2929
handlePlayerChoice = true,
3030
numKeysForPlayerChoice = true,
31+
handleSpecFrame = true,
3132
postAuctions = false,
3233
ignoreInProgressQuests = true,
3334
}
@@ -267,19 +268,29 @@ function ns:GetOptionsTable()
267268
name = wrapName("Crafting Orders"),
268269
desc = "Handle Crafting Orders: Start them, Craft them, Complete them",
269270
descStyle = "inline", width = "full", type = "toggle",
271+
hidden = WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE,
270272
},
271273
handlePlayerChoice = {
272274
order = increment(),
273275
name = wrapName("Player Choice"),
274276
desc = "Use keybinding to select the first Player Choice option",
275277
descStyle = "inline", width = "full", type = "toggle",
278+
hidden = not C_AddOns.DoesAddOnExist("Blizzard_PlayerChoiceUI"),
276279
},
277280
numKeysForPlayerChoice = {
278281
order = increment(),
279282
name = wrapName("Number keys for Player Choice"),
280283
desc = "Use the number keys (1 -> 0) to select Player Choices",
281284
disabled = function() return not db.handlePlayerChoice end,
282285
descStyle = "inline", width = "full", type = "toggle",
286+
hidden = not C_AddOns.DoesAddOnExist("Blizzard_PlayerChoiceUI"),
287+
},
288+
handleSpecFrame = {
289+
order = increment(),
290+
name = wrapName(SPECIALIZATION),
291+
desc = "Use the number keys (1 -> 4) to select a specialization while the specialization tab is open",
292+
descStyle = "inline", width = "full", type = "toggle",
293+
hidden = WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE,
283294
},
284295
},
285296
},

0 commit comments

Comments
 (0)