mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
feat(tooltip): frame stack highlight, anchors, and GetSourceLocation
Retail's frame stack tooltip marks one entry and, after the list, prints its anchors and the script that created it. Port both halves. SetFrameStack now takes (showHidden, showRegions, highlightIndexChanged) and returns the highlighted entry, as the current client does. The marked line opens with "-->", regions list after their frame in FRAMESTACK_REGION_COLOR, and ANCHORS / SOURCE sections follow the list. The formats are the client's own, read from its string table; the non-highlight indent and the ANCHORS header are inferred from it. Stratum 0 prints as WORLD, which 4.3.4's FrameStrataToString names and 1.12's table does not. OnTooltipSetFrameStack now carries the highlighted entry as its argument. region:GetSourceLocation() (9.2.5) records where each frame was built: a Lua CreateFrame takes the caller's "file:line" from lua_getstack / lua_getinfo "Sl" inside the call, stepping over C levels, with the chunk name as luaO_chunkid writes it; an XML frame takes the file FUN_XML_LOAD_FILE is processing. Regions answer for their parent frame. The XML file tracker moves out of Xml::ScriptPath into Xml::FileStack so both consumers share it. GetPoint on a screen anchor: CSimpleTop is a bare CLayoutFrame, and Script SetPoint stores it as the relative layout for a nil relativeTo. The stock reader forms `layout - 0x24` for it and reads the 36 bytes before the top object as a region header. Frame::GetPointGuard now implements GetPoint itself and pushes nil for the top, as 3.3.5 and 4.3.4 do; the frame stack's anchor lines test for it the same way. The guard's header drops the claim that the engine never clears dependents' anchors: CLayoutFrame::DestroyLayout does. DebugTools: the frame stack runs the modern FrameStackTooltip on the new method. Left/Right Alt move the mark, Ctrl (released) opens the marked entry in the TableInspector, Shift adds texture information, fsobj is set after an Alt press, and /fstack reads [showHidden [showRegions]] through StringToBoolean. The modifier keys come from MODIFIER_STATE_CHANGED instead of retail's polled KeyCommand table. The green FrameStackHighlight cover and showAnchors are not ported: the cover frames sit at TOOLTIP strata under the cursor and become the top entry themselves.
This commit is contained in:
+7
-34
@@ -27,12 +27,11 @@
|
||||
// 3.3.5's FrameXML_ProcessFile (0x00813EE0) joins `<Script file>` onto the
|
||||
// XML file's directory exactly as it joins `<Include file>`, always.
|
||||
//
|
||||
// Track the XML file being processed (co-hook of FUN_XML_LOAD_FILE, which
|
||||
// recurses for <Include>, hence a stack) and, at the <Script> call into
|
||||
// FUN_LUA_LOAD_FILE (return address RET_XML_SCRIPT_FILE_LOAD, seen through
|
||||
// Script::LoadFile's shared hook), retry a backslash path that does not exist
|
||||
// as given against that file's directory. The retry is used only when the
|
||||
// joined file exists, so a root-relative
|
||||
// At the <Script> call into FUN_LUA_LOAD_FILE (return address
|
||||
// RET_XML_SCRIPT_FILE_LOAD, seen through Script::LoadFile's shared hook),
|
||||
// retry a backslash path that does not exist as given against the directory
|
||||
// of the XML file being processed (Xml::FileStack). The retry is used only
|
||||
// when the joined file exists, so a root-relative
|
||||
// `<Script file="Interface\AddOns\X\y.lua"/>` that works on vanilla keeps
|
||||
// working, and a genuinely missing file still fails with the engine's own
|
||||
// message.
|
||||
@@ -47,6 +46,7 @@
|
||||
#include "Offsets.h"
|
||||
#include "addons/EngineIO.h"
|
||||
#include "script/LoadFile.h"
|
||||
#include "xml/FileStack.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@@ -54,17 +54,6 @@ namespace Xml::ScriptPath {
|
||||
|
||||
namespace {
|
||||
|
||||
using XmlLoadFile_t = uintptr_t(__fastcall *)(const char *path, void *ctx, void *status);
|
||||
|
||||
XmlLoadFile_t g_origXmlLoadFile = nullptr;
|
||||
|
||||
// XML files currently being processed, innermost last. <Include> nesting is
|
||||
// shallow; deeper levels still count so pops stay balanced, they just are not
|
||||
// consulted.
|
||||
constexpr int kMaxDepth = 16;
|
||||
const char *g_xmlStack[kMaxDepth];
|
||||
int g_depth = 0;
|
||||
|
||||
bool FileExists(const char *path) {
|
||||
return reinterpret_cast<AddOns::EngineIO::FileExistsFn>(
|
||||
static_cast<uintptr_t>(Offsets::FUN_FILE_EXISTS))(path, 1) != 0;
|
||||
@@ -87,34 +76,18 @@ void CollapseDotDot(char *s) {
|
||||
}
|
||||
}
|
||||
|
||||
uintptr_t __fastcall XmlLoadFile_h(const char *path, void *ctx, void *status) {
|
||||
if (g_depth < kMaxDepth)
|
||||
g_xmlStack[g_depth] = path;
|
||||
++g_depth;
|
||||
const uintptr_t r = g_origXmlLoadFile(path, ctx, status);
|
||||
--g_depth;
|
||||
return r;
|
||||
}
|
||||
|
||||
const Game::HookAutoRegister _xmlLoadFileHook{
|
||||
Offsets::FUN_XML_LOAD_FILE,
|
||||
reinterpret_cast<void *>(&XmlLoadFile_h),
|
||||
reinterpret_cast<void **>(&g_origXmlLoadFile)};
|
||||
|
||||
// For the XML `<Script file>` call site only: a `file=` value that contains a
|
||||
// subdirectory and does not exist as given is retried relative to the XML
|
||||
// file being processed; the joined path is returned when that file exists.
|
||||
const char *Resolve(const char *path, uintptr_t retAddr, char *buf, size_t bufSize) {
|
||||
if (retAddr != Offsets::RET_XML_SCRIPT_FILE_LOAD || path == buf)
|
||||
return path;
|
||||
if (g_depth <= 0 || g_depth > kMaxDepth)
|
||||
return path;
|
||||
if (std::strchr(path, '\\') == nullptr)
|
||||
return path; // the engine already joined it onto the XML's directory
|
||||
if (FileExists(path))
|
||||
return path; // root-relative, as vanilla loads it
|
||||
|
||||
const char *xml = g_xmlStack[g_depth - 1];
|
||||
const char *xml = Xml::FileStack::Current();
|
||||
const char *slash = xml ? std::strrchr(xml, '\\') : nullptr;
|
||||
if (slash == nullptr)
|
||||
return path;
|
||||
|
||||
Reference in New Issue
Block a user