diff --git a/TalentTreeTweaks.toc b/TalentTreeTweaks.toc index bb02daa..de3b7fb 100644 --- a/TalentTreeTweaks.toc +++ b/TalentTreeTweaks.toc @@ -12,3 +12,4 @@ core.lua modules\tooltipIds.lua modules\exportInspectedBuild.lua modules\shiftClickToLinkSpells.lua +modules\debugNodeInfo.lua diff --git a/modules/debugNodeInfo.lua b/modules/debugNodeInfo.lua new file mode 100644 index 0000000..9d3faba --- /dev/null +++ b/modules/debugNodeInfo.lua @@ -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 diff --git a/modules/shiftClickToLinkSpells.lua b/modules/shiftClickToLinkSpells.lua index a1b60b2..e78c1d5 100644 --- a/modules/shiftClickToLinkSpells.lua +++ b/modules/shiftClickToLinkSpells.lua @@ -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() @@ -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(); diff --git a/modules/tooltipIds.lua b/modules/tooltipIds.lua index 18b647d..8598f9a 100644 --- a/modules/tooltipIds.lua +++ b/modules/tooltipIds.lua @@ -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() @@ -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 @@ -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) @@ -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 @@ -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