added commission tracker to HUD
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
|
||||
#include "HUDCommissionTrackerWidget.h"
|
||||
|
||||
#include "Components/PanelWidget.h"
|
||||
#include "NakedDesire/Commissions/Commission.h"
|
||||
#include "NakedDesire/Commissions/MissionSubsystem.h"
|
||||
#include "NakedDesire/UI/Phone/Apps/ForumCommissionWidget.h"
|
||||
|
||||
void UHUDCommissionTrackerWidget::NativeConstruct()
|
||||
{
|
||||
Super::NativeConstruct();
|
||||
|
||||
if (UMissionSubsystem* Missions = GetMissionSubsystem())
|
||||
Missions->OnBoardChanged.AddUniqueDynamic(this, &UHUDCommissionTrackerWidget::Rebuild);
|
||||
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
void UHUDCommissionTrackerWidget::NativeDestruct()
|
||||
{
|
||||
if (UMissionSubsystem* Missions = GetMissionSubsystem())
|
||||
Missions->OnBoardChanged.RemoveDynamic(this, &UHUDCommissionTrackerWidget::Rebuild);
|
||||
|
||||
Super::NativeDestruct();
|
||||
}
|
||||
|
||||
void UHUDCommissionTrackerWidget::Rebuild()
|
||||
{
|
||||
if (!CommissionContainer || !CommissionEntryClass)
|
||||
return;
|
||||
|
||||
CommissionContainer->ClearChildren();
|
||||
|
||||
UMissionSubsystem* Missions = GetMissionSubsystem();
|
||||
if (!Missions)
|
||||
return;
|
||||
|
||||
// Only accepted commissions are "active" — offered / completed / expired stay on the forum.
|
||||
for (UCommission* Commission : Missions->GetAcceptedCommissions())
|
||||
{
|
||||
if (!Commission)
|
||||
continue;
|
||||
|
||||
UForumCommissionWidget* Entry = CreateWidget<UForumCommissionWidget>(this, CommissionEntryClass);
|
||||
if (!Entry)
|
||||
continue;
|
||||
|
||||
// SetCommission collapses the accept control and keeps the row's objective progress polling live;
|
||||
// the HUD row BP simply omits the accept / abandon buttons (both optional binds).
|
||||
Entry->SetCommission(Commission);
|
||||
CommissionContainer->AddChild(Entry);
|
||||
}
|
||||
}
|
||||
|
||||
UMissionSubsystem* UHUDCommissionTrackerWidget::GetMissionSubsystem() const
|
||||
{
|
||||
const UWorld* World = GetWorld();
|
||||
return World ? World->GetSubsystem<UMissionSubsystem>() : nullptr;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CommonUserWidget.h"
|
||||
#include "HUDCommissionTrackerWidget.generated.h"
|
||||
|
||||
class UPanelWidget;
|
||||
class UForumCommissionWidget;
|
||||
class UMissionSubsystem;
|
||||
|
||||
// On-screen tracker for accepted commissions (GDD §13 / Phase 7 objective-tracker), so the player can
|
||||
// read their active objectives during play without opening the phone forum. Mirrors the forum's accepted
|
||||
// section: reads the live board from UMissionSubsystem, rebuilds on OnBoardChanged, and reuses the forum
|
||||
// row class for per-objective progress polling. Display-only — no accept / abandon controls.
|
||||
UCLASS(Abstract)
|
||||
class NAKEDDESIRE_API UHUDCommissionTrackerWidget : public UCommonUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
protected:
|
||||
virtual void NativeConstruct() override;
|
||||
virtual void NativeDestruct() override;
|
||||
|
||||
private:
|
||||
// Holds one row per accepted commission.
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UPanelWidget> CommissionContainer;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "HUD")
|
||||
TSubclassOf<UForumCommissionWidget> CommissionEntryClass;
|
||||
|
||||
// Bound to UMissionSubsystem::OnBoardChanged (a dynamic delegate, hence UFUNCTION).
|
||||
UFUNCTION()
|
||||
void Rebuild();
|
||||
|
||||
UMissionSubsystem* GetMissionSubsystem() const;
|
||||
};
|
||||
@@ -48,7 +48,8 @@ private:
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UCommonTextBlock> DescriptionText;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
// Optional so display-only hosts (e.g. the HUD commission tracker) can reuse this row without a button.
|
||||
UPROPERTY(meta = (BindWidgetOptional))
|
||||
TObjectPtr<UButton> AcceptButton;
|
||||
|
||||
UPROPERTY(meta = (BindWidgetOptional))
|
||||
|
||||
Reference in New Issue
Block a user