119 lines
3.9 KiB
C++
119 lines
3.9 KiB
C++
#pragma once
|
|
#include "UMG_classes.hpp"
|
|
#include <spdlog/spdlog.h>
|
|
#include <unordered_map>
|
|
|
|
namespace SDK {
|
|
class UEngine;
|
|
class UObject;
|
|
class UWorld;
|
|
class UWidget;
|
|
class APawn;
|
|
class UGameplayStatics;
|
|
class UConsole;
|
|
class UInputSettings;
|
|
class UKismetStringLibrary;
|
|
class UGameInstance;
|
|
class ULocalPlayer;
|
|
class APlayerController;
|
|
}
|
|
|
|
struct WidgetTrackInfo {
|
|
std::string ClassName;
|
|
std::string RootWidgetClass;
|
|
std::string OuterClass;
|
|
bool WasInViewport = false;
|
|
int ConstructCount = 0;
|
|
int DestructCount = 0;
|
|
std::chrono::steady_clock::time_point FirstSeen;
|
|
};
|
|
static std::unordered_map<std::string, WidgetTrackInfo> g_WidgetTracker;
|
|
|
|
/**
|
|
* @brief Reposition from left a widget that only displays at left and nothing at right
|
|
* @param Widget UUserWdget to offset.
|
|
* @param offset offset to apply.
|
|
* @param screenWidth current screen width.
|
|
* @param screenHeight current screen height.
|
|
* @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 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
|
|
* @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.
|
|
* @param widget UUserWidget* pointer.
|
|
* @param left offset.
|
|
* @param right offset.
|
|
* @param ExcludeObjects excluded objects in depth check
|
|
* @param ExcludeClass excluded class widgets in depth check
|
|
*/
|
|
void ApplyOffsetsRecursive(SDK::UWidget* widget, float left, float right = 0,
|
|
const std::vector<SDK::UObject*>& ExcludeObjects = {},
|
|
const std::vector<std::string>& ExcludeClass = {}, int MaxDepth = INT_MAX);
|
|
|
|
/**
|
|
* @brief Apply offsets recursively to Overlay.
|
|
* @param widget UUserWidget* pointer.
|
|
* @param Offset (left and right offsets).
|
|
* @param alignment widget (left, right, center, fill ...)
|
|
* @param ExcludeNames excluded class widgets in depth check
|
|
* @param MaxDepth Max depth to go through root component
|
|
*/
|
|
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);
|
|
|
|
/**
|
|
* @brief Tracks potential widgets candidates for HUD & UI at construction
|
|
* @param widget UUserWidget* pointer.
|
|
*/
|
|
void TrackWidgetConstruct(SDK::UUserWidget* widget);
|
|
|
|
/**
|
|
* @brief Tracks potential widgets candidates for HUD & UI at destruction
|
|
* @param widget UUserWidget* pointer.
|
|
*/
|
|
void TrackWidgetDestruct(SDK::UUserWidget* widget);
|
|
|
|
/**
|
|
* @brief Dump and log previously searched UI & HUD wisgets
|
|
* @param logger the log object.
|
|
*/
|
|
void DumpUIAnalysis(std::shared_ptr<spdlog::logger> logger);
|
|
|
|
/**
|
|
* @brief Clear previously tracked widgets
|
|
*/
|
|
void ClearWidgetTracking();
|
|
|
|
/**
|
|
* @brief Dump all widgets
|
|
* @param Widget a UWidget instance to browse
|
|
* @param Depth the depth to start from
|
|
* @param MaxDepth the maximal depth to reach
|
|
*/
|
|
void DumpWidgetRecursive(SDK::UWidget* Widget, int Depth = 0, int MaxDepth = 2);
|
|
|
|
void SetLogger(std::shared_ptr<spdlog::logger> logger = nullptr);
|