mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
932e6ed82fcd4afeecd627a4e2922b7ef59a23e0
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
932e6ed82f |
feat(texture): wrap modes and tiling
texture:SetTexture(file, wrapModeHorizontal, wrapModeVertical), the XML hWrapMode / vWrapMode attributes, texture:SetHorizTile / GetHorizTile / SetVertTile / GetVertTile and the XML horizTile / vertTile attributes. Wrap. 1.12 fixes a texture's wrap when its file loads. CSimpleTexture::SetTexture (0x00770200) builds the flags word with CGxTexFlags (0x0058A980) from one wrap argument for both axes, and TextureCreate (0x00449D90) caches the handle under the name and that word, so a repeating copy of a file is its own shared texture. The device reads one bit per axis (3 for U, 4 for V), repeat or clamp, so the mirror and border modes clamp. A texture with a mode or a tile flag loads through a co-hook on that SetTexture: the same body, with a repeat per axis. The engine's same-file early-out (0x0044AC70) ignores flags, so the co-hook also compares the held image's wrap (its device texture's flags at +0x3C, or a loading BLP handle's at +0x150), and for the same file it swaps in the other copy and keeps the pixel shader. Changing a mode or a tile flag reloads the held file the same way. The Lua method is registered again so it stores the wrap arguments before the engine handler (0x0079BB40) runs: true or "REPEAT" repeats, anything else clamps. Tiling. A tiled axis repeats, and each non-zero coordinate on it becomes the texture's length in script units over the image's size in texels. The script units are the engine's own coordinate push: DivideByScreenScaleX (0x0041AE40) of aspect (0x0041AD70) x 1024 x length, over the effective scale. The texels are the device texture's width and height (+0x24 / +0x28): the file's size, halved only past the GPU limit and untouched by BaseMip. The layer batch keeps a pointer to the eight coordinates (0x00772FD0), so the count is written whenever an input changes: after each corner store, after both native SetTexCoord forms (0x00770410, 0x007704C0), on a tile change, and after CSimpleTexture::Emit (0x007706E0), whose device lookup loads the image. A tile change counts against the held image before the repeating copy of the same file replaces it, since the copy has no size until it is drawn. A texture showing an atlas does not tile (the atlases are parts of their files), and neither does one with SetTexCoordModifiesRect on. SetAtlas clears modes and tiling. A tiled status bar texture takes StatusBar::Fill's anchored layout instead of 1.12's crop, which would size it by the count, and its fill sets no coordinates. An XML <TexCoords> that moves a tiled axis off 0..1 logs "Invalid TexCoords value (horizTile is on)" at error level (new Xml::Error) and falls back to the whole image. Also corrects the AtlasData.h note on the atlas tile flags: 4 is horizontal and 2 is vertical. |
||
|
|
b032dc09ac |
refactor(texture): shared hooks for the texture constructor and corner store
MinHook takes one hook per address. Texture::Mask hooked the CSimpleTexture constructor (0x0076FC40) to drop its state when pool memory is reused, and Texture::Transform hooked the corner store (0x007705B0) to turn the quad again after each layout. Texture wrap modes and tiling need both hooks too, so each hook now has an owner that fans out to listeners: - Texture::Construct runs its listeners before the constructor, on the memory it is about to build. Mask listens. - Texture::CornerStore runs its listeners after the store. Transform listens. The store writes only the corners. The layer batch reads them through a pointer on every draw, so nothing marks the layer changed. The XML number parse through SStrToFloat (0x0064AAA0) moves into Xml::FloatAttr, which NativeSetters and Transform's rotation attributes now share. |
||
|
|
43594398f0 |
refactor(xml): one observer owns the per-type XML loader hooks
MinHook allows one hook per address, so the texture, font string and
button loader hooks lived in Xml::ParentKey, which then read every other
module's attribute for it (mask, atlas, wordwrap, registerForClicks), and
CountInvisibleLetters hooked the EditBox loader on its own.
Xml::TypeLoad now owns the hooks on the engine's per-type node loaders,
the way Xml::FrameLoad owns FUN_XML_FRAME_LOAD's, and fans out to
subscribers after the engine has loaded each node:
- texture FUN_XML_TEXTURE_LOAD 0x0076FE20
- font string FUN_XML_FONTSTRING_LOAD 0x00770F40
- button FUN_XML_BUTTON_LOAD 0x007788C0 (CheckButton's loader
calls it first)
- edit box FUN_XML_EDITBOX_LOAD 0x00779FB0
- status bar FUN_XML_STATUSBAR_LOAD 0x00782EF0 (new; calls
FUN_XML_FRAME_LOAD first at 0x00782F06, ret 8)
All five share the sub-object convention __thiscall(loader, node,
status), ret 8, object = loader - OFF_XML_LOADER_SUBOBJECT. An inherited
template goes through the same loader first, so a node's subscribers run
after its templates'. The texture and font string loads keep running in
the node's mixin scope (Xml::Mixin::Begin / End), as before.
Each attribute is now read in the module that owns its setter:
Texture::Mask (mask), Texture::Atlas (atlas, useAtlasSize),
FontString::WordWrap (wordwrap), Frame::ClickMask (registerForClicks) and
EditBox::CountInvisibleLetters (countInvisibleLetters). The XML-only
entry points Atlas::SetFromXml, WordWrap::Set and ClickMask::SetFromXml
become private, and ClickMask.h and WordWrap.h go. ParentKey keeps only
its own binding work. Same hook addresses, same order around the engine
call, no behavior change.
|
||
|
|
bd02983a08 |
feat(lua): WowTrimHorizontalScrollBar
Retail's horizontal bar is its vertical one with x and y swapped. Classic Era has no horizontal bar and this client no horizontal scroll bar art, so the template is WowClassicScrollBar with every anchor, size and inset swapped, and retail's horizontal atlas names (UI-ScrollBar-EndCap-Left/ Right, _UI-ScrollBar-Center, UI-ScrollBar-ScrollLeft/RightButton-*, ids from the 1.15 member table) bind to the Classic art transposed: the top cap is the left cap, the up arrow the left arrow. Transposing keeps the art's top-left lighting, which a quarter turn would move. The square knob takes the swapped crop of the same file. Atlas entries gain a transposed flag: SetTexCoord composition maps sprite x down the file rect and y across it. An inline |A icon is one axis-aligned rect, so a transposed atlas is not drawn there. |
||
|
|
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. |
||
|
|
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.
|
||
|
|
09c5832ae8 |
fix(texture): make texture coordinates address the atlas art, not the file
With an atlas applied, SetTexCoord was addressing the whole sheet, so a crop showed a slice of the surrounding art rather than a part of the sprite, and GetTexCoord reported the atlas rect where a caller expected what it had asked for. Both came from one cause: SetAtlas was writing the atlas rect into the region's only set of coordinates, leaving the caller's own nowhere to live. A live client shows the two are separate state there: GetTexCoord reads the full 0..1 rect immediately after SetAtlas, with GetAtlas still reporting the atlas, so 0..1 means all of the sprite rather than all of the sheet. Keep the caller's coordinates alongside the atlas name and compose: SetTexCoord records them in sprite space and writes the mapped result for the engine to draw, GetTexCoord hands them back. Both handlers are co-hooked and pass straight through for a texture with no atlas, which is every texture in the game until an addon calls SetAtlas -- the empty-map test is the whole cost in that case. Both the 4-argument and 8-argument corner forms compose; anything else is left to the engine to reject so its own error text is what the author sees. ResetTexCoord becomes a plain restore of identity, which is what it always was conceptually -- the atlas rect now falls out of composing identity rather than being a special case. Also clear the atlas on SetTexture rather than inferring it from the texture handle. The handle comparison cannot detect a re-set to the very file the atlas names, because the engine returns the same HTEXTURE, so GetAtlas kept reporting an atlas that was no longer showing. That guard predates this change. It stays for recycled regions, which is the case it is actually good for and the reason this module needs no region constructor hook. Verified in-game against a registered quarter-rect atlas: identity is reported after SetAtlas, a crop reads back in sprite space, the engine receives the composed file-space rect from both argument forms, reset returns to the full sprite, SetTexture clears the atlas even to the same file, and a texture with no atlas behaves exactly as before. |
||
|
|
4015fee5e2 |
feat(texture): add texture:ResetTexCoord
Drops a crop made with SetTexCoord or SetSpriteSheetCell and goes back to showing the whole of whatever the texture points at. What "the whole of it" means was the only open question, and the generated API docs answer none of it -- ResetTexCoord is listed with no arguments, no returns and no description, and Blizzard's own FrameXML never calls it. Settled by testing a live client instead: with an atlas applied, GetTexCoord reads the full 0..1 rect, and a reset after a SetTexCoord returns to that with GetAtlas still reporting the atlas. So the source and the user's texcoords are separate state there, and 0..1 means "all of the sprite" rather than "all of the sheet". Here an atlas IS its texcoords -- SetAtlas is SetTexture plus SetTexCoord, with no second layer to hold the sub-rect -- so identity for an atlas'd texture is the atlas's own rect. Resetting to a literal 0,0,1,1 would show the whole sheet where retail shows the sprite, so the atlas rect is restored instead, which reproduces the visible result. Reuses GetAtlas's staleness guard, so a texture pointed elsewhere since resets to the full rect. Verified in-game against a registered quarter-rect atlas: SetAtlas gives the rect, SetTexCoord replaces it, ResetTexCoord restores it with the atlas still set, and a plain textured region with no atlas resets to 0,0,1,1 with GetAtlas nil. |
||
|
|
c3cf9e6f3a |
feat(texture): add atlas support — C_Texture, SetAtlas, and |A markup
An atlas names a texture plus a sub-rect inside it, so SetAtlas is the engine's own SetTexture + SetTexCoord (+ the size setters for useAtlasSize) driven off one lookup. Every step delegates to the engine's Lua handlers, so the argument guards and the UI-scale conversion stay in force and this module only adds the name resolution. Adds C_Texture.GetAtlasInfo / GetAtlasExists / GetAtlasID / GetAtlasElementID / GetAtlasElements, the RegisterAtlas extension for addons that ship their own sprite sheet, texture:SetAtlas / GetAtlas, and the |A:name:h:w|a inline markup alongside the existing |T form. All five readers key off one bound set, so GetAtlasExists is true exactly when GetAtlasInfo returns a table. The built-in table is five rows on purpose. Measured against Classic Era's UiTextureAtlas tables and the community listfile: 0 of 868 atlas sheets exist in this client's art, and while Blizzard kept the original vanilla filename as the atlas name for 16 members, only 5 have dimensions that agree — vanilla's own scrollbar template draws a centered 16x16 out of a 32x32 file that the atlas calls 18x16. Texcoords are not derivable from the two tables, so the rest grow from _classicapi_DumpAtlasMisses() rather than from guesses. AtlasData.h carries the full derivation. |A shares every scanner, measure, wrap and placement stage with |T — ParseAtlasIcon fills the same IconDesc, since an atlas is exactly the path-plus-sub-rect that struct already holds. That makes the chat anti-spoof mandatory, not optional: IconFilter now defangs |A too, or a player could render art by typing it into /say and the speech bubble. GetAtlas stores the HTEXTURE it installed and clears itself when the region points elsewhere, which gives the correct nil-after-SetTexture behavior and avoids a second hook on FUN_SIMPLETEXTURE_CTOR — Texture::Mask owns that target and MinHook refuses a duplicate, which would abort the whole hook install. |