Space Plunder
Loading...
Searching...
No Matches
UQuestSystemObjectiveWidget Class Reference

A widget class used to display quest objectives. More...

#include <QuestSystemObjectiveWidget.h>

Inheritance diagram for UQuestSystemObjectiveWidget:

Public Member Functions

 UQuestSystemObjectiveWidget (const FObjectInitializer &ObjectInitializer)
 
void SetObjective (const FQuestObjectives &Objective)
 
FQuestObjectives GetQuestObjective () const
 

Public Attributes

bool bShortObjectiveDescription = false
 
int32 ShortenedLength = 17
 

Protected Member Functions

virtual void NativeConstruct () override
 
virtual bool Initialize () override
 
void SetValues ()
 

Protected Attributes

FQuestObjectives QuestObjective
 
FLinearColor CompleteColor = FLinearColor::Blue
 
FLinearColor InProgressColor = FLinearColor::Yellow
 
FLinearColor OptionalColor = FLinearColor::White
 
FLinearColor FailedColor = FLinearColor::Red
 
class UTextBlock * ObjectiveNameText = nullptr
 
class UTextBlock * ObjectiveProgressText = nullptr
 
TSubclassOf< class UBaseQuestSystemWidgetObjectiveTipTextClass = nullptr
 
class UImage * StatusImage = nullptr
 
class UProgressBar * ProgressBar = nullptr
 
class UProgressBar * FailProgressBar = nullptr
 
class UOverlay * ProgressOverlay = nullptr
 
class UScrollBox * QuestObjectiveTipBox = nullptr
 

Detailed Description

A widget class used to display quest objectives.

Constructor & Destructor Documentation

◆ UQuestSystemObjectiveWidget()

UQuestSystemObjectiveWidget::UQuestSystemObjectiveWidget ( const FObjectInitializer & ObjectInitializer)
17 :Super(ObjectInitializer)
18{
19 const ConstructorHelpers::FClassFinder<UBaseQuestSystemWidget> ObjectiveTipBP(TEXT("/QuestSystem/Widgets/WBP_QuestSystemObjectiveTip"));
20 if (!ensure(ObjectiveTipBP.Class != nullptr)) return;
21 ObjectiveTipTextClass = ObjectiveTipBP.Class;
22}
TSubclassOf< class UBaseQuestSystemWidget > ObjectiveTipTextClass
Definition QuestSystemObjectiveWidget.h:60

Member Function Documentation

◆ GetQuestObjective()

FQuestObjectives UQuestSystemObjectiveWidget::GetQuestObjective ( ) const
166{
167 return QuestObjective;
168}
FQuestObjectives QuestObjective
Definition QuestSystemObjectiveWidget.h:44

◆ Initialize()

bool UQuestSystemObjectiveWidget::Initialize ( )
overrideprotectedvirtual
32{
33 const bool Success = Super::Initialize();
34 if (!ensure(ObjectiveNameText != nullptr)) return false;
35 if (!ensure(ObjectiveProgressText != nullptr)) return false;
36 if (!ensure(StatusImage != nullptr)) return false;
37 if (!ensure(QuestObjectiveTipBox != nullptr)) return false;
38 if (!ensure(ProgressBar != nullptr)) return false;
39 if (!ensure(FailProgressBar != nullptr)) return false;
40 if(!Success) return false;
41 return true;
42}
class UProgressBar * ProgressBar
Definition QuestSystemObjectiveWidget.h:65
class UProgressBar * FailProgressBar
Definition QuestSystemObjectiveWidget.h:67
class UTextBlock * ObjectiveProgressText
Definition QuestSystemObjectiveWidget.h:58
class UTextBlock * ObjectiveNameText
Definition QuestSystemObjectiveWidget.h:56
class UImage * StatusImage
Definition QuestSystemObjectiveWidget.h:62
class UScrollBox * QuestObjectiveTipBox
Definition QuestSystemObjectiveWidget.h:71

◆ NativeConstruct()

void UQuestSystemObjectiveWidget::NativeConstruct ( )
overrideprotectedvirtual
26{
27 Super::NativeConstruct();
28 SetValues();
29}
void SetValues()
Definition QuestSystemObjectiveWidget.cpp:45

◆ SetObjective()

void UQuestSystemObjectiveWidget::SetObjective ( const FQuestObjectives & Objective)
160{
161 QuestObjective = Objective;
162 SetValues();
163}

◆ SetValues()

void UQuestSystemObjectiveWidget::SetValues ( )
protected
46{
47 // if(QuestObjective == nullptr){return;}
48 //- Set Objective Text, Shorten if needed //
49 FString ObjectiveText;
51 {
53 {
54 FString ObjectiveSubString = UKismetStringLibrary::GetSubstring(QuestObjective.ObjectiveDescription, 0, ShortenedLength);
55 ObjectiveText = ObjectiveSubString.Append("...");
56 }
57 else
58 {
60 }
61 }
62 else
63 {
65 }
66 // if (!ensure(QuestObjective != nullptr)) return;
67 // if (!ensure(QuestObjective.ObjectiveDescription.Len() >= 0)) return;
68 // UE_LOG(LogTemp, Warning, TEXT("ObjectiveDescription: %s"), *QuestObjective->ObjectiveDescription);
69
70 if(ObjectiveNameText == nullptr){return;}
71 ObjectiveNameText->SetText(FText::FromString(ObjectiveText));
72
73 //- Set Objective Progress //
75 {
76 ObjectiveProgressText->SetVisibility(ESlateVisibility::Visible);
77 const FText FormattedProgress = FText::Format( NSLOCTEXT("","","{0}/{1}"),
78 FText::AsNumber(QuestObjective.GetCurrentProgress()),
79 FText::AsNumber(QuestObjective.RequiredProgress));
80 // UE_LOG(LogQuestSystem,Warning,TEXT("%s Current Progress %i"), *QuestObjective.ObjectiveDescription, QuestObjective.CurrentProgress);
81 ObjectiveProgressText->SetText(FormattedProgress);
82 }
83 else
84 {
85 ObjectiveProgressText->SetVisibility(ESlateVisibility::Collapsed);
86 }
87
88 QuestObjectiveTipBox->ClearChildren();
89
91 {
92 for(const FString& QuestObjectiveTip : QuestObjective.ObjectiveHints)
93 {
94 UBaseQuestSystemWidget* ObjectiveTipText = CreateWidget<UBaseQuestSystemWidget>(GetOwningPlayer(), ObjectiveTipTextClass);
95 if(ObjectiveTipText == nullptr){continue;}
96 ObjectiveTipText->TitleText = QuestObjectiveTip;
97 if(QuestObjectiveTipBox == nullptr){continue;}
98 QuestObjectiveTipBox->AddChild(ObjectiveTipText);
99 }
100 }
101 if(ProgressOverlay != nullptr)
102 {
104 {
105 ProgressOverlay->SetVisibility(ESlateVisibility::Visible);
106 }
107 else
108 {
109 ProgressOverlay->SetVisibility(ESlateVisibility::Collapsed);
110 }
111
112 }
113 if(ProgressBar != nullptr)
114 {
116 {
117 ProgressBar->SetVisibility(ESlateVisibility::Visible);
119 }
120 else
121 {
122 ProgressBar->SetVisibility(ESlateVisibility::Collapsed);
123 }
124 }
125 if(FailProgressBar != nullptr)
126 {
128 {
129 FailProgressBar->SetVisibility(ESlateVisibility::Visible);
131 }
132 else
133 {
134 FailProgressBar->SetVisibility(ESlateVisibility::Collapsed);
135 }
136
137 }
138 if(QuestObjective.GetStatus() == EQuestStatus::Active)
139 {
140 StatusImage->SetBrushTintColor(InProgressColor);
141 }
143 {
144 StatusImage->SetBrushTintColor(OptionalColor);
145 }
147 {
148 StatusImage->SetBrushTintColor(CompleteColor);
149 QuestObjectiveTipBox->ClearChildren();
150 if(QuestObjective.GetIsSuccessful() == false)
151 {
152 StatusImage->SetBrushTintColor(FailedColor);
153 QuestObjectiveTipBox->ClearChildren();
154 }
155 }
156
157}
Definition BaseQuestSystemWidget.h:12
FString TitleText
Definition BaseQuestSystemWidget.h:17
class UOverlay * ProgressOverlay
Definition QuestSystemObjectiveWidget.h:69
int32 ShortenedLength
Definition QuestSystemObjectiveWidget.h:33
FLinearColor FailedColor
Definition QuestSystemObjectiveWidget.h:53
bool bShortObjectiveDescription
Definition QuestSystemObjectiveWidget.h:27
FLinearColor OptionalColor
Definition QuestSystemObjectiveWidget.h:51
FLinearColor CompleteColor
Definition QuestSystemObjectiveWidget.h:47
FLinearColor InProgressColor
Definition QuestSystemObjectiveWidget.h:49
float GetCurrentProgressPercent() const
Definition QuestData.h:496
EQuestStatus GetStatus() const
Definition QuestData.h:543
bool GetIsActive() const
Definition QuestData.h:517
bool bIsOptional
Definition QuestData.h:379
FString ObjectiveDescription
Definition QuestData.h:367
int32 GetCurrentProgress() const
Definition QuestData.h:487
bool bShowFailProgress
Definition QuestData.h:388
int32 RequiredProgress
Definition QuestData.h:384
bool bShowProgress
Definition QuestData.h:386
bool GetIsSuccessful() const
Definition QuestData.h:534
float GetFailProgressPercent() const
Definition QuestData.h:500
bool GetIsComplete() const
Definition QuestData.h:539

Member Data Documentation

◆ bShortObjectiveDescription

bool UQuestSystemObjectiveWidget::bShortObjectiveDescription = false

◆ CompleteColor

FLinearColor UQuestSystemObjectiveWidget::CompleteColor = FLinearColor::Blue
protected

◆ FailedColor

FLinearColor UQuestSystemObjectiveWidget::FailedColor = FLinearColor::Red
protected

◆ FailProgressBar

class UProgressBar* UQuestSystemObjectiveWidget::FailProgressBar = nullptr
protected

◆ InProgressColor

FLinearColor UQuestSystemObjectiveWidget::InProgressColor = FLinearColor::Yellow
protected

◆ ObjectiveNameText

class UTextBlock* UQuestSystemObjectiveWidget::ObjectiveNameText = nullptr
protected

◆ ObjectiveProgressText

class UTextBlock* UQuestSystemObjectiveWidget::ObjectiveProgressText = nullptr
protected

◆ ObjectiveTipTextClass

TSubclassOf<class UBaseQuestSystemWidget> UQuestSystemObjectiveWidget::ObjectiveTipTextClass = nullptr
protected

◆ OptionalColor

FLinearColor UQuestSystemObjectiveWidget::OptionalColor = FLinearColor::White
protected

◆ ProgressBar

class UProgressBar* UQuestSystemObjectiveWidget::ProgressBar = nullptr
protected

◆ ProgressOverlay

class UOverlay* UQuestSystemObjectiveWidget::ProgressOverlay = nullptr
protected

◆ QuestObjective

FQuestObjectives UQuestSystemObjectiveWidget::QuestObjective
protected

◆ QuestObjectiveTipBox

class UScrollBox* UQuestSystemObjectiveWidget::QuestObjectiveTipBox = nullptr
protected

◆ ShortenedLength

int32 UQuestSystemObjectiveWidget::ShortenedLength = 17

◆ StatusImage

class UImage* UQuestSystemObjectiveWidget::StatusImage = nullptr
protected

The documentation for this class was generated from the following files: