Skip to content

Commit

Permalink
Added a debug NodeInfo module, which dumps a talent's nodeInfo when C…
Browse files Browse the repository at this point in the history
…TRL-clicking the talent button
  • Loading branch information
Numynum committed Oct 4, 2022
1 parent 75ff2d0 commit 0d951e3
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 32 deletions.
1 change: 1 addition & 0 deletions TalentTreeTweaks.toc
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ core.lua
modules\tooltipIds.lua
modules\exportInspectedBuild.lua
modules\shiftClickToLinkSpells.lua
modules\debugNodeInfo.lua
112 changes: 112 additions & 0 deletions modules/debugNodeInfo.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
local _, TTT = ...;
--- @type TalentTreeTweaks_Main
local Main = TTT.Main;

local Module = Main:NewModule('DebugNodeInfo');

function Module:OnEnable()
EventRegistry:RegisterCallback('TalentButton.OnClick', self.OnButtonClick, self);
end

function Module:OnDisable()
EventRegistry:UnregisterCallback('TalentButton.OnClick', self);
end

function Module:GetDescription()
return 'CTRL-clicking a talent will open a table inspector of your choice, with the nodeInfo associated with the node.';
end

function Module:GetName()
return 'Debug Talent.nodeInfo';
end

function Module:GetOptions(defaultOptionsTable, db)
local defaultDb = {
tinspect = true,
viragDevTool = true,
luaBrowser = true,
slashDump = false,
}
self.db = db;
for k, v in pairs(defaultDb) do
if db[k] == nil then
db[k] = v;
end
end

local set = function(info, value)
self.db[info[#info]] = value;
end;
local get = function(info)
return self.db[info[#info]];
end;
local order = 5;
local function increment() order = order + 1; return order; end;

defaultOptionsTable.args.extraDescription = {
type = 'description',
name = 'You can toggle any of the following on/off to enable/disable the integration with that debug tool.',
order = increment(),
};
defaultOptionsTable.args.tinspect = {
type = 'toggle',
name = '/tinspect',
desc = 'Opens Blizzard\'s table inspect window.',
get = get,
set = set,
order = increment(),
};
defaultOptionsTable.args.viragDevTool = {
type = 'toggle',
name = 'ViragDevTool',
desc = 'Use ViragDevTool to inspect the nodeInfo table.',
get = get,
set = set,
disabled = not select(4, GetAddOnInfo('ViragDevTool')), -- 4-> loadable
order = increment(),
};
defaultOptionsTable.args.luaBrowser = {
type = 'toggle',
name = 'LuaBrowser',
desc = 'Use LuaBrowser to inspect the nodeInfo table.',
get = get,
set = set,
disabled = not select(4, GetAddOnInfo('LuaBrowser')), -- 4-> loadable
order = increment(),
};
defaultOptionsTable.args.slashDump = {
type = 'toggle',
name = '/dump',
desc = 'Dump the nodeInfo table to chat.',
get = get,
set = set,
order = increment(),
};

return defaultOptionsTable;
end

function Module:OnButtonClick(buttonFrame, mouseButton)
if mouseButton ~= 'LeftButton' or not IsControlKeyDown() then
return;
end
local nodeInfo = buttonFrame.nodeInfo

if self.db.tinspect then
UIParentLoadAddOn("Blizzard_DebugTools");
DisplayTableInspectorWindow(nodeInfo);
end

if self.db.viragDevTool and ViragDevTool_AddData then
ViragDevTool_AddData(nodeInfo, 'NodeInfo ID ' .. nodeInfo.ID);
end

if self.db.luaBrowser and SlashCmdList.LuaBrowser then
_G['TalentTreeTweaksDebugNodeInfo'] = nodeInfo;
SlashCmdList.LuaBrowser('code TalentTreeTweaksDebugNodeInfo');
end

if self.db.slashDump then
DevTools_Dump(nodeInfo, 'value');
end
end
10 changes: 3 additions & 7 deletions modules/shiftClickToLinkSpells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ local Main = TTT.Main;

local Module = Main:NewModule('LinkSpells');

function Module:OnInitialize()
EventRegistry:RegisterCallback('TalentButton.OnClick', self.OnButtonClick, self);
end

function Module:OnEnable()
self.enabled = true
EventRegistry:RegisterCallback('TalentButton.OnClick', self.OnButtonClick, self);
end

function Module:OnDisable()
self.enabled = false
EventRegistry:UnregisterCallback('TalentButton.OnClick', self);
end

function Module:GetDescription()
Expand All @@ -29,7 +25,7 @@ function Module:GetOptions(defaultOptionsTable, db)
end

function Module:OnButtonClick(buttonFrame, mouseButton)
if not self.enabled or mouseButton ~= 'LeftButton' or not IsModifiedClick('CHATLINK') then
if mouseButton ~= 'LeftButton' or not IsModifiedClick('CHATLINK') then
return;
end
local spellId = buttonFrame:GetSpellID();
Expand Down
48 changes: 23 additions & 25 deletions modules/tooltipIds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ local Main = TTT.Main;

local Module = Main:NewModule('TooltipIds');

function Module:OnInitialize()
function Module:OnEnable()
EventRegistry:RegisterCallback("TalentDisplay.TooltipCreated", self.OnTalentTooltipCreated, self)
EventRegistry:RegisterCallback("ProfessionSpecs.SpecPerkEntered", self.OnProfessionPerkEntered, self)
EventRegistry:RegisterCallback("ProfessionSpecs.SpecPathEntered", self.OnProfessionPathEntered, self)
end

function Module:OnEnable()
self.enabled = true
end

function Module:OnDisable()
self.enabled = false
EventRegistry:UnregisterCallback("TalentDisplay.TooltipCreated", self)
EventRegistry:UnregisterCallback("ProfessionSpecs.SpecPerkEntered", self)
EventRegistry:UnregisterCallback("ProfessionSpecs.SpecPathEntered", self)
end

function Module:GetDescription()
Expand All @@ -26,24 +24,24 @@ function Module:GetName()
return 'Tooltip IDs'
end

local defaultDb = {
talentTooltip = {
enabled = true,
nodeId = true,
entryId = true,
definitionId = false,
spellId = true,
},
professionTooltip = {
enabled = true,
nodeId = true,
entryId = true,
definitionId = false,
spellId = true,
},
}

function Module:GetOptions(defaultOptionsTable, db)
local defaultDb = {
talentTooltip = {
enabled = true,
nodeId = true,
entryId = true,
definitionId = false,
spellId = true,
},
professionTooltip = {
enabled = true,
nodeId = true,
entryId = true,
definitionId = false,
spellId = true,
},
}
self.db = db;
for k, v in pairs(defaultDb) do
if db[k] == nil then
Expand Down Expand Up @@ -135,7 +133,7 @@ function Module:AddGenericTraitButtonTooltips(button, tooltip, settings)
end

function Module:OnTalentTooltipCreated(button, tooltip)
if not self.enabled or not self.db.talentTooltip.enabled then return end
if not self.db.talentTooltip.enabled then return end
local settings = self.db.talentTooltip
if settings.nodeId then
self:AddItemToTooltip('NodeId', button.GetNodeID and button:GetNodeID() or button:GetNodeInfo().ID, tooltip)
Expand All @@ -144,7 +142,7 @@ function Module:OnTalentTooltipCreated(button, tooltip)
end

function Module:OnProfessionPerkEntered(perkId)
if not self.enabled or not self.db.professionTooltip.enabled then return end
if not self.db.professionTooltip.enabled then return end

local tooltip = GameTooltip
if not tooltip:IsShown() then return end
Expand All @@ -159,7 +157,7 @@ function Module:OnProfessionPerkEntered(perkId)
end

function Module:OnProfessionPathEntered(nodeId)
if not self.enabled or not self.db.professionTooltip.enabled then return end
if not self.db.professionTooltip.enabled then return end

local tooltip = GameTooltip
if not tooltip:IsShown() then return end
Expand Down

0 comments on commit 0d951e3

Please sign in to comment.