Setup player preview for equipment panel
This commit is contained in:
@@ -2,3 +2,22 @@
|
||||
|
||||
|
||||
#include "HUDWidget.h"
|
||||
#include "Components/ProgressBar.h"
|
||||
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
||||
#include "NakedDesire/Stats/StatsManager.h"
|
||||
|
||||
void UHUDWidget::NativeConstruct()
|
||||
{
|
||||
Super::NativeConstruct();
|
||||
|
||||
const ANakedDesireCharacter* Player = Cast<ANakedDesireCharacter>(GetOwningPlayerPawn());
|
||||
if (!Player)
|
||||
return;
|
||||
|
||||
Player->StatsManager->EmbarrassmentUpdate.AddUniqueDynamic(this, &UHUDWidget::OnEmbarrassmentUpdated);
|
||||
}
|
||||
|
||||
void UHUDWidget::OnEmbarrassmentUpdated(float CurrentValue, float MaxValue)
|
||||
{
|
||||
EmbarrassmentBar->SetPercent(CurrentValue / MaxValue);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,20 @@
|
||||
#include "CommonUserWidget.h"
|
||||
#include "HUDWidget.generated.h"
|
||||
|
||||
class UProgressBar;
|
||||
|
||||
UCLASS(Abstract)
|
||||
class NAKEDDESIRE_API UHUDWidget : public UCommonUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UProgressBar> EmbarrassmentBar;
|
||||
|
||||
protected:
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
private:
|
||||
UFUNCTION()
|
||||
void OnEmbarrassmentUpdated(float CurrentValue, float MaxValue);
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "EquipmentPanelWidget.h"
|
||||
#include "EquipmentSlotMenuWidget.h"
|
||||
#include "EquipmentSlotWidget.h"
|
||||
#include "NakedDesire/Global/PlayerPreviewCaptureSubsystem.h"
|
||||
|
||||
void UInventoryScreenWidget::NativeOnActivated()
|
||||
{
|
||||
@@ -35,6 +36,22 @@ void UInventoryScreenWidget::NativeOnActivated()
|
||||
}
|
||||
|
||||
CloseMenu();
|
||||
|
||||
// Spin up the impostor scene-capture preview only while this screen is open.
|
||||
if (UPlayerPreviewCaptureSubsystem* Preview = GetWorld()->GetSubsystem<UPlayerPreviewCaptureSubsystem>())
|
||||
{
|
||||
Preview->SetPreviewActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
void UInventoryScreenWidget::NativeOnDeactivated()
|
||||
{
|
||||
Super::NativeOnDeactivated();
|
||||
|
||||
if (UPlayerPreviewCaptureSubsystem* Preview = GetWorld()->GetSubsystem<UPlayerPreviewCaptureSubsystem>())
|
||||
{
|
||||
Preview->SetPreviewActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
void UInventoryScreenWidget::HandleSlotClicked(UEquipmentSlotWidget* SlotWidget)
|
||||
|
||||
@@ -28,6 +28,7 @@ class NAKEDDESIRE_API UInventoryScreenWidget : public UCommonActivatableWidget
|
||||
|
||||
protected:
|
||||
virtual void NativeOnActivated() override;
|
||||
virtual void NativeOnDeactivated() override;
|
||||
|
||||
private:
|
||||
void HandleSlotClicked(UEquipmentSlotWidget* SlotWidget);
|
||||
|
||||
Reference in New Issue
Block a user