123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
- #include "SExtBuildProgress.h"
- #include "Widgets/SBoxPanel.h"
- #include "Widgets/Notifications/SProgressBar.h"
- #include "Widgets/Text/STextBlock.h"
- #include "Widgets/Input/SButton.h"
- #include "EditorStyleSet.h"
- #include "UnrealEdMisc.h"
- SBuildProgressWidget::SBuildProgressWidget()
- {
- }
- SBuildProgressWidget::~SBuildProgressWidget()
- {
- }
- SExtBuildProgressWidget::SExtBuildProgressWidget()
- {
- }
- SExtBuildProgressWidget::~SExtBuildProgressWidget()
- {
- }
- void SExtBuildProgressWidget::Construct( const FArguments& InArgs )
- {
- ChildSlot
- [
- SNew(SBorder)
- .BorderImage(FAppStyle::Get().GetBrush("Brushes.Header"))
- .Padding(0.0f)
- [
- SNew(SVerticalBox)
- + SVerticalBox::Slot()
- .VAlign(VAlign_Top)
- .AutoHeight()
- .Padding(10.0f, 10.0f, 10.0f, 2.0f)
- [
- SNew(STextBlock)
- .Text(NSLOCTEXT("BuildProgress", "BuildStatusLabel", "Build Status"))
- .Font(FAppStyle::Get().GetFontStyle("HeadingExtraSmall"))
- .ColorAndOpacity(FAppStyle::Get().GetSlateColor("Colors.White"))
- ]
- + SVerticalBox::Slot()
- .VAlign(VAlign_Top)
- .Padding(10.0f, 2.0f)
- [
- SNew(SHorizontalBox)
- + SHorizontalBox::Slot()
- .AutoWidth()
- [
- SNew(STextBlock)
- .Text(this, &SExtBuildProgressWidget::OnGetBuildTimeText)
- ]
- + SHorizontalBox::Slot()
- .AutoWidth()
- .Padding(10.0f, 0, 10.0f, 7.0f)
- [
- SNew(STextBlock)
- .Text(this, &SExtBuildProgressWidget::OnGetProgressText)
- ]
- ]
- + SVerticalBox::Slot()
- .HAlign(HAlign_Fill)
- .VAlign(VAlign_Center)
- .AutoHeight()
- .Padding(10.0f, 1.0f)
- [
- SNew(STextBlock)
- .Text(NSLOCTEXT("BuildProgress", "BuildProgressLabel", "Build Progress"))
- ]
- + SVerticalBox::Slot()
- .HAlign(HAlign_Fill)
- .VAlign(VAlign_Center)
- .AutoHeight()
- .Padding(10.0f, 7.0f, 10.0f, 7.0f)
- [
- SNew(SProgressBar)
- .Percent(this, &SExtBuildProgressWidget::OnGetProgressFraction)
- ]
- + SVerticalBox::Slot()
- .Padding(15.0f, 10.0f)
- .HAlign(HAlign_Right)
- .VAlign(VAlign_Bottom)
- [
- SNew(SButton)
- .TextStyle(FAppStyle::Get(), "DialogButtonText")
- .Text(NSLOCTEXT("BuildProgress", "StopBuildButtonLabel", "Stop Build"))
- .OnClicked(this, &SExtBuildProgressWidget::OnStopBuild)
- ]
- ]
- ];
- // Reset progress indicators
- BuildStartTime = -1;
- bStoppingBuild = false;
- SetBuildStatusText( FText::GetEmpty() );
- SetBuildProgressPercent( 0, 100 );
- }
- FText SExtBuildProgressWidget::OnGetProgressText() const
- {
- return ProgressStatusText;
- }
- void SExtBuildProgressWidget::UpdateProgressText()
- {
- if( ProgressNumerator > 0 && ProgressDenominator > 0 )
- {
- FFormatNamedArguments Args;
- Args.Add( TEXT("StatusText"), BuildStatusText );
- Args.Add( TEXT("ProgressCompletePercentage"), FText::AsPercent( (float)ProgressNumerator/ProgressDenominator) );
- ProgressStatusText = FText::Format( NSLOCTEXT("BuildProgress", "ProgressStatusFormat", "{StatusText} ({ProgressCompletePercentage})"), Args );
- }
- else
- {
- ProgressStatusText = BuildStatusText;
- }
- }
- FText SExtBuildProgressWidget::OnGetBuildTimeText() const
- {
- // Only show a percentage if there is something interesting to report
- return BuildStatusTime;
- }
- TOptional<float> SExtBuildProgressWidget::OnGetProgressFraction() const
- {
- // Only show a percentage if there is something interesting to report
- if( ProgressNumerator > 0 && ProgressDenominator > 0 )
- {
- return (float)ProgressNumerator/ProgressDenominator;
- }
- else
- {
- // Return non-value to indicate marquee mode
- // for the progress bar.
- return TOptional<float>();
- }
- }
- void SExtBuildProgressWidget::SetBuildType(EBuildType InBuildType)
- {
- BuildType = InBuildType;
- }
- FText SExtBuildProgressWidget::BuildElapsedTimeText() const
- {
- // Display elapsed build time.
- return FText::AsTimespan( FDateTime::Now() - BuildStartTime );
- }
- void SExtBuildProgressWidget::UpdateTime()
- {
- BuildStatusTime = BuildElapsedTimeText();
- }
- void SExtBuildProgressWidget::SetBuildStatusText( const FText& StatusText )
- {
- UpdateTime();
-
- // Only update the text if we haven't canceled the build.
- if( !bStoppingBuild )
- {
- BuildStatusText = StatusText;
- UpdateProgressText();
- }
- }
- void SExtBuildProgressWidget::SetBuildProgressPercent( int32 InProgressNumerator, int32 InProgressDenominator )
- {
- UpdateTime();
- // Only update the progress bar if we haven't canceled the build.
- if( !bStoppingBuild )
- {
- ProgressNumerator = InProgressNumerator;
- ProgressDenominator = InProgressDenominator;
- UpdateProgressText();
- }
- }
- void SExtBuildProgressWidget::MarkBuildStartTime()
- {
- BuildStartTime = FDateTime::Now();
- }
- FReply SExtBuildProgressWidget::OnStopBuild()
- {
- FUnrealEdMisc::Get().SetMapBuildCancelled( true );
-
- SetBuildStatusText( NSLOCTEXT("UnrealEd", "StoppingMapBuild", "Stopping Map Build...") );
- bStoppingBuild = true;
- return FReply::Handled();
- }
|