mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
4f3ee595e7520749749f77fa151ed9984aa211f1
12
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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> |
||
|
|
e9e431e014 |
feat(frame): add SetClampRectInsets / GetClampRectInsets (#69)
* feat(frame): add SetClampRectInsets / GetClampRectInsets Later clients let a frame that is clamped to the screen keep a different rect on screen than its own: SetClampRectInsets(left, right, top, bottom) grows or shrinks the rect the clamp uses. Zygor Guides Viewer 2.0 sets them on its frames while building them (a negative top inset lets a frame's top go off screen), and 3.3.5's own FrameXML uses them too. The engine clamps a frame to the screen inside its rect calculation (0x00767A20): it resolves the edges and, for a clamped frame, slides the rect onto the screen. Hook that calculation: for a frame with insets, take the unclamped rect, grow it by the insets (converted from the frame's units to layout units with the inverse of Script GetLeft's scaling), slide that onto the screen with the engine's own steps and order, and move the frame's rect by the same amount. Frames without insets go through the engine's clamp as before. SetClampRectInsets re-lays the frame out, as SetClampedToScreen does, and (0, 0, 0, 0) clears the insets. Sign convention from 3.3.5's own calls: WorldMapFrame (0, 0, 0, -60) "don't overlap the xp/rep bars", chat frames (-35, 35, 26, -50). Verified in-game (1.12.1 client via VanillaFixes): a clamped 100x100 frame placed 10 above the bottom of the screen stays at 10, moves to 60 with (0, 0, 0, -60) and back to 10 once cleared; a frame placed 20 over the top is clamped to the edge and, with a top inset of -25, keeps its 20 over. GetClampRectInsets returns the insets set. * refactor(frame): address review of SetClampRectInsets Use the existing OFF_REGION_ANCHOR and UI coordinate globals instead of new duplicate offsets, and move the pixel/anchor-unit conversion into one shared Game::PixelToInternal / InternalToPixel pair (replacing the copies in LinePool, Transform and Metrics). Restore only the clamp bit around the unclamped rect calculation so other layout flag bits survive. Add doc descriptors for both methods and drop version/implementation notes from the user docs. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
61db68dd7f |
fix(lua): gate frame-method self with the engine's own type check
Every engine frame method validates its `self` in three steps before
touching it: lua_type == table, resolve to the CFrameScriptObject, then
the IsA(typeId) vmethod at vtable+0x10. We did the first two and skipped
the third, so ResolveObject handed back a pointer for ANY frame and the
method cast it to whatever type it expected.
That was reachable from plain Lua, not just through a mirror or a hook.
The per-type method dispatcher is an __index handler that rawgeti's the
method closure out of the Lua registry, so frame methods are ordinary
first-class values, and
GameTooltip.SetSpellByID(ShapeshiftButton1, 133)
reached the tooltip builder with a Button, writing tooltip fields through
Button memory. The engine refuses that same call with "Wrong object type
for member function".
Game::Lua::ResolveTypedObject runs the engine's prologue and raises the
engine's own three error strings, read from .data rather than reinvented.
FrameScriptTypeId mirrors the lazy id assignment, so a check is valid
before any stock method of the type has run. Seven per-type wrappers stop
a call site pairing a method with the wrong class's id, and
ResolveTypedObjectAny covers a method that more than one type reaches.
45 call sites across 19 files now gate self. model/DisplayInfo.cpp had
already worked this out for Model alone and loses its private copy.
Type ids are per CLASS, one shared by all of that class's methods. Each
was read from the prologue of a method that can only belong to its class:
a base-class method registered into several tables carries the BASE id, so
sampling GetObjectType or GetDrawLayer would have produced a gate that
accepts unrelated types. Frame comes from Script_RegisterEvent and Texture
from Script_SetDesaturated, both cross-checked against the first entry of
their table.
Deliberately left ungated: the binding `owner` in bindings/Api.cpp and the
three co-hook sites in texture/Atlas.cpp. Each only uses the pointer as an
identity key and never casts it, so a gate would tighten the contract for
no safety gain -- and raising inside a co-hook would fire before the
original ran.
Verified in-game: the Button-as-tooltip call now raises the engine's
error; a Button still reaches a Frame-registry method
(button:SetAttribute round-trips), so IsA does accept derived types; and
fontstring:GetRotation() still answers -- that reader is registered on
both the Texture and FontString registries and needs the id pair rather
than the Texture id alone.
|
||
|
|
0c8468cf2f |
refactor(reload): auto-register per-/reload cleanup; fix Time::Timer stale refs
Modules that keep reload-fragile file-static state (Lua registry refs, frame/object-pointer-keyed maps, cached event-slot indices) each expose a PrepareForReload() that DllMain called from the FrameScript_Initialize hook. That list was hand-maintained, so a new module could silently forget to wire itself in -- the failure mode behind the Frame::Attributes stale-ref bug and Tooltip::SetEvents issue #33. Add Game::ReloadAutoRegister + Game::RunReloadCleanups(), mirroring the existing ModuleAutoRegister / HookAutoRegister / WorldTick::AutoSubscribe patterns. Each module self-registers with one file-scope line after its PrepareForReload: static const Game::ReloadAutoRegister _reloadReg{&PrepareForReload}; DllMain's 11-call manual list collapses to a single RunReloadCleanups(); a new module can no longer be forgotten. Player::NameCache::Flush stays an explicit call -- it's a save-before-teardown, not a stale-state clear, and also runs on the glue-return path. A sweep of all file-static state found one uncovered module: Time::Timer pins C_Timer.After/NewTimer/NewTicker callbacks in the Lua registry but never released them on /reload -- a surviving/stale ref could fire a dead closure. Add Time::Timer::PrepareForReload (release each pending timer's registry callback, clear the queue) and self-register it. - Game.{h,cpp}: ReloadAutoRegister + RunReloadCleanups. - DllMain.cpp: collapse the manual list to RunReloadCleanups(); drop 6 now-dead includes. - 11 existing reload modules + Time::Timer: add the self-register line. Behavior-preserving (same cleanups, before the Lua teardown); auto-register order is unspecified across TUs but every callback only clears its own state. |
||
|
|
7f1e632b49 |
feat(texture): add MaskTexture object API with multi-mask and rotation
Backport frame:CreateMaskTexture plus texture:AddMaskTexture / RemoveMaskTexture / GetNumMaskTextures / GetMaskTexture -- positioned, rect-based masks, the object form later clients use (SetMask(path) stays the simple single-shape form). Positioned masks sample via texgen (object-space vertex position through a per-unit texture matrix), the mechanism of the engine's own minimap disc mask, so no vertex UV stream is consumed per mask. That lifts both v1 limits at once: - Up to 7 masks apply at once (device stage cap); a texture shows only the intersection of all of them. - mask:SetRotation rotates the clip shape (folded into the matrix), and a mask can move/resize each frame, so the clip animates. State is restored in a co-hook on the indexed submit (FUN_GX_PRIM_INDEXED) the engine issues after the stream call, not inside the stream hook -- restoring earlier reverts the state the queued draw is flushed with. Two incidental fixes: a SetTexCoord-cropped base now masks against the same rect the engine's corner store uses, and a recycled mask region is detached from every base still holding it. Offsets.h: add the texgen / coord-transform / texture-matrix / state-journal / indexed-submit constants (decoded from the D3D9 backend state flush FUN_005a2f00), and fix the FUN_GX_TEXUNIT_ENABLE/_DISABLE mislabel (they are texture-matrix push/pop, not stage enable/disable). |
||
|
|
04d4bf3326 |
fix(text): inset rotated glyph UVs half a texel against font-atlas bleed
An axis-aligned glyph quad samples its atlas cell on exact texel boundaries, so bilinear filtering never crosses into a neighbouring glyph. A quad rotated by FontString:SetRotation samples along diagonals, and at the cell border the filter pulls in texels from ADJACENT cells -- rendering as dotted fragments of other glyphs strung along the rotated text's edges. Machine-dependent (renderer, driver filtering, resolution/UI-scale phase decide whether samples land inside the cell), which is why it reproduced on a user's 1440p setup but not locally. The engine has the same hazard with its bit-7 font nodes and ships the fix: FUN_TEXT_EMITTER's init-once block (0x005CCBE0) sets four globals to +/-0.001953125 (half a texel of the 256px font page) and shrinks each glyph's UV rect by that per edge. Mirror exactly that inset for quads we rotate: InsetGlyphUVs walks the node's page buffers in four-vert quads and nudges each vert's u/v toward the cell centre. The rotation baseline now captures/restores UVs alongside positions so the inset never compounds across restore->rotate cycles, and SetRotation(0) puts the untouched cell edges back. Unrotated text is unaffected. |
||
|
|
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. |
||
|
|
5978d7dd62 |
fix(texture): measure vertex offsets against the untouched layout rect (#27)
* fix(texture): measure vertex offsets against the untouched layout rect * fix(texture): honor SetTexCoordModifiesRect instead of dropping the crop The flag is not inert in 1.12. Script_SetTexCoordModifiesRect (0x0079C080) writes the Lua boolean to region+0x124 and Script_GetTexCoordModifiesRect (0x0079C120) reads it back (1/nil), and all three FUN_REGION_TEXCOORD_CROP call sites gate on that field: the 4-arg and 8-arg SetTexCoord writers (FUN_00770410 / FUN_007704C0) crop+store only when it is set, and the layout-resolve store path (FUN_00770670) crops when set / stores the raw anchor rect when clear. The earlier "toggling it changes nothing" probe was a timing artifact: the crop applies at the next SetTexCoord or layout resolve, never retroactively. So instead of removing the crop call, ApplyFromRect now applies it under the engine's own gate. Default state (flag clear) behaves exactly as this PR intends -- untouched layout rect, wedges fixed -- while a region that DID opt in keeps its offsets measured against the same cropped rect the engine stores, so the immediate apply and the corner-store co-hook can never disagree about the base rect in either flag state. Adds OFF_REGION_TEXCOORD_MODIFIES_RECT (0x124) to Offsets.h with the derivation, and corrects the FUN_REGION_TEXCOORD_CROP comment that implied a partial SetTexCoord always shrinks the drawn quad. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
59c3bf9e0f |
feat(text): add FontString:GetGlyphVerts() introspection
The fontstring analog of Texture:GetCorners — returns the first glyph's four baked vertex positions plus the bounding box of all glyph verts (12 numbers). Because the text paint (FUN_005c8710) is translate-only, these node-local coords track the on-screen positions directly, so a 0-vs-90 dump reads the rotation direction arithmetically. Also documents, on RotateVerts, why that dump can NOT settle rotation CHIRALITY on its own: node-local glyph-vert Y handedness is not determinable from the verts alone, so the visual comparison against the retail-verified Texture:SetRotation is the arbiter. The RotateVerts sine is unchanged (matches Texture:SetRotation / retail CCW-for-positive). |
||
|
|
3ab690ac53 |
fix(texture): correct vertex-offset units and the corner-store contract (#26)
* fix(texture): correct vertex-offset units and the corner-store contract The SetVertexOffset/SetRotation corner writes were wrong in four coupled ways, found by driving pixel-ruler and wedge fixtures against a raw corner-array readback: - Offsets converted px->anchor with the global 1024-normalized factor alone, so a region scaled 0.9 got every offset 1/0.9 too large (a 24px request measured at 26.67px). Offsets are now stored in the caller's LOCAL pixels and folded through the region's live effective scale (+0x7C) inside WriteCorners, which also makes them track later scale changes. Verified at two scale points (0.9 and 0.45): a 24px offset lands at 24.00px on both. - The anchor space is Y-DOWN (a rect reads top=0.222 < bottom=0.277), so +offsetY -- up, the retail contract -- is numerically negative there. It was added positive, sending every vertical offset the wrong way. - The draw consumes the +0xD4 array with y INVERTED about the rect's horizontal midline, and CULLS a quad whose slot y-parity flips: quads stored at their target positions rendered as exact y-mirrors of the stored corners, and mirroring the values in place culled every transformed quad, including a plain rotated square. Each corner's mirrored data is therefore written into its VERTICAL PARTNER's slot (BL<->TL, BR<->TR): positions land on target after the draw's flip, and the slot parity keeps the winding the draw accepts. For an axis-aligned rect this degenerates to exactly what the engine itself writes -- which is why none of it was visible on plain rects or centered squares, both mirror-invariant as point sets. - With that store contract, the y-down-transposed rotation matrix is the one that renders a positive angle counter-clockwise (settled with a rotated-bar fixture; squares and near-equilateral arrows are direction-blind). Only regions carrying an active transform are affected: the corner-store co-hook passes untracked regions through unchanged. * feat(texture): GetCorners debug binding texture:GetCorners() returns the raw drawn-quad corner array (+0xD4) and the resolved layout rect -- 12 numbers, no unit conversion. Diagnostic tooling: comparing stored corners against rendered pixels is what made the corner-store contract measurable from Lua. Kept for future transform triage; note that with the mirrored-partner store the raw values deliberately differ from the on-screen positions. |
||
|
|
6b13368e65 |
feat(fontstring): backport FontString:SetRotation / GetRotation
Generalizes the region-transform module (formerly texture-only) to serve the FontString method registry too, backporting the modern `fontstring:SetRotation(angle [, cx, cy])` and `GetRotation()`. Rotation is visual only, matching retail: GetStringWidth/GetStringHeight/ GetRect/SetPoint stay axis-aligned. A positive angle is CCW, same convention as Texture:SetRotation; the optional cx,cy pivot is a superset of retail (centre-only). How it works: the text paint copy-out (FUN_005c8710) is translate-only, so a rotation baked into the node-local glyph verts survives to screen. SetRotation rotates the live verts immediately (like the texture path) around the vert bounding-box centre, idempotently via an axis-aligned baseline snapshot (restore -> rotate). The baseline is re-captured on every fresh vertex bake, wired through inline-texture's DrawBuilder co-hook (gated on g_buildEmitSeq > 0 so clean paints never double-rotate, since inline-texture owns every text-render hook). Node page-buffer vertex layout added to Offsets.h (cross-verified across the emitter, FUN_005c8710, and FUN_005ce0c0). Known limitation: inline |T icons in a rotated fontstring don't turn with the text (separate anchored regions). Plain text rotates correctly. |
||
|
|
76f48de67f |
Inline |T…|t texture escapes (with coin strings, texture methods, and TextureUtil) (#24)
* feat(text): inline |T...|t texture escapes in chat and display text
Backport modern inline-texture markup to the 1.12 text engine: |Tpath:h|t
renders an icon inline in FontStrings / chat, for BLP and uncompressed TGA.
- Rendering primitive: resolve a path to a resident CGxTexture via FUN_0044acf0
and draw it as a textured quad through the UI text VB path.
- Positioning: co-hook the per-line glyph emitter (FUN_005ccbe0); render plain
runs by delegating to the original per segment (threading the pen through
linkState[4], read as a float), record icon quads at the pen, and flush them
in the paint pass (FUN_005c8fe0) translated by each node origin. Handles the
FontString pipe-doubling (|T -> ||T), the bit-3 per-call batch-clear mode,
multi-icon and multi-line accumulation, and font-relative vertical centering.
- Measure/wrap: co-hook the shared tokenizer (FUN_005c2810) so an inline-texture
span is one near-zero-width token, so icons no longer force early line wrap.
- Editbox exclusion: read the focused-editbox global (DAT_00cf4dc8) and suppress
icon recording while an input field is focused, so editboxes show raw,
editable markup while cached display text keeps its icons.
Diagnostic scaffolding (stats/capture Lua helpers) is still present. Follow-ups:
exact icon width in measure (hover-box accuracy), texcoords for sprite sheets,
vertex color, and the already-built editbox case. See docs/InlineTextureEscapes.md.
* fix(text): exclude editboxes from inline textures via node flag bit 6
Editable text (node flags [+0x5c] bit 6 / 0x40 -- verified in-game: the macro
editbox is 0x4D vs chat display 0x20D and FontStrings 0x0D) now shows raw,
editable |T...|t markup instead of rendered icons, checked per node in the
tokenizer, emitter, and flush. This is the 1.12 analog of 4.3.4's per-render
texture-disable flag (tokenizer bit 0x1000).
Replaces the earlier focus-global-only exclusion, which only caught single-line
inputs that rebuild on each keystroke; bit 6 also covers multi-line editors
(the macro editor) that build once while un-focused. The keyboard-focus global
(DAT_00cf4dc8) is kept as a fallback. Removes the failed monochrome heuristic.
Diagnostic scaffolding remains; a docs update and cleanup pass follow.
* feat(text): inline-texture texcoords + fix vertical flip
- Add the width / offset / texcoord fields to the escape
(:width:offsetX:offsetY:texW:texH:left:right:top:bottom), so a sprite sheet
such as UI-RaidTargetingIcons can be cropped to a single cell.
- Fix a vertical flip: the UI device backend is OpenGL (bottom-left texture
origin), so top screen corners map to v1 and bottom corners to v0. The flip
was invisible on symmetric icons but obvious on directional ones (raid-target
markers, swords).
* docs(text): document the completed inline-texture RE map
Fold this session's findings into InlineTextureEscapes.md now that the feature
ships: the frame -> renderNode -> group -> node -> line render hierarchy;
segmented-delegation positioning (the float linkState[4] pen read, the bit-3
per-call batch-clear handling, first-line multi-line accumulation); font-relative
vertical centring; the FontString pipe-doubling (|T arrives as ||T); the shared
tokenizer measure/wrap fix; editbox exclusion via node flag bit 6 (0x40), with
the failed focus-global and monochrome attempts recorded so they aren't retried;
and the texcoord fields plus the OpenGL bottom-left vertical flip.
* chore(text): enable inline textures by default on this branch
* feat(text): inline-texture vertex colour tint (:r:g:b)
Parse the trailing r:g:b (0-255) positional fields of the inline-texture
escape and apply them as the quad's vertex colour, so |T...:r:g:b|t tints
the icon (the font stage's default MODULATE COLOROP does texture.rgb x
tint; white = untinted). The bytes pack to 0xFFrrggbb -- the same
0xAARRGGBB order the tokenizer builds for |cAARRGGBB text, verified from
FUN_005c2810's colour branch -- so the value flows straight into the
existing vertex colour slot. Threaded parse -> IconDesc -> IconRecord ->
DrawTexturedQuad. Verified in-game (red/green/blue/white diamonds).
Also record the hover-accuracy (measure-width) verdict in the docs: the
tokenizer reports an icon as ~zero width, so GetStringWidth/wrap/hit-test
undercount it. Scoped by disassembly (FUN_005c6940 width backend,
FUN_005c6b70 per-glyph advance, FUN_005cdc20/FUN_005c7260 wrap): the token
contract has no width field, there is no single cold choke, and the only
fixes are hot per-glyph hooks (against the MinHook-collision guidance) or
~6 parallel measure-loop hooks -- for a mostly-cosmetic gain. Deferred.
* docs(text): record editbox/measure findings; strip inline-texture debug scaffolding
No behavior change — functionally identical to the shipped inline-texture
feature. This captures what a long investigation established and removes the
temporary debug instrumentation added during it.
Comments (src/text/InlineTexture.cpp):
- The tokenizer's `flags & 0x40` gate is load-bearing for RENDER, not just
measure: a suppressed editbox delegates to the ORIGINAL emitter, which
re-enters the tokenizer to lay out glyphs, so bit 0x40 (EDITABLE) must make
the tokenizer stand down or the macro editor draws BLANK instead of raw.
- bit 6 (NodeEditable) and the focus global (InputFocused) are COMPLEMENTARY,
not redundant: bit 6 catches the un-focused macro editor; the focus global is
the only signal for single-line focused inputs (chat box, pfChatCopyBox),
whose nodes lack bit 6 (0x0D/0x20D, indistinguishable from display).
- Removed the tokenizer call/pipe/span counters and the ZZWIDTH TokCap capture
(debug-only), and the now-unused g_lastFocused/g_lastMono stats fields.
Docs (docs/InlineTextureEscapes.md):
- Editbox exclusion: two complementary signals, and VERIFIED against retail —
typing `|T` into a chat box or macro editor shows raw there too; only
addon/system text renders. Our editbox-raw + display-renders split matches.
- Measure gap: added the focus-time caveat (icon ~0 width unfocused; counts the
literal path text while an editbox is focused — the editbox-raw tradeoff).
- Vertex-colour tint documented in the descriptor-fields section.
* feat(chat): strip player-injected |T icon spoofs from chat + bubbles
Vanilla neutralizes player-TYPED escapes in chat (a typed |c/|H/|T shows
raw); only trusted text (addon AddMessage, shift-clicked links) renders
them. Our Text::InlineTexture backport broke that parity for |T alone: it
detects the neutralized ||T form and draws the icon anyway, so a player
could /say |Tpath|t and put a real icon in everyone's chat AND the speech
bubble over their head. This restores vanilla behavior for |T while leaving
|c/|r/|H/|h exactly as vanilla.
It can only be done at the chat source, not the text emitter: addon |T and
player |T reach the emitter as byte-identical ||T (vanilla doubles the
unrecognized |T for both), so the only place they differ is provenance --
server chat flows through the chat dispatcher FUN_0049A870, addon print does
not. That one function copies the message into a single buffer fed to BOTH
the chat frame and the say/yell bubble spawn (FUN_00608AC0), so sanitizing
on entry covers both. (ECX is the MESSAGE, not the "sender name" the old
note claimed -- verified from the call site in FUN_0049D560.)
Structure mirrors Net::PacketDispatch (one hook, fanned out), since MinHook
allows only one hook per target and this choke point already had the
GUID-capture concern on it:
- Chat::Dispatch -- single owner of the FUN_0049A870 hook; orchestrates
- Chat::IconFilter -- pure Sanitize(); no hook, no engine state
- Chat::CurrentGUID -- GUID globals + getter + DispatchScope RAII (no
longer owns a hook)
Defang detail (the subtle bit): the message arrives doubled (||T). Blanking
the PIPE would leave a lone `|` + space -- an INVALID escape the chat frame
tolerates but the bubble text setter chokes on, producing an empty bubble
that fades instantly. So we keep the `||` (a valid literal-pipe escape) and
blank the `T`; for a lone |T we blank both chars. No dangling `|`, no |T
opener survives. Verified in-game: typed |T shows raw in chat and bubble,
addon icons still render, colours and links untouched.
* feat(text): per-editbox inline-texture suppression
Inline-texture rendering was globally suppressed whenever any editbox held
focus (VAR_FOCUSED_EDITBOX != 0), so opening the chat box flipped every
rendered icon/emote in chat history to raw |T...|t.
Replace the global check with per-editbox buffer correlation: suppress inline
rendering only for text that belongs to the FOCUSED editbox, matched by
pointer range against its own text buffers. Chat history keeps rendering while
you type.
The editbox keeps its text in two buffers (both verified via Ghidra), and both
must be matched or the field desyncs (raw width but a rendered icon):
- INPUT buffer ([fe+0x32C]/[fe+0x334], selected by [fe+0x318]&8) — the
caret/width MEASURE path reads it in place (FUN_0077da80 -> FUN_00772ae0 ->
FUN_005c6940, which loops the tokenizer).
- DISPLAY buffer (*([fe+0x328]+0xF0)) — a SStrDup'd copy the editbox actually
RENDERS from (FUN_00771d80); the emitter node text and the re-entrant render
tokenizer see this one.
TextInFocusedEditbox() bounds each buffer by a tight strlen (distinct heap
allocations -> no false-match cap) and runs only on pipe-leading tokens after a
null-focus short-circuit, so it stays off the hot path. A display FontString
measured while an editbox is focused matches neither buffer, so its icons now
measure correctly -- an improvement over the old global.
Editbox struct offsets centralized in Offsets.h (OFF_EDITBOX_BUFFER_SELECT /
BUFFER / BUFFER_MASKED / TEXT_FONTSTRING).
* feat(chat): raid-target marker substitutions ({rt1}/{skull}/…)
Expand the modern raid-target marker tokens in chat into inline icons, backported
onto the inline-texture renderer. {rt1}..{rt8} plus the named aliases ({star},
{circle}/{coin}, {diamond}, {triangle}, {moon}, {square}, {cross}/{x}, {skull};
case-insensitive) each become a |T escape cropping Interface\TargetingFrame\
UI-RaidTargetingIcons to the matching 64x64 cell (mapping verified against the
client's UnitPopup.lua: col=(N-1)%4, row=(N-1)/4).
Chat::RaidMarkers::Substitute runs in Chat::Dispatch AFTER the |T anti-spoof
sanitize, so players get the fixed, safe marker icons without a path to inject an
arbitrary texture. It emits the pipe-DOUBLED ||T…||t form: the inline emitter
renders both, but this is what survives into speech bubbles — the vanilla bubble
text builder (FUN_004b1600) truncates a lone |T while preserving ||, and pfUI's
bubble reskin copies the bubble's FontString text into its own FontString, which
then renders the icon through the normal paint path. (This is the form bubbles
rendered before the anti-spoof filter defanged the ||T opener.)
InlineTexture emitter fixes for the standalone-FontString (bit-3, batch-clear)
render path that bubbles/tooltips use — chat lines are unaffected:
- Colour: clearing bit 3 switches the engine to per-glyph colour from
colorState=[node+0x2c], whose alpha byte is a stale ~0x07; force the glyph
alpha opaque (keeping RGB) so a FontString coloured via SetTextColor with plain
text doesn't render near-transparent (which showed only pfUI's dark outline =
"black text"). |c-coloured text already has full alpha, so it's a no-op for chat.
- Horizontal justify: the engine positions centre/right-justified text using the
MEASURED width, which counts inline icons as ~zero (the measure gap), so the
rendered line overflows its box. Pre-sum the line's icon widths and shift the pen
(half for centre, full for right) so text+icons justify as a unit.
- Default centerFrac 0.5 -> 0.6 (better vertical centring across chat + bubbles).
* fix(text): suppress inline textures in editboxes by content match
The per-editbox suppression missed the chat input box: a pasted `|T…|t` rendered
as an icon instead of raw markup. An in-game probe showed why — the editbox
renders its text through a TRANSIENT copy: same bytes as the input buffer, but a
distinct heap allocation with no pointer link to the editbox in either direction
(every offset/back-pointer scan of fe / its FontString / the render node came back
-1). So the prior pointer/node-identity checks (input buffer, SetText copy,
FontString +0x48, node == *(fe+0x328)) could never match the render.
Match on CONTENT instead:
- Emitter: EmitLineIsFocusedEditbox compares the render line's bytes against the
focused editbox's input buffer (the emitter is handed the whole line, so a
bounded strcmp identifies it). Chat-history lines differ, so their icons keep
rendering while an editbox is focused.
- Measure (caret/GetStringWidth): unchanged pointer path — the tokenizer reads the
input buffer in place, so TextInFocusedEditbox still matches by range.
- Re-entrant render: the suppressed emitter brackets its delegated raw layout with
a text range (g_reentryLo/Hi); the tokenizer stands down across the whole span
via TextInReentry, so `|T` isn't eaten as a zero-width token (which drew BLANK).
Drops the dead node-identity/second-and-third-buffer heuristics. Covers any focused
input (chat box, pfChatCopyBox, macro editor).
* fix(text): drop stale icon records for reused chat line FontStrings
Inline-texture icons could paint as a ghost strip at the bottom of the screen
after chat had been busy for a while. The chat frame reuses its line
FontStrings: when a line is cleared (text set empty) or reused for markup-free
text, the draw builder early-returns on it, so the emitter never runs — and so
never erases that node's old icon record. The paint flush still walked the node
and drew its now-stale record at the FontString's parked position.
Gate the flush draw on the node's LIVE text still containing `|T`: if a node has
an icon record but its current text has no markup, the record is stale — drop it
and skip drawing. Kills the bottom-of-screen ghost.
(The separate scroll-freeze — icons only refreshed on the chat's dirty repaints —
is a different, deeper issue tracked next.)
* fix(text): stop chat icons vanishing — suppress only input boxes, not editable chat display
pfUI renders the chat scrollback through EDITABLE nodes (flags 0x45: bit 6
editable, no bit 3). The inline-texture emitter's blanket NodeEditable gate
suppressed inline rendering for ALL editable nodes, so those chat icons blanked
whenever that display was live — during scroll and as messages arrived, which
read as icons "disappearing/reappearing."
Gate suppression on a true INPUT box instead: editable (bit 6) AND bit 3 (0x08).
Macro editor 0x4D and name/chat input 0xC8 all carry 0x08; the chat scrollback
0x45 does not — so real input boxes still show raw |T markup while the chat
display keeps its icons. Also drop the flush's NodeEditable draw-gate: a
suppressed input box never records, so any record reaching the flush is a real
display line.
Pointer/content match alone can't cover a focused input box because its render
form is pipe-doubled (||T) while the input buffer is single-pipe, so the compare
misses.
* feat(text): inline |T icons as fontstring-anchored engine regions
Port 4.3.4's CSimpleEmbeddedTexture model. Each icon the emitter records
becomes a pooled CSimpleTexture ANCHORED TO ITS OWNING FONTSTRING,
configured off-render on the WorldTick, and drawn by the engine's own
region pipeline. 1.12 chat lines are real CSimpleFontStrings (the
ScrollingMessageFrame display refresh FUN_00788750 drives one per visible
line), so a co-hook on CSimpleFontString::RebuildString (0x7724A0) maps
every text node to its owner and one mechanism covers chat, tooltips, and
standalone FontStrings.
This replaces the raw-GxU-quad renderer and every overlay attempt:
- engine-drawn regions keep their textures resident: no flicker, verified
across three concurrent clients
- the anchor system moves icons with their lines: scroll costs nothing
- icons mirror the owner's shown state: faded lines hide their icons
- all engine mutation happens outside the render pass: no pending-layout
corruption, survives /reload (pointers dropped in PrepareForReload)
- placement verified pixel-exact against owner rects
RE landmarks recorded in Offsets.h:
- fs+0xF8 is an HTEXTBLOCK handle; the text node is at handle+8
- Show (0x77FCB0) no-ops unless desired-shown (+0xC4) is set, and
SetParentAndLayer(show=0) clears it on reparent
- the renderer draws the corner array (+0xD4), stored from the rect by
SetTexCoord - realize (0x768060) must run between SetPoint and
SetTexCoord or the corners go stale (the historical invisible-icon and
frozen-top-left-icon bugs)
- pen coords are y-down from the owner fontstring's BOTTOM edge; anchor
offsets use Script_SetPoint's pixel scale (LinePool::PixelToInternal)
* refactor(text): inline |T icons = pixel-perfect quads + residency holders
Replace the fontstring-anchored region approach with a hybrid that
decouples position from residency, because the two live in different
coordinate spaces that no single scale could reconcile:
- POSITION: draw each icon as a raw GxU quad in the text engine's own
render space (pen + node origin), the same coordinate system and
dynamic VB the glyphs use. Pixel-exact by construction — no anchor/
layout-space conversion. This is the original quad math; the region
detour proved pen-space and anchor-space differ by the text paint's
projection, not a scalar, so region anchoring could never be exact.
- RESIDENCY: a raw quad binds an unowned texture the engine evicts under
VRAM pressure (the flicker on scroll / blank on a 2nd client). So for
each distinct texture path, Text::InlineTexturePool creates ONE managed
CSimpleTexture, draws it every frame (a ~2px, alpha 1/255 corner box),
and never touches it again — its engine-managed draw is the live
reference that keeps the texture resident for the quads to bind.
Verified in-game: icons pixel-perfect across chat / bubbles / wrapped
lines / sizes / tint, no flicker on scroll, and two concurrent clients
both render — the residency-holder premise (untested before: the earlier
"disproof" had non-drawing holders) finally validated with a holder that
actually draws. Non-zero holder alpha is load-bearing: a fully
transparent region gets culled and residency is lost.
Diagnostics (probe, perf counters, scale/bias tune knobs) stripped; the
SEH fault guard on the flush stays.
* feat(text): render inline |T icons as engine regions anchored to their fontstring
Replace the raw-quad + residency-holder hybrid as the default renderer with
the 4.3.4 CSimpleEmbeddedTexture model: one pooled CSimpleTexture per visible
icon, anchored RELATIVE TO THE OWNING FONTSTRING. Engine-drawn, so texture
residency (the chat scroll flicker / blank 2nd client) is impossible by
construction; engine-anchored, so icons track their line for free.
The pen<->anchor bridge that unblocked this: RebuildString (0x7724A0)
multiplies every text-unit quantity by fs+0x7C when creating the text node,
and the node origin is the fontstring's justification anchor point mapped by
a single measurable scale K (verified with two-position probes: origin =
rectJustifyRef x K, K ~ 1470 = physical px per anchor unit, both axes, no
drift). Placement pipeline:
- RebuildString co-hook records node -> owning fontstring (a node only
speaks for its fs while it IS fs+0xF8->block+8, killing the stale-node
clear race around rebuilds).
- The paint hook converts each icon's pen-space quad through K and queues
fs-relative placements; regions are keyed BY FONTSTRING (nodes die on
every SetText - node keying orphaned regions into an accumulating wall).
- Placements apply on WorldTick, never mid-render. SetPoint offsets are
divided by the region's effective scale (+0x7C; anchor resolution
multiplies stored offsets by the scale chain - measured 0.0319 stored ->
0.0290 resolved = x0.91), then converged exactly by a per-region rect
readback correction each tick (deterministic, self-healing; a same-call
readback read stale pooled rects and shipped 7.4px crests).
- Engine SetTexCoord (0x770410) takes the 4-float rect Y-FIRST INTERLEAVED
{v0,u0,v1,u1} (diagnosed in-game: {u,v,u,v} rendered the raid-mark moon
as the circle cell); it is absolute, and the +0x124 shrink-by-UV-span
flag stays clear so crops stretch to the rect like modern clients.
- Expired/hidden lines are swept every tick (regions parent to the chat
frame, not the line, so they cannot inherit the line's own hide).
The quad renderer and residency holders remain behind
_classicapi_InlineTexMode (0 = quads, 1 = regions [default], 2 = overlay
A/B) as the bring-up oracle, plus diagnostics (_classicapi_InlineTexProbeFS
/ RegionDump / RegionCal / HolderCfg). Calibrated residual: RegionCal
(3, -1) pen units.
* fix(text): apply the inline-icon LEAD pad at draw time
The emitter reserves w + 1.5x pad in every inline icon's advance (lead 1x,
trail 0.5x), but FlushLayout drew the icon at the raw pen - all reserved gap
landed AFTER the icon, none before. Mid-text icons looked balanced only
because their surplus trailing gap padded the following text; a string-FINAL
icon (the money-string copper coin) sat jammed against its digits, and the
locale format strings had grown per-coin offsetX hacks to compensate.
Draw at pen + w x iconPadFrac (quads and regions share the cx), matching the
emitter's reservation. The coin formats drop to zero offsets - verified
against the texture itself: the three coin arts in UI-MoneyIcons are
byte-identical in alpha (same bounds, same center of mass, measured from the
exported BLP's DXT3 data), so no coin ever needed a positional nudge.
RegionCal's baked x constant drops 3 -> 0: the +3 calibrated pre-fix was
exactly this missing lead pad (user re-calibrated (0,-1) post-fix). The 1px
y residual remains the pen->anchor map's one true constant.
* fix(text): make inline-icon state lifetime-exact; fix every scroll-landing loss
Chat icons randomly landed shown-or-hidden when lines scrolled, and stale
icons ghosted at parked positions. Root causes, each found by in-game
triangulation (FsDump/Broken/Stats diagnostics, included), all fixed:
- Placements are FS-RELATIVE, computed at PAINT time in one coherent
snapshot (icon coords + fs rect in the same flush). The old apply-time fs
rect read raced the chat relayout after SetText and parked icons off
their line, where the dedup froze them.
- The queue tail gate now matches the per-icon build gate EXACTLY (incl.
K); any not-ready input skips-and-retries instead of queueing {} - an
empty queue froze lines iconless via the dedup (early-session K window).
- K (pen->anchor scale) is derived PER NODE from its own fontstring - pen
space scales with each fs's frame-scale chain, so a global chat-derived K
mis-sized icons on differently-scaled fontstrings. Global cache kept as a
+/-10%-clamped fallback.
- Stuck-blockless fontstrings (RebuildString releases the block on a
SetText that lands on an unresolved rect and never rebuilds; the zombie
node keeps painting) are re-dirtied so the engine rebuilds - the icon
pipeline then resumes naturally.
- First-line-of-build detection comes from a draw-builder co-hook
(FUN_005CDC20) build stamp - exact - with the old text-pointer heuristic
only as fallback for emitter paths outside the builder.
- THE LIFETIME FIX: co-hook the gxu text-node free (FUN_005CD950, the
single site where every node dies and its address becomes reusable) and
erase ALL per-node state there. Anything in the maps now refers to a
live node by construction: inherited ghost records on recycled nameplate
fontstrings, orphaned owners (dropNoFs 61k -> 0), and reload leftovers
lose their mechanism of existence.
- Ghost guard rescans the FONTSTRING's text (fs+0xF0, proven trustworthy),
not the node text pointer (which lied on pfUI chat lines and made the old
scan erase LIVE records every frame - the persistent iconless LFG lines).
False matches can only false-keep, never false-erase.
- Freshness TTL: regions stay only while the paint keeps re-queueing their
fontstring (deduped touches count); parked/orphaned fs regions expire in
~1s. Do NOT build-version records against the builder counter - the
builder runs every paint but only emits when dirty, so a version check
erases good records on every clean paint (the all-icons-gone regression).
Diagnostics added (Lua): _classicapi_InlineTexFsDump (pipeline triangulation
with chain classification), _classicapi_InlineTexBroken (names the broken
lines), _classicapi_InlineTexStats gains queued/drop/nudge counters and the
SEH fault address.
Also removes the FrameTick glue-screen attempt (b164d68): hooking the UI
render root regressed in-world chat; glue-screen icon support will be
re-approached without touching the in-world render path. The
FUN_UI_RENDER_ROOT offset stays documented for that retry.
* fix(text): pointer probes must allow Large-Address-Aware heap (>2GB)
LooksReadable capped plausible pointers at 0x7FFF0000. This client is LAA
(VanillaFixes), so heap allocations above 0x80000000 are valid and routine
once the heap grows - and the flush's layout walk BREAKS on an "unreadable"
node, so a single high-heap node silently truncated the walk and every node
AFTER it in the layout list lost its icons. That was the irreducible random
per-ROW missing-chat-icon bug that survived every renderer architecture
since the guard shipped with the first inline-texture commit (
|