initial commit; cv 0.0.3

This commit is contained in:
2026-09-07 19:33:58 -04:00
commit abf065ddde
63 changed files with 8816 additions and 0 deletions

125
Api/WidgetLayoutLibrary.hpp Normal file
View File

@@ -0,0 +1,125 @@
#pragma once
#include <optional>
#include <Reflection/UnrealObjectRef.hpp>
#include "UmgTypes.hpp"
#include "UnrealWrapper.hpp"
#include "PanelSlot.hpp"
#include "CanvasPanelSlot.hpp"
namespace PalUIExtension::Api
{
class WidgetLayoutLibrary : public UnrealWrapper
{
public:
static auto ClassPath() -> const TCHAR* { return STR("/Script/UMG.WidgetLayoutLibrary"); }
static auto CDOPath() -> const TCHAR* { return STR("/Script/UMG.Default__WidgetLayoutLibrary"); }
static auto DebugTag() -> const TCHAR* { return STR("WidgetLayoutLibrary"); }
static auto Instance() -> WidgetLayoutLibrary&
{
static WidgetLayoutLibrary Singleton{};
return Singleton;
}
// ---- slot casts ---------------------------------------------------
auto SlotAsCanvasSlot(UObject* Widget) -> CanvasPanelSlot
{
return GetSingleton<CanvasPanelSlot>(STR("SlotAsCanvasSlot"), Widget);
}
auto SlotAsWrapBoxSlot(UObject* Widget) -> PanelSlot { return GetSingleton<PanelSlot>(STR("SlotAsWrapBoxSlot"), Widget); }
auto SlotAsWidgetSwitcherSlot(UObject* Widget) -> PanelSlot { return GetSingleton<PanelSlot>(STR("SlotAsWidgetSwitcherSlot"), Widget); }
auto SlotAsVerticalBoxSlot(UObject* Widget) -> PanelSlot { return GetSingleton<PanelSlot>(STR("SlotAsVerticalBoxSlot"), Widget); }
auto SlotAsUniformGridSlot(UObject* Widget) -> PanelSlot { return GetSingleton<PanelSlot>(STR("SlotAsUniformGridSlot"), Widget); }
auto SlotAsSizeBoxSlot(UObject* Widget) -> PanelSlot { return GetSingleton<PanelSlot>(STR("SlotAsSizeBoxSlot"), Widget); }
auto SlotAsScrollBoxSlot(UObject* Widget) -> PanelSlot { return GetSingleton<PanelSlot>(STR("SlotAsScrollBoxSlot"), Widget); }
auto SlotAsScaleBoxSlot(UObject* Widget) -> PanelSlot { return GetSingleton<PanelSlot>(STR("SlotAsScaleBoxSlot"), Widget); }
auto SlotAsSafeBoxSlot(UObject* Widget) -> PanelSlot { return GetSingleton<PanelSlot>(STR("SlotAsSafeBoxSlot"), Widget); }
auto SlotAsOverlaySlot(UObject* Widget) -> PanelSlot { return GetSingleton<PanelSlot>(STR("SlotAsOverlaySlot"), Widget); }
auto SlotAsHorizontalBoxSlot(UObject* Widget) -> PanelSlot { return GetSingleton<PanelSlot>(STR("SlotAsHorizontalBoxSlot"), Widget); }
auto SlotAsGridSlot(UObject* Widget) -> PanelSlot { return GetSingleton<PanelSlot>(STR("SlotAsGridSlot"), Widget); }
auto SlotAsBorderSlot(UObject* Widget) -> PanelSlot { return GetSingleton<PanelSlot>(STR("SlotAsBorderSlot"), Widget); }
// ---- viewport / mouse ----------------------------------------------
auto RemoveAllWidgets(UObject* WorldContextObject) -> bool
{
struct P { UObject* WorldContextObject; } p{ WorldContextObject };
return Call(STR("RemoveAllWidgets"), p);
}
auto GetViewportSize(UObject* WorldContextObject) -> std::optional<FVector2D_>
{
struct P { UObject* WorldContextObject; FVector2D_ ReturnValue; } p{ WorldContextObject, {} };
return CallForReturn(STR("GetViewportSize"), p, &P::ReturnValue);
}
auto GetViewportScale(UObject* WorldContextObject) -> std::optional<float>
{
struct P { UObject* WorldContextObject; float ReturnValue; } p{ WorldContextObject, 0.f };
return CallForReturn(STR("GetViewportScale"), p, &P::ReturnValue);
}
auto GetMousePositionOnViewport(UObject* WorldContextObject) -> std::optional<FVector2D_>
{
struct P { UObject* WorldContextObject; FVector2D_ ReturnValue; } p{ WorldContextObject, {} };
return CallForReturn(STR("GetMousePositionOnViewport"), p, &P::ReturnValue);
}
auto GetMousePositionOnPlatform() -> std::optional<FVector2D_>
{
return CallForReturn<FVector2D_>(STR("GetMousePositionOnPlatform"));
}
struct MousePositionDPI { float X{}; float Y{}; };
auto GetMousePositionScaledByDPI(UObject* Player) -> std::optional<MousePositionDPI>
{
struct P { UObject* Player; float LocationX; float LocationY; bool ReturnValue; }
p{ Player, 0.f, 0.f, false };
if (!Call(STR("GetMousePositionScaledByDPI"), p) || !p.ReturnValue) return std::nullopt;
return MousePositionDPI{ p.LocationX, p.LocationY };
}
auto ProjectWorldLocationToWidgetPosition(UObject* PlayerController, FVector_ WorldLocation, bool bPlayerViewportRelative) -> std::optional<FVector2D_>
{
struct P
{
UObject* PlayerController;
FVector_ WorldLocation;
FVector2D_ ScreenPosition;
bool bPlayerViewportRelative;
bool ReturnValue;
} p{ PlayerController, WorldLocation, {}, bPlayerViewportRelative, false };
if (!Call(STR("ProjectWorldLocationToWidgetPosition"), p) || !p.ReturnValue) return std::nullopt;
return p.ScreenPosition;
}
private:
WidgetLayoutLibrary() : UnrealWrapper(ResolveCDO(), ClassOf<WidgetLayoutLibrary>(), DebugTag()) {}
WidgetLayoutLibrary(const WidgetLayoutLibrary&) = delete;
auto operator=(const WidgetLayoutLibrary&) -> WidgetLayoutLibrary& = delete;
static auto ResolveCDO() -> UObject*
{
static Reflection::UnrealObjectRef Ref{ CDOPath(), DebugTag() };
return Ref.Get();
}
auto CallStaticObjectGetter(const TCHAR* FunctionName, UObject* InObject) -> UObject*
{
struct P { UObject* InObject; UObject* ReturnValue; } p{ InObject, nullptr };
auto Result = CallForReturn(FunctionName, p, &P::ReturnValue);
return (Result && *Result) ? *Result : nullptr;
}
template <typename T>
auto GetSingleton(const TCHAR* FunctionName, UObject* InObject) -> T
{
UObject* Obj = CallStaticObjectGetter(FunctionName, InObject);
return Obj ? T{ Obj } : T{};
}
};
}