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

make logs scrollable and append new messages at the bottom (+auto-scroll to bottom)

closes #115
parent 74594d11
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -49,11 +49,11 @@ void USFFadeHandler::Tick()
case EFadeState::FadingOut:
if (!NewLevelName.IsEmpty())
{
GameInstance->UpdateHUD("Loading Map");
FSFLoggingUtils::Log("[USFFadeHandler::Tick()]: Opening Map now", false);
UGameplayStatics::OpenLevel(GameInstance->GetWorld(), *NewLevelName, false);
SetTimerForNextTick();
FadeState = EFadeState::WaitForLevelLoaded;
GameInstance->UpdateHUD("Loading Map");
}
else if (GameInstance->HasEnded())
{
......@@ -76,6 +76,10 @@ void USFFadeHandler::Tick()
GameInstance->OnLevelLoaded();
FSFLoggingUtils::Log("[USFFadeHandler::Tick()]: Fading in now", false);
FadeIn();
//log empty string to HUD so that it scrolls to the bottom
//for the scrolling the text needs to have been rendered once to know the actual length
//(if lines are auto-wrapped into multiple lines)
GameInstance->LogToHUD("");
break;
// Its Faded in, everything done, cleanup
......
......@@ -78,12 +78,14 @@ void USFHUDWidget::AddLogMessage(const FString& Text)
LogMessages.RemoveAt(0);
FString LogString = "";
for (int i = LogMessages.Num() - 1; i >= 0; --i)
for (int i = 0; i < LogMessages.Num(); i++)
{
FString Message = LogMessages[i];
LogString += Message + "\n";
LogString += Message + (i < LogMessages.Num()-1 ? "\n" : "");
}
LogsTextBox->SetText(FText::FromString(LogString));
LogsTextBox->SetAutoWrapText(true);
LogsScrollBox->ScrollToEnd();
}
......
......@@ -87,6 +87,7 @@ private:
TArray<FString> LogMessages;
UPROPERTY(EditAnywhere, meta = (BindWidget)) UTextBlock* LogsTextBox;
UPROPERTY(EditAnywhere, meta = (BindWidget)) UScrollBox* LogsScrollBox;
UPROPERTY(EditAnywhere, meta = (BindWidget)) UButton* StartButton;
UPROPERTY(EditAnywhere, meta = (BindWidget)) UButton* NextButton;
......@@ -97,5 +98,5 @@ private:
UPROPERTY(EditAnywhere, meta = (BindWidget))
UImage* CursorImage; //only used for HMD fake HUD
UPROPERTY(EditAnywhere) int MaxNumberShownLogMessages = 7;
UPROPERTY(EditAnywhere) int MaxNumberShownLogMessages = 100;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment