From 5598847f6bd68fa0e9fcda37686a11bb0202df10 Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Fri, 13 Mar 2026 19:22:41 +0100 Subject: [PATCH] Addressed an issue where UI would not show for certain resolutions --- libs/UEngine/UEWidgets.cpp | 7 +++---- libs/UEngine/UEWidgets.hpp | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/libs/UEngine/UEWidgets.cpp b/libs/UEngine/UEWidgets.cpp index 7da5f3d..bba186e 100644 --- a/libs/UEngine/UEWidgets.cpp +++ b/libs/UEngine/UEWidgets.cpp @@ -21,13 +21,12 @@ void ApplyTransformOffset(SDK::UWidget* Widget, float OffsetX, float OffsetY) { Widget->SetRenderTransform(Transform); } -void CenterWidget(SDK::UUserWidget* Widget, float offset, float screenWidth, float screenHeight, float aspectRatio, float targetAspect, float compensation) { +void CenterWidget(SDK::UUserWidget* Widget, float offset, float screenWidth, float screenHeight, float targetWidth, float targetHeight, float compensation) { if (!Widget) return; - float targetHeight = (float)screenHeight; // For UW displays - float targetWidth = screenWidth; + float aspectRatio = screenWidth / screenHeight; + float targetAspect = targetWidth / targetHeight; if (aspectRatio > targetAspect) { - targetHeight = 1080.f; // clamp at 1080 for UW float scale = targetHeight / screenHeight; // horizontal scale to apply to get the same vertical size as 1080p targetWidth = (float)screenWidth * scale; } diff --git a/libs/UEngine/UEWidgets.hpp b/libs/UEngine/UEWidgets.hpp index bef95f1..423a05b 100644 --- a/libs/UEngine/UEWidgets.hpp +++ b/libs/UEngine/UEWidgets.hpp @@ -35,11 +35,11 @@ static std::unordered_map g_WidgetTracker; * @param offset offset to apply. * @param screenWidth current screen width. * @param screenHeight current screen height. - * @param aspectRatio current screen aspect ratio. - * @param targetAspect target aspect ratio to apply compensation for (default is 16:9 depending on game). + * @param targetWidth width the game desires to render UI or HUD. + * @param targetHeight height the game desires to render UI or HUD. * @param compensation additional compensation after widget resize. */ -void CenterWidget(SDK::UUserWidget* Widget, float offset, float screenWidth, float screenHeight, float aspectRatio, float targetAspect = 16.f / 9.f, float compensation = 0.f); +void CenterWidget(SDK::UUserWidget* Widget, float offset, float screenWidth, float screenHeight, float targetWidth = 1920.f, float targetHeight = 1080.f, float compensation = 0.f); /** * @brief Reposition from left a widget that only displays at left and nothing at right