mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
The FontString methods 4.3.4 has that 1.12 lacked. SetWordWrap is 1.12's own SetNonSpaceWrap on 4.3.4's style bit 0x40 (set when the text does not wrap). 1.12's text engine already honours the bit: TextBlockCreate turns it into text flag 0x2, and the layout and line count stop after one line on it. A change lays the string out again as SetText does, shared with SetMaxLines as FontString::Layout::Invalidate; a rebuild alone left a text-sized string at its old height, so the fit cut at a whole word with no ellipsis. GetFieldSize returns what 1.12 holds rather than 4.3.4's constant 8191: n - 1 bytes for a string with XML bytes="n" (SetText's SStrCopy keeps one for the terminator), and infinity for a string with no fixed size, whose buffer grows to any length.
47 lines
1.8 KiB
C++
47 lines
1.8 KiB
C++
// This file is part of ClassicAPI.
|
|
//
|
|
// ClassicAPI is free software: you can redistribute it and/or modify it under the terms
|
|
// of the GNU General Public License as published by the Free Software Foundation, either
|
|
// version 3 of the License, or (at your option) any later version.
|
|
//
|
|
// ClassicAPI is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
// PURPOSE. See the GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License along with
|
|
// ClassicAPI. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
#include "fontstring/Layout.h"
|
|
|
|
#include "Game.h"
|
|
#include "Offsets.h"
|
|
|
|
#include <cstdint>
|
|
|
|
namespace FontString::Layout {
|
|
|
|
namespace {
|
|
|
|
// FUN_HANDLE_RELEASE — DecRef a ref-counted handle. __fastcall(handle).
|
|
using HandleRelease_t = void(__fastcall *)(void *handle);
|
|
// FUN_LAYOUT_RESIZE — region layout resize (0 = invalidate). __thiscall(region,
|
|
// int); dummy-EDX form.
|
|
using LayoutInvalidate_t = void(__fastcall *)(void *region, void *edx, int arg);
|
|
|
|
} // namespace
|
|
|
|
void Invalidate(void *fs) {
|
|
Game::Ref<float>(fs, Offsets::OFF_FONTSTRING_WIDTH_CACHE) = 0.0f;
|
|
Game::Ref<float>(fs, Offsets::OFF_FONTSTRING_HEIGHT_CACHE) = 0.0f;
|
|
void *block = Game::Read<void *>(fs, Offsets::OFF_FONTSTRING_TEXT_BLOCK);
|
|
if (block != nullptr) {
|
|
reinterpret_cast<HandleRelease_t>(Offsets::FUN_HANDLE_RELEASE)(block);
|
|
Game::Ref<void *>(fs, Offsets::OFF_FONTSTRING_TEXT_BLOCK) = nullptr;
|
|
}
|
|
Game::Ref<uint32_t>(fs, Offsets::OFF_FONTSTRING_DIRTY_FLAGS) &= ~1u;
|
|
void *region = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(fs) + 0x24);
|
|
reinterpret_cast<LayoutInvalidate_t>(Offsets::FUN_LAYOUT_RESIZE)(region, nullptr, 0);
|
|
}
|
|
|
|
} // namespace FontString::Layout
|