mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
feat(xml): registerForClicks and wordwrap attributes
1.12's loaders read neither attribute: the Button loader (0x007788C0) has no registerForClicks, and the font string loader (0x00770F40) reads nonspacewrap but not wordwrap. Both were silently ignored, so ported templates got the default click mask and wrapping text. Both are read in the loader hooks Xml::ParentKey already owns, after the engine's loader and before OnLoad, and only when present and non-empty, so a node's value beats its template's and an OnLoad call still overrides it. No new hooks. registerForClicks follows 3.3.5's CSimpleButton::LoadXML. Storm's tokenizer (0x0064AE50, the one 3.3.5 calls) splits the value on spaces and commas. Each name ORs in its bits through Frame::MouseRegistration::MaskForName, the RegisterForMouse name table (3.3.5's MouseButtonStringToBitmask, AnyUp / AnyDown included). The result replaces the mask through the engine's own setter 0x00779730 (__thiscall(button, mask), ret 4, writes only +0x330). wordwrap goes through FontString::WordWrap::Set, the body of fontstring:SetWordWrap: it clears the font's override of the no-wrap style bit and lays the string out again when the value changes. Tested in game: WowStyle1DropdownTemplate's Text (wordwrap="false") now reports CanWordWrap() = nil.
This commit is contained in:
@@ -42,15 +42,32 @@
|
||||
// can silently displace, so it is reserved for names nobody else contends —
|
||||
// unlike TargetUnit (see CLAUDE.md), no loaded DLL or addon has cause to
|
||||
// replace RegisterForClicks.
|
||||
//
|
||||
// The XML attribute `registerForClicks` is 3.3.5's CSimpleButton::LoadXML:
|
||||
// Storm's tokenizer (FUN_STORM_STR_TOKENIZE, the one 3.3.5 calls) splits the
|
||||
// value on spaces and commas, each name ORs in its bits
|
||||
// (Frame::MouseRegistration::MaskForName, 3.3.5's MouseButtonStringToBitmask,
|
||||
// which knows AnyUp / AnyDown), and the result REPLACES the mask through the
|
||||
// engine's setter, as RegisterForClicks does. 1.12's Button loader has no such
|
||||
// attribute.
|
||||
|
||||
#include "frame/ClickMask.h"
|
||||
|
||||
#include "Game.h"
|
||||
#include "Offsets.h"
|
||||
#include "baselib/Ascii.h"
|
||||
#include "frame/MouseRegistration.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Frame::ClickMask {
|
||||
|
||||
namespace {
|
||||
|
||||
using Tokenize_t = void(__stdcall *)(const char **cursor, char *out, unsigned outSize,
|
||||
const char *delims, int *outQuoted);
|
||||
using SetClickMask_t = void(__thiscall *)(void *button, uint32_t mask);
|
||||
|
||||
// The engine's own click-type names, in mask-bit order.
|
||||
constexpr const char *kUpNames[] = {"LeftButtonUp", "MiddleButtonUp", "RightButtonUp",
|
||||
"Button4Up", "Button5Up"};
|
||||
@@ -93,4 +110,17 @@ const Game::ModuleAutoRegister _autoreg{&RegisterLuaFunctions};
|
||||
|
||||
} // namespace
|
||||
|
||||
void SetFromXml(void *button, const char *value) {
|
||||
auto tokenize = reinterpret_cast<Tokenize_t>(Offsets::FUN_STORM_STR_TOKENIZE);
|
||||
uint32_t mask = 0;
|
||||
char token[1024];
|
||||
const char *cursor = value;
|
||||
while (cursor != nullptr && *cursor != '\0') {
|
||||
token[0] = '\0';
|
||||
tokenize(&cursor, token, sizeof token, " ,", nullptr);
|
||||
mask |= Frame::MouseRegistration::MaskForName(token);
|
||||
}
|
||||
reinterpret_cast<SetClickMask_t>(Offsets::FUN_BUTTON_SET_CLICK_MASK)(button, mask);
|
||||
}
|
||||
|
||||
} // namespace Frame::ClickMask
|
||||
|
||||
Reference in New Issue
Block a user