Add methods to analyze widgets. Add method to manipulate overlay widgets. UCanvasPanelSlot manipulation improvement

This commit is contained in:
2026-02-24 07:09:15 +01:00
parent 22d08fa0a0
commit bba66fb4c7
2 changed files with 214 additions and 17 deletions

View File

@@ -1,5 +1,7 @@
#pragma once
#include "UMG_classes.hpp"
#include <spdlog/spdlog.h>
#include <unordered_map>
#include <atomic>
inline std::atomic_bool g_Console_Enabled { false };
@@ -18,6 +20,18 @@ namespace SDK {
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;
// Unreal Engine functions
/**
* @brief Gets the current player Pawn from the world.
@@ -34,8 +48,40 @@ void ReactivateDevConsole(std::shared_ptr<spdlog::logger> logger);
/**
* @brief Apply offsets recursively to UVCanvasPanelSlot.
* @param widget type of UUserWidget* (pointer).
* @param widget UUserWidget* pointer.
* @param left offset.
* @param right offset.
*/
void ApplyOffsetsRecursive(SDK::UWidget* widget, float left, float right = 0);
void ApplyOffsetsRecursive(SDK::UWidget* widget, float left, float right = 0, 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 Offset, SDK::EHorizontalAlignment alignment,
const std::vector<std::string>& ExcludeNames = {}, int MaxDepth = INT_MAX);
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);
void ClearWidgetTracking();