mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
829b1cfed3bc5318d14330eb1eeab557ea7ddce6
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
165ccf3e9c |
refactor(lua): share the engine's flag readers as Game::Lua::ToFlag and Game::StringToFlag
Twenty modules each declared their own typedef or wrapper for FUN_LUA_TO_BOOLEAN_LOOSE (4.3.4's StringToBOOL(L, index, default)) or FUN_XML_ATTR_TO_BOOL (StringToBOOL(const char *)). Route them all through one helper each. frame/Cooldown.cpp had a C++ copy of both that read unknown attribute text as true; the engine's reader, which 4.3.4's XML loader uses, reads it as false. SetReverse/SetDrawEdge now also truncate numbers like every other 1.12 flag method. |
||
|
|
fbcc1c9ae1 |
feat(editbox): add SetCountInvisibleLetters / IsCountInvisibleLetters (#88)
* feat(xml): read parentKey, function= and button font style= from XML Later clients' XML has three attributes vanilla's parser keeps on the node but never reads. Ported UIs lean on all three: Zygor Guides Viewer 2.0 uses parentKey 69 times (its arrow, skin buttons and step frames), binds its main frame's whole OnLoad with function=, and names button fonts with style=. All three hook the engine's per-object XML node loaders. Those run on the object's layout sub-object ((object+0x24)->vtable[+8], called from the frame builder at 0x006EE4D9 and the region factory at 0x006F2756), so the object is `this - OFF_XML_LOADER_SUBOBJECT`. The loaders: frames FUN_00769820 (every derived frame type's loader calls it first), textures FUN_0076FE20, font strings FUN_00770F40, and Button's FUN_XML_BUTTON_LOAD (CheckButton's calls it first). Each hook runs the engine's loader, then: - parentKey="Name" sets parent[Name] = object on the Lua wrappers, the parent being the object's script-region parent (OFF_REGION_PARENT, which GetParent reads). An unnamed element has no wrapper yet, so it is registered the way the engine's own lazy path does (ScriptRegister(object, NULL), as GetParent does); a named one is never registered here, since SetName already did that under its name. The builder loads content and child frames before it finalizes, so a parent's <OnLoad> already sees its keys, and keys inside a virtual template bind on every frame built from it. - A script element with function="Name" becomes frame:SetScript(<element>, _G[Name]). The loader runs before the builder's finalize, so a bound OnLoad fires at the usual point. - A NormalFont / HighlightFont / DisabledFont with style and no inherits is applied through the engine's own setter for that state with _G[style]. Vanilla reads only inherits there and otherwise leaves the button's embedded font empty, so its text had no font. Adds FUN_XML_FRAME_LOAD / FUN_XML_TEXTURE_LOAD / FUN_XML_FONTSTRING_LOAD / FUN_XML_BUTTON_LOAD, OFF_XML_LOADER_SUBOBJECT and OFF_SCRIPT_REGION_NAME, with their derivations. Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0): probe XML gets its parent keys on a Frame, a Texture, a FontString, a button's NormalTexture and a frame inside an inherited template; an <OnShow function="..."/> handler runs; a button with <NormalFont style="GameFontHighlightSmall"/> reports that font object. Zygor's frames build with their keys, its main frame's OnLoad runs, and it loads without a Lua error. * feat(editbox): add SetCountInvisibleLetters / IsCountInvisibleLetters 3.3.5's EditBox can count color codes and hyperlink markup toward its SetMaxLetters limit: SetCountInvisibleLetters(true), or countInvisibleLetters="true" in XML (its macro text, friends broadcast and BNet report boxes). Off is the default. AceGUI-3.0's MultiLineEditBox calls the setter while building. 1.12's SetMaxLetters limit (+0x340) counts only visible letters: its counter (0x0077BC80) skips the markup classes in the edit box's per-byte table (+0x330), so with a limit of 5 "|cffff0000abcdefg|r" keeps "|cffff0000abcde" (checked in-game). That is 3.x's default (off). With the flag on, the limit check's three counts (returns 0x0077C09F, 0x0077C0C1, 0x0077C0E9) count each markup token at its length instead. The counter's other callers, the cursor movement and GetUTF8CursorPosition, are unchanged. For XML, hook the EditBox node loader (0x00779FB0, identified by the "letters"/"autoFocus"/"multiLine" attributes it reads after calling the frame loader) and, after it runs, read the attribute and parse it with the engine's own boolean parser (0x006F1B30, as for autoFocus). The loader follows the node-loader convention of the XML attributes change (OFF_XML_LOADER_SUBOBJECT), which this builds on. Verified in-game (1.12.1 client via VanillaFixes): with SetMaxLetters(12), "|cffff0000abcdefg|r" is kept whole with the flag off and cut to "|cffff0000ab" with it on; an XML EditBox with letters="12" and countInvisibleLetters="true" reports the flag on and cuts the text the same way. * docs: correct GetNumLetters note, drop version comparisons GetNumLetters counts the letters you see (FUN_007992C0 calls the same counter as the limit check), not bytes. Remove the 3.3.5 / stock 1.12 / later-client comparisons from the new XML and edit box sections. * fix(frame): build extra templates' child frames in CreateFrame The multi-template graft called the main vtable's +8 slot, which is the Lua method lookup FUN_00778590, not a node applier, passing the XML node as the Lua state. Its second call (the +0x24 sub-object's node loader) applied the template's content, but <Frames> children are built only by FUN_0076A060 from the finalize step, so an extra template's child frames were never created. Call the node loader, then FUN_XML_FRAME_LOAD_CHILD_FRAMES directly, so OnLoad is not re-run. Correct the notes in Offsets.h and CreateFrame.cpp. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |