#pragma once #include namespace dnf90_combat_panel { // Current EXE sub_10DC420 transforms a point around the live UI pivot. using NativeTransformPoint = void (__thiscall*)(void*, float*, float*, float, float); struct Position { int x; int y; }; inline bool PositionSidecar( int nativeX, int nativeY, int nativeWidth, int nativeHeight, int viewportWidth, int viewportHeight, int clientWidth, int clientHeight, int sidecarWidth, int sidecarHeight, int frameRight, int frameTop, void* transformOwner, NativeTransformPoint transform, Position* result) { if (!result || !transformOwner || !transform || viewportWidth < 320 || viewportWidth > 16384 || viewportHeight < 200 || viewportHeight > 16384 || clientWidth < 8 || clientWidth > 16384 || clientHeight < 8 || clientHeight > 16384 || nativeX < -64 || nativeY < -64 || nativeX > viewportWidth || nativeY > viewportHeight || nativeWidth < 160 || nativeWidth > 640 || nativeHeight < 200 || nativeHeight > 760 || sidecarWidth <= 0 || sidecarHeight <= 0) { return false; } float right = static_cast(nativeX + nativeWidth + frameRight); float top = static_cast(nativeY - frameTop); float left = static_cast(nativeX); float unusedY = static_cast(nativeY); transform(transformOwner, &right, &top, 0.0f, 0.0f); transform(transformOwner, &left, &unusedY, 0.0f, 0.0f); // Comparisons also reject NaN, before any float-to-int conversion. if (!(right >= -65536.0f && right <= 65536.0f && top >= -65536.0f && top <= 65536.0f && left >= -65536.0f && left <= 65536.0f)) { return false; } int x = static_cast(right * clientWidth / viewportWidth); int y = static_cast(top * clientHeight / viewportHeight); if (x + sidecarWidth > clientWidth - 4) { x = static_cast(left * clientWidth / viewportWidth) - sidecarWidth; } if (x + sidecarWidth > clientWidth - 4) x = clientWidth - sidecarWidth - 4; if (x < 4) x = 4; if (y + sidecarHeight > clientHeight - 4) y = clientHeight - sidecarHeight - 4; if (y < 4) y = 4; result->x = x; result->y = y; return true; } }