mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
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.
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "Game.h"
|
||||
#include "Offsets.h"
|
||||
#include "baselib/Ascii.h"
|
||||
#include "frame/Layout.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
@@ -317,8 +318,6 @@ void Anim::PostLoadXML() {
|
||||
|
||||
namespace {
|
||||
|
||||
using StringToPoint_t = int(__fastcall *)(const char *name, int *point);
|
||||
using PointToString_t = const char *(__fastcall *)(int point);
|
||||
|
||||
Anim *Self(void *L) { return static_cast<Anim *>(Resolve(L, 1, Anim::s_class)); }
|
||||
Anim *SelfOf(void *L, Class &cls) { return static_cast<Anim *>(Resolve(L, 1, cls)); }
|
||||
@@ -699,7 +698,7 @@ int __fastcall Script_SetOrigin(void *L) {
|
||||
return 0;
|
||||
}
|
||||
int point = Offsets::FRAMEPOINT_CENTER;
|
||||
if (!reinterpret_cast<StringToPoint_t>(Offsets::FUN_STRING_TO_FRAME_POINT)(Game::Lua::ToString(L, 2), &point))
|
||||
if (!Frame::Layout::StringToPoint(Game::Lua::ToString(L, 2), &point))
|
||||
point = Offsets::FRAMEPOINT_CENTER;
|
||||
a->originPoint = point;
|
||||
a->originX = Game::PixelToInternal(static_cast<float>(Game::Lua::ToNumber(L, 3)));
|
||||
@@ -711,7 +710,7 @@ int __fastcall Script_GetOrigin(void *L) {
|
||||
Anim *a = OriginSelf(L);
|
||||
if (a == nullptr)
|
||||
return 0;
|
||||
Game::Lua::PushString(L, reinterpret_cast<PointToString_t>(Offsets::FUN_FRAME_POINT_TO_STRING)(a->originPoint));
|
||||
Game::Lua::PushString(L, Frame::Layout::PointToString(a->originPoint));
|
||||
Game::Lua::PushNumber(L, a->originX);
|
||||
Game::Lua::PushNumber(L, a->originY);
|
||||
return 3;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "Game.h"
|
||||
#include "Offsets.h"
|
||||
#include "baselib/Ascii.h"
|
||||
#include "frame/Layout.h"
|
||||
#include "xml/FrameLoad.h"
|
||||
#include "xml/KeyValues.h"
|
||||
#include "xml/Mixin.h"
|
||||
@@ -42,7 +43,6 @@ namespace Animation::Xml {
|
||||
namespace {
|
||||
|
||||
using SetScriptText_t = bool(__fastcall *)(void *object, void *edx, const char *name, const char *text);
|
||||
using StringToPoint_t = int(__fastcall *)(const char *name, int *point);
|
||||
|
||||
const void *FindChild(const void *node, const char *tag) {
|
||||
for (const void *c = ::Xml::FirstChild(node); c != nullptr; c = ::Xml::NextSibling(c))
|
||||
@@ -158,7 +158,7 @@ void LoadOrigin(Anim *anim, const void *node) {
|
||||
float x = 0.0f, y = 0.0f;
|
||||
const char *pointName = ::Xml::Attr(origin, "point");
|
||||
if (pointName != nullptr &&
|
||||
reinterpret_cast<StringToPoint_t>(Offsets::FUN_STRING_TO_FRAME_POINT)(pointName, &point)) {
|
||||
Frame::Layout::StringToPoint(pointName, &point)) {
|
||||
if (const void *offset = FindChild(origin, "Offset")) {
|
||||
const void *abs = FindChild(offset, "AbsDimension");
|
||||
const void *dim = abs != nullptr ? abs : offset;
|
||||
|
||||
@@ -60,9 +60,6 @@ using IndexAtPoint_t = void(__fastcall *)(void *editBox, void *edx, float x, flo
|
||||
using FontHeight_t = float(__fastcall *)(void *fs, void *edx, int mode);
|
||||
using MeasureRun_t = float(__fastcall *)(void *fs, void *edx, const uint8_t *text, int len);
|
||||
using PixelAlignY_t = float(__stdcall *)(float length);
|
||||
using ClearAllPoints_t = void(__fastcall *)(void *anchor);
|
||||
using SetPoint_t = void(__thiscall *)(void *anchor, int point, void *relAnchor, int relPoint, float x, float y,
|
||||
int flag);
|
||||
using Extent_t = float(__fastcall *)(void *anchor, void *edx);
|
||||
using FireVariadic_t = void(__cdecl *)(void *frame, uint32_t *slotPtr, const char *fmt, ...);
|
||||
|
||||
@@ -176,10 +173,8 @@ bool AnchorX(const Rows &rows, int line, uint32_t pos, float &x, int &relPoint)
|
||||
|
||||
// Anchors `region` as the placer did, at `y`.
|
||||
void Anchor(const Rows &rows, void *region, int relPoint, float x, float y, int flag) {
|
||||
void *anchor = Of(region);
|
||||
reinterpret_cast<ClearAllPoints_t>(Offsets::FUN_LAYOUT_CLEAR_ALL_POINTS)(anchor);
|
||||
reinterpret_cast<SetPoint_t>(Offsets::FUN_REGION_SET_POINT)(anchor, Offsets::FRAMEPOINT_TOPLEFT, Of(rows.fs),
|
||||
relPoint, x, y, flag);
|
||||
Frame::Layout::ClearAllPoints(region);
|
||||
Frame::Layout::SetPoint(region, Offsets::FRAMEPOINT_TOPLEFT, Of(rows.fs), relPoint, x, y, flag != 0);
|
||||
}
|
||||
|
||||
// --- the click ---------------------------------------------------------------
|
||||
|
||||
@@ -542,18 +542,14 @@ CVar::Factory::Handle g_countdownForCooldowns = nullptr;
|
||||
void *CreateCountdown(void *frame) {
|
||||
using SetFont_t = uint32_t(__thiscall *)(void *fs, const char *path, float height,
|
||||
uint32_t flags, uint8_t force);
|
||||
using SetPoint_t = void(__thiscall *)(void *anchor, int point, void *relAnchor, int relPoint,
|
||||
float x, float y, int flag);
|
||||
void *fs = Frame::Region::CreateFontString(frame, Offsets::DRAWLAYER_OVERLAY, 0);
|
||||
if (fs == nullptr)
|
||||
return nullptr;
|
||||
if (reinterpret_cast<SetFont_t>(Offsets::FUN_SIMPLEFONTSTRING_SET_FONT)(
|
||||
fs, "Fonts\\FRIZQT__.TTF", Game::PixelToInternal(16.0f), Offsets::FONT_FLAG_OUTLINE, 0))
|
||||
Game::Ref<uint32_t>(fs, Offsets::OFF_FONTSTRING_FONT_FLAGS) &= ~1u;
|
||||
reinterpret_cast<SetPoint_t>(Offsets::FUN_REGION_SET_POINT)(
|
||||
Game::Ptr<void>(fs, Offsets::OFF_REGION_ANCHOR), Offsets::FRAMEPOINT_CENTER,
|
||||
Game::Ptr<void>(frame, Offsets::OFF_FRAME_LAYOUT_SUBOBJECT), Offsets::FRAMEPOINT_CENTER,
|
||||
0.0f, Game::PixelToInternal(-1.0f), 1);
|
||||
Frame::Layout::SetPoint(fs, Offsets::FRAMEPOINT_CENTER, Frame::Layout::Of(frame),
|
||||
Offsets::FRAMEPOINT_CENTER, 0.0f, Game::PixelToInternal(-1.0f));
|
||||
// Built before the frame is shown, the region starts unshown (live:
|
||||
// IsShown() nil), where a script-created one on a shown frame is drawn.
|
||||
// Shown as the engine's callers show a region: the desired flag, then Show.
|
||||
|
||||
+10
-15
@@ -64,6 +64,7 @@
|
||||
#include "Game.h"
|
||||
#include "Offsets.h"
|
||||
#include "debug/Log.h"
|
||||
#include "frame/Layout.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -75,8 +76,6 @@ namespace {
|
||||
|
||||
using ClearPointByRelative_t = void(__thiscall *)(void *layout, void *relativeTo,
|
||||
int doRelayout);
|
||||
using GetRelative_t = void *(__thiscall *)(void *node);
|
||||
using PointToString_t = const char *(__fastcall *)(int point);
|
||||
|
||||
// SEH-guarded readability probe. Standalone with only raw pointers and no
|
||||
// C++ objects in scope, per the MSVC __try/__except constraint. A fault on
|
||||
@@ -104,8 +103,7 @@ void CleanDanglingAnchors(void *region) {
|
||||
auto *base = static_cast<uint8_t *>(region);
|
||||
auto *top = Game::Read<uint8_t *>(Offsets::VAR_UI_CONTEXT_PTR);
|
||||
for (int i = 0; i < Offsets::REGION_ANCHOR_SLOT_COUNT; ++i) {
|
||||
auto *node = Game::Read<uint8_t *>(
|
||||
base, Offsets::OFF_REGION_ANCHOR_ARRAY + i * 4);
|
||||
auto *node = static_cast<uint8_t *>(Frame::Layout::PointNode(region, i));
|
||||
if (node == nullptr)
|
||||
continue;
|
||||
// Only relativeTo-carrying nodes can dangle; the rel-less node type
|
||||
@@ -140,16 +138,14 @@ void CleanDanglingAnchors(void *region) {
|
||||
}
|
||||
|
||||
int PushPoint(void *L, void *region, int point) {
|
||||
auto *node = Game::Read<uint8_t *>(region, Offsets::OFF_REGION_ANCHOR_ARRAY + point * 4);
|
||||
if (node == nullptr)
|
||||
Frame::Layout::Point p;
|
||||
if (!Frame::Layout::GetPoint(region, point, &p))
|
||||
return 0;
|
||||
|
||||
auto pointName = reinterpret_cast<PointToString_t>(Offsets::FUN_FRAME_POINT_TO_STRING);
|
||||
auto *vtable = Game::Read<uintptr_t *>(node, 0);
|
||||
auto *relative = static_cast<uint8_t *>(reinterpret_cast<GetRelative_t>(
|
||||
vtable[Offsets::VTBL_ANCHOR_NODE_GET_RELATIVE / sizeof(uintptr_t)])(node));
|
||||
const double x = Game::InternalToPixel(Game::Read<float>(node, Offsets::OFF_ANCHOR_NODE_X));
|
||||
const double y = Game::InternalToPixel(Game::Read<float>(node, Offsets::OFF_ANCHOR_NODE_Y));
|
||||
const auto pointName = &Frame::Layout::PointToString;
|
||||
auto *relative = static_cast<uint8_t *>(p.relativeLayout);
|
||||
const double x = Game::InternalToPixel(p.x);
|
||||
const double y = Game::InternalToPixel(p.y);
|
||||
|
||||
Game::Lua::PushString(L, pointName(point));
|
||||
if (relative == nullptr) {
|
||||
@@ -161,8 +157,7 @@ int PushPoint(void *L, void *region, int point) {
|
||||
Game::Lua::PushNil(L); // anchored to the screen
|
||||
else
|
||||
Game::Lua::PushObject(L, relative - Offsets::OFF_REGION_ANCHOR);
|
||||
Game::Lua::PushString(
|
||||
L, pointName(Game::Read<int>(node, Offsets::OFF_ANCHOR_NODE_RELATIVE_POINT)));
|
||||
Game::Lua::PushString(L, pointName(p.relPoint));
|
||||
Game::Lua::PushNumber(L, x);
|
||||
Game::Lua::PushNumber(L, y);
|
||||
return 5;
|
||||
@@ -183,7 +178,7 @@ int __fastcall GetPoint_h(void *L) {
|
||||
|
||||
// The index-th set slot, in point order (TOPLEFT .. BOTTOMRIGHT).
|
||||
for (int point = 0, found = 0; point < Offsets::REGION_ANCHOR_SLOT_COUNT; ++point) {
|
||||
if (Game::Read<uint8_t *>(region, Offsets::OFF_REGION_ANCHOR_ARRAY + point * 4) == nullptr)
|
||||
if (Frame::Layout::PointNode(region, point) == nullptr)
|
||||
continue;
|
||||
if (found >= index)
|
||||
return PushPoint(L, region, point);
|
||||
|
||||
@@ -79,4 +79,74 @@ inline bool GetResolvedRect(void *object, float (&rect)[4]) {
|
||||
return GetRect(object, rect);
|
||||
}
|
||||
|
||||
// The anchor node in `point`'s slot (FRAMEPOINT_*), or nullptr when the slot
|
||||
// is unset.
|
||||
inline void *PointNode(const void *object, int point) {
|
||||
return *reinterpret_cast<void *const *>(static_cast<const uint8_t *>(object) +
|
||||
Offsets::OFF_REGION_ANCHOR_ARRAY +
|
||||
point * static_cast<int>(sizeof(void *)));
|
||||
}
|
||||
|
||||
// One anchor, as the engine's GetPoint reads it. `relativeLayout` comes from
|
||||
// the node's own getter (vtable +0x0C): a layout sub-object, the screen's
|
||||
// (VAR_UI_CONTEXT_PTR) for a point on the screen, or null for the node type
|
||||
// with no relative. `relPoint` is set only with a relative: that 12-byte
|
||||
// node {vtable, x, y} has no field for it. Offsets are in layout units.
|
||||
struct Point {
|
||||
void *relativeLayout;
|
||||
int relPoint;
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
|
||||
// Reads `point`'s anchor. False when the slot is unset.
|
||||
inline bool GetPoint(const void *object, int point, Point *out) {
|
||||
using GetRelative_t = void *(__thiscall *)(void *node);
|
||||
auto *node = static_cast<uint8_t *>(PointNode(object, point));
|
||||
if (node == nullptr)
|
||||
return false;
|
||||
const auto *vtable = *reinterpret_cast<const uintptr_t *const *>(node);
|
||||
out->relativeLayout = reinterpret_cast<GetRelative_t>(
|
||||
vtable[Offsets::VTBL_ANCHOR_NODE_GET_RELATIVE / sizeof(uintptr_t)])(node);
|
||||
out->relPoint = out->relativeLayout != nullptr
|
||||
? *reinterpret_cast<const int *>(node + Offsets::OFF_ANCHOR_NODE_RELATIVE_POINT)
|
||||
: 0;
|
||||
out->x = *reinterpret_cast<const float *>(node + Offsets::OFF_ANCHOR_NODE_X);
|
||||
out->y = *reinterpret_cast<const float *>(node + Offsets::OFF_ANCHOR_NODE_Y);
|
||||
return true;
|
||||
}
|
||||
|
||||
// CLayoutFrame::SetPoint (FUN_REGION_SET_POINT): `point` of `object` to
|
||||
// `relPoint` of `relativeLayout`, offsets in layout units. The relative is a
|
||||
// layout sub-object, as the engine stores it: `Of(relative)`, or one an
|
||||
// anchor node or the XML loader already holds. The engine refuses a null
|
||||
// relative or the object itself (error 0x57), and `resize` lays the object
|
||||
// out at once (benilla-re ui/anchors).
|
||||
inline void SetPoint(void *object, int point, void *relativeLayout, int relPoint, float x,
|
||||
float y, bool resize = true) {
|
||||
using Fn = void(__thiscall *)(void *, int, void *, int, float, float, int);
|
||||
reinterpret_cast<Fn>(Offsets::FUN_REGION_SET_POINT)(Of(object), point, relativeLayout,
|
||||
relPoint, x, y, resize ? 1 : 0);
|
||||
}
|
||||
|
||||
// CLayoutFrame::ClearAllPoints (FUN_LAYOUT_CLEAR_ALL_POINTS): frees all nine
|
||||
// anchor slots and unlinks the object from each relative.
|
||||
inline void ClearAllPoints(void *object) {
|
||||
using Fn = void(__fastcall *)(void *);
|
||||
reinterpret_cast<Fn>(Offsets::FUN_LAYOUT_CLEAR_ALL_POINTS)(Of(object));
|
||||
}
|
||||
|
||||
// The engine's point names (FUN_STRING_TO_FRAME_POINT): "TOPLEFT" and the
|
||||
// rest to FRAMEPOINT_*. False for a string that names no point.
|
||||
inline bool StringToPoint(const char *name, int *point) {
|
||||
using Fn = int(__fastcall *)(const char *, int *);
|
||||
return reinterpret_cast<Fn>(Offsets::FUN_STRING_TO_FRAME_POINT)(name, point) != 0;
|
||||
}
|
||||
|
||||
// FUN_FRAME_POINT_TO_STRING: a FRAMEPOINT_* value's name.
|
||||
inline const char *PointToString(int point) {
|
||||
using Fn = const char *(__fastcall *)(int);
|
||||
return reinterpret_cast<Fn>(Offsets::FUN_FRAME_POINT_TO_STRING)(point);
|
||||
}
|
||||
|
||||
} // namespace Frame::Layout
|
||||
|
||||
+9
-22
@@ -52,19 +52,14 @@ namespace Frame::Points {
|
||||
|
||||
namespace {
|
||||
|
||||
using StringToPoint_t = int(__fastcall *)(const char *name, int *point);
|
||||
using RemoveDependent_t = void(__fastcall *)(void *relative, void *edx, void *layout, int mask);
|
||||
using GetRelative_t = void *(__thiscall *)(void *node);
|
||||
using DeleteNode_t = void(__thiscall *)(void *node, int flags);
|
||||
using SetPoint_t = void(__thiscall *)(void *anchor, int point, void *relAnchor, int relPoint,
|
||||
float x, float y, int flag);
|
||||
|
||||
// The point named by argument 2, or -1 after raising the usage error.
|
||||
int PointArg(void *L, void *region, const char *usage) {
|
||||
int point = 0;
|
||||
if (!Game::Lua::IsString(L, 2) ||
|
||||
!reinterpret_cast<StringToPoint_t>(Offsets::FUN_STRING_TO_FRAME_POINT)(
|
||||
Game::Lua::ToString(L, 2), &point)) {
|
||||
!Frame::Layout::StringToPoint(Game::Lua::ToString(L, 2), &point)) {
|
||||
Game::Lua::Error(L, usage, Game::Lua::ObjectDisplayName(region));
|
||||
return -1;
|
||||
}
|
||||
@@ -93,16 +88,15 @@ int __fastcall Script_ClearPoint(void *L) {
|
||||
auto **slot = reinterpret_cast<uint8_t **>(static_cast<uint8_t *>(region) +
|
||||
Offsets::OFF_REGION_ANCHOR_ARRAY + point * 4);
|
||||
uint8_t *node = *slot;
|
||||
if (node == nullptr)
|
||||
Frame::Layout::Point p;
|
||||
if (!Frame::Layout::GetPoint(region, point, &p))
|
||||
return 0;
|
||||
auto *vtable = Game::Read<uintptr_t *>(node, 0);
|
||||
void *relative = reinterpret_cast<GetRelative_t>(
|
||||
vtable[Offsets::VTBL_ANCHOR_NODE_GET_RELATIVE / sizeof(uintptr_t)])(node);
|
||||
void *relative = p.relativeLayout;
|
||||
if (relative != nullptr)
|
||||
reinterpret_cast<RemoveDependent_t>(Offsets::FUN_LAYOUT_REMOVE_DEPENDENT)(
|
||||
relative, nullptr, static_cast<uint8_t *>(region) + Offsets::OFF_REGION_ANCHOR,
|
||||
1 << point);
|
||||
reinterpret_cast<DeleteNode_t>(vtable[0])(node, 1);
|
||||
reinterpret_cast<DeleteNode_t>(Game::Read<uintptr_t *>(node, 0)[0])(node, 1);
|
||||
*slot = nullptr;
|
||||
return 0;
|
||||
}
|
||||
@@ -112,18 +106,11 @@ int __fastcall Script_ClearPoint(void *L) {
|
||||
void ShiftPoints(void *region, float dx, float dy, bool zero) {
|
||||
Frame::GetPointGuard::CleanDanglingAnchors(region);
|
||||
for (int point = 0; point < Offsets::REGION_ANCHOR_SLOT_COUNT; ++point) {
|
||||
uint8_t *node = Game::Read<uint8_t *>(region, Offsets::OFF_REGION_ANCHOR_ARRAY + point * 4);
|
||||
if (node == nullptr)
|
||||
Frame::Layout::Point p;
|
||||
if (!Frame::Layout::GetPoint(region, point, &p))
|
||||
continue;
|
||||
auto *vtable = Game::Read<uintptr_t *>(node, 0);
|
||||
void *relative = reinterpret_cast<GetRelative_t>(
|
||||
vtable[Offsets::VTBL_ANCHOR_NODE_GET_RELATIVE / sizeof(uintptr_t)])(node);
|
||||
const int relativePoint = Game::Read<int>(node, Offsets::OFF_ANCHOR_NODE_RELATIVE_POINT);
|
||||
const float x = zero ? 0.0f : Game::Read<float>(node, Offsets::OFF_ANCHOR_NODE_X) + dx;
|
||||
const float y = zero ? 0.0f : Game::Read<float>(node, Offsets::OFF_ANCHOR_NODE_Y) + dy;
|
||||
reinterpret_cast<SetPoint_t>(Offsets::FUN_REGION_SET_POINT)(
|
||||
static_cast<uint8_t *>(region) + Offsets::OFF_REGION_ANCHOR, point, relative,
|
||||
relativePoint, x, y, 1);
|
||||
Frame::Layout::SetPoint(region, point, p.relativeLayout, p.relPoint,
|
||||
zero ? 0.0f : p.x + dx, zero ? 0.0f : p.y + dy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,9 +53,6 @@ namespace {
|
||||
constexpr int kInsertModeTop = 1;
|
||||
constexpr int kInsertModeBottom = 2;
|
||||
|
||||
using SetPoint_t = void(__thiscall *)(void *anchor, int point, void *relAnchor, int relPoint, float x, float y,
|
||||
int flag);
|
||||
using ClearAllPoints_t = void(__fastcall *)(void *anchor);
|
||||
using PixelAlignY_t = float(__stdcall *)(float length);
|
||||
|
||||
// The frames in TOP mode. Every frame is rebuilt on /reload, so the set is
|
||||
@@ -81,7 +78,7 @@ void SetLinePoint(void *smf, void *anchor, int point, void *relative, int relati
|
||||
y = -y;
|
||||
}
|
||||
}
|
||||
reinterpret_cast<SetPoint_t>(Offsets::FUN_REGION_SET_POINT)(anchor, point, relative, relativePoint, x, y, flag);
|
||||
Frame::Layout::SetPoint(Frame::Layout::OwnerOf(anchor), point, relative, relativePoint, x, y, flag != 0);
|
||||
}
|
||||
|
||||
// The layout's SetPoint for a line it has just made; the line's parent is
|
||||
@@ -186,7 +183,7 @@ const Frame::Destruction::AutoSubscribe _destructionSub{&OnFrameDestroyed};
|
||||
void AnchorLine(void *smf, int index) {
|
||||
void *line = LineOf(smf, index);
|
||||
void *anchor = Of(line);
|
||||
reinterpret_cast<ClearAllPoints_t>(Offsets::FUN_LAYOUT_CLEAR_ALL_POINTS)(anchor);
|
||||
Frame::Layout::ClearAllPoints(line);
|
||||
if (index == 0)
|
||||
SetLinePoint(smf, anchor, Offsets::FRAMEPOINT_BOTTOMLEFT, Of(smf), Offsets::FRAMEPOINT_BOTTOMLEFT,
|
||||
Game::Read<float>(smf, Offsets::OFF_SCROLLINGMESSAGEFRAME_INSET_LEFT),
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include "Offsets.h"
|
||||
#include "baselib/Ascii.h"
|
||||
#include "frame/Destruction.h"
|
||||
#include "frame/Layout.h"
|
||||
#include "statusbar/Display.h"
|
||||
#include "texture/Wrap.h"
|
||||
#include "xml/FrameLoad.h"
|
||||
@@ -97,8 +98,6 @@ struct State {
|
||||
std::unordered_map<const void *, State> g_state;
|
||||
|
||||
using Update_t = void(__fastcall *)(void *bar, void *edx, float elapsed);
|
||||
using SetPoint_t = void(__thiscall *)(void *anchor, int point, void *relative, int relativePoint, float x,
|
||||
float y, int doResize);
|
||||
using SetTexCoordRect_t = void(__thiscall *)(void *texture, const float *rect);
|
||||
using SetTexCoordCorners_t = void(__thiscall *)(void *texture, const float *corners);
|
||||
using GetFillFraction_t = float(__fastcall *)(void *bar, void *edx);
|
||||
@@ -134,9 +133,7 @@ float FillFraction(void *bar, int fillStyle) {
|
||||
void Uncrop(void *texture) { Game::Ref<int>(texture, Offsets::OFF_REGION_TEXCOORD_MODIFIES_RECT) = 0; }
|
||||
|
||||
void SetPoint(void *texture, int point, void *bar, float x, float y) {
|
||||
reinterpret_cast<SetPoint_t>(Offsets::FUN_REGION_SET_POINT)(
|
||||
Game::Ptr<uint8_t>(texture, Offsets::OFF_REGION_ANCHOR), point,
|
||||
Game::Ptr<uint8_t>(bar, Offsets::OFF_REGION_ANCHOR), point, x, y, 1);
|
||||
Frame::Layout::SetPoint(texture, point, Frame::Layout::Of(bar), point, x, y);
|
||||
}
|
||||
|
||||
// The image's full coordinates, as 4.3.4's SetRotatesTexture sets them.
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include "Offsets.h"
|
||||
#include "cursor/Hover.h"
|
||||
#include "cvar/Factory.h"
|
||||
#include "frame/Layout.h"
|
||||
#include "frame/Region.h"
|
||||
#include "object/Resolve.h"
|
||||
#include "target/SoftInteract.h"
|
||||
@@ -66,8 +67,6 @@ namespace {
|
||||
|
||||
using SetTexture_t = uint32_t(__thiscall *)(void *tex, const char *path, int a, uint32_t blend,
|
||||
int b);
|
||||
using SetPoint_t = void(__thiscall *)(void *anchor, int point, void *relAnchor, int relPoint,
|
||||
float x, float y, int flag);
|
||||
using SetSize_t = void(__thiscall *)(void *anchor, float internal);
|
||||
using ShowHide_t = void(__fastcall *)(void *tex);
|
||||
using PlateScreenPos_t = bool(__fastcall *)(void *unit, void *worldFrame, float *screen);
|
||||
@@ -151,9 +150,8 @@ void Show(Icon &icon, uint64_t guid, void *worldFrame) {
|
||||
reinterpret_cast<SetSize_t>(Offsets::FUN_LAYOUT_SET_HEIGHT)(Anchor(icon.tex), size);
|
||||
icon.shownSize = size;
|
||||
}
|
||||
reinterpret_cast<SetPoint_t>(Offsets::FUN_REGION_SET_POINT)(
|
||||
Anchor(icon.tex), Offsets::FRAMEPOINT_BOTTOM, Anchor(worldFrame),
|
||||
Offsets::FRAMEPOINT_BOTTOMLEFT, screen[0], screen[1], 1);
|
||||
Frame::Layout::SetPoint(icon.tex, Offsets::FRAMEPOINT_BOTTOM, Anchor(worldFrame),
|
||||
Offsets::FRAMEPOINT_BOTTOMLEFT, screen[0], screen[1]);
|
||||
SetShown(icon, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// fontstring itself (Emit_h below), so the texture is resident by
|
||||
// construction, moves with its line and shows exactly when its line does.
|
||||
|
||||
#include "frame/Layout.h"
|
||||
#include "text/InlineTexturePool.h"
|
||||
|
||||
#include "Game.h"
|
||||
@@ -40,8 +41,6 @@ namespace {
|
||||
using SetTexture_t = uint32_t(__thiscall *)(void *tex, const char *path, int a, uint32_t blend,
|
||||
int b);
|
||||
using SetColor_t = void(__thiscall *)(void *tex, const void *colorBGRA);
|
||||
using SetPoint_t = void(__thiscall *)(void *anchor, int point, void *relAnchor, int relPoint,
|
||||
float x, float y, int flag);
|
||||
using Realize_t = void(__thiscall *)(void *anchor, int flag);
|
||||
using SetTexCoord_t = void(__thiscall *)(void *tex, const float *coords4);
|
||||
using DeletingDestructor_t = void(__thiscall *)(void *region, int flags);
|
||||
@@ -196,14 +195,12 @@ void ApplyPlacement(IconRegion &r, void *fs, const Placement &p, uint32_t fsColo
|
||||
// has no frame, so nothing changes the ctor's scale of 1 (CLayoutFrame
|
||||
// 0x00767680) and the offsets land exactly as given, as 4.3.4's
|
||||
// CSimpleEmbeddedTexture's do.
|
||||
auto setPoint = reinterpret_cast<SetPoint_t>(Offsets::FUN_REGION_SET_POINT);
|
||||
void *texAnchor = reinterpret_cast<uint8_t *>(r.tex) + Offsets::OFF_REGION_ANCHOR;
|
||||
void *fsAnchor = f + Offsets::OFF_REGION_ANCHOR;
|
||||
setPoint(texAnchor, Offsets::FRAMEPOINT_BOTTOMLEFT, fsAnchor, Offsets::FRAMEPOINT_BOTTOMLEFT,
|
||||
p.x0, p.y0, 1);
|
||||
setPoint(texAnchor, Offsets::FRAMEPOINT_TOPRIGHT, fsAnchor, Offsets::FRAMEPOINT_BOTTOMLEFT,
|
||||
p.x1, p.y1, 1);
|
||||
reinterpret_cast<Realize_t>(Offsets::FUN_REGION_LAYOUT_REALIZE)(texAnchor, 0);
|
||||
void *fsAnchor = Frame::Layout::Of(f);
|
||||
Frame::Layout::SetPoint(r.tex, Offsets::FRAMEPOINT_BOTTOMLEFT, fsAnchor,
|
||||
Offsets::FRAMEPOINT_BOTTOMLEFT, p.x0, p.y0);
|
||||
Frame::Layout::SetPoint(r.tex, Offsets::FRAMEPOINT_TOPRIGHT, fsAnchor,
|
||||
Offsets::FRAMEPOINT_BOTTOMLEFT, p.x1, p.y1);
|
||||
reinterpret_cast<Realize_t>(Offsets::FUN_REGION_LAYOUT_REALIZE)(Frame::Layout::Of(r.tex), 0);
|
||||
}
|
||||
|
||||
// Applies `want` to the fontstring's textures: create and configure each. The
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
|
||||
#include "Game.h"
|
||||
#include "Offsets.h"
|
||||
#include "frame/Layout.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -51,8 +52,6 @@ namespace {
|
||||
using Clear_t = void(__fastcall *)(void *self);
|
||||
Clear_t g_clearOriginal = nullptr;
|
||||
|
||||
using SetPoint_t = void(__thiscall *)(void *anchor, int point, void *relAnchor, int relPoint,
|
||||
float x, float y, int flag);
|
||||
|
||||
constexpr uint32_t kMaxTextures = 3;
|
||||
|
||||
@@ -66,9 +65,8 @@ void RestoreLineBelow(uint8_t *tooltip, uint32_t line) {
|
||||
if (left == nullptr || left[line] == nullptr || left[line + 1] == nullptr)
|
||||
return;
|
||||
const float gap = Game::PixelToInternal(Game::Read<float>(Offsets::VAR_TOOLTIP_LINE_GAP));
|
||||
reinterpret_cast<SetPoint_t>(Offsets::FUN_REGION_SET_POINT)(
|
||||
left[line + 1] + Offsets::OFF_REGION_ANCHOR, Offsets::FRAMEPOINT_TOPLEFT,
|
||||
left[line] + Offsets::OFF_REGION_ANCHOR, Offsets::FRAMEPOINT_BOTTOMLEFT, 0.0f, gap, 1);
|
||||
Frame::Layout::SetPoint(left[line + 1], Offsets::FRAMEPOINT_TOPLEFT,
|
||||
Frame::Layout::Of(left[line]), Offsets::FRAMEPOINT_BOTTOMLEFT, 0.0f, gap);
|
||||
}
|
||||
|
||||
// True when the texture routine has re-anchored `line` since the clear: a
|
||||
|
||||
@@ -83,8 +83,6 @@ namespace {
|
||||
|
||||
using GetName_t = const char *(__thiscall *)(void *object);
|
||||
using StrataToString_t = const char *(__fastcall *)(int strata);
|
||||
using PointToString_t = const char *(__fastcall *)(int point);
|
||||
using GetRelative_t = void *(__thiscall *)(void *node);
|
||||
|
||||
// 4.3.4's line colors, packed {b,g,r,a} like every add-line color; two of each
|
||||
// so neighbouring frame levels alternate (s_frameStack*Colors). Regions take
|
||||
@@ -186,20 +184,18 @@ void AddRegions(void *L, const Entry &frame, float x, float y, bool showHidden,
|
||||
void AddDetails(void *L, void *self, void *object, const uint32_t &color,
|
||||
const uint32_t &headerColor) {
|
||||
Frame::GetPointGuard::CleanDanglingAnchors(object);
|
||||
auto pointName = reinterpret_cast<PointToString_t>(Offsets::FUN_FRAME_POINT_TO_STRING);
|
||||
const auto pointName = &Frame::Layout::PointToString;
|
||||
char text[1024];
|
||||
int n = 0;
|
||||
for (int slot = 0; slot < Offsets::REGION_ANCHOR_SLOT_COUNT; ++slot) {
|
||||
auto *node = Game::Read<uint8_t *>(object, Offsets::OFF_REGION_ANCHOR_ARRAY + slot * 4);
|
||||
if (node == nullptr)
|
||||
Frame::Layout::Point p;
|
||||
if (!Frame::Layout::GetPoint(object, slot, &p))
|
||||
continue;
|
||||
if (n++ == 0)
|
||||
Lines::Add(self, "ANCHORS", headerColor);
|
||||
auto *vtable = Game::Read<uintptr_t *>(node, 0);
|
||||
auto *relative = static_cast<uint8_t *>(reinterpret_cast<GetRelative_t>(
|
||||
vtable[Offsets::VTBL_ANCHOR_NODE_GET_RELATIVE / sizeof(uintptr_t)])(node));
|
||||
const double x = Game::InternalToPixel(Game::Read<float>(node, Offsets::OFF_ANCHOR_NODE_X));
|
||||
const double y = Game::InternalToPixel(Game::Read<float>(node, Offsets::OFF_ANCHOR_NODE_Y));
|
||||
auto *relative = static_cast<uint8_t *>(p.relativeLayout);
|
||||
const double x = Game::InternalToPixel(p.x);
|
||||
const double y = Game::InternalToPixel(p.y);
|
||||
// A screen anchor's target is the top itself, a bare CLayoutFrame with
|
||||
// no region in front of it (Offsets VAR_UI_CONTEXT_PTR): no name to
|
||||
// show, and `relative - OFF_REGION_ANCHOR` must not be formed.
|
||||
@@ -210,7 +206,7 @@ void AddDetails(void *L, void *self, void *object, const uint32_t &color,
|
||||
FormatName(L, relative - Offsets::OFF_REGION_ANCHOR, relativeName, sizeof(relativeName));
|
||||
std::snprintf(text, sizeof(text), " <%d> %s %s %s %.2f %.2f", n, pointName(slot),
|
||||
relativeName,
|
||||
pointName(Game::Read<int>(node, Offsets::OFF_ANCHOR_NODE_RELATIVE_POINT)),
|
||||
pointName(p.relPoint),
|
||||
x, y);
|
||||
} else {
|
||||
std::snprintf(text, sizeof(text), " <%d> %s %.2f %.2f", n, pointName(slot), x, y);
|
||||
|
||||
+6
-10
@@ -60,6 +60,7 @@
|
||||
|
||||
#include "Game.h"
|
||||
#include "Offsets.h"
|
||||
#include "frame/Layout.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
@@ -69,9 +70,6 @@ namespace Tooltip::Layout {
|
||||
namespace {
|
||||
|
||||
using ResetPosition_t = void(__fastcall *)(void *tooltip, void *edx, int force);
|
||||
using ClearAllPoints_t = void(__fastcall *)(void *layout);
|
||||
using SetPoint_t = void(__thiscall *)(void *anchor, int point, void *relAnchor, int relPoint,
|
||||
float x, float y, int flag);
|
||||
using Script_t = int(__fastcall *)(void *L);
|
||||
|
||||
ResetPosition_t g_resetPositionOriginal = nullptr;
|
||||
@@ -122,15 +120,13 @@ void __fastcall ResetPosition_h(void *self, void *edx, int force) {
|
||||
return;
|
||||
}
|
||||
|
||||
void *layout = tooltip + Offsets::OFF_FRAME_LAYOUT_SUBOBJECT;
|
||||
reinterpret_cast<ClearAllPoints_t>(Offsets::FUN_LAYOUT_CLEAR_ALL_POINTS)(layout);
|
||||
Frame::Layout::ClearAllPoints(tooltip);
|
||||
|
||||
const bool top = type == Offsets::TOOLTIP_ANCHOR_TOP;
|
||||
reinterpret_cast<SetPoint_t>(Offsets::FUN_REGION_SET_POINT)(
|
||||
layout, top ? Offsets::FRAMEPOINT_BOTTOM : Offsets::FRAMEPOINT_TOP, owner,
|
||||
top ? Offsets::FRAMEPOINT_TOP : Offsets::FRAMEPOINT_BOTTOM,
|
||||
Game::Read<float>(tooltip, Offsets::OFF_TOOLTIP_OFFSET_X),
|
||||
Game::Read<float>(tooltip, Offsets::OFF_TOOLTIP_OFFSET_Y), 1);
|
||||
Frame::Layout::SetPoint(tooltip, top ? Offsets::FRAMEPOINT_BOTTOM : Offsets::FRAMEPOINT_TOP,
|
||||
owner, top ? Offsets::FRAMEPOINT_TOP : Offsets::FRAMEPOINT_BOTTOM,
|
||||
Game::Read<float>(tooltip, Offsets::OFF_TOOLTIP_OFFSET_X),
|
||||
Game::Read<float>(tooltip, Offsets::OFF_TOOLTIP_OFFSET_Y));
|
||||
}
|
||||
|
||||
const Game::HookAutoRegister _resetPositionHook{
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "Game.h"
|
||||
#include "Offsets.h"
|
||||
#include "frame/Layout.h"
|
||||
#include "frame/Region.h"
|
||||
|
||||
#include <cstdint>
|
||||
@@ -49,8 +50,6 @@ namespace {
|
||||
using GetName_t = const char *(__thiscall *)(void *self);
|
||||
using SetName_t = void(__thiscall *)(void *region, const char *name);
|
||||
using SetFont_t = void(__thiscall *)(void *fontHolder, void *fontObject);
|
||||
using SetPoint_t = void(__thiscall *)(void *anchor, int point, void *relAnchor, int relPoint,
|
||||
float x, float y, int flag);
|
||||
using HideFontString_t = void(__fastcall *)(void *fs);
|
||||
using AddFontStrings_t = void(__thiscall *)(void *tooltip, void *left, void *right);
|
||||
|
||||
@@ -88,10 +87,8 @@ void *CreateLine(void *parent, const char *name, void *fontSource, int point,
|
||||
reinterpret_cast<SetFont_t>(Offsets::FUN_FONTSTRING_SET_FONT)(
|
||||
fsBytes + Offsets::OFF_FONTSTRING_FONT_HOLDER, fontObject);
|
||||
|
||||
reinterpret_cast<SetPoint_t>(Offsets::FUN_REGION_SET_POINT)(
|
||||
fsBytes + Offsets::OFF_REGION_ANCHOR, point,
|
||||
reinterpret_cast<uint8_t *>(relRegion) + Offsets::OFF_REGION_ANCHOR, relPoint,
|
||||
Game::PixelToInternal(x), Game::PixelToInternal(y), 1);
|
||||
Frame::Layout::SetPoint(fsBytes, point, Frame::Layout::Of(relRegion), relPoint,
|
||||
Game::PixelToInternal(x), Game::PixelToInternal(y));
|
||||
|
||||
// The clear only hides lines below `numLines`, so a spare line has to
|
||||
// start hidden — the same `+0xC4 = 0` + hide the clear does.
|
||||
|
||||
+5
-14
@@ -37,6 +37,7 @@
|
||||
// a frame's children are built (RetryUnder, before its OnLoad) and once more
|
||||
// when the outermost frame build returns (Flush), which reports what is left.
|
||||
|
||||
#include "frame/Layout.h"
|
||||
#include "xml/Anchors.h"
|
||||
|
||||
#include "Game.h"
|
||||
@@ -51,11 +52,7 @@ namespace Xml::Anchors {
|
||||
|
||||
namespace {
|
||||
|
||||
using StringToPoint_t = int(__fastcall *)(const char *name, int *point);
|
||||
using ReadDimension_t = int(__fastcall *)(const void *node, float *x, float *y, void *status);
|
||||
using GetRelative_t = void *(__thiscall *)(void *anchorNode);
|
||||
using SetPoint_t = void(__thiscall *)(void *anchor, int point, void *relAnchor, int relPoint,
|
||||
float x, float y, int flag);
|
||||
|
||||
bool HasValue(const char *s) { return s != nullptr && *s != '\0'; }
|
||||
|
||||
@@ -115,12 +112,8 @@ namespace {
|
||||
// LayoutFrame inner, the setter's relAnchor), or nullptr when the point is
|
||||
// unset or has no target.
|
||||
void *EngineTarget(void *object, int point) {
|
||||
void *anchorNode = Game::Read<void *>(
|
||||
object, Offsets::OFF_REGION_ANCHOR_ARRAY + point * static_cast<int>(sizeof(void *)));
|
||||
if (anchorNode == nullptr)
|
||||
return nullptr;
|
||||
const void *vtable = Game::Read<const void *>(anchorNode, 0);
|
||||
return Game::Read<GetRelative_t>(vtable, Offsets::VTBL_ANCHOR_NODE_GET_RELATIVE)(anchorNode);
|
||||
Frame::Layout::Point p;
|
||||
return Frame::Layout::GetPoint(object, point, &p) ? p.relativeLayout : nullptr;
|
||||
}
|
||||
|
||||
// Sets one anchor. False only when its relativeKey does not resolve (yet).
|
||||
@@ -132,7 +125,7 @@ bool ApplyAnchor(void *object, const void *anchor, void *status) {
|
||||
if (!HasValue(relativeKey) && !inlineOffset)
|
||||
return true;
|
||||
|
||||
auto toPoint = reinterpret_cast<StringToPoint_t>(Offsets::FUN_STRING_TO_FRAME_POINT);
|
||||
const auto toPoint = &Frame::Layout::StringToPoint;
|
||||
int point = 0;
|
||||
const char *pointName = Xml::Attr(anchor, "point");
|
||||
if (!HasValue(pointName) || !toPoint(pointName, &point))
|
||||
@@ -159,9 +152,7 @@ bool ApplyAnchor(void *object, const void *anchor, void *status) {
|
||||
if (dimension != nullptr)
|
||||
reinterpret_cast<ReadDimension_t>(Offsets::FUN_XML_READ_DIMENSION)(dimension, &x, &y, status);
|
||||
|
||||
reinterpret_cast<SetPoint_t>(Offsets::FUN_REGION_SET_POINT)(
|
||||
Game::Ptr<void>(object, Offsets::OFF_REGION_ANCHOR), point, relAnchor, relativePoint, x,
|
||||
y, 1);
|
||||
Frame::Layout::SetPoint(object, point, relAnchor, relativePoint, x, y);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user