228 lines
9.5 KiB
C++
228 lines
9.5 KiB
C++
#pragma once
|
|
|
|
#include <Unreal/FText.hpp>
|
|
#include <Unreal/NameTypes.hpp>
|
|
|
|
#include "UmgTypes.hpp"
|
|
#include "UnrealWrapper.hpp"
|
|
|
|
namespace PalUIExtension::Api
|
|
{
|
|
|
|
class Widget : public UnrealWrapper
|
|
{
|
|
public:
|
|
static auto ClassPath() -> const TCHAR* { return STR("/Script/UMG.Widget"); }
|
|
static auto DebugTag() -> const TCHAR* { return STR("Widget"); }
|
|
|
|
Widget() = default;
|
|
explicit Widget(UObject* Obj) : Widget(Obj, ClassOf<Widget>(), DebugTag()) {}
|
|
|
|
// ---- visibility / enable ------------------------------------------
|
|
|
|
auto SetVisibility(ESlateVisibility_ InVisibility) -> bool
|
|
{
|
|
struct P { ESlateVisibility_ InVisibility; } p{ InVisibility };
|
|
return Call(STR("SetVisibility"), p);
|
|
}
|
|
auto GetVisibility() -> std::optional<ESlateVisibility_>
|
|
{
|
|
return CallForReturn<ESlateVisibility_>(STR("GetVisibility"));
|
|
}
|
|
|
|
auto SetIsEnabled(bool bInIsEnabled) -> bool
|
|
{
|
|
struct P { bool bInIsEnabled; } p{ bInIsEnabled };
|
|
return Call(STR("SetIsEnabled"), p);
|
|
}
|
|
auto GetIsEnabled() -> std::optional<bool>
|
|
{
|
|
return CallForReturn<bool>(STR("GetIsEnabled"));
|
|
}
|
|
|
|
auto IsVisible() -> std::optional<bool> { return CallForReturn<bool>(STR("IsVisible")); }
|
|
auto IsRendered() -> std::optional<bool> { return CallForReturn<bool>(STR("IsRendered")); }
|
|
auto IsInViewport() -> std::optional<bool> { return CallForReturn<bool>(STR("IsInViewport")); }
|
|
auto IsHovered() -> std::optional<bool> { return CallForReturn<bool>(STR("IsHovered")); }
|
|
|
|
// ---- render transform ---------------------------------------------
|
|
|
|
auto SetRenderTransform(FWidgetTransform_ InTransform) -> bool
|
|
{
|
|
struct P { FWidgetTransform_ InTransform; } p{ InTransform };
|
|
return Call(STR("SetRenderTransform"), p);
|
|
}
|
|
auto SetRenderTranslation(FVector2D_ Translation) -> bool
|
|
{
|
|
struct P { FVector2D_ Translation; } p{ Translation };
|
|
return Call(STR("SetRenderTranslation"), p);
|
|
}
|
|
auto SetRenderScale(FVector2D_ Scale) -> bool
|
|
{
|
|
struct P { FVector2D_ Scale; } p{ Scale };
|
|
return Call(STR("SetRenderScale"), p);
|
|
}
|
|
auto SetRenderShear(FVector2D_ Shear) -> bool
|
|
{
|
|
struct P { FVector2D_ Shear; } p{ Shear };
|
|
return Call(STR("SetRenderShear"), p);
|
|
}
|
|
auto SetRenderTransformPivot(FVector2D_ Pivot) -> bool
|
|
{
|
|
struct P { FVector2D_ Pivot; } p{ Pivot };
|
|
return Call(STR("SetRenderTransformPivot"), p);
|
|
}
|
|
auto SetRenderTransformAngle(float Angle) -> bool
|
|
{
|
|
struct P { float Angle; } p{ Angle };
|
|
return Call(STR("SetRenderTransformAngle"), p);
|
|
}
|
|
auto GetRenderTransformAngle() -> std::optional<float>
|
|
{
|
|
return CallForReturn<float>(STR("GetRenderTransformAngle"));
|
|
}
|
|
|
|
auto SetRenderOpacity(float InOpacity) -> bool
|
|
{
|
|
struct P { float InOpacity; } p{ InOpacity };
|
|
return Call(STR("SetRenderOpacity"), p);
|
|
}
|
|
auto GetRenderOpacity() -> std::optional<float>
|
|
{
|
|
return CallForReturn<float>(STR("GetRenderOpacity"));
|
|
}
|
|
|
|
// ---- clipping / cursor ---------------------------------------------
|
|
|
|
auto SetClipping(EWidgetClipping_ InClipping) -> bool
|
|
{
|
|
struct P { EWidgetClipping_ InClipping; } p{ InClipping };
|
|
return Call(STR("SetClipping"), p);
|
|
}
|
|
auto GetClipping() -> std::optional<EWidgetClipping_>
|
|
{
|
|
return CallForReturn<EWidgetClipping_>(STR("GetClipping"));
|
|
}
|
|
|
|
auto SetCursor(EMouseCursorByte_ InCursor) -> bool
|
|
{
|
|
struct P { EMouseCursorByte_ InCursor; } p{ InCursor };
|
|
return Call(STR("SetCursor"), p);
|
|
}
|
|
auto ResetCursor() -> bool { return CallVoid(STR("ResetCursor")); }
|
|
|
|
// ---- tooltips -------------------------------------------------------
|
|
//
|
|
// FText here is the same ownership question flagged in
|
|
// FTextFromString: you are handing a refcounted object into a frame
|
|
// the engine will destruct. Confirm who owns the allocation before
|
|
// shipping this on a hot path.
|
|
auto SetToolTipText(const FText& InToolTipText) -> bool
|
|
{
|
|
struct P { FText InToolTipText; } p{ InToolTipText };
|
|
return Call(STR("SetToolTipText"), p);
|
|
}
|
|
auto SetToolTip(UObject* InWidget) -> bool
|
|
{
|
|
struct P { UObject* Widget; } p{ InWidget };
|
|
return Call(STR("SetToolTip"), p);
|
|
}
|
|
|
|
// ---- focus ----------------------------------------------------------
|
|
|
|
auto SetKeyboardFocus() -> bool { return CallVoid(STR("SetKeyboardFocus")); }
|
|
auto SetFocus() -> bool { return CallVoid(STR("SetFocus")); }
|
|
auto SetUserFocus(UObject* PlayerController) -> bool
|
|
{
|
|
struct P { UObject* PlayerController; } p{ PlayerController };
|
|
return Call(STR("SetUserFocus"), p);
|
|
}
|
|
|
|
auto HasKeyboardFocus() -> std::optional<bool> { return CallForReturn<bool>(STR("HasKeyboardFocus")); }
|
|
auto HasMouseCapture() -> std::optional<bool> { return CallForReturn<bool>(STR("HasMouseCapture")); }
|
|
auto HasAnyUserFocus() -> std::optional<bool> { return CallForReturn<bool>(STR("HasAnyUserFocus")); }
|
|
auto HasFocusedDescendants()-> std::optional<bool> { return CallForReturn<bool>(STR("HasFocusedDescendants")); }
|
|
|
|
auto HasUserFocus(UObject* PlayerController) -> std::optional<bool>
|
|
{
|
|
struct P { UObject* PlayerController; bool ReturnValue; } p{ PlayerController, false };
|
|
return CallForReturn(STR("HasUserFocus"), p, &P::ReturnValue);
|
|
}
|
|
auto HasUserFocusedDescendants(UObject* PlayerController) -> std::optional<bool>
|
|
{
|
|
struct P { UObject* PlayerController; bool ReturnValue; } p{ PlayerController, false };
|
|
return CallForReturn(STR("HasUserFocusedDescendants"), p, &P::ReturnValue);
|
|
}
|
|
auto HasMouseCaptureByUser(int32 UserIndex, int32 PointerIndex) -> std::optional<bool>
|
|
{
|
|
struct P { int32 UserIndex; int32 PointerIndex; bool ReturnValue; }
|
|
p{ UserIndex, PointerIndex, false };
|
|
return CallForReturn(STR("HasMouseCaptureByUser"), p, &P::ReturnValue);
|
|
}
|
|
|
|
// ---- navigation -----------------------------------------------------
|
|
|
|
auto SetNavigationRuleBase(EUINavigation_ Direction, EUINavigationRule_ Rule) -> bool
|
|
{
|
|
struct P { EUINavigation_ Direction; EUINavigationRule_ Rule; } p{ Direction, Rule };
|
|
return Call(STR("SetNavigationRuleBase"), p);
|
|
}
|
|
auto SetNavigationRuleExplicit(EUINavigation_ Direction, UObject* InWidget) -> bool
|
|
{
|
|
struct P { EUINavigation_ Direction; UObject* InWidget; } p{ Direction, InWidget };
|
|
return Call(STR("SetNavigationRuleExplicit"), p);
|
|
}
|
|
auto SetNavigationRule(EUINavigation_ Direction, EUINavigationRule_ Rule, FName WidgetToFocus) -> bool
|
|
{
|
|
struct P { EUINavigation_ Direction; EUINavigationRule_ Rule; FName WidgetToFocus; }
|
|
p{ Direction, Rule, WidgetToFocus };
|
|
return Call(STR("SetNavigationRule"), p);
|
|
}
|
|
auto SetAllNavigationRules(EUINavigationRule_ Rule, FName WidgetToFocus) -> bool
|
|
{
|
|
struct P { EUINavigationRule_ Rule; FName WidgetToFocus; } p{ Rule, WidgetToFocus };
|
|
return Call(STR("SetAllNavigationRules"), p);
|
|
}
|
|
|
|
// ---- layout / lifetime ----------------------------------------------
|
|
|
|
auto GetDesiredSize() -> std::optional<FVector2D_>
|
|
{
|
|
return CallForReturn<FVector2D_>(STR("GetDesiredSize"));
|
|
}
|
|
auto ForceLayoutPrepass() -> bool { return CallVoid(STR("ForceLayoutPrepass")); }
|
|
auto InvalidateLayoutAndVolatility() -> bool { return CallVoid(STR("InvalidateLayoutAndVolatility")); }
|
|
auto ForceVolatile(bool bForce) -> bool
|
|
{
|
|
struct P { bool bForce; } p{ bForce };
|
|
return Call(STR("ForceVolatile"), p);
|
|
}
|
|
auto RemoveFromParent() -> bool { return CallVoid(STR("RemoveFromParent")); }
|
|
|
|
// ---- relationships ---------------------------------------------------
|
|
//
|
|
// Returns the raw UPanelWidget*. Not a PanelWidget wrapper, because
|
|
// PanelWidget derives from this class and cannot be named here.
|
|
// Wrap it at the call site: PanelWidget{ *w.GetParentObject() }.
|
|
auto GetParentObject() -> std::optional<UObject*>
|
|
{
|
|
return CallForReturn<UObject*>(STR("GetParent"));
|
|
}
|
|
|
|
// UWidget::Slot is a UPROPERTY with no getter.
|
|
auto GetSlotObject() const -> UObject*
|
|
{
|
|
auto Ptr = PropertyPtr<UObject*>(STR("Slot"));
|
|
return Ptr ? *Ptr : nullptr;
|
|
}
|
|
|
|
auto GetOwningPlayer() -> std::optional<UObject*> { return CallForReturn<UObject*>(STR("GetOwningPlayer")); }
|
|
auto GetOwningLocalPlayer() -> std::optional<UObject*> { return CallForReturn<UObject*>(STR("GetOwningLocalPlayer")); }
|
|
auto GetGameInstance() -> std::optional<UObject*> { return CallForReturn<UObject*>(STR("GetGameInstance")); }
|
|
|
|
protected:
|
|
Widget(UObject* Obj, UClass* Expected, const TCHAR* Tag)
|
|
: UnrealWrapper(Obj, Expected, Tag) {}
|
|
};
|
|
}
|