From e7b6c39ace1d1759850d2567063633abae2f4732 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Tue, 27 Oct 2026 18:06:55 -0500 Subject: [PATCH] feat(debugtools): port retail's table inspector Replace the minimal /tinspect window with retail's Blizzard_TableInspector and its anchor and attribute providers. The window lists a table's anchors and its fields grouped by type, with child frames and regions, editable numbers, strings and booleans, a filter, back and forward history, open-parent, duplicate, and Show / Highlight / Dynamic Updates toggles. The provider XML is retail's, unchanged. 1.12 changes to the main window: a backdrop and plain title bar replace the gear-manager art, the scroll-up and plus buttons replace two retail textures, and the scroll frame and filter box are small unnamed templates. Windows come from a frame pool and have no names, so the stock InputBoxTemplate's $parent-named border and UIPanelScrollFrameTemplate's named scroll bar would be shared by every window. /tinspect works as on retail: a table result opens on it; otherwise it opens on the frame under the cursor, or UIParent. Ctrl in /fstack opens TableAttributeDisplay. The frame highlight (AnchorHighlightMixin, FrameHighlightTemplate) comes from retail's Blizzard_DebugTools. !!!ClassicAPI gains retail's TruncatedTooltipScriptTemplate and PanelDragBarTemplate, GetAppropriateTooltip, GameTooltip_AddNormalLine and GameTooltip_AddColoredLine. --- README.md | 2 +- .../AddOns/!!!ClassicAPI/!!!ClassicAPI.toc | 2 + .../FrameXML/SharedUIPanelTemplates.lua | 114 ++++ .../FrameXML/SharedUIPanelTemplates.xml | 25 + .../AddOns/!!!ClassicAPI/Util/FrameUtil.lua | 4 + .../AddOns/!!!ClassicAPI/Util/GameTooltip.lua | 12 + .../Util/SlashCommandsRegistry.lua | 21 +- .../ClassicAPI_DebugTools.toc | 5 +- .../ClassicAPI_DebugTools/DebugTools.lua | 59 +- .../ClassicAPI_DebugTools/DebugTools.xml | 185 +----- .../ClassicAPI_DebugTools/TableInspector.lua | 578 +++++++++--------- .../ClassicAPI_DebugTools/TableInspector.xml | 319 ++++++++++ .../TableInspectorAnchorDataProvider.lua | 62 ++ .../TableInspectorAnchorDataProvider.xml | 50 ++ .../TableInspectorAttributeDataProvider.lua | 239 ++++++++ .../TableInspectorAttributeDataProvider.xml | 118 ++++ .../TableInspectorDataProvider.lua | 29 + 17 files changed, 1355 insertions(+), 469 deletions(-) create mode 100644 src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.xml create mode 100644 src/embed/AddOns/ClassicAPI_DebugTools/TableInspector.xml create mode 100644 src/embed/AddOns/ClassicAPI_DebugTools/TableInspectorAnchorDataProvider.lua create mode 100644 src/embed/AddOns/ClassicAPI_DebugTools/TableInspectorAnchorDataProvider.xml create mode 100644 src/embed/AddOns/ClassicAPI_DebugTools/TableInspectorAttributeDataProvider.lua create mode 100644 src/embed/AddOns/ClassicAPI_DebugTools/TableInspectorAttributeDataProvider.xml create mode 100644 src/embed/AddOns/ClassicAPI_DebugTools/TableInspectorDataProvider.lua diff --git a/README.md b/README.md index 3bd76bd8..c7cba457 100644 --- a/README.md +++ b/README.md @@ -466,7 +466,7 @@ that you use one of these commands: | `/dump ` | Shows a Lua value in the chat frame. It shows tables and all return values. Use it to examine the return values of `GetSpellInfo`, `C_Item.GetItemInfoInstant`, and other functions. | | `/etrace` | Opens the event trace window. Other forms: `/etrace start`, `/etrace stop`, `/etrace add EVENT`, and more. | | `/framestack [showHidden [showRegions]]` (or `/fstack`) | Shows a tooltip with a list of the frames under the cursor. A `-->` mark shows one frame, with its anchors and the file and line that made it. Left Alt and Right Alt move the mark. Ctrl opens the marked frame in the table inspector. Shift shows its texture files. | -| `/tinspect ` (or `/tins`) | Opens the table inspector on the result of ``. | +| `/tinspect [expr]` (or `/tins`) | Opens a table inspector on the result of `expr`. With no table, it opens on the frame under the cursor. The window shows the anchors and the fields of the table, grouped by type. You can edit numbers, strings and booleans, filter the lines, and open a child table or frame. | | `/luaerrors` (or `/scripterrors`) | Opens the Lua error window. | ## Building diff --git a/src/embed/AddOns/!!!ClassicAPI/!!!ClassicAPI.toc b/src/embed/AddOns/!!!ClassicAPI/!!!ClassicAPI.toc index f7fa9db9..ed0d8a8c 100644 --- a/src/embed/AddOns/!!!ClassicAPI/!!!ClassicAPI.toc +++ b/src/embed/AddOns/!!!ClassicAPI/!!!ClassicAPI.toc @@ -65,6 +65,8 @@ Util\MacroOptions.lua Util\SecureStateDriver.lua Util\MacroIconSelection.lua +FrameXML\SharedUIPanelTemplates.xml + Options\Panel.lua APIDocumentation\BaseAPIMixin.lua diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.lua b/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.lua new file mode 100644 index 00000000..1b7371cd --- /dev/null +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.lua @@ -0,0 +1,114 @@ +-- Backport of two templates from retail's +-- Blizzard_SharedXML/Mainline/SharedUIPanelTemplates.lua. +-- +-- Difference from the retail source: PanelDragBarMixin:UpdateCursor does +-- nothing. 1.12's cursor table has no UI_MOVE_CURSOR. + +function TruncatedTooltipScript_OnEnter(self) + local text = self.truncatedTooltipScriptText or self.Text; + if text:IsTruncated() then + local tooltip = GetAppropriateTooltip(); + tooltip:SetOwner(self, "ANCHOR_RIGHT"); + GameTooltip_AddNormalLine(tooltip, text:GetText()); + tooltip:Show(); + end +end + +function TruncatedTooltipScript_OnLeave(self) + local tooltip = GetAppropriateTooltip(); + if tooltip:GetOwner() == self then + tooltip:Hide(); + end +end + +PanelDragBarMixin = {}; + +function PanelDragBarMixin:OnLoad() + self:RegisterForDrag("LeftButton"); + self:SetTarget(self:GetParent()); + self.suspendDrag = false; +end + +function PanelDragBarMixin:SetDragSuspended(suspendDrag) + self.suspendDrag = suspendDrag; +end + +function PanelDragBarMixin:Init(target) + self:SetTarget(target); +end + +function PanelDragBarMixin:SetTarget(target) + self.target = target; + self.isMovingTarget = false; +end + +function PanelDragBarMixin:OnDragStart() + if self.suspendDrag then + return; + end + + local target = self.target; + + local continueDragStart = true; + if target.onDragStartCallback then + continueDragStart = target.onDragStartCallback(self); + end + + if self.onDragStartCallback then + continueDragStart = self.onDragStartCallback(self); + end + + if continueDragStart then + self.isMovingTarget = true; + target:StartMoving(); + end + + self:UpdateCursor(); +end + +function PanelDragBarMixin:OnDragStop() + if self.suspendDrag then + return; + end + + local target = self.target; + + local continueDragStop = true; + if target.onDragStopCallback then + continueDragStop = target.onDragStopCallback(self); + end + + if self.onDragStopCallback then + continueDragStop = self.onDragStopCallback(self); + end + + if continueDragStop then + self.isMovingTarget = false; + target:StopMovingOrSizing(); + end + + self:UpdateCursor(); +end + +function PanelDragBarMixin:SetOnDragStartCallback(onDragStartCallback) + self.onDragStartCallback = onDragStartCallback; +end + +function PanelDragBarMixin:SetOnDragStopCallback(onDragStopCallback) + self.onDragStopCallback = onDragStopCallback; +end + +function PanelDragBarMixin:OnEnter() + if self.showCursorOnHover then + self:UpdateCursor(); + end +end + +function PanelDragBarMixin:OnLeave() + if self.showCursorOnHover then + self:UpdateCursor(); + end +end + +function PanelDragBarMixin:UpdateCursor() +end diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.xml b/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.xml new file mode 100644 index 00000000..6aa8ea08 --- /dev/null +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.xml @@ -0,0 +1,25 @@ + + +