Add widget position and transform offset functions.

This commit is contained in:
2026-03-07 16:54:49 +01:00
parent 6c4ba505e1
commit 87dd5e2f37

View File

@@ -32,6 +32,14 @@ struct WidgetTrackInfo {
};
static std::unordered_map<std::string, WidgetTrackInfo> 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<spdlog::logger> 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<std::string>& 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);
/**