You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb trivial #jira none #preflight 61a8b5eb0263140fa845cf96 #ROBOMERGE-AUTHOR: mark.lintott #ROBOMERGE-SOURCE: CL 18351086 in //UE5/Release-5.0/... via CL 18351102 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469) [CL 18351103 by mark lintott in ue5-release-engine-test branch]
255 lines
6.3 KiB
C++
255 lines
6.3 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SZenCacheStatistics.h"
|
|
#include "ZenServerInterface.h"
|
|
#include "Math/UnitConversion.h"
|
|
#include "Math/BasicMathExpressionEvaluator.h"
|
|
#include "Misc/ExpressionParser.h"
|
|
#include "Styling/StyleColors.h"
|
|
#include "Widgets/Layout/SGridPanel.h"
|
|
#include "Widgets/Text/STextBlock.h"
|
|
#include "Widgets/SBoxPanel.h"
|
|
#include "Internationalization/FastDecimalFormat.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "ZenEditor"
|
|
|
|
static FString SingleDecimalFormat(double Value)
|
|
{
|
|
const FNumberFormattingOptions NumberFormattingOptions = FNumberFormattingOptions()
|
|
.SetUseGrouping(true)
|
|
.SetMinimumFractionalDigits(1)
|
|
.SetMaximumFractionalDigits(1);
|
|
return FastDecimalFormat::NumberToString(Value, ExpressionParser::GetLocalizedNumberFormattingRules(), NumberFormattingOptions);
|
|
};
|
|
|
|
void SZenCacheStatisticsDialog::Construct(const FArguments& InArgs)
|
|
{
|
|
this->ChildSlot
|
|
[
|
|
SNew(SVerticalBox)
|
|
|
|
+ SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(0, 20, 0, 0)
|
|
.Expose(GridSlot)
|
|
[
|
|
GetGridPanel()
|
|
]
|
|
];
|
|
|
|
RegisterActiveTimer(0.5f, FWidgetActiveTimerDelegate::CreateSP(this, &SZenCacheStatisticsDialog::UpdateGridPanels));
|
|
}
|
|
|
|
EActiveTimerReturnType SZenCacheStatisticsDialog::UpdateGridPanels(double InCurrentTime, float InDeltaTime)
|
|
{
|
|
(*GridSlot)
|
|
[
|
|
GetGridPanel()
|
|
];
|
|
|
|
SlatePrepass(GetPrepassLayoutScaleMultiplier());
|
|
|
|
return EActiveTimerReturnType::Continue;
|
|
}
|
|
|
|
TSharedRef<SWidget> SZenCacheStatisticsDialog::GetGridPanel()
|
|
{
|
|
TSharedRef<SGridPanel> Panel = SNew(SGridPanel);
|
|
|
|
#if UE_WITH_ZEN
|
|
|
|
UE::Zen::FZenStats ZenStats;
|
|
|
|
UE::Zen::GetDefaultServiceInstance().GetStats(ZenStats);
|
|
|
|
int32 Row = 0;
|
|
double SumTotalGetMB = 0.0;
|
|
double SumTotalPutMB = 0.0;
|
|
|
|
const float RowMargin = 0.0f;
|
|
const float TitleMargin = 10.0f;
|
|
const float ColumnMargin = 10.0f;
|
|
const FSlateColor TitleColor = FStyleColors::AccentWhite;
|
|
const FSlateFontInfo TitleFont = FCoreStyle::GetDefaultFontStyle("Bold", 10);
|
|
|
|
Panel->AddSlot(0, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin, 0.0f, TitleMargin))
|
|
.ColorAndOpacity(TitleColor)
|
|
.Font(TitleFont)
|
|
.Text(LOCTEXT("Cache", "Cache"))
|
|
.Text(LOCTEXT("CacheType", "Cache Type"))
|
|
];
|
|
|
|
Panel->AddSlot(1, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin, 0.0f, TitleMargin))
|
|
.ColorAndOpacity(TitleColor)
|
|
.Font(TitleFont)
|
|
.Justification(ETextJustify::Left)
|
|
.Text(LOCTEXT("Location", "Location"))
|
|
];
|
|
|
|
Panel->AddSlot(2, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin, 0.0f, TitleMargin))
|
|
.ColorAndOpacity(TitleColor)
|
|
.Font(TitleFont)
|
|
.Justification(ETextJustify::Left)
|
|
.Text(LOCTEXT("HitPercentage", "Hit%"))
|
|
];
|
|
|
|
Panel->AddSlot(3, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin, 0.0f, TitleMargin))
|
|
.ColorAndOpacity(TitleColor)
|
|
.Font(TitleFont)
|
|
.Justification(ETextJustify::Left)
|
|
.Text(LOCTEXT("Read", "Read"))
|
|
];
|
|
|
|
Panel->AddSlot(4, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin, 0.0f, TitleMargin))
|
|
.ColorAndOpacity(TitleColor)
|
|
.Font(TitleFont)
|
|
.Justification(ETextJustify::Left)
|
|
.Text(LOCTEXT("Write", "Write"))
|
|
];
|
|
|
|
Panel->AddSlot(5, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin, 0.0f, TitleMargin))
|
|
.ColorAndOpacity(TitleColor)
|
|
.Font(TitleFont)
|
|
.Justification(ETextJustify::Left)
|
|
.Text(LOCTEXT("Details", "Details"))
|
|
];
|
|
Row++;
|
|
|
|
Panel->AddSlot(0, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin))
|
|
.Text(LOCTEXT("ZenServer", "Zen"))
|
|
];
|
|
|
|
Panel->AddSlot(1, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin))
|
|
.Text(LOCTEXT("LocalServer", "Local"))
|
|
];
|
|
|
|
Panel->AddSlot(2, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin))
|
|
.Text_Lambda([ZenStats] { return FText::FromString(SingleDecimalFormat(ZenStats.CacheStats.HitRatio * 100.0) + TEXT(" %")); })
|
|
];
|
|
|
|
Panel->AddSlot(5, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin))
|
|
.Text_Lambda([this] { return FText::FromString(FString::Printf(TEXT("%s:%d"), UE::Zen::GetDefaultServiceInstance().GetHostName(), UE::Zen::GetDefaultServiceInstance().GetPort() )); })
|
|
];
|
|
|
|
Row++;
|
|
|
|
int32 EndpointIndex = 1;
|
|
|
|
for (const UE::Zen::FZenEndPointStats& EndpointStats : ZenStats.UpstreamStats.EndPointStats)
|
|
{
|
|
Panel->AddSlot(0, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin))
|
|
.Text_Lambda([EndpointStats] { return FText::FromString(EndpointStats.Name); })
|
|
];
|
|
|
|
Panel->AddSlot(1, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin))
|
|
.Text(LOCTEXT("RemoteServer", "Remote"))
|
|
];
|
|
|
|
Panel->AddSlot(2, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin))
|
|
.Text_Lambda([EndpointStats] { return FText::FromString(SingleDecimalFormat(EndpointStats.HitRatio * 100.0) + TEXT(" %")); })
|
|
];
|
|
|
|
Panel->AddSlot(3, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin))
|
|
.Text_Lambda([EndpointStats] { return FText::FromString(SingleDecimalFormat(EndpointStats.DownloadedMB) + TEXT(" MB")); })
|
|
];
|
|
|
|
Panel->AddSlot(4, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin))
|
|
.Text_Lambda([EndpointStats] { return FText::FromString(SingleDecimalFormat(EndpointStats.UploadedMB) + TEXT(" MB")); })
|
|
];
|
|
|
|
Panel->AddSlot(5, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin))
|
|
.Text_Lambda([EndpointStats] { return FText::FromString(EndpointStats.Url); })
|
|
];
|
|
|
|
SumTotalGetMB += EndpointStats.DownloadedMB;
|
|
SumTotalPutMB += EndpointStats.UploadedMB;
|
|
|
|
Row++;
|
|
}
|
|
|
|
Panel->AddSlot(0, Row)
|
|
[
|
|
SNew(STextBlock)
|
|
.Text(FText::FromString(TEXT("Total")))
|
|
.Margin(FMargin(ColumnMargin, RowMargin))
|
|
.ColorAndOpacity(TitleColor)
|
|
.Font(TitleFont)
|
|
.Justification(ETextJustify::Left)
|
|
];
|
|
|
|
Panel->AddSlot(3, Row)
|
|
.HAlign(HAlign_Right)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin))
|
|
.Justification(ETextJustify::Left)
|
|
.ColorAndOpacity(TitleColor)
|
|
.Font(TitleFont)
|
|
.Text(FText::FromString(SingleDecimalFormat(SumTotalGetMB) + TEXT(" MB")))
|
|
];
|
|
|
|
Panel->AddSlot(4, Row)
|
|
.HAlign(HAlign_Right)
|
|
[
|
|
SNew(STextBlock)
|
|
.Margin(FMargin(ColumnMargin, RowMargin))
|
|
.Justification(ETextJustify::Left)
|
|
.ColorAndOpacity(TitleColor)
|
|
.Font(TitleFont)
|
|
.Text(FText::FromString(SingleDecimalFormat(SumTotalPutMB) + TEXT(" MB")))
|
|
];
|
|
#endif
|
|
|
|
return Panel;
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|