From 87dd5e2f37bcff6d62e1212c3ad2e79e5a27bcf9 Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Sat, 7 Mar 2026 16:54:49 +0100 Subject: [PATCH] Add widget position and transform offset functions. --- libs/UEngine/UETools.hpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/libs/UEngine/UETools.hpp b/libs/UEngine/UETools.hpp index a952d00..d5a268f 100644 --- a/libs/UEngine/UETools.hpp +++ b/libs/UEngine/UETools.hpp @@ -32,6 +32,14 @@ struct WidgetTrackInfo { }; static std::unordered_map g_WidgetTracker; +/** + * @brief Gets the current game resolution (not native display) and aspect ratio. + * @param outWidth screen width. + * @param outHeight screen height. + * @param outAspectRatio aspect ratio computed. + */ +void GetResolution(int& outWidth, int& outHeight, float& outAspectRatio); + // Unreal Engine functions /** * @brief Gets the current player Pawn from the world. @@ -46,7 +54,15 @@ SDK::APawn* GetPawnFromWorld(SDK::UWorld* world = nullptr); */ void ReactivateDevConsole(std::shared_ptr logger); -void ApplyOffsetsSmart(SDK::UWidget* Widget, float Left, float Right, int MaxDepth); +/** + * @brief Reposition from left a widget that only displays at left and nothing at right + * @param Widget UUserWdget to offset. + * @param offset left offset to apply. + * @param Alignment widget aligment (0.5, 0.5) is centered for eg. + */ +void ApplyPositionOffset(SDK::UUserWidget* Widget, float offset, SDK::FVector2D Alignment); + +float ApplyOffsetsSmart(SDK::UWidget* Widget, float Left, float Right, int MaxDepth); /** * @brief Apply offsets recursively to UVCanvasPanelSlot. @@ -71,6 +87,14 @@ void ApplyOffsetsRecursive(SDK::UWidget* widget, float left, float right = 0, void ApplyOverlayOffsetRecursive(SDK::UWidget* Widget, float left, float right, SDK::EHorizontalAlignment alignment, const std::vector& ExcludeNames = {}, int MaxDepth = INT_MAX); +/** + * @brief Apply transform to a widget. + * @param Widget UWidget* pointer. + * @param OffsetX (left offset). + * @param OffsetY (top offset). + */ +void ApplyTransformOffset(SDK::UWidget* Widget, float OffsetX, float OffsetY = 0); + void FindAndApplyCanvasRecursive(SDK::UWidget* widget, float offset, int MaxDepth = INT_MAX, int currentDepth = 0); /**