Skip to content
Snippets Groups Projects
Commit 6e6cec42 authored by Jonathan Ehret's avatar Jonathan Ehret
Browse files

fix crash when having more than 6 factors due to limited number of text blocks in HUD

parent 50a63fd7
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "HUD/SFHUDWidget.h" #include "HUD/SFHUDWidget.h"
#include "Help/SFUtils.h" #include "Help/SFUtils.h"
#include "Logging/SFLoggingUtils.h"
USFHUDWidget::USFHUDWidget(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) USFHUDWidget::USFHUDWidget(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
...@@ -27,12 +28,18 @@ void USFHUDWidget::SetPhase(const FString& Text) ...@@ -27,12 +28,18 @@ void USFHUDWidget::SetPhase(const FString& Text)
void USFHUDWidget::SetCondition(const TMap<FString, FString>& Texts) void USFHUDWidget::SetCondition(const TMap<FString, FString>& Texts)
{ {
//TODO: as of now we have a fixed number of text blocks, maybe this can be made dynamic
TArray<UTextBlock*> TextBlocks = { TArray<UTextBlock*> TextBlocks = {
ConditionText1, ConditionText2, ConditionText3, ConditionText4, ConditionText5, ConditionText6 ConditionText1, ConditionText2, ConditionText3, ConditionText4, ConditionText5, ConditionText6
}; };
int TextIndex=0; int TextIndex=0;
for(auto FactorLevel : Texts) for(auto FactorLevel : Texts)
{ {
if(TextIndex>=TextBlocks.Num())
{
FSFLoggingUtils::Log("Not all factor levels fit in the HUD, so only showing the first 6 levels");
break;
}
TextBlocks[TextIndex++]->SetText(FText::FromString(FactorLevel.Key + ": "+FactorLevel.Value)); TextBlocks[TextIndex++]->SetText(FText::FromString(FactorLevel.Key + ": "+FactorLevel.Value));
} }
while(TextIndex<TextBlocks.Num()) while(TextIndex<TextBlocks.Num())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment