mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
feat(ui): Lua error window replaces the stock error box
The Lua error window (/luaerrors) moves from the load-on-demand ClassicAPI_DebugTools into !!!ClassicAPI and becomes the client's error display. Each error opens it with the message, time, count and stack, and the arrows page through every error so far. 1.12.1's error handler is FrameXML's _ERRORMESSAGE (BasicControls.xml). It reports an error as ScriptErrors_Message:SetText(message) and then ScriptErrors:Show(), and only while the stock box is hidden. The window's OnLoad takes those two slots, the same two !BugGrabber 2.1.1 takes: SetText records the error and Show does nothing, so the stock box stays hidden and every error arrives. Errors still pass through the handler first, so: - !BugGrabber loads after !!!ClassicAPI and takes the slots back. BugSack gets the errors and the window does not open. - An addon that calls seterrorhandler (pfUI) replaces _ERRORMESSAGE, so neither shows. One that wraps the old handler still ends here. The engine's error function (0x00703B40) is C. It runs at the point of the error, before the stack unwinds, and calls the registered handler. From the SetText slot, level 1 is the slot, 2 is _ERRORMESSAGE, 3 is that C function and 4 is the code that failed, so the stack starts at debugstack(4), the level !BugGrabber's GrabError reads from the same slot. The text is ClassicAPI's ScrollingEditBoxTemplate with a MinimalScrollBar. The bottom row has Reload UI, arrows that wrap around the index label, and Close. /luaerrors opens or closes the window and /luaerrors clear empties it; the old on/off handler install is gone. Not tested in game yet.
This commit is contained in:
@@ -498,6 +498,23 @@ without a DLL rebuild. Without this file, the game uses the copy with the
|
||||
newer `## Version:`. The copy is hidden and always enabled, the same as
|
||||
the embedded addon.
|
||||
|
||||
## Lua errors
|
||||
|
||||
ClassicAPI replaces the game's Lua error box with a Lua error window. The
|
||||
window opens when an error occurs. It shows the message, the time, the count
|
||||
and the stack of each error. You can select and copy the text. The arrow
|
||||
buttons show the previous and the next error. The **Reload UI** button
|
||||
reloads the interface.
|
||||
|
||||
If you use `!BugGrabber` (with BugSack), BugGrabber gets the errors and the
|
||||
window does not open. If an addon sets its own error handler, the window also
|
||||
does not open.
|
||||
|
||||
| Command | Purpose |
|
||||
|---------|---------|
|
||||
| `/luaerrors` (or `/scripterrors`) | Opens or closes the Lua error window. |
|
||||
| `/luaerrors clear` | Removes all errors from the window. |
|
||||
|
||||
## Debug tools
|
||||
|
||||
ClassicAPI contains a backport of Blizzard's `Blizzard_DebugTools` addon,
|
||||
@@ -513,7 +530,6 @@ that you use one of these commands:
|
||||
| `/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. The tooltip also shows the addon that made the marked frame. When `scriptProfile` is `1`, it shows the CPU time of the frame scripts. |
|
||||
| `/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. |
|
||||
| `/profiler` (or `/prof`) | Opens the profiler. The profiler shows the Lua memory, the allocations and the CPU time of each addon, frame, event and global function. `/profiler widget` shows a small window with the Lua memory, the frame rate and the addons that use the most. `/profiler reset` sets the counters to zero. CPU times need `scriptProfile` `1`. `/profiler profile on` sets it and reloads the UI. |
|
||||
|
||||
## Building
|
||||
|
||||
@@ -137,6 +137,8 @@ FrameXML\LayoutFrame.xml
|
||||
FrameXML\SharedUIPanelTemplates.xml
|
||||
FrameXML\ColorSwatch.lua
|
||||
FrameXML\ColorSwatch.xml
|
||||
FrameXML\ScriptErrorsFrame.lua
|
||||
FrameXML\ScriptErrorsFrame.xml
|
||||
|
||||
Menu\MenuConstants.lua
|
||||
Menu\Classic\MenuConstants.lua
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
-- Backport of retail's Blizzard_ScriptErrorsFrame to vanilla 1.12 / Lua 5.0:
|
||||
-- the window that shows each Lua error with its time, count and stack, and
|
||||
-- pages through them. Retail always loads it; it lives here, not in the
|
||||
-- load-on-demand ClassicAPI_DebugTools, so that it is there for the first
|
||||
-- error.
|
||||
--
|
||||
-- How errors get here: 1.12's error handler (_ERRORMESSAGE, FrameXML\
|
||||
-- BasicControls.xml) reports each one as
|
||||
-- ScriptErrors_Message:SetText(message); ScriptErrors:Show();
|
||||
-- The frame's OnLoad takes those two slots, the same two !BugGrabber takes,
|
||||
-- so the stock box never shows and this window gets the error instead:
|
||||
-- - An addon that loads later and takes the slots again (!BugGrabber, which
|
||||
-- BugSack reads) replaces this window.
|
||||
-- - An addon that calls seterrorhandler replaces _ERRORMESSAGE, so neither
|
||||
-- shows; one that chains to the old handler (geterrorhandler) ends here.
|
||||
-- The stock box stays hidden, so the handler's IsVisible gate always passes
|
||||
-- and every error arrives. message() calls _ERRORMESSAGE, so its text shows
|
||||
-- here too.
|
||||
--
|
||||
-- Implementation differences from the retail source:
|
||||
-- - Global functions in the 3.3.5 style, not retail's
|
||||
-- ScriptErrorsFrameMixin.
|
||||
-- - The text is a ScrollingEditBoxTemplate with a MinimalScrollBar, the
|
||||
-- ScrollBox pair retail uses for scrolling edit boxes, not retail's
|
||||
-- ScrollFrameTemplate, which ClassicAPI does not port.
|
||||
-- - The stack starts at a fixed level, as in 3.3.5; 1.12 has no
|
||||
-- GetErrorCallstackHeight. The engine's error function (0x703B40) is C
|
||||
-- and calls the handler, so from the SetText slot level 1 is the slot,
|
||||
-- 2 is _ERRORMESSAGE, 3 is that C function and 4 is the code that failed.
|
||||
-- !BugGrabber's GrabError reads level 4 from the same slot. A handler
|
||||
-- that chains to _ERRORMESSAGE adds one level on top.
|
||||
-- - No Locals section: 1.12 has no debuglocals.
|
||||
-- - No scriptErrors cvar (1.12 always shows errors), no LUA_WARNING, no
|
||||
-- gamepad legend.
|
||||
-- - Lua 5.0: no `...` expression, no # operator.
|
||||
|
||||
DEBUGLOCALS_LEVEL = 4;
|
||||
|
||||
local ERROR_FORMAT = "|cffffd200Message:|r|cffffffff %s|r\n"
|
||||
.. "|cffffd200Time:|r|cffffffff %s|r\n"
|
||||
.. "|cffffd200Count:|r|cffffffff %s|r\n"
|
||||
.. "|cffffd200Stack:|r\n"
|
||||
.. "|cffffffff%s|r";
|
||||
|
||||
local INDEX_ORDER_FORMAT = "%d / %d";
|
||||
|
||||
function ScriptErrorsFrame_OnLoad(self)
|
||||
self.index = 0;
|
||||
self.errorData = {};
|
||||
self.seen = {};
|
||||
|
||||
-- No default text: with none set, an empty window would apply nil.
|
||||
self.ScrollingEditBox:SetDefaultTextEnabled(false);
|
||||
self.ScrollingEditBox:RegisterCallback("OnFocusGained", function(_, editBox)
|
||||
editBox:HighlightText(0);
|
||||
end, self);
|
||||
|
||||
-- Retail turns the wheel on with the OnMouseWheel script; 1.12 does not.
|
||||
local scrollBox = self.ScrollingEditBox:GetScrollBox();
|
||||
scrollBox:EnableMouseWheel(true);
|
||||
ScrollUtil.RegisterScrollBoxWithScrollBar(scrollBox, self.ScrollBar);
|
||||
|
||||
ScriptErrors_Message.SetText = function(_, message)
|
||||
ScriptErrorsFrame_OnError(message, debugstack(DEBUGLOCALS_LEVEL));
|
||||
end
|
||||
ScriptErrors.Show = function() end
|
||||
end
|
||||
|
||||
function ScriptErrorsFrame_OnError(message, stack)
|
||||
local self = ScriptErrorsFrame;
|
||||
message = tostring(message);
|
||||
stack = stack or "";
|
||||
|
||||
local messageKey = message .. "\n" .. stack;
|
||||
local index = self.seen[messageKey];
|
||||
if ( index ) then
|
||||
local errorData = self.errorData[index];
|
||||
errorData.count = errorData.count + 1;
|
||||
else
|
||||
table.insert(self.errorData, { count = 1, message = message, time = date(), stack = stack });
|
||||
index = table.getn(self.errorData);
|
||||
self.seen[messageKey] = index;
|
||||
end
|
||||
|
||||
if ( not self:IsShown() ) then
|
||||
self.index = index;
|
||||
self:Show();
|
||||
else
|
||||
ScriptErrorsFrame_Update();
|
||||
end
|
||||
end
|
||||
|
||||
function ScriptErrorsFrame_Update()
|
||||
local self = ScriptErrorsFrame;
|
||||
if ( not self.errorData[self.index] ) then
|
||||
self.index = table.getn(self.errorData);
|
||||
end
|
||||
|
||||
-- SetText puts the cursor and the scroll back at the top.
|
||||
local errorData = self.errorData[self.index];
|
||||
if ( errorData ) then
|
||||
self.ScrollingEditBox:SetText(string.format(ERROR_FORMAT, errorData.message, errorData.time, errorData.count, errorData.stack));
|
||||
self.ScrollingEditBox:GetEditBox():HighlightText(0);
|
||||
else
|
||||
self.ScrollingEditBox:ClearText();
|
||||
end
|
||||
|
||||
local numErrors = table.getn(self.errorData);
|
||||
ScriptErrorsFramePrevious:SetEnabled(numErrors > 1);
|
||||
ScriptErrorsFrameNext:SetEnabled(numErrors > 1);
|
||||
ScriptErrorsFrameIndexLabel:SetText(string.format(INDEX_ORDER_FORMAT, self.index, numErrors));
|
||||
end
|
||||
|
||||
-- Previous / Next wrap around, as on retail.
|
||||
function ScriptErrorsFrame_ChangeDisplayedIndex(delta)
|
||||
local self = ScriptErrorsFrame;
|
||||
local numErrors = table.getn(self.errorData);
|
||||
local index = self.index + delta;
|
||||
if ( index < 1 ) then
|
||||
index = numErrors;
|
||||
elseif ( index > numErrors ) then
|
||||
index = 1;
|
||||
end
|
||||
self.index = index;
|
||||
ScriptErrorsFrame_Update();
|
||||
end
|
||||
|
||||
function ScriptErrorsFrame_HandleSlashCmd(msg)
|
||||
local self = ScriptErrorsFrame;
|
||||
if ( string.lower(msg or "") == "clear" ) then
|
||||
self.index = 0;
|
||||
self.errorData = {};
|
||||
self.seen = {};
|
||||
ScriptErrorsFrame_Update();
|
||||
elseif ( self:IsShown() ) then
|
||||
self:Hide();
|
||||
else
|
||||
self:Show();
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,139 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\..\..\..\..\WoW\Data\Interface\AddOns\Blizzard_SharedXML\UI.xsd">
|
||||
<Frame name="ScriptErrorsFrame" parent="UIParent" movable="true" hidden="true" toplevel="true" frameStrata="DIALOG" enableMouse="true">
|
||||
<Size x="384" y="260"/>
|
||||
<Anchors>
|
||||
<Anchor point="CENTER"/>
|
||||
</Anchors>
|
||||
<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
|
||||
<BackgroundInsets>
|
||||
<AbsInset left="11" right="12" top="12" bottom="11"/>
|
||||
</BackgroundInsets>
|
||||
<TileSize>
|
||||
<AbsValue val="32"/>
|
||||
</TileSize>
|
||||
<EdgeSize>
|
||||
<AbsValue val="32"/>
|
||||
</EdgeSize>
|
||||
</Backdrop>
|
||||
<Layers>
|
||||
<!-- ARTWORK, not BACKGROUND: the Backdrop above draws its
|
||||
background and border into BACKGROUND, and it is applied
|
||||
after the textures declared here, so a header in that layer
|
||||
ends up behind the window border. Every Blizzard frame that
|
||||
uses UI-DialogBox-Header puts it in ARTWORK for this reason. -->
|
||||
<Layer level="ARTWORK">
|
||||
<Texture name="$parentTitleBG" file="Interface\DialogFrame\UI-DialogBox-Header">
|
||||
<Size x="256" y="64"/>
|
||||
<Anchors>
|
||||
<Anchor point="TOP">
|
||||
<Offset x="0" y="12"/>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
<FontString name="$parentTitle" inherits="GameFontNormal" text="LUA_ERROR">
|
||||
<Anchors>
|
||||
<Anchor point="TOP">
|
||||
<Offset x="0" y="-2"/>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
<FontString name="$parentIndexLabel" inherits="GameFontNormal" justifyH="CENTER">
|
||||
<Size x="70" y="16"/>
|
||||
<Anchors>
|
||||
<Anchor point="BOTTOM">
|
||||
<Offset x="0" y="20"/>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
</Layer>
|
||||
</Layers>
|
||||
<Frames>
|
||||
<Frame name="$parentTitleButton">
|
||||
<Size x="256" y="20"/>
|
||||
<Anchors>
|
||||
<Anchor point="TOP"/>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
this:RegisterForDrag("LeftButton");
|
||||
</OnLoad>
|
||||
<OnDragStart>ScriptErrorsFrame:StartMoving();</OnDragStart>
|
||||
<OnDragStop>ScriptErrorsFrame:StopMovingOrSizing();</OnDragStop>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
<!-- The edit box and its scroll bar fill the interior inside the
|
||||
32px dialog border, 16 to 368, where the Close button ends:
|
||||
the bar is 25 wide and sits 4 to the right of the edit box.
|
||||
Retail's numbers do not carry over here: its ScriptErrorsFrame
|
||||
inherits UIPanelDialogTemplate, a thin GearManager border. -->
|
||||
<Frame parentKey="ScrollingEditBox" inherits="ScrollingEditBoxTemplate">
|
||||
<KeyValues>
|
||||
<KeyValue key="fontName" value="GameFontHighlightSmall" type="string"/>
|
||||
</KeyValues>
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT" x="16" y="-32"/>
|
||||
<Anchor point="BOTTOMRIGHT" x="-45" y="58"/>
|
||||
</Anchors>
|
||||
</Frame>
|
||||
<EventFrame parentKey="ScrollBar" inherits="MinimalScrollBar">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT" relativeKey="$parent.ScrollingEditBox" relativePoint="TOPRIGHT" x="4" y="0"/>
|
||||
<Anchor point="BOTTOMLEFT" relativeKey="$parent.ScrollingEditBox" relativePoint="BOTTOMRIGHT" x="4" y="0"/>
|
||||
</Anchors>
|
||||
</EventFrame>
|
||||
<Button name="$parentReload" inherits="UIPanelButtonTemplate" text="RELOADUI">
|
||||
<Size x="96" y="24"/>
|
||||
<Anchors>
|
||||
<Anchor point="BOTTOMLEFT">
|
||||
<Offset x="16" y="16"/>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnClick>ReloadUI();</OnClick>
|
||||
</Scripts>
|
||||
</Button>
|
||||
<Button name="$parentPrevious">
|
||||
<Size x="32" y="32"/>
|
||||
<Anchors>
|
||||
<Anchor point="RIGHT" relativeTo="$parentIndexLabel" relativePoint="LEFT"/>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnClick>ScriptErrorsFrame_ChangeDisplayedIndex(-1);</OnClick>
|
||||
</Scripts>
|
||||
<NormalTexture file="Interface\Buttons\UI-SpellbookIcon-PrevPage-Up"/>
|
||||
<PushedTexture file="Interface\Buttons\UI-SpellbookIcon-PrevPage-Down"/>
|
||||
<DisabledTexture file="Interface\Buttons\UI-SpellbookIcon-PrevPage-Disabled"/>
|
||||
<HighlightTexture file="Interface\Buttons\UI-Common-MouseHilight" alphaMode="ADD"/>
|
||||
</Button>
|
||||
<Button name="$parentNext">
|
||||
<Size x="32" y="32"/>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parentIndexLabel" relativePoint="RIGHT"/>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnClick>ScriptErrorsFrame_ChangeDisplayedIndex(1);</OnClick>
|
||||
</Scripts>
|
||||
<NormalTexture file="Interface\Buttons\UI-SpellbookIcon-NextPage-Up"/>
|
||||
<PushedTexture file="Interface\Buttons\UI-SpellbookIcon-NextPage-Down"/>
|
||||
<DisabledTexture file="Interface\Buttons\UI-SpellbookIcon-NextPage-Disabled"/>
|
||||
<HighlightTexture file="Interface\Buttons\UI-Common-MouseHilight" alphaMode="ADD"/>
|
||||
</Button>
|
||||
<Button name="$parentClose" inherits="UIPanelButtonTemplate" text="CLOSE">
|
||||
<Size x="96" y="24"/>
|
||||
<Anchors>
|
||||
<Anchor point="BOTTOMRIGHT">
|
||||
<Offset x="-16" y="16"/>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnClick>ScriptErrorsFrame:Hide();</OnClick>
|
||||
</Scripts>
|
||||
</Button>
|
||||
</Frames>
|
||||
<Scripts>
|
||||
<OnLoad>ScriptErrorsFrame_OnLoad(this);</OnLoad>
|
||||
<OnShow>ScriptErrorsFrame_Update();</OnShow>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
</Ui>
|
||||
@@ -1000,6 +1000,15 @@ SlashCmdList["STOPMACRO"] = function(msg)
|
||||
end
|
||||
SLASH_STOPMACRO1 = "/stopmacro";
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- The Lua error window is always loaded (FrameXML\ScriptErrorsFrame).
|
||||
|
||||
SlashCmdList["LUAERRORS"] = function(msg)
|
||||
ScriptErrorsFrame_HandleSlashCmd(msg);
|
||||
end
|
||||
SLASH_LUAERRORS1 = "/luaerrors";
|
||||
SLASH_LUAERRORS2 = "/scripterrors";
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Debug tools: load on demand, as retail's chat frame does with
|
||||
-- Blizzard_DebugTools. The commands live here; the tools load on first use.
|
||||
@@ -1056,14 +1065,6 @@ end
|
||||
SLASH_TINSPECT1 = "/tinspect";
|
||||
SLASH_TINSPECT2 = "/tins";
|
||||
|
||||
SlashCmdList["LUAERRORS"] = function(msg)
|
||||
if ( LoadDebugTools() ) then
|
||||
ScriptErrorsFrame_HandleSlashCmd(msg);
|
||||
end
|
||||
end
|
||||
SLASH_LUAERRORS1 = "/luaerrors";
|
||||
SLASH_LUAERRORS2 = "/scripterrors";
|
||||
|
||||
SlashCmdList["PROFILER"] = function(msg)
|
||||
if ( LoadDebugTools() ) then
|
||||
ClassicAPIProfiler_HandleSlashCmd(msg);
|
||||
|
||||
@@ -199,11 +199,13 @@ SECOND_NUMBER_CAP = " M";
|
||||
SECOND_NUMBER_CAP_NO_SPACE = "M";
|
||||
THIRD_NUMBER = "billion";
|
||||
FOURTH_NUMBER = "trillion";
|
||||
LUA_ERROR = "Lua Error";
|
||||
MINUTES_SECONDS = "%.2d:%.2d";
|
||||
PAPERDOLL_EQUIPMENTMANAGER = "Equipment Manager";
|
||||
PAPERDOLL_NEWEQUIPMENTSET = "New Set";
|
||||
PERCENTAGE_STRING = "%d%%";
|
||||
PLAYER_LIST_DELIMITER = ", ";
|
||||
RELOADUI = "Reload UI";
|
||||
SET_FRIENDNOTE_LABEL = "Set Notes for %s:";
|
||||
SET_NOTE = "Set Note";
|
||||
SILVER_AMOUNT = "%d Silver";
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
-- FrameStackTooltip section).
|
||||
-- * No UIPanelDialogTemplate, no clampedToScreen, no
|
||||
-- OnSizeChanged in vanilla -- frames have fixed dimensions.
|
||||
-- * No debuglocals
|
||||
--
|
||||
-- UX additions cherry-picked from modern Blizzard_EventTrace
|
||||
-- (10.x+, anniversary _classic_era_):
|
||||
@@ -40,7 +39,6 @@ EVENT_TRACE_MAX_ENTRIES = 1000;
|
||||
EVENT_TRACE_NUM_BUTTONS = 26;
|
||||
EVENT_TRACE_FRAME_HEIGHT = (EVENT_TRACE_NUM_BUTTONS * EVENT_TRACE_EVENT_HEIGHT) + 68;
|
||||
|
||||
DEBUGLOCALS_LEVEL = 4;
|
||||
local _normalFontColor = { 1, .82, 0, 1 };
|
||||
|
||||
EVENT_TRACE_SYSTEM_TIMES = {};
|
||||
@@ -821,185 +819,6 @@ function EventTraceFrameEvent_OnClick(self)
|
||||
EventTraceFrame_Update();
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- ScriptErrorsFrame
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
local ERROR_FORMAT = "|cffffd200Message:|r|cffffffff %s|r\n"
|
||||
.. "|cffffd200Time:|r|cffffffff %s|r\n"
|
||||
.. "|cffffd200Count:|r|cffffffff %s|r\n"
|
||||
.. "|cffffd200Stack:|r|cffffffff %s|r";
|
||||
|
||||
local INDEX_ORDER_FORMAT = "%d / %d";
|
||||
|
||||
local _ScriptErrorsFrame;
|
||||
local _previousErrorHandler;
|
||||
|
||||
function ScriptErrorsFrame_OnLoad(self)
|
||||
local titleFS = getglobal(self:GetName() .. "Title");
|
||||
if (titleFS) then
|
||||
titleFS:SetText("Lua Error");
|
||||
end
|
||||
self:RegisterForDrag("LeftButton");
|
||||
self.seen = {};
|
||||
self.order = {};
|
||||
self.count = {};
|
||||
self.messages = {};
|
||||
self.times = {};
|
||||
_ScriptErrorsFrame = self;
|
||||
end
|
||||
|
||||
function ScriptErrorsFrame_OnShow(self)
|
||||
ScriptErrorsFrame_Update();
|
||||
end
|
||||
|
||||
function ScriptErrorsFrame_OnError(message, keepHidden)
|
||||
if (message == nil) then return; end
|
||||
local stack = debugstack(DEBUGLOCALS_LEVEL) or "";
|
||||
|
||||
local messageStack = message .. stack;
|
||||
|
||||
if (_ScriptErrorsFrame) then
|
||||
local index = _ScriptErrorsFrame.seen[messageStack];
|
||||
if (index) then
|
||||
_ScriptErrorsFrame.count[index] = _ScriptErrorsFrame.count[index] + 1;
|
||||
_ScriptErrorsFrame.messages[index] = message;
|
||||
_ScriptErrorsFrame.times[index] = date();
|
||||
else
|
||||
table.insert(_ScriptErrorsFrame.order, stack);
|
||||
index = table.getn(_ScriptErrorsFrame.order);
|
||||
_ScriptErrorsFrame.count[index] = 1;
|
||||
_ScriptErrorsFrame.messages[index] = message;
|
||||
_ScriptErrorsFrame.times[index] = date();
|
||||
_ScriptErrorsFrame.seen[messageStack] = index;
|
||||
end
|
||||
|
||||
if (not _ScriptErrorsFrame:IsShown() and not keepHidden) then
|
||||
_ScriptErrorsFrame.index = index;
|
||||
_ScriptErrorsFrame:Show();
|
||||
else
|
||||
ScriptErrorsFrame_Update();
|
||||
end
|
||||
end
|
||||
|
||||
-- Chain through to whatever previous handler existed (e.g. BugGrabber)
|
||||
if (_previousErrorHandler and _previousErrorHandler ~= ScriptErrorsFrame_OnError) then
|
||||
pcall(_previousErrorHandler, message);
|
||||
end
|
||||
end
|
||||
|
||||
function ScriptErrorsFrame_Update()
|
||||
local editBox = getglobal("ScriptErrorsFrameScrollFrameText");
|
||||
local index = _ScriptErrorsFrame.index;
|
||||
if (not index or not _ScriptErrorsFrame.order[index]) then
|
||||
index = table.getn(_ScriptErrorsFrame.order);
|
||||
_ScriptErrorsFrame.index = index;
|
||||
end
|
||||
|
||||
if (index == 0) then
|
||||
editBox:SetText("");
|
||||
ScriptErrorsFrame_UpdateButtons();
|
||||
return;
|
||||
end
|
||||
|
||||
local text = string.format(ERROR_FORMAT,
|
||||
_ScriptErrorsFrame.messages[index],
|
||||
_ScriptErrorsFrame.times[index],
|
||||
_ScriptErrorsFrame.count[index],
|
||||
_ScriptErrorsFrame.order[index]);
|
||||
|
||||
editBox:SetText(text);
|
||||
editBox:HighlightText(0);
|
||||
editBox:SetCursorPosition(0);
|
||||
|
||||
local scrollFrame = getglobal("ScriptErrorsFrameScrollFrame");
|
||||
if (scrollFrame and scrollFrame.SetVerticalScroll) then
|
||||
scrollFrame:SetVerticalScroll(0);
|
||||
end
|
||||
|
||||
ScriptErrorsFrame_UpdateButtons();
|
||||
end
|
||||
|
||||
function ScriptErrorsFrame_UpdateButtons()
|
||||
local index = _ScriptErrorsFrame.index;
|
||||
local numErrors = table.getn(_ScriptErrorsFrame.order);
|
||||
local nextBtn = getglobal("ScriptErrorsFrameNext");
|
||||
local prevBtn = getglobal("ScriptErrorsFramePrevious");
|
||||
local idxLbl = getglobal("ScriptErrorsFrameIndexLabel");
|
||||
|
||||
if (index == 0 or numErrors == 0) then
|
||||
nextBtn:Disable();
|
||||
prevBtn:Disable();
|
||||
else
|
||||
if (numErrors == 1) then
|
||||
nextBtn:Disable();
|
||||
prevBtn:Disable();
|
||||
elseif (index == 1) then
|
||||
nextBtn:Enable();
|
||||
prevBtn:Disable();
|
||||
elseif (index == numErrors) then
|
||||
nextBtn:Disable();
|
||||
prevBtn:Enable();
|
||||
else
|
||||
nextBtn:Enable();
|
||||
prevBtn:Enable();
|
||||
end
|
||||
end
|
||||
|
||||
idxLbl:SetText(string.format(INDEX_ORDER_FORMAT, index, numErrors));
|
||||
end
|
||||
|
||||
function ScriptErrorsFrameButton_OnClick(self)
|
||||
local id = self:GetID();
|
||||
if (id == 1) then
|
||||
_ScriptErrorsFrame.index = _ScriptErrorsFrame.index + 1;
|
||||
else
|
||||
_ScriptErrorsFrame.index = _ScriptErrorsFrame.index - 1;
|
||||
end
|
||||
ScriptErrorsFrame_Update();
|
||||
end
|
||||
|
||||
function ScriptErrorsFrame_TitleButton_OnDragStart()
|
||||
_ScriptErrorsFrame.moving = true;
|
||||
_ScriptErrorsFrame:StartMoving();
|
||||
end
|
||||
|
||||
function ScriptErrorsFrame_TitleButton_OnDragStop()
|
||||
_ScriptErrorsFrame.moving = nil;
|
||||
_ScriptErrorsFrame:StopMovingOrSizing();
|
||||
end
|
||||
|
||||
function ScriptErrorsFrame_HandleSlashCmd(msg)
|
||||
if (msg == nil) then msg = ""; end
|
||||
msg = string.lower(msg);
|
||||
if (msg == "on" or msg == "install") then
|
||||
_previousErrorHandler = geterrorhandler();
|
||||
seterrorhandler(ScriptErrorsFrame_OnError);
|
||||
_ChatPrint("Lua error capture installed.");
|
||||
elseif (msg == "off" or msg == "uninstall") then
|
||||
if (_previousErrorHandler) then
|
||||
seterrorhandler(_previousErrorHandler);
|
||||
end
|
||||
_ChatPrint("Lua error capture uninstalled.");
|
||||
elseif (msg == "test") then
|
||||
ScriptErrorsFrame_OnError("test error from /luaerrors test");
|
||||
elseif (msg == "clear") then
|
||||
_ScriptErrorsFrame.seen = {};
|
||||
_ScriptErrorsFrame.order = {};
|
||||
_ScriptErrorsFrame.count = {};
|
||||
_ScriptErrorsFrame.messages = {};
|
||||
_ScriptErrorsFrame.times = {};
|
||||
_ScriptErrorsFrame.index = 0;
|
||||
ScriptErrorsFrame_Update();
|
||||
else
|
||||
if (_ScriptErrorsFrame:IsShown()) then
|
||||
_ScriptErrorsFrame:Hide();
|
||||
else
|
||||
_ScriptErrorsFrame:Show();
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- FrameStackTooltip
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
@@ -261,142 +261,6 @@
|
||||
</Scripts>
|
||||
</Frame>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
<!-- ScriptErrorsFrame -->
|
||||
<!-- ================================================================ -->
|
||||
|
||||
<Frame name="ScriptErrorsFrame" parent="UIParent" movable="true" hidden="true" toplevel="true" frameStrata="DIALOG" enableMouse="true">
|
||||
<Size x="384" y="260"/>
|
||||
<Anchors>
|
||||
<Anchor point="CENTER"/>
|
||||
</Anchors>
|
||||
<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
|
||||
<BackgroundInsets>
|
||||
<AbsInset left="11" right="12" top="12" bottom="11"/>
|
||||
</BackgroundInsets>
|
||||
<TileSize>
|
||||
<AbsValue val="32"/>
|
||||
</TileSize>
|
||||
<EdgeSize>
|
||||
<AbsValue val="32"/>
|
||||
</EdgeSize>
|
||||
</Backdrop>
|
||||
<Layers>
|
||||
<!-- ARTWORK, not BACKGROUND: the Backdrop above draws its
|
||||
background and border into BACKGROUND, and it is applied
|
||||
after the textures declared here, so a header in that layer
|
||||
ends up behind the window border. Every Blizzard frame that
|
||||
uses UI-DialogBox-Header puts it in ARTWORK for this reason. -->
|
||||
<Layer level="ARTWORK">
|
||||
<Texture name="$parentTitleBG" file="Interface\DialogFrame\UI-DialogBox-Header">
|
||||
<Size x="256" y="64"/>
|
||||
<Anchors>
|
||||
<Anchor point="TOP">
|
||||
<Offset x="0" y="12"/>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
</Layer>
|
||||
<Layer level="ARTWORK">
|
||||
<FontString name="$parentTitle" inherits="GameFontNormal" text="Lua Error">
|
||||
<Anchors>
|
||||
<Anchor point="TOP">
|
||||
<Offset x="0" y="-2"/>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
<FontString name="$parentIndexLabel" inherits="GameFontNormal" justifyH="CENTER">
|
||||
<Size x="70" y="16"/>
|
||||
<Anchors>
|
||||
<Anchor point="BOTTOM">
|
||||
<Offset x="0" y="20"/>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
</Layer>
|
||||
</Layers>
|
||||
<Frames>
|
||||
<Frame name="$parentTitleButton">
|
||||
<Size x="256" y="20"/>
|
||||
<Anchors>
|
||||
<Anchor point="TOP">
|
||||
<Offset x="0" y="0"/>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
this:RegisterForDrag("LeftButton");
|
||||
</OnLoad>
|
||||
<OnDragStart>ScriptErrorsFrame_TitleButton_OnDragStart();</OnDragStart>
|
||||
<OnDragStop>ScriptErrorsFrame_TitleButton_OnDragStop();</OnDragStop>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
<!-- Width leaves room for the scroll bar inside the border.
|
||||
UIPanelScrollFrameTemplate hangs its bar off this frame's
|
||||
right edge (+6, 16 wide, button art a little wider), so the
|
||||
bar ends at about right + 23. The frame's interior margin is
|
||||
368, where the Close button ends, which puts the widest this
|
||||
can be at 328. Blizzard's own numbers do not carry over here:
|
||||
its ScriptErrorsFrame inherits UIPanelDialogTemplate, a thin
|
||||
GearManager border, not this 32px dialog backdrop. -->
|
||||
<ScrollFrame name="$parentScrollFrame" inherits="UIPanelScrollFrameTemplate">
|
||||
<Size x="328" y="170"/>
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT">
|
||||
<Offset x="16" y="-32"/>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
<ScrollChild>
|
||||
<EditBox name="$parentText" multiLine="true" letters="4000" autoFocus="false">
|
||||
<Size x="328" y="170"/>
|
||||
<Scripts>
|
||||
<OnEscapePressed>this:ClearFocus();</OnEscapePressed>
|
||||
<OnEditFocusGained>this:HighlightText(0);</OnEditFocusGained>
|
||||
</Scripts>
|
||||
<FontString inherits="GameFontHighlightSmall"/>
|
||||
</EditBox>
|
||||
</ScrollChild>
|
||||
</ScrollFrame>
|
||||
<Button name="$parentPrevious" inherits="UIPanelButtonTemplate" text="Previous" id="2">
|
||||
<Size x="96" y="24"/>
|
||||
<Anchors>
|
||||
<Anchor point="BOTTOMLEFT">
|
||||
<Offset x="16" y="16"/>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnClick>ScriptErrorsFrameButton_OnClick(this);</OnClick>
|
||||
</Scripts>
|
||||
</Button>
|
||||
<Button name="$parentNext" inherits="UIPanelButtonTemplate" text="Next" id="1">
|
||||
<Size x="96" y="24"/>
|
||||
<Anchors>
|
||||
<Anchor point="BOTTOMLEFT">
|
||||
<Offset x="116" y="16"/>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnClick>ScriptErrorsFrameButton_OnClick(this);</OnClick>
|
||||
</Scripts>
|
||||
</Button>
|
||||
<Button name="$parentClose" inherits="UIPanelButtonTemplate" text="Close">
|
||||
<Size x="96" y="24"/>
|
||||
<Anchors>
|
||||
<Anchor point="BOTTOMRIGHT">
|
||||
<Offset x="-16" y="16"/>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnClick>ScriptErrorsFrame:Hide();</OnClick>
|
||||
</Scripts>
|
||||
</Button>
|
||||
</Frames>
|
||||
<Scripts>
|
||||
<OnLoad>ScriptErrorsFrame_OnLoad(this);</OnLoad>
|
||||
<OnShow>ScriptErrorsFrame_OnShow(this);</OnShow>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
<!-- Frame highlight (retail Blizzard_DebugTools.xml) -->
|
||||
<!-- ================================================================ -->
|
||||
|
||||
Reference in New Issue
Block a user