mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
dceec8b74cf831248d522ec354e9950411fa4a2e
21
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
dceec8b74c |
feat: engine pieces for retail's ScrollBox
What the ScrollBox port needs from the DLL, and three engine bugs it hit. Fixes: - GetWidth / GetHeight answer a rect-derived size over the layout scale, as 4.3.4 does. 1.12's getters leave the division out, so an anchored region under a UI scale read scaled (a 160-high track at 0.91 answered 145.6, and the scroll bar thumb stopped short). GetRect and GetScaledRect use them. - A <Size>, <Anchor> or <Offset> with only `x` applies. The engine's dimension reader decides "no attributes" from `y` alone; a co-hook answers as 4.3.4 does. Xml::Anchors' "0" attribute workaround goes. - KeyValue type="global" walks a dotted path, as retail's own templates need (ScrollControllerMixin.Directions.Decrease). New: - <Texture atlas="..." useAtlasSize="...">, applied as SetAtlas. - securecall / securecallfunction / secureexecuterange, as probed on retail: results returned, errors to the error handler, the range walk goes on after one. - AddSourceLocationExclude(fileName): GetSourceLocation steps over that file's levels. - region:AdjustPointsOffset(x, y) / ClearPointsOffset(), re-setting each anchor through the engine's SetPoint. Retail, probed: Clear zeroes the offsets rather than undoing adjustments. - Enum.InputContext. |
||
|
|
9edce4a9f9 |
feat(xml): intrinsic frame types, script binding types, EventFrame
A top-level frame element with intrinsic="true" defines a frame type:
<EventFrame> and CreateFrame("EventFrame") build a frame of the element's
own type with the definition applied first (its mixins, content and child
frames, then the templates and the element's own). Retail's EventFrame,
EventButton, EventEditBox and EventScrollFrame are ported verbatim;
ScrollBox and its scroll bars are EventFrames.
The builder keeps a definition instead of building it, detached from its
document the way the template registrar keeps a virtual node, and
registers its name with FrameXML_RegisterFactory. The one factory for
every intrinsic name builds the base type, for the node the builder hook
is building.
An intrinsic's scripts are its intrinsic bindings. Each script now has
retail's three (LE_SCRIPT_BINDING_TYPE_INTRINSIC_PRECALL, _EXTRINSIC,
_INTRINSIC_POSTCALL), as probed on retail:
- SetScript and GetScript read and write the extrinsic binding, so
SetScript(script, nil) keeps the intrinsics.
- GetScript(script, binding) reads one; HookScript(script, hook) hooks
the extrinsic, so the hook runs before the postcall, and
HookScript(script, hook, binding) hooks an intrinsic.
- An intrinsic element without intrinsicOrder binds the precall.
A slot with intrinsic bindings holds a dispatcher closure over the three,
which runs each in its own context under the script error handler. Every
writer of a slot releases its old handler first, so after SetScript and
after each XML node load a new handler moves into the extrinsic binding.
The check compares the closure, not the ref number: luaL_ref hands the
released number straight back. Frame::ScriptArgs looks inside the
dispatcher as it does the HookScript wrapper.
|
||
|
|
7e1edce462 |
feat(xml): inherit="prepend"/"append" on <Scripts> handlers
A handler element with inherit="prepend" now runs the inherited template's handler first and then its own; "append" runs its own first. Vanilla's loader let the node's handler replace the template's. Template nodes load onto the same frame before the node's own content, so the handler a template set is captured when that template's load returns, then joined with the node's handler (body, function= or method=) in a C closure that calls both with the same arguments. Elements apply in document order. The function= binding skips scripts that ScriptInherit sets. Also binds luaL_unref as Game::Lua::Unref and drops an unused local typedef for it. |
||
|
|
9027e22e4f |
feat(xml): <Anchor> x/y and relativeKey, parentArray
Retail templates write anchor offsets as attributes and name anchor targets by key path. 1.12's anchor loader reads point, relativePoint, relativeTo and an <Offset> child only, so those anchors landed on the parent with no offset. After each frame, texture and font string loads, Xml::Anchors re-sets every <Anchor> that has relativeKey or x/y. The target is the key path, or the one the engine's own anchor node resolved. The offsets go through the engine's XmlReadDimension (0x006F1EB0), the reader the loader uses for <Offset>. The point is set with the engine's setter. A frame loads its layers before its child <Frames>, so a layer anchored to a child frame cannot resolve at load. Such anchors are queued and retried once a frame's children are built, before its OnLoad, and again when the outermost build returns, which reports what is still missing. parentArray="Name" appends the region to parent.Name in load order. |
||
|
|
d93861d746 |
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. |
||
|
|
63078578b4 |
refactor(game): route every SStrCmpI call through Game::StrCmpI
Twelve files each declared their own SStrCmpI function-pointer type and cast FUN_SSTR_CMP_I at the call. One wrapper in Game now owns the __stdcall signature (a __cdecl copy drifts ESP by 12 per call) and the "whole string" length default. Tooltip::Hyperlink's prefix test moves from the CRT _strnicmp to the same wrapper, which the engine's SStrCmpI calls anyway. |
||
|
|
6c5269e3e6 |
feat(profiling): add per-addon memory and CPU usage
Backport UpdateAddOnMemoryUsage / GetAddOnMemoryUsage and the script profiling family (scriptProfile, GetFunctionCPUUsage, UpdateAddOnCPUUsage, GetAddOnCPUUsage, GetFrameCPUUsage, GetEventCPUUsage, GetScriptCPUUsage, ResetCPUUsage), mirroring 3.3.5's engine mechanism. - Gc::Hooks owns the GC lifecycle hooks (luaC_link, newlstr, luaS_newudata, freeobj); Gc::Tag stamps each new object with the engine's context word (3.3.5's lua_tainted rule) and sums sizes with the engine's own free sizes. - lua_gctag pins: the addon load window (two call patches in FUN_ADDON_LOAD_ONE) and template application (engine single-name sites + Xml::Inherits lists). - Profile::Cpu keeps 3.3.5's per-closure Profile records through Lua's own call/return hook, installed only when scriptProfile is 1; tail calls, error unwinds and coroutines handled. - ScriptArgs observers time every handler run; signals counted at each dispatcher (call-site redirect inside FUN_FIRE_EVENT, not a MinHook). - Frame::ScriptSlots enumerates a frame's script slots without creating them, for GetFrameCPUUsage. - Add the unordered_dense submodule (v5.3.2); share ResolveRecord via addons/Registry; fix the AddOnEntry inline-name comments. |
||
|
|
165ccf3e9c |
refactor(lua): share the engine's flag readers as Game::Lua::ToFlag and Game::StringToFlag
Twenty modules each declared their own typedef or wrapper for FUN_LUA_TO_BOOLEAN_LOOSE (4.3.4's StringToBOOL(L, index, default)) or FUN_XML_ATTR_TO_BOOL (StringToBOOL(const char *)). Route them all through one helper each. frame/Cooldown.cpp had a C++ copy of both that read unknown attribute text as true; the engine's reader, which 4.3.4's XML loader uses, reads it as false. SetReverse/SetDrawEdge now also truncate numbers like every other 1.12 flag method. |
||
|
|
b83bb5b52b |
feat(frame): draw the Cooldown sweep natively, as 4.3.4's CGCooldown
A Cooldown was vanilla's indicator Model with CooldownFrameTemplate loaded into it, so SetReverse and SetDrawEdge stored flags that changed nothing, and every cooldown paid a Model's per-frame cost. Cooldown is now a CSimpleFrame subclass built the way CGCooldown::Create builds it: one SMemAlloc block, the engine's frame constructor, and copies of CSimpleFrame's two vtables with 4.3.4's overrides in their 1.12 slots (update, layer emit, alpha, size change, LoadXML, identity, destructor). It runs 4.3.4's sweep / flash / reverse state machine and queues the star fan, flash and edge as layer-batch strips animated in place. - The five methods live in a class method hash of their own, so only a Cooldown has them; it is released after CGGameUI's unregister pass. - GetObjectType / GetFrameType answer through the engine's virtuals; the Lua re-registrations are gone. - star4.blp ships with 1.12; edge.blp does not, so its 16x16 image is created in memory through TextureCreateWithCallback. - A Cooldown inheriting the stock Model CooldownFrameTemplate applies 4.3.4's template (setAllPoints, hidden); reverse / drawEdge XML attributes are read. - CooldownFrame_SetTimer calls SetCooldown on a Cooldown and keeps 1.12's body for the Models stock buttons use. - Mask.cpp's path loader moves to texture/Load; frame/RenderBatch queues quads into a layer batch. Verified in-game: sweep, flash and hide; reverse with the edge line; stock action-button cooldowns unchanged; repeated /reload. |
||
|
|
2cab0dcb12 |
feat(xml): support mixin= and method= on XML elements
mixin="A, B" on frames, textures, font strings and animation groups copies each global table onto the element's Lua table, as Mixin() does. The outermost load of an object applies the whole inherits chain once, templates first, before the engine loads any node, so KeyValues and scripts build on the mixins instead of being overwritten by them. A missing mixin logs a load warning. Script elements take method="Name", binding self[Name] as the handler, on frames, animation groups and animations. |
||
|
|
a2e3eed0de |
feat(xml): support <KeyValues> on XML elements
A <KeyValue key= value= type= keyType=/> entry sets object[key] = value on frames, textures, font strings, animation groups and animations. Types are nil, boolean, number, string and global, as in the later clients' schema. Template entries apply first so an element's own entries win, and all are set before OnLoad. Bad entries log a load warning and are skipped. C_XMLUtil.GetTemplateInfo now returns the template's own entries in keyValues instead of an empty table. |
||
|
|
943597ca0d |
feat(texture): load masks from XML and release mask textures
- <Texture mask="path"> applies texture:SetMask(path). - <MaskTexture> in a <Layer> builds a MaskTexture, and its <MaskedTextures> entries (childKey or target) attach it to textures. xml/Layers.cpp replaces the engine's layer loader with the same loop plus a MaskTexture branch, so the engine no longer warns on the tag. - SetMask closes the mask texture's handle on replace, clear, region reuse and reload, as SetTexture does with the texture it held. - SetMask keeps its previous mask when the file does not load, using SetTexture's own status test, instead of masking with the opaque fallback texture. - API.md documents the XML forms and that a mask with an opaque edge does not clip past its rectangle (the device has no border address mode). |
||
|
|
e84496d036 |
feat(animation): the animation system - AnimationGroup, Animation, Alpha, Scale, Rotation, Translation (#89)
* feat(animation): the animation system - AnimationGroup, Animation, Alpha, Scale, Rotation, Translation Later clients animate regions in the renderer; vanilla has none of it, and ported UIs build on it everywhere (Zygor Guides Viewer 2.0: 25 XML groups plus CreateAnimationGroup in its guide window's OnLoad, which stopped there). - Util/Animation.lua (bundled addon): the runtime. Groups and animations with the later-client API (Play/Stop/Pause/Finish, progress and smooth progress, order/startDelay/endDelay/duration timeline, NONE/REPEAT/BOUNCE looping, NONE/IN/OUT/IN_OUT smoothing, maxFramerate, the group and animation scripts). One driver frame ticks playing groups; effects go through the region's own setters and the region's state is restored when the group ends, as later clients never persist them. - animation/Bridge.cpp: CreateAnimationGroup / GetAnimationGroups / StopAnimating on the region base registry, forwarding to the runtime the bundled addon registers via _classicapi_SetAnimationRuntime. - xml loaders: an <Animations> child becomes descriptor tables (attributes, <Scripts> bodies and function= names, <Origin>) handed to runtime.LoadXML before the builder finalizes. Adds OFF_XML_NODE_TEXT. This extends the node-loader hooks of the XML attributes change, which it builds on. Known limits of the 1.12 renderer: Scale pivots on a frame's own anchor point (exact when anchored by its center) and resizes textures anchored by one point; Rotation needs texture:SetRotation (textures, font strings). Group templates (inherits on an AnimationGroup, CreateAnimationGroup's template argument) are not supported yet and are ignored. Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0): a probe XML <Animations> group builds with Play(); every AnimationGroup and animation method exists; a Lua-built group plays through 12 updates to progress 1.0 and fires OnFinished; Zygor's step flash group (Alpha) plays and stops, and its guide window finishes its OnLoad. Not checked yet: Scale, Rotation and Translation on screen (Zygor's own groups with them load without error, but no one has watched them play), REPEAT and BOUNCE looping, the smoothing curves, and maxFramerate. * refactor(animation): port 4.3.4's CSimpleAnimGroup/CSimpleAnim to C++ Replace the Lua animation runtime with a C++ port of the 4.3.4 engine classes. Groups and animations are real 1.12 script objects (engine header from ConstructScriptObject, our own vtable), so GetObjectType, IsObjectType, GetName/$parent globals, SetScript/HookScript and the shared __index dispatch all go through the engine's mechanisms. - Group/Anim: the 4.3.4 timeline (orders, delays, looping, cosine smoothing, 1/30 s throttle, pause/stop/finish) and every method. - Region: per-region state ticked from a CSimpleFrame::OnFrameUpdate co-hook (shown frames only); 4.3.4's alpha model (store, reset each tick, add change, restore when the last alpha group ends, children included). CreateAnimationGroup, GetAnimationGroups, StopAnimating. - Xml: <Animations> with 4.3.4's attribute set, inherits/templates, script bodies and function= through SetScriptObjectScript. - Frame::Destruction: a shared hub over the frame destructor; groups die with their frame, and Frame::Alpha moves onto it. Translation, Scale and Rotation keep their values and timing but do not move anything yet. * feat(animation): apply Translation to what regions draw Port 4.3.4's AddAnimTranslation: a frame hands the offset to every texture and font string below it (or only the target), a texture moves the four corners its draw record points at, and a font string moves its text block's string position. Rects, anchors and mouse areas stay put. - StoreAnimPosition / PreOnAnimUpdate / ResetPosition mirror 4.3.4, with the base taken from the engine's own layout (the corner store for textures, inset x layout scale + rect corner for font strings). - Co-hooks on the texture and font string OnFrameSizeChanged callbacks move the base when the layout moves a region mid-animation and keep the animation's offset, as 4.3.4's own legs do. - A frame is marked while it plays a position group, so the end of its last one puts everything below it back. Scale and Rotation still keep their values without drawing. * feat(animation): apply Scale and Rotation to textures Port 4.3.4's AddAnimScale / AddAnimRotation with GetOriginOffset, ApplyScaleAnim and ApplyRotationAnim on the texture's drawn corners: the origin point on the quad, its offset turned along the bottom edge, and a counter-clockwise positive angle. Frames hand both to every texture below them, or only the target. Font strings do not scale or turn yet. * feat(animation): scale and turn font strings Port CSimpleFontString's AddAnimScale / AddAnimRotation: the animated rotation and x scale replace the string's for the update, and the text is baked again when they change (the engine's node invalidate, as 4.3.4 invalidates the CGxString). After the bake, the glyphs are scaled and turned about the node origin, where 4.3.4's InitializeTextLine turns them, with the engine's half-texel UV inset for turned glyphs. The text is stretched rather than drawn at a larger font size. * feat(animation): add Path and ControlPoint Port 4.3.4's CSimplePathAnim and CSimpleControlPoint: a Path moves the region's drawing through its control points with AddAnimTranslation, the points spread evenly over the progress, in straight lines (NONE) or on 4.3.4's Catmull-Rom spline (SMOOTH). ControlPoint is its own script object with offset, order and SetParent; BuildSpline keeps 4.3.4's order shuffle when an order is taken. XML reads `curve` and <ControlPoints>, with templates for CreateControlPoint and `inherits`. One deviation from the decompiled CreateControlPoint: a point made without an order takes the highest order + 1 (as SetParent does), so points made one after another keep their creation order. * fix(texture): keep shape changes made during a position animation Texture:SetRotation and SetVertexOffset wrote the drawn corners, which the next animation update replaced with the corners stored when the group started. While a position group plays they now write the stored corners, so the new shape shows with the animation on top and stays after the group ends. FontString:SetRotation on text an animation has turned or scaled bakes the glyphs again instead of re-turning them in place, so the bake applies both. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
e75e585551 |
feat(frame): register Cooldown as a real frame type, so XML <Cooldown> works
4.3.4 registers "Cooldown" in the frame-type factory table, beside
GameTooltip and the model types. Vanilla has no such type: the
CreateFrame hook rewrote a "Cooldown" request as a Model with
CooldownFrameTemplate, so XML <Cooldown> elements were still "Unknown
frame type".
The Cooldown module now registers the type through the engine's own
FrameXML_RegisterFactory (0x006EE880), during the game Lua registration
pass, which CGGameUI::Initialize runs before the game-UI factory list
and before FrameXML loads. The table is never cleared, so a /reload's
second registration is a no-op, as for the engine's own types. The
factory builds the engine's Model (0x006EECF0) and marks it, and XML and
CreateFrame both reach it through the builder. CreateFrame drops its
Cooldown special case, and Cooldown.h goes away (nothing outside the
module calls it).
Every 4.3.4 Cooldown draws a sweep without a template; here the sweep is
CooldownFrameTemplate. A Cooldown loads it under its first node, before
the node's own templates and content, through a new
Xml::FrameLoad::AutoSubscribeBefore observer. Xml::LoadNode is the
shared "load this node onto the frame" step that Inherits also uses.
The template is setAllPoints, and a 4.3.4 Cooldown starts unanchored, so
the observer then calls CLayoutFrame::ClearAllPoints (0x00767620). A new
frame has no anchors at that point, so this restores exactly that.
Without it, a Cooldown with its own Size and CENTER anchor kept
TOPLEFT/BOTTOMRIGHT on UIParent and stretched across the screen.
Verified in-game (1.12.1 via VanillaFixes) with a throwaway test addon:
a bare XML <Cooldown>, an XML <Cooldown> child inheriting
CooldownFrameTemplate, and CreateFrame("Cooldown") with no template each
report "Cooldown", stay a Model, load UI-Cooldown-Indicator at scale
0.75, and draw a visible sweep. The bare one sits at its own 36x36
CENTER anchor, the child fills its host, and a plain Model still reports
"Model".
|
||
|
|
4ea0223f34 |
feat(xml): read inherits as a template list, and CreateFrame's id
4.3.4 reads `inherits` as a list. CSimpleFrame::LoadXML tokenizes it
on " ," and loads each template, left to right, before the node's own
content, so later templates override earlier ones; FindParent walks the
same list for a `parent`. Vanilla's frame loader, child-frames builder
and builder parent walk each look the whole string up as one name, so
XML `inherits="A, B"` failed with "Couldn't find inherited node".
Each of the three steps now takes a list the same way: every name in
order through the engine's own step, then the node itself. A single
name keeps the engine's path untouched. Textures and font strings keep
one template, as in 4.3.4.
CreateFrame is now 4.3.4's Script_CreateFrame on vanilla's builder:
- every name in a template list must resolve, or it raises the engine's
"Couldn't find inherited node" error; the whole list goes on the
request node, so the frame is built through the list path above with
all templates applied before OnLoad. The old hook built with the
first template and grafted the rest after OnLoad, and it skipped
missing names.
- the 5th argument `id` is set on the node, so GetID() in OnLoad
returns it.
The id has to be on the request node before the builder runs, and
vanilla builds and frees that node in its own body, so the function is
replaced, with the engine's node constructor, attribute setter,
builder, status object and error strings.
Verified in-game (1.12.1 via VanillaFixes) with a throwaway test addon:
XML and CreateFrame lists apply left to right (B's size over A's), both
templates' regions and children exist when the last template's OnLoad
runs, a missing name is skipped in XML and an error in CreateFrame, a
space-separated list takes its parent from a template, CreateFrame's id
reaches OnLoad, and CreateFrame("Cooldown") still reports "Cooldown".
|
||
|
|
00f32e0e2f |
feat(xml): load <Attributes> on frames, as 4.3.4 does
4.3.4's CSimpleFrame::LoadXML reads an <Attributes> child through LoadXML_Attributes; 1.12's frame loader (FUN_XML_FRAME_LOAD) walks its child elements and silently skips the unknown one, so ported templates lost every attribute. Each <Attribute name= type= value=> is now set the way 4.3.4 sets it: type nil/boolean/number/string (default), converted with the loader's own helpers (FUN_XML_ATTR_TO_BOOL, new FUN_SSTR_TO_FLOAT), stored without firing OnAttributeChanged (through our SetAttributeNoHandler, so unit/type* behave as when set from Lua), and malformed entries logged through the loader's status sink with 4.3.4's warning texts (VTBL_XML_STATUS_ADD, level 1). FUN_XML_FRAME_LOAD was already hooked by Xml::ParentKey, and MinHook takes one hook per address, so Xml::FrameLoad now owns it and fans out after the engine loads each node (the RunnerHook / WorldTick pattern). ParentKey's frame binds and the attribute loader subscribe; its node helpers and loader-safe wrapper push moved there too. OFF_COBJECT_LUA_REGISTRY_REF duplicated OFF_COBJECT_LUA_REF (both 0x08) and is folded into it. Verified in-game with a test addon: template attributes inherited and overridden by the frame's own, number / boolean / nil types, a mixed- case name, values present by OnLoad, no OnAttributeChanged on load, and the three FrameXML.log warnings. |
||
|
|
5df5ce00cf |
fix(xml): resolve <Script file> subdirectory paths relative to the XML file (#80)
* fix(xml): resolve <Script file> subdirectory paths relative to the XML file The XML file processor joins <Include file> onto the including file's directory, but <Script file> only when the value has no backslash (strchr at 0x006EE06E); a value with one is loaded from the game root. So <Script file="widgets\AceGUIWidget-Button.lua"/> inside Libs\AceGUI-3.0\AceGUI-3.0.xml fails with "Error loading widgets\AceGUIWidget-Button.lua" - all 23 AceGUI-3.0 widget files in Zygor Guides Viewer 2.0, and every other addon that embeds AceGUI-3.0. Later clients resolve it relative to the XML file. Co-hook the XML file processor (FUN_XML_LOAD_FILE) to track the file being processed, and at the <Script> call into FUN_LUA_LOAD_FILE (return address RET_XML_SCRIPT_FILE_LOAD) retry a backslash path that does not exist as given against that file's directory, only when the joined file exists. Root-relative paths that load on vanilla are unchanged. FUN_LUA_LOAD_FILE is already co-hooked by AddOns::SavedVarsFirst, which now calls Xml::ScriptPath::Resolve first. Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0): a probe addon's <Script file="sub\File.lua"/> loads from its XML file's folder, and Zygor's AceGUI-3.0 option pages, built from those widget files, work. * refactor(xml): share the Lua file-loader hook; collapse .. in Script paths FUN_LUA_LOAD_FILE now has one owner, Script::LoadFile, which runs path rewriters and then suppressors. Xml::ScriptPath is a rewriter and AddOns::SavedVarsFirst a suppressor, so neither module reaches into the other's hook. Xml::ScriptPath joins onto the XML file's folder with each \..\ collapsed first, as FUN_XML_LOAD_FILE does before its own joins; the tracked pointer is the caller's uncollapsed path, so an XML file reached through <Include file="..\x.xml"/> joined onto a path with .. in it. The user docs no longer name later clients or what 1.12 does. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
fbcc1c9ae1 |
feat(editbox): add SetCountInvisibleLetters / IsCountInvisibleLetters (#88)
* feat(xml): read parentKey, function= and button font style= from XML Later clients' XML has three attributes vanilla's parser keeps on the node but never reads. Ported UIs lean on all three: Zygor Guides Viewer 2.0 uses parentKey 69 times (its arrow, skin buttons and step frames), binds its main frame's whole OnLoad with function=, and names button fonts with style=. All three hook the engine's per-object XML node loaders. Those run on the object's layout sub-object ((object+0x24)->vtable[+8], called from the frame builder at 0x006EE4D9 and the region factory at 0x006F2756), so the object is `this - OFF_XML_LOADER_SUBOBJECT`. The loaders: frames FUN_00769820 (every derived frame type's loader calls it first), textures FUN_0076FE20, font strings FUN_00770F40, and Button's FUN_XML_BUTTON_LOAD (CheckButton's calls it first). Each hook runs the engine's loader, then: - parentKey="Name" sets parent[Name] = object on the Lua wrappers, the parent being the object's script-region parent (OFF_REGION_PARENT, which GetParent reads). An unnamed element has no wrapper yet, so it is registered the way the engine's own lazy path does (ScriptRegister(object, NULL), as GetParent does); a named one is never registered here, since SetName already did that under its name. The builder loads content and child frames before it finalizes, so a parent's <OnLoad> already sees its keys, and keys inside a virtual template bind on every frame built from it. - A script element with function="Name" becomes frame:SetScript(<element>, _G[Name]). The loader runs before the builder's finalize, so a bound OnLoad fires at the usual point. - A NormalFont / HighlightFont / DisabledFont with style and no inherits is applied through the engine's own setter for that state with _G[style]. Vanilla reads only inherits there and otherwise leaves the button's embedded font empty, so its text had no font. Adds FUN_XML_FRAME_LOAD / FUN_XML_TEXTURE_LOAD / FUN_XML_FONTSTRING_LOAD / FUN_XML_BUTTON_LOAD, OFF_XML_LOADER_SUBOBJECT and OFF_SCRIPT_REGION_NAME, with their derivations. Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0): probe XML gets its parent keys on a Frame, a Texture, a FontString, a button's NormalTexture and a frame inside an inherited template; an <OnShow function="..."/> handler runs; a button with <NormalFont style="GameFontHighlightSmall"/> reports that font object. Zygor's frames build with their keys, its main frame's OnLoad runs, and it loads without a Lua error. * feat(editbox): add SetCountInvisibleLetters / IsCountInvisibleLetters 3.3.5's EditBox can count color codes and hyperlink markup toward its SetMaxLetters limit: SetCountInvisibleLetters(true), or countInvisibleLetters="true" in XML (its macro text, friends broadcast and BNet report boxes). Off is the default. AceGUI-3.0's MultiLineEditBox calls the setter while building. 1.12's SetMaxLetters limit (+0x340) counts only visible letters: its counter (0x0077BC80) skips the markup classes in the edit box's per-byte table (+0x330), so with a limit of 5 "|cffff0000abcdefg|r" keeps "|cffff0000abcde" (checked in-game). That is 3.x's default (off). With the flag on, the limit check's three counts (returns 0x0077C09F, 0x0077C0C1, 0x0077C0E9) count each markup token at its length instead. The counter's other callers, the cursor movement and GetUTF8CursorPosition, are unchanged. For XML, hook the EditBox node loader (0x00779FB0, identified by the "letters"/"autoFocus"/"multiLine" attributes it reads after calling the frame loader) and, after it runs, read the attribute and parse it with the engine's own boolean parser (0x006F1B30, as for autoFocus). The loader follows the node-loader convention of the XML attributes change (OFF_XML_LOADER_SUBOBJECT), which this builds on. Verified in-game (1.12.1 client via VanillaFixes): with SetMaxLetters(12), "|cffff0000abcdefg|r" is kept whole with the flag off and cut to "|cffff0000ab" with it on; an XML EditBox with letters="12" and countInvisibleLetters="true" reports the flag on and cuts the text the same way. * docs: correct GetNumLetters note, drop version comparisons GetNumLetters counts the letters you see (FUN_007992C0 calls the same counter as the limit check), not bytes. Remove the 3.3.5 / stock 1.12 / later-client comparisons from the new XML and edit box sections. * fix(frame): build extra templates' child frames in CreateFrame The multi-template graft called the main vtable's +8 slot, which is the Lua method lookup FUN_00778590, not a node applier, passing the XML node as the Lua state. Its second call (the +0x24 sub-object's node loader) applied the template's content, but <Frames> children are built only by FUN_0076A060 from the finalize step, so an extra template's child frames were never created. Call the node loader, then FUN_XML_FRAME_LOAD_CHILD_FRAMES directly, so OnLoad is not re-run. Correct the notes in Offsets.h and CreateFrame.cpp. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
c54556f6a1 |
refactor: centralize engine field/global access via Game::Read/Ref/Ptr
Replace the raw `*reinterpret_cast<const T *>(base + Offsets::OFF_X)` idiom (and its double-cast variant when base wasn't already a byte pointer) with three typed accessors in Game.h: Game::Read<T>(base, offset) field value read Game::Ref<T>(base, offset) writable field lvalue Game::Ptr<T>(base, offset) pointer to a field (arrays / out-params) Game::Read<T>(address) / Ref<T>(address) fixed-VA globals Pure mechanical refactor, zero behavior change: ~330 cast sites across 84 files collapse to 651 helper calls. Offsets stay in Offsets.h per the single-source-of-truth rule — the helpers only remove the cast noise and fold away the inner `reinterpret_cast<uint8_t*>(obj)` base casts. Left as raw casts by design: FUN_* function-pointer casts, void*/char* VA handles passed as arguments (caches, method registries), subobject- anchor pointers fed to __thiscall helpers, `void *volatile` player-ptr readiness gates (converting would strip volatile), and VA-as-array-base captures that are subscripted later. |
||
|
|
9e03f69e9b |
xml: add C_XMLUtil.GetTemplateInfo() and DoesTemplateExist()
Both resolve by name through the engine's own template lookup
(FUN_006ee6f0) -- the same path inherits= uses -- so they're
case-insensitive and cover Blizzard FrameXML plus addon templates.
GetTemplateInfo returns { type, width, height, keyValues, inherits } or
nil if the template doesn't exist. type is the element tag; width/height
are the RAW values from a <Size> element declared directly on the
template (0 if none / inherited) -- read straight from the attributes
rather than via the engine's Size parser (FUN_006f1eb0), which applies
UI-scale conversion we don't want here. inherits is the inherits=
attribute or nil. keyValues is always empty (vanilla's XML schema has no
<KeyValues> element) and sourceLocation is omitted (a 10.2 feature;
vanilla records no per-node file/line) -- both parity-safe.
DoesTemplateExist returns a bool.
Verified in-game: DoesTemplateExist true/false as expected; GetTemplate-
Info nil for a missing name; StatFrameTemplate -> 104x13; FriendsFrame-
TabTemplate -> inherits "CharacterFrameTabButtonTemplate".
|
||
|
|
694a7415ab |
xml: add C_XMLUtil.GetTemplates()
Backport the modern C_XMLUtil.GetTemplates() -- enumerate every
registered virtual XML template as { name, type }.
The engine keeps virtual templates (the <Frame virtual="true"> etc. that
inherits= targets) in a Storm hash table. The XML parser (FUN_006ede10)
registers each via FUN_006ee500 and the inherits resolver reads the same
table via FUN_006ee6f0, so it's the authoritative template store. The
new module walks it: each node carries the template name (+0x14) and its
parsed definition node (+0x18), whose element tag string (+0x8) is the
frame type ("Frame" / "Button" / ...).
Covers both Blizzard FrameXML and addon templates; rebuilt on /reload.
Fonts are a separate registry and correctly excluded (matching retail).
Returns an empty table before the first template registers (mask ==
0xFFFFFFFF). Pure read, no hooks. Verified in-game: 212 templates,
entry 1 = { name="AtlasLootDefaultFrameButtonTemplate", type="Button" }.
|