mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
7e95bbcf690f19fdd9fbbf5e17dee76edee0a5c9
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7e95bbcf69 |
refactor(frame): anchor calls and reads through Frame::Layout
Thirteen files declared their own typedefs for the engine's anchor
functions:
- SetPoint (FUN_REGION_SET_POINT 0x00767C70) in 11 files;
- ClearAllPoints (FUN_LAYOUT_CLEAR_ALL_POINTS 0x00767620) in 3;
- the point-name converters (FUN_STRING_TO_FRAME_POINT 0x006F1840,
FUN_FRAME_POINT_TO_STRING 0x006F1890) in 6.
Five places read an anchor slot by hand: the node at
OFF_REGION_ANCHOR_ARRAY, its relative through vtable +0x0C, and the
point and offsets. Points.cpp's ShiftPoints also read the relative point
from nodes with no relative. Those nodes are 12 bytes {vtable, x, y} and
have no such field.
Frame::Layout now has SetPoint, ClearAllPoints, StringToPoint,
PointToString, PointNode and GetPoint, taking the object like its other
calls. SetPoint's relative is a layout sub-object, as the engine stores
it, and its last argument is the engine's resize flag (benilla-re
ui/anchors). GetPoint reads the relative point only when the node has a
relative.
|
||
|
|
238e35ae53 |
feat(animation): from/to alpha, setToFinalAlpha, target keys, scale from/to
Later clients' animation attributes and the methods behind them, on the animation port's own objects. Alpha fromAlpha / toAlpha (SetFromAlpha / SetToAlpha / GetFromAlpha / GetToAlpha): an absolute alpha. Each update the target's alpha becomes from + (to - from) x progress, through Region::SetAnimAlpha, which takes AddAnimAlpha's target rule but sets instead of adding: a frame's own alpha through its vtable setter, a texture's or font string's vertex alpha through FUN_REGION_GET_COLOR / FUN_FONTSTRING_SET_COLOR. Earlier orders apply at full progress before the current order updates, so the last write wins. Setting either end turns the mode on, an unset end is 0, and SetChange returns to the relative change. Absolute values and the 0 default follow Blizzard's own code: it starts fades with SetFromAlpha(region:GetAlpha()) and fades in with toAlpha="1" alone. AnimationGroup setToFinalAlpha (SetToFinalAlpha / IsSetToFinalAlpha): when the group finishes (Finish included), Region::KeepAnimAlpha makes the alpha each alpha animation's target ended on the stored alpha, so the end restores that. Stop restores the stored alpha as before. targetKey / childKey (SetTargetKey / SetChildKey), with SetTarget, SetTargetName, SetTargetParent and GetTarget: a key path from the animation, where $parent steps to the group, then its region, then that region's parent; childKey "X" is "$parent.$parent.X". The steps among the animation objects are taken by Region::FindRegionByKey, and the rest goes to the relativeKey resolver in Xml::Anchors, now public with a switch for its leading-global rule. A name or key is looked up again on Play, as 4.3.4 looks up `target`; the setters also look it up at once and return whether they found a region. GetTarget returns the group's region when there is no target. Scale fromScaleX / fromScaleY / toScaleX / toScaleY (SetScaleFrom / SetScaleTo / GetScaleFrom / GetScaleTo): the scale goes from `from` to `to`, passed to AddAnimScale as 1 - scale. SetScale sets the end, so 4.3.4's scale is the case from = 1 and its results do not change. Tested in game with an XML test addon: childKey and targetKey resolve, the absolute alpha and the last-write-wins rule give each order's end value, setToFinalAlpha keeps 0.5 after the group finishes, a group without it restores alpha 1, and the from/to scale values load. |
||
|
|
0b7076d330 |
feat(frame): add GetCurrentKeyBoardFocus, SetMaxAnimFramerate and GetMaxAnimFramerate
GetCurrentKeyBoardFocus returns the focused edit box, or nil. SetMaxAnimFramerate / GetMaxAnimFramerate set and read the animation step rate (default 30 per second), which was a fixed constant before. Both mirror 4.3.4's SimpleFrameScript_Scripts.cpp. GetText moves to the not-worth-it list. |
||
|
|
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> |