From b83bb5b52b11ffd51dd59aa7465b1185222f2bd4 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Thu, 22 Oct 2026 22:15:17 -0500 Subject: [PATCH] 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. --- AddOns/!!!ClassicAPI/!!!ClassicAPI.toc | 1 + AddOns/!!!ClassicAPI/Util/Cooldown.lua | 27 + docs/API.md | 44 +- src/Offsets.h | 145 +++- src/api/Documentation.cpp | 12 + src/api/Documentation.h | 3 + src/frame/Cooldown.cpp | 1042 ++++++++++++++++++------ src/frame/RenderBatch.cpp | 62 ++ src/frame/RenderBatch.h | 50 ++ src/texture/Load.cpp | 100 +++ src/texture/Load.h | 38 + src/texture/Mask.cpp | 51 +- src/xml/FrameLoad.h | 4 +- 13 files changed, 1243 insertions(+), 336 deletions(-) create mode 100644 AddOns/!!!ClassicAPI/Util/Cooldown.lua create mode 100644 src/frame/RenderBatch.cpp create mode 100644 src/frame/RenderBatch.h create mode 100644 src/texture/Load.cpp create mode 100644 src/texture/Load.h diff --git a/AddOns/!!!ClassicAPI/!!!ClassicAPI.toc b/AddOns/!!!ClassicAPI/!!!ClassicAPI.toc index c3bc9099..6d997807 100644 --- a/AddOns/!!!ClassicAPI/!!!ClassicAPI.toc +++ b/AddOns/!!!ClassicAPI/!!!ClassicAPI.toc @@ -49,6 +49,7 @@ Util\Vector4D.lua Util\UiMapPoint.lua Util\UIParent.lua Util\ActionButton.lua +Util\Cooldown.lua Util\WorldMap.lua Util\AuraDurationModifiers.lua Util\AuraUtil.lua diff --git a/AddOns/!!!ClassicAPI/Util/Cooldown.lua b/AddOns/!!!ClassicAPI/Util/Cooldown.lua new file mode 100644 index 00000000..aa0eff3e --- /dev/null +++ b/AddOns/!!!ClassicAPI/Util/Cooldown.lua @@ -0,0 +1,27 @@ +-- CooldownFrame_SetTimer for both kinds of cooldown frame. A Cooldown frame +-- (CreateFrame("Cooldown") or ) takes 4.3.4's body (Cooldown.lua), +-- which hands the timer to the frame's own SetCooldown. Every other frame is +-- one of 1.12's indicator Models (CooldownFrameTemplate, as the action, bag, +-- spellbook and paper-doll buttons build theirs) and keeps 1.12's body, which +-- drives the model's sweep from CooldownFrame_OnUpdateModel. + +function CooldownFrame_SetTimer(this, start, duration, enable) + if ( this:IsObjectType("Cooldown") ) then + if ( start and start > 0 and duration > 0 and enable > 0 ) then + this:SetCooldown(start, duration); + this:Show(); + else + this:Hide(); + end + return; + end + if ( start > 0 and duration > 0 and enable > 0) then + this.start = start; + this.duration = duration; + this.stopping = 0; + this:SetSequence(0); + this:Show(); + else + this:Hide(); + end +end diff --git a/docs/API.md b/docs/API.md index 8ffcbee7..e9ecf2a9 100644 --- a/docs/API.md +++ b/docs/API.md @@ -6496,7 +6496,8 @@ ignores a negative `id`. ### `CreateFrame("Cooldown" [, name, parent, template])` -Creates a cooldown frame. The frame shows a cooldown sweep. +Creates a cooldown frame. The frame shows a dark sweep that moves clockwise +over its area, then a short flash, then hides itself. ```lua local cd = CreateFrame("Cooldown", nil, button, "CooldownFrameTemplate") @@ -6505,43 +6506,44 @@ cd:IsObjectType("Cooldown") -- true cd:SetCooldown(GetTime(), 10) -- start, duration in seconds cd:SetReverse(false) cd:GetReverse() -- false -cd:SetDrawEdge(false) -cd:GetDrawEdge() -- false +cd:SetDrawEdge(true) +cd:GetDrawEdge() -- true ``` | Method | Notes | | --- | --- | -| `cooldown:SetCooldown(start, duration)` | Sets the sweep. `start` and `duration` are numbers in seconds. `start` is a time value, for example the value that `GetTime()` returns. The frame shows the sweep. If `start` or `duration` is not positive, the frame hides. | -| `cooldown:SetReverse(reverse)` / `cooldown:GetReverse()` | Sets and returns the reverse flag. The flag is `false` when the frame is created. | -| `cooldown:SetDrawEdge(drawEdge)` / `cooldown:GetDrawEdge()` | Sets and returns the draw-edge flag. The flag is `false` when the frame is created. | +| `cooldown:SetCooldown(start, duration)` | Starts the sweep and shows the frame. `start` and `duration` are numbers in seconds. `start` is a time value, for example the value that `GetTime()` returns. When `duration` is over, the frame shows the flash for one second and then hides. | +| `cooldown:SetReverse(reverse)` / `cooldown:GetReverse()` | Sets and returns the reverse flag. With the flag set, the sweep starts full and becomes empty. At the end, the frame stays shown with no flash. The flag is `false` when the frame is created. | +| `cooldown:SetDrawEdge(drawEdge)` / `cooldown:GetDrawEdge()` | Sets and returns the draw-edge flag. With the flag set, a bright line moves along the edge of the sweep. The flag is `false` when the frame is created. | If `start` or `duration` is not a number, `SetCooldown` gives the error `Usage: :SetCooldown(start, duration)`. -You can also use `CooldownFrame_SetTimer(cd, start, duration, 1)` to set -the sweep. +The draw-edge flag applies from the next `SetCooldown` call. -The reverse flag and the draw-edge flag do not change the sweep picture. -The getter methods return the values that the setter methods set. +You can also use `CooldownFrame_SetTimer(cd, start, duration, enable)`. +This function calls `SetCooldown` on a cooldown frame. If `start`, +`duration`, or `enable` is not more than 0, it hides the frame. -Use these methods on a cooldown frame. A call on a frame of another type -gives an error. +Only cooldown frames have these five methods. -XML files can also create a cooldown frame with a `` element: +A new cooldown frame has a sweep that is already over. If the frame is +shown before the first `SetCooldown` call, it hides itself after one +second. + +XML files can also create a cooldown frame with a `` element. +The `reverse` and `drawEdge` attributes set the two flags: ```xml - + ``` -Every cooldown frame shows the sweep, also without a template. Its -`template` and `inherits` templates apply after the sweep, so they can -change it. - -A cooldown frame starts without anchors. Give it a position with -`SetPoint`, `SetAllPoints`, or ``. `CooldownFrameTemplate` sets -the frame to the full size of its parent. +A cooldown frame needs no template. A cooldown frame starts without +anchors. Give it a position with `SetPoint`, `SetAllPoints`, or +``. `CooldownFrameTemplate` sets the frame to the full size of +its parent, and the frame starts hidden. ### `frame:SetShown(shown)` diff --git a/src/Offsets.h b/src/Offsets.h index 2cab60f2..84390d63 100644 --- a/src/Offsets.h +++ b/src/Offsets.h @@ -3817,16 +3817,6 @@ enum Offsets { // GetEffectiveAlpha calls it for its `self` type check, then reads the // byte. FUN_SCRIPT_FRAME_GETALPHA = 0x00774DC0, - // Region GetObjectType / IsObjectType (Region table 0x0087C9B8 entries - // 0/1, ctx VAR_REGION_METHOD_REGISTRY) and Frame GetFrameType / - // IsFrameType (Frame table 0x00878EC0 entries 0/1, ctx - // VAR_FRAME_METHOD_REGISTRY), per docs/raw_methods.txt. - // `Frame::Cooldown` re-registers these names on the Model registry and - // delegates to them for every frame that is not a marked Cooldown. - FUN_SCRIPT_REGION_GETOBJECTTYPE = 0x007A11D0, - FUN_SCRIPT_REGION_ISOBJECTTYPE = 0x007A1290, - FUN_SCRIPT_FRAME_GETFRAMETYPE = 0x00773640, - FUN_SCRIPT_FRAME_ISFRAMETYPE = 0x00773700, // Hyperlink scripts. ScrollingMessageFrame and SimpleHTML share a base // whose GetScriptByName override (0x007A3700, in the vtables at slots @@ -10840,10 +10830,123 @@ enum Offsets { // FUN_0048FBF0 after LoadScriptFunctions and before FrameXML loads — and // the glue UI's FUN_0046A400. FUN_FRAMEXML_REGISTER_FACTORY = 0x006EE880, - // The "Model" factory from that default list: allocates the 0x3DC-byte - // CSimpleModel and constructs it on `parent` (0x0076C8E0). - // `CSimpleFrame *__fastcall(CSimpleFrame *parent)`. - FUN_FRAMEXML_CREATE_MODEL = 0x006EECF0, + + // ---- Subclassing CSimpleFrame (Frame::Cooldown) ------------------------- + // The "Frame" factory of the default list (0x006EEC10) is + // `SMemAlloc(SIMPLEFRAME_SIZE, file, line, 0)` then the constructor + // `CSimpleFrame::CSimpleFrame` — `__thiscall(frame, parent)`, `ret 4` — + // which stores VTBL_SIMPLEFRAME at +0 and VTBL_SIMPLEFRAME_LAYOUT at + // OFF_FRAME_LAYOUT_SUBOBJECT (0x007692E5 / 0x007692EB). Every derived + // factory (Model 0x006EECF0: 0x3DC bytes, CSimpleModel ctor) has the same + // shape. Slot 0's deleting destructor (0x00769380) runs the destructor + // body FUN_FRAME_DESTRUCTOR and SMemFrees the block, so a larger block + // from SMemAlloc frees cleanly. The vtables are 36 and 11 slots: the main + // one ends where the layout one's successor (title region, 0x0081C528) + // begins, and the layout one ends at VTBL_SIMPLEFRAME (benilla-re + // ui/frames, dumped from the exe). + SIMPLEFRAME_SIZE = 0x314, + FUN_SIMPLEFRAME_CONSTRUCTOR = 0x00769090, + VTBL_SIMPLEFRAME = 0x0081C498, + VTBL_SIMPLEFRAME_SLOTS = 36, + VTBL_SIMPLEFRAME_LAYOUT = 0x0081C46C, + VTBL_SIMPLEFRAME_LAYOUT_SLOTS = 11, + // Main-vtable slots, all __thiscall (CSimpleFrame's own in brackets): + // +0x00 deleting destructor (this, flags), ret 4 [0x00769380] + // +0x08 GetScriptMethod (this, L, name) -> int, ret 8 [0x00778590]: + // FUN_FRAMESCRIPT_PUSH_METHOD on the class hash, else the base + // class's lookup — the `__index` dispatcher's per-class step + // +0x10 IsA (this, int typeId) -> bool, ret 4 [0x00484780] + // +0x18 IsObjectType (this, const char *) -> bool, ret 4 [0x004847B0] + // +0x1C GetObjectType (this) -> const char * [0x00484800]: + // what Script GetObjectType (0x007A11D0) and GetFrameType + // (0x00773640) push, after IsA(Region/Frame id) via +0x10 + // +0x38 OnFrameUpdate (this, float elapsedSec), ret 4 [0x0076B2C0]: + // the update walk's per-frame call (CSimpleTop 0x00765707); + // runs OnUpdate + // +0x44 EmitLayer (this, batch, int layer), ret 8 [0x0076B3A0]: + // the level rebuild's per-frame call (0x007659ED) — 4.3.4's + // OnFrameRender(batch, layer) + // +0x84 Hide (this) / +0x88 Show (this): the visibility half of 1.12's + // Show/Hide; Script Show/Hide (0x00775750/0x00775810) and the XML + // `hidden` attribute (0x007698A6/0x007698BA) first write + // OFF_FRAME_SHOWN 1/0, then call these. + // (+0x28 is VTBL_FRAME_SET_FRAME_ALPHA.) + VTBL_FRAME_DELETING_DESTRUCTOR = 0x00, + VTBL_FRAME_GET_SCRIPT_METHOD = 0x08, + VTBL_FRAME_IS_A = 0x10, + VTBL_FRAME_IS_OBJECT_TYPE = 0x18, + VTBL_FRAME_GET_OBJECT_TYPE = 0x1C, + VTBL_FRAME_ON_FRAME_UPDATE = 0x38, + VTBL_FRAME_EMIT_LAYER = 0x44, + VTBL_FRAME_HIDE = 0x84, + VTBL_FRAME_SHOW = 0x88, + // Layout-vtable slots, `this` = the layout sub-object: + // +0x00 OnFrameSizeChanged (this, const float *oldRect), ret 4 + // [0x0076B580] + // +0x04 deleting destructor thunk: `sub ecx, 0x24; jmp 0x00769380` + // (0x0076C410) — it does NOT go through slot 0 + // +0x08 VTBL_XML_NODE_LOADER (FUN_XML_FRAME_LOAD) + // +0x0C GetLayoutParent (this) -> layout or 0 [0x0076C6E0] + VTBL_LAYOUT_ON_FRAME_SIZE_CHANGED = 0x00, + VTBL_LAYOUT_DELETING_DESTRUCTOR = 0x04, + VTBL_LAYOUT_GET_LAYOUT_PARENT = 0x0C, + // CLayoutFrame::LoadXML's `setAllPoints="true"` (0x00767800) is + // FUN_LAYOUT_SET_ALL_POINTS(layout, GetLayoutParent(), 1). + // + // CSimpleFrame::NotifyLayerChanged — `void __thiscall(frame, int layer)`, + // `ret 4`: marks one draw layer for a rebuild, in the frame's own mask + // when it draws itself (FRAME_FLAG_SCROLLED), else in its level's when + // the frame is visible. Nothing to mark when it is not: showing it + // joins the level, which rebuilds it. + FUN_FRAME_NOTIFY_LAYER_CHANGED = 0x0076A990, + + // ---- Per-class method hashes -------------------------------------------- + // Every frame class keeps its Lua methods in a Storm hash of 10 dwords + // (0x28 bytes): +0x00 the node allocator vtable VTBL_METHOD_HASH_ALLOCATOR, + // +0x04 the node link offset 0xC, +0x08/+0x0C an empty list (head = &+0x08, + // tail = &+0x08 | 1), +0x10..+0x20 zero (the bucket array), +0x24 the + // bucket mask, -1 until the first registration allocates 4 buckets. + // That is the whole static initializer (Model's 0x0076F5F0, Frame's + // 0x00778310 — both store 0x00806CB8). FUN_REGISTER_FRAME_METHODS fills + // one (it always appends a node: re-registering a name it holds without + // unregistering first leaves the old node and its stale ref), and + // FrameScriptUnregisterMethods — `void __fastcall(hash)` — unrefs each + // function in the live Lua state and frees the nodes, keeping the + // buckets for the next registration. + // FrameScriptPushMethod — `int __fastcall(L, const char *name, hash)`, + // callee pops `hash`: pushes registry[ref] and answers 1 when found. + VTBL_METHOD_HASH_ALLOCATOR = 0x00806CB8, + METHOD_HASH_SIZE = 0x28, + FUN_FRAMESCRIPT_PUSH_METHOD = 0x00702000, + FUN_FRAMESCRIPT_UNREGISTER_METHODS = 0x00701F20, + // CGGameUI::UnregisterScriptFunctions — `void __cdecl(void)`: the mirror + // of LoadScriptFunctions, called from the game UI's shutdown (0x00490CBA) + // on /reload and logout while the game Lua state is still open. Releases + // the class hashes (GameTooltip, Minimap, PlayerModel, ...) with + // FUN_FRAMESCRIPT_UNREGISTER_METHODS and unregisters the globals. + FUN_GAMEUI_UNREGISTER_SCRIPT_FUNCTIONS = 0x00490CE0, + + // ---- Layer batch quads ---------------------------------------------------- + // A layer batch (0x30 bytes, benilla-re ui/draworder) counts its entries + // at +0x04 and keeps its quads in an array at +0x08: capacity, count + // (+0x0C), records (+0x10), growth step. A record is 0x1C bytes: device + // texture (FUN_TEXTURE_GET_RENDERABLE), float[4][3] positions, float[4][2] + // texcoords, blend mode, colour pointer or 0, colour stride (4 = one + // colour per vertex, 0 = one for all), pixel shader or 0. The texture + // emit FUN_00772FD0 writes exactly that after reserving one record with + // FUN_RENDERBATCH_RESERVE_QUADS — `void __thiscall(array, extra, round)`, + // `ret 8`, a no-op while there is room. The batch keeps the POINTERS and + // re-reads them on every draw (FUN_0076FB00: a 4-vertex strip with the + // indices {0,1,2,3} at 0x00878CDC, so the triangles are 0-1-2 and + // 1-2-3); it is rebuilt only when a layer is marked changed. A record + // with a colour and a blend mode below 2 draws with blend 2 (alpha), the + // same promotion 3.3.5's SortByTexture makes. + FUN_RENDERBATCH_RESERVE_QUADS = 0x00773280, + OFF_RENDERBATCH_ENTRY_COUNT = 0x04, + OFF_RENDERBATCH_QUADS = 0x08, + OFF_RENDERBATCH_QUAD_COUNT = 0x0C, + OFF_RENDERBATCH_QUAD_RECORDS = 0x10, + RENDERBATCH_QUAD_SIZE = 0x1C, // CLayoutFrame::ClearAllPoints — `void __fastcall(layout)`, layout = // object + OFF_FRAME_LAYOUT_SUBOBJECT. Frees all 9 anchor slots and // unlinks the frame from each relative frame. Script ClearAllPoints @@ -11029,6 +11132,20 @@ enum Offsets { // load — calling it each frame IS the residency reference (what the // minimap's masked draw does for its mask at 0x004ec65c). FUN_TEXTURE_LOAD_BY_PATH = 0x00449D90, + // TextureCreateWithCallback — `HTEXTURE __fastcall(uint32 w, uint32 h, + // uint32 mips, uint32 format, uint32 flags, void *owner, callback, const + // char *name, int force)`: a named texture whose texels `callback` + // supplies, never deduplicated by name. The portrait cache (0x00525F58: + // 64x64, 1 mip, GXTEX_FORMAT_ARGB8888, FUN_GX_TEXFLAGS_INIT(1, 0,0, 0,0,0, + // 1, 0), "Portrait2") is the model. The callback is `void + // __fastcall(uint32 command, uint32 w, uint32 h, uint32 face, uint32 + // level, void *owner, uint32 *stride, const void **texels)`, `ret 0x18`; + // on GXTEX_CMD_LATCH it answers stride = w * 4 and the texels, which it + // keeps (the portrait's 0x00525AE0 hands its cached array over without a + // copy), and ignores every other command. + FUN_TEXTURE_CREATE_WITH_CALLBACK = 0x00449BF0, + GXTEX_FORMAT_ARGB8888 = 2, + GXTEX_CMD_LATCH = 1, PTR_TEXLOAD_DESC_VTBL = 0x007FFA10, FUN_GX_TEXFLAGS_INIT = 0x0058A980, FUN_TEXTURE_GET_RENDERABLE = 0x0044ACF0, diff --git a/src/api/Documentation.cpp b/src/api/Documentation.cpp index a29f746d..ebad2b20 100644 --- a/src/api/Documentation.cpp +++ b/src/api/Documentation.cpp @@ -167,10 +167,16 @@ const WidgetSystem kWidgetSystems[] = { {Offsets::VAR_MODEL_METHOD_REGISTRY, "SimpleModelAPI"}, }; +// Hashes of the frame classes this DLL adds (NameWidgetSystem). +std::vector g_ownWidgetSystems; + const char *WidgetSystemFor(const void *registry) { for (const WidgetSystem &w : kWidgetSystems) if (reinterpret_cast(w.registry) == registry) return w.system; + for (const WidgetSystem &w : g_ownWidgetSystems) + if (reinterpret_cast(w.registry) == registry) + return w.system; return nullptr; } @@ -659,6 +665,12 @@ void RecordFrameMethods(const void *registry, const Game::Lua::FrameMethodEntry } } +void NameWidgetSystem(const void *registry, const char *system) { + if (WidgetSystemFor(registry) != nullptr) + return; + g_ownWidgetSystems.push_back({reinterpret_cast(registry), system}); +} + void RecordEnum(const char *parent, const char *sub, const Game::Lua::EnumIntegerEntry *entries, int count, const char *system) { if (g_pass == ENV_NONE || sub == nullptr) diff --git a/src/api/Documentation.h b/src/api/Documentation.h index 85d51be1..ae82aabe 100644 --- a/src/api/Documentation.h +++ b/src/api/Documentation.h @@ -34,6 +34,9 @@ void RecordGlobal(const char *name, const Game::Doc::Function *doc); void RecordTable(const char *table, const char *name, const Game::Doc::Function *doc); void RecordFrameMethods(const void *registry, const Game::Lua::FrameMethodEntry *table, int count, const Game::Doc::Method *docs, int docCount); +// Names the widget system of a method hash this DLL owns (a frame class it +// adds), alongside the engine registries the exporter already knows. +void NameWidgetSystem(const void *registry, const char *system); void RecordEnum(const char *parent, const char *sub, const Game::Lua::EnumIntegerEntry *entries, int count, const char *system); diff --git a/src/frame/Cooldown.cpp b/src/frame/Cooldown.cpp index a55f87b3..e09a7e3a 100644 --- a/src/frame/Cooldown.cpp +++ b/src/frame/Cooldown.cpp @@ -11,119 +11,760 @@ // You should have received a copy of the GNU General Public License along with // ClassicAPI. If not, see . -// `Cooldown` frame type, following 4.3.4's CGCooldown -// (wowdecomp15595: WoW/Source/Ui/CGCooldown.{h,cpp}, -// CGCooldown_Scripts.cpp). +// `Cooldown` frame type: 4.3.4's CGCooldown (wowdecomp15595: +// WoW/Source/Ui/CGCooldown.{h,cpp}, CGCooldown_Scripts.cpp), a CSimpleFrame +// subclass that draws its own sweep. No model, no template, no Lua driver. // -// 4.3.4 has a native CSimpleFrame subclass with its own object type, its -// own script metatable, and five methods: +// The class is built the way CGCooldown::Create builds it: one SMemAlloc block +// of the CSimpleFrame size plus CGCooldown's fields, the engine's CSimpleFrame +// constructor, then our own copies of CSimpleFrame's two vtables with +// CGCooldown's overrides in the slots 1.12 has for them (Offsets.h +// "Subclassing CSimpleFrame"): // -// SetCooldown(start, duration) -- seconds, as GetTime() values -// SetReverse(reverse) -- StringToBOOL(L, 2, 1) -// GetReverse() -- boolean -// SetDrawEdge(drawEdge) -- StringToBOOL(L, 2, 1) -// GetDrawEdge() -- boolean +// 4.3.4 virtual 1.12 slot +// ~CGCooldown +0x00 (and the layout thunk +0x04) +// GetScriptMetaTable +0x08 GetScriptMethod: own hash, then Frame's +// IsA(type) / IsA(name) +0x10 / +0x18 +// GetObjectTypeName +0x1C, what GetObjectType/GetFrameType push +// OnLayerUpdate(elapsed) +0x38 OnFrameUpdate +// OnFrameRender(batch, layer) +0x44 EmitLayer +// UpdateAlpha +0x28 SetFrameAlpha +// OnFrameSizeChanged(rect) layout +0x00 +// LoadXML(node, status) layout +0x08 // -// Vanilla has no such class. Its cooldown sweep is a Model built from -// FrameXML's CooldownFrameTemplate (the UI-Cooldown-Indicator model), -// whose OnUpdateModel script plays sequence 0 as the sweep and sequence 1 -// as the end flash, then hides -- the same sweep-then-flash state machine -// CGCooldown::OnLayerUpdate runs in C++. So a Cooldown here is that Model, -// plus this module's five methods with 4.3.4's signatures, argument -// checks, and defaults, driving the model through FrameXML's own -// CooldownFrame_SetTimer -- the exact call 4.3.4's Cooldown.lua makes on -// top of SetCooldown. +// The five methods live in a method hash of their own, exactly like each +// engine frame class's (Offsets.h "Per-class method hashes"), so only a +// Cooldown has them, and they reach `self` through the engine's own IsA gate +// with a type id taken from the engine's counter. The hash is released where +// the engine releases its own, at the end of CGGameUI::UnregisterScriptFunctions. // -// "Cooldown" is a real frame type: this module registers it in the -// engine's frame-type table (FUN_FRAMEXML_REGISTER_FACTORY), so XML -// `` and CreateFrame("Cooldown") both reach CreateCooldown -// through the builder. The factory builds the engine's Model and marks it; -// the frame then loads CooldownFrameTemplate ahead of its own templates -// (BeforeFrameNode), because every 4.3.4 Cooldown draws a sweep. +// Drawing. 1.12's layer batch draws quads (four-vertex strips) whose vertex +// arrays it keeps by pointer, so the geometry is queued once per layer rebuild +// and animated in place: the star fan (s_starIndices, eight triangles around +// vertex 9) is four strips {v2k, v9, v2k+1, v2k+2}, the flash and edge quads +// are one strip each in the order their index lists {0,2,1, 1,2,3} draw. A +// change to WHICH strips are queued (a texture loaded, the edge switched) +// marks the layer changed so it is rebuilt. Vertex z is 0, as 1.12's texture +// regions write it (CSimpleTexture::SetVertices 0x007705B0); 4.3.4 writes 1. // -// Two 4.3.4 rendering flags have no counterpart in the indicator model, -// which has neither a reversed sweep nor an edge texture: SetReverse and -// SetDrawEdge store and report their values exactly as 4.3.4 does, but do -// not change how the sweep draws. SetCooldown's stored start/duration -// (milliseconds, as CGCooldown keeps them) are likewise kept for parity -// even though no 4.3.4 getter exposes them. +// Textures. star4.blp ships with 1.12 (byte-identical to 4.3.4's). edge.blp +// does not, and a texture under the embedded addon's path would not load: +// BLPs open through SFile, not the read the addon redirects. So the edge is +// 4.3.4's 16x16 image as texels in the DLL, through the engine's procedural +// texture path, created once per process. // -// The methods are registered on the MODEL registry -- the narrowest -// registry a Cooldown resolves through -- so in Lua they are visible on -// every Model. Only a marked Cooldown may call them; any other Model -// gets the engine's own wrong-object-type error, as if the method had -// been called on the wrong class in 4.3.4. GetObjectType / IsObjectType -// and GetFrameType / IsFrameType are re-registered on the same registry -// (most recent registration wins) and delegate to the engine's own -// implementations for every frame that is not a marked Cooldown, so a -// Cooldown reports "Cooldown" while a plain Model is untouched. +// The stock CooldownFrameTemplate is a Model template (the indicator model and +// its OnUpdateModel / OnAnimFinished scripts), which vanilla's own buttons +// keep using. 4.3.4's CooldownFrameTemplate is `