Files
tedwardsandCursor ff5640a020 Establish UE 5.8 known-good baseline with Batch 1 archaeology docs.
Initialize Git with LFS for binary assets and add standard Unreal Engine .gitignore/.gitattributes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-16 19:40:19 -07:00

43 lines
1.8 KiB
C++

// REALMS IN RUIN. Copyright (c) 2025 Trevor Edwards. All rights reserved.
#include "UI/HUD/RIRHUD.h"
#include "UI/Widgets/RIRUserWidget.h"
#include "UI/WidgetController/OverlayWidgetController.h"
UOverlayWidgetController* ARIRHUD::GetOverlayWidgetController(const FWidgetControllerParams& WCParams)
{
if (OverlayWidgetController == nullptr)
{
OverlayWidgetController = NewObject<UOverlayWidgetController>(this, OverlayWidgetControllerClass);
OverlayWidgetController->SetWidgetControllerParams(WCParams);
OverlayWidgetController->BindCallbacksToDependencies();
return OverlayWidgetController;
}
return OverlayWidgetController;
}
void ARIRHUD::InitOverlay(APlayerController* PC, APlayerState* PS, UAbilitySystemComponent* ASC, UAttributeSet* AS)
{
// Ensure that both the widget and its controller class are properly assigned in the editor or constructor
checkf(OverlayWidgetClass, TEXT("Overlay Widget Class uninitialized, please fill out WBP_PlayerHUD"));
checkf(OverlayWidgetControllerClass, TEXT("Overlay Widget Controller Class uninitialized, please fill out WBP_PlayerHUD"));
// Create the UMG overlay widget from the specified class
UUserWidget* Widget = CreateWidget<UUserWidget>(GetWorld(), OverlayWidgetClass);
OverlayWidget = Cast<URIRUserWidget>(Widget);
// Package the controller parameters (used to bind player data to the UI)
const FWidgetControllerParams WidgetControllerParams(PC, PS, ASC, AS);
UOverlayWidgetController* WidgetController = GetOverlayWidgetController(WidgetControllerParams);
// Assign the controller to the widget so it can bind and respond to gameplay data
OverlayWidget->SetWidgetController(WidgetController);
// Broadcast Initial Attribute values
WidgetController->BroadcastInitialInitialValues();
// Add the widget to the viewport to make it visible to the player
Widget->AddToViewport();
}