Skip to content

Commit f05c82a

Browse files
committed
Update in preparation for legion remix
1 parent cf2b08d commit f05c82a

File tree

2 files changed

+137
-24
lines changed

2 files changed

+137
-24
lines changed

modules/copyTalentButtonInfo.lua

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@ function Module:OnEnable()
2424
Util:ContinueOnAddonLoaded('Blizzard_GenericTraitUI', function()
2525
self:SetupHook(GenericTraitFrame);
2626
end);
27+
Util:ContinueOnAddonLoaded('Blizzard_RemixArtifactUI', function()
28+
self:SetupHook(RemixArtifactFrame);
29+
end);
2730
Util:ContinueOnAddonLoaded(TalentViewerLoader and TalentViewerLoader:GetLodAddonName() or 'TalentTreeViewer', function()
2831
local talentsTab = TalentViewer and TalentViewer.GetTalentFrame and TalentViewer:GetTalentFrame();
2932
if not talentsTab then return; end
3033
self:SetupHook(talentsTab);
3134
end);
35+
if TalentViewer then
36+
TalentViewer:GetTalentFrame():UnregisterCallback(TalentFrameBaseMixin.Event.TalentButtonAcquired, self);
37+
end
3238
self:RegisterEvent('PLAYER_REGEN_DISABLED');
3339
self:RegisterEvent('PLAYER_REGEN_ENABLED');
3440
EventRegistry:RegisterCallback("TalentDisplay.TooltipCreated", self.OnTalentTooltipCreated, self)
@@ -47,6 +53,9 @@ function Module:OnDisable()
4753
if GenericTraitFrame then
4854
GenericTraitFrame:UnregisterCallback(TalentFrameBaseMixin.Event.TalentButtonAcquired, self);
4955
end
56+
if RemixArtifactFrame then
57+
RemixArtifactFrame:UnregisterCallback(TalentFrameBaseMixin.Event.TalentButtonAcquired, self);
58+
end
5059
EventRegistry:UnregisterCallback("TalentDisplay.TooltipCreated", self)
5160
end
5261

@@ -141,17 +150,17 @@ Module.hookedTooltipFrames = {};
141150
function Module:OnSpellbookUpdate()
142151
local spellBookFrame = Util:GetTalentContainerFrame().SpellBookFrame;
143152

144-
for _, frame in pairs(spellBookFrame.PagedSpellsFrame.frames) do
145-
if frame.elementData and frame.spellBookItemInfo then -- Avoid header or spacer frames
153+
for _, frame in pairs(spellBookFrame.PagedSpellsFrame.frames) do
154+
if frame.elementData and frame.spellBookItemInfo then -- Avoid header or spacer frames
146155
local button = frame.Button;
147156
if self:IsHooked(button, 'OnEnter') then
148157
return;
149158
end
150159
self.hookedTooltipFrames[button] = true;
151160
self:SecureHookScript(button, 'OnEnter', 'OnSpellbookButtonEnter');
152161
self:SecureHookScript(button, 'OnLeave', 'OnSpellbookButtonLeave');
153-
end
154-
end
162+
end
163+
end
155164
end
156165

157166
function Module:OnTalentTooltipCreated(_, tooltip)

modules/debugNodeInfo.lua

Lines changed: 124 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,65 @@
11
local _, TTT = ...;
22
--- @type TalentTreeTweaks_Main
33
local Main = TTT.Main;
4+
--- @type TalentTreeTweaks_Util
5+
local Util = TTT.Util;
46
local L = TTT.L;
57

6-
local Module = Main:NewModule('DebugNodeInfo');
8+
--- @class TalentTreeTweaks_DebugNodeInfo: AceModule, AceHook-3.0, AceEvent-3.0
9+
local Module = Main:NewModule('DebugNodeInfo', 'AceHook-3.0', 'AceEvent-3.0');
10+
11+
function Module:OnInitialize()
12+
self.bindingButton = CreateFrame('Button', 'TalentTreeTweaks_DebugNodeInfoButton');
13+
self.bindingButton:SetScript('OnClick', function()
14+
if self.targetButton then
15+
self:ShowDebugInfo(self.targetButton);
16+
end
17+
end);
18+
end
719

820
function Module:OnEnable()
9-
EventRegistry:RegisterCallback('TalentButton.OnClick', self.OnButtonClick, self);
21+
Util:OnTalentUILoad(function()
22+
self:SetupHook(Util:GetTalentFrame());
23+
end);
24+
Util:ContinueOnAddonLoaded('Blizzard_GenericTraitUI', function()
25+
self:SetupHook(GenericTraitFrame);
26+
end);
27+
Util:ContinueOnAddonLoaded('Blizzard_RemixArtifactUI', function()
28+
self:SetupHook(RemixArtifactFrame);
29+
end);
30+
Util:ContinueOnAddonLoaded(TalentViewerLoader and TalentViewerLoader:GetLodAddonName() or 'TalentTreeViewer', function()
31+
local talentsTab = TalentViewer and TalentViewer.GetTalentFrame and TalentViewer:GetTalentFrame();
32+
if not talentsTab then return; end
33+
self:SetupHook(talentsTab);
34+
end);
35+
self:RegisterEvent('PLAYER_REGEN_DISABLED');
36+
self:RegisterEvent('PLAYER_REGEN_ENABLED');
37+
EventRegistry:RegisterCallback("TalentDisplay.TooltipCreated", self.OnTalentTooltipCreated, self)
1038
end
1139

1240
function Module:OnDisable()
13-
EventRegistry:UnregisterCallback('TalentButton.OnClick', self);
41+
self.targetButton = nil;
42+
self:DisableBinding();
43+
self:UnhookAll();
44+
45+
local talentFrame = Util:GetTalentFrameIfLoaded();
46+
if talentFrame then
47+
talentFrame:UnregisterCallback(TalentFrameBaseMixin.Event.TalentButtonAcquired, self);
48+
end
49+
if TalentViewer then
50+
TalentViewer:GetTalentFrame():UnregisterCallback(TalentFrameBaseMixin.Event.TalentButtonAcquired, self);
51+
end
52+
if GenericTraitFrame then
53+
GenericTraitFrame:UnregisterCallback(TalentFrameBaseMixin.Event.TalentButtonAcquired, self);
54+
end
55+
if RemixArtifactFrame then
56+
RemixArtifactFrame:UnregisterCallback(TalentFrameBaseMixin.Event.TalentButtonAcquired, self);
57+
end
58+
EventRegistry:UnregisterCallback("TalentDisplay.TooltipCreated", self)
1459
end
1560

1661
function Module:GetDescription()
17-
return L['CTRL-clicking a talent will open a table inspector of your choice, with the nodeInfo associated with the node.'];
62+
return L['Allows you to press CTRL-D to open a table inspector of your choice, with the nodeInfo associated with the node.'];
1863
end
1964

2065
function Module:GetName()
@@ -27,7 +72,6 @@ function Module:GetOptions(defaultOptionsTable, db)
2772
viragDevTool = true,
2873
luaBrowser = true,
2974
slashDump = false,
30-
addButtonToTable = true,
3175
}
3276
self.db = db;
3377
for k, v in pairs(defaultDb) do
@@ -43,21 +87,15 @@ function Module:GetOptions(defaultOptionsTable, db)
4387
return self.db[info[#info]];
4488
end;
4589
local order = 5;
46-
local function increment() order = order + 1; return order; end;
90+
local function increment()
91+
order = order + 1; return order;
92+
end;
4793

4894
defaultOptionsTable.args.extraDescription = {
4995
type = 'description',
5096
name = L['You can toggle any of the following on/off to enable/disable the integration with that debug tool.'],
5197
order = increment(),
5298
};
53-
defaultOptionsTable.args.addButtonToTable = {
54-
type = 'toggle',
55-
name = L['Add the button to NodeInfo table when dumped'],
56-
desc = L['Adds a _button property to the nodeInfo table, which is a reference to the talent button.'],
57-
get = get,
58-
set = set,
59-
order = increment(),
60-
};
6199
defaultOptionsTable.args.tinspect = {
62100
type = 'toggle',
63101
name = '/tinspect',
@@ -96,15 +134,81 @@ function Module:GetOptions(defaultOptionsTable, db)
96134
return defaultOptionsTable;
97135
end
98136

99-
function Module:OnButtonClick(buttonFrame, mouseButton)
100-
if mouseButton ~= 'LeftButton' or not IsControlKeyDown() then
137+
function Module:SetupHook(talentsTab)
138+
talentsTab:RegisterCallback(TalentFrameBaseMixin.Event.TalentButtonAcquired, self.OnTalentButtonAcquired, self);
139+
for talentButton in talentsTab:EnumerateAllTalentButtons() do
140+
self:OnTalentButtonAcquired(talentButton);
141+
end
142+
self:SecureHook(talentsTab, 'ShowSelections', 'OnShowSelections');
143+
end
144+
145+
function Module:EnableBinding()
146+
if not InCombatLockdown() then
147+
SetOverrideBinding(
148+
self.bindingButton,
149+
true,
150+
'CTRL-D',
151+
string.format('CLICK %s:LeftButton', self.bindingButton:GetName())
152+
);
153+
end
154+
end
155+
156+
function Module:DisableBinding()
157+
if not InCombatLockdown() then
158+
ClearOverrideBindings(self.bindingButton);
159+
end
160+
end
161+
162+
function Module:PLAYER_REGEN_DISABLED()
163+
if self.targetButton then
164+
self:DisableBinding();
165+
end
166+
end
167+
168+
function Module:PLAYER_REGEN_ENABLED()
169+
if self.targetButton then
170+
self:EnableBinding();
171+
end
172+
end
173+
174+
function Module:OnTalentButtonEnter(talentButton)
175+
self.targetButton = talentButton;
176+
self:EnableBinding();
177+
end
178+
179+
function Module:OnTalentButtonLeave()
180+
self.targetButton = nil;
181+
self:DisableBinding();
182+
end
183+
184+
function Module:OnTalentButtonAcquired(talentButton)
185+
if self:IsHooked(talentButton, 'OnEnter') then
101186
return;
102187
end
103-
local nodeInfo = buttonFrame.nodeInfo or buttonFrame.GetNodeInfo and buttonFrame:GetNodeInfo() or {};
104-
if self.db.addButtonToTable then
105-
nodeInfo = Mixin({}, nodeInfo);
106-
nodeInfo._button = buttonFrame;
188+
self:SecureHookScript(talentButton, 'OnEnter', 'OnTalentButtonEnter');
189+
self:SecureHookScript(talentButton, 'OnLeave', 'OnTalentButtonLeave');
190+
end
191+
192+
function Module:OnShowSelections(talentsTab)
193+
for _, button in pairs(talentsTab.SelectionChoiceFrame.selectionFrameArray) do
194+
self:OnTalentButtonAcquired(button);
195+
end
196+
end
197+
198+
function Module:OnTalentTooltipCreated(_, tooltip)
199+
local text = GREEN_FONT_COLOR:WrapTextInColorCode(L['CTRL-D to debug nodeInfo']);
200+
if InCombatLockdown() then
201+
text = string.format('%s|cFFFF0000 %s|r', text, L['blocked in combat']);
107202
end
203+
tooltip:AddLine(text);
204+
tooltip:Show();
205+
end
206+
207+
function Module:ShowDebugInfo(buttonFrame)
208+
local nodeInfo = buttonFrame.nodeInfo or buttonFrame.GetNodeInfo and buttonFrame:GetNodeInfo() or {};
209+
nodeInfo = Mixin({}, nodeInfo);
210+
nodeInfo._button = buttonFrame;
211+
nodeInfo._entryInfo = buttonFrame.entryInfo or buttonFrame.GetEntryInfo and buttonFrame:GetEntryInfo() or nil;
108212

109213
if self.db.tinspect then
110214
UIParentLoadAddOn("Blizzard_DebugTools");

0 commit comments

Comments
 (0)