2016-01-07 08:17:16 -05:00
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2014-08-05 09:04:35 -04:00
# include "IntroTutorialsPrivatePCH.h"
# include "STutorialRoot.h"
# include "SEditorTutorials.h"
# include "EditorTutorialSettings.h"
2014-08-28 06:22:40 -04:00
# include "TutorialStateSettings.h"
2014-09-17 05:44:56 -04:00
# include "AssetEditorManager.h"
# include "ToolkitManager.h"
2014-09-17 08:30:32 -04:00
# include "IToolkit.h"
# include "IToolkitHost.h"
2014-09-18 08:10:29 -04:00
# include "EngineAnalytics.h"
# include "Runtime/Analytics/Analytics/Public/Interfaces/IAnalyticsProvider.h"
2014-09-18 16:42:40 -04:00
# include "Editor/MainFrame/Public/Interfaces/IMainFrameModule.h"
2014-10-14 22:50:06 -04:00
# include "NotificationManager.h"
# include "SNotificationList.h"
2015-06-29 14:06:00 -04:00
# include "Kismet/GameplayStatics.h"
2014-08-05 09:04:35 -04:00
# define LOCTEXT_NAMESPACE "STutorialRoot"
void STutorialRoot : : Construct ( const FArguments & InArgs )
{
CurrentTutorial = nullptr ;
CurrentTutorialStage = 0 ;
2014-09-18 08:10:29 -04:00
CurrentTutorialStartTime = FPlatformTime : : Seconds ( ) ;
2014-08-05 09:04:35 -04:00
ChildSlot
[
SNullWidget : : NullWidget
] ;
}
2015-01-27 14:54:15 -05:00
void STutorialRoot : : AttachWidget ( TSharedPtr < SWidget > Widget )
{
//This checkSlow is just here to ensure we know what we're doing
checkSlow ( ChildSlot . GetWidget ( ) = = SNullWidget : : NullWidget ) ;
ChildSlot . AttachWidget ( Widget . ToSharedRef ( ) ) ;
}
void STutorialRoot : : DetachWidget ( )
{
ChildSlot . DetachWidget ( ) ;
}
2014-08-05 09:04:35 -04:00
void STutorialRoot : : MaybeAddOverlay ( TSharedRef < SWindow > InWindow )
{
if ( InWindow - > HasOverlay ( ) )
{
---- Merging with SlateDev branch ----
Introduces the concept of "Active Ticking" to allow Slate to go to sleep when there is no need to update the UI.
While asleep, Slate will skip the Tick & Paint pass for that frame entirely.
- There are TWO ways to "wake" Slate and cause a Tick/Paint pass:
1. Provide some sort of input (mouse movement, clicks, and key presses). Slate will always tick when the user is active.
- Therefore, if the logic in a given widget's Tick is only relevant in response to user action, there is no need to register an active tick.
2. Register an Active Tick. Currently this is an all-or-nothing situation, so if a single active tick needs to execute, all of Slate will be ticked.
- The purpose of an Active Tick is to allow a widget to "drive" Slate and guarantee a Tick/Paint pass in the absence of any user action.
- Examples include animation, async operations that update periodically, progress updates, loading bars, etc.
- An empty active tick is registered for viewports when they are real-time, so game project widgets are unaffected by this change and should continue to work as before.
- An Active Tick is registered by creating an FWidgetActiveTickDelegate and passing it to SWidget::RegisterActiveTick()
- There are THREE ways to unregister an active tick:
1. Return EActiveTickReturnType::StopTicking from the active tick function
2. Pass the FActiveTickHandle returned by RegisterActiveTick() to SWidget::UnregisterActiveTick()
3. Destroy the widget responsible for the active tick
- Sleeping is currently disabled, can be enabled with Slate.AllowSlateToSleep cvar
- There is currently a little buffer time during which Slate continues to tick following any input. Long-term, this is planned to be removed.
- The duration of the buffer can be adjusted using Slate.SleepBufferPostInput cvar (defaults to 1.0f)
- The FCurveSequence API has been updated to work with the active tick system
- Playing a curve sequence now requires that you pass the widget being animated by the sequence
- The active tick will automatically be registered on behalf of the widget and unregister when the sequence is complete
- GetLerpLooping() has been removed. Instead, pass true as the second param to Play() to indicate that the animation will loop. This causes the active tick to be registered indefinitely until paused or jumped to the start/end.
[CL 2391669 by Dan Hertzka in Main branch]
2014-12-17 16:07:57 -05:00
// check we don't already have a widget overlay for this window
2014-08-05 09:04:35 -04:00
TWeakPtr < SEditorTutorials > * FoundWidget = TutorialWidgets . Find ( InWindow ) ;
if ( FoundWidget = = nullptr )
{
TSharedPtr < SEditorTutorials > TutorialWidget = nullptr ;
InWindow - > AddOverlaySlot ( )
[
SNew ( SHorizontalBox )
+ SHorizontalBox : : Slot ( )
. VAlign ( VAlign_Fill )
. HAlign ( HAlign_Fill )
[
SAssignNew ( TutorialWidget , SEditorTutorials )
. ParentWindow ( InWindow )
. OnNextClicked ( FOnNextClicked : : CreateSP ( this , & STutorialRoot : : HandleNextClicked ) )
. OnBackClicked ( FSimpleDelegate : : CreateSP ( this , & STutorialRoot : : HandleBackClicked ) )
. OnHomeClicked ( FSimpleDelegate : : CreateSP ( this , & STutorialRoot : : HandleHomeClicked ) )
2014-09-18 08:10:29 -04:00
. OnCloseClicked ( FSimpleDelegate : : CreateSP ( this , & STutorialRoot : : HandleCloseClicked ) )
2014-08-05 09:04:35 -04:00
. OnGetCurrentTutorial ( FOnGetCurrentTutorial : : CreateSP ( this , & STutorialRoot : : HandleGetCurrentTutorial ) )
. OnGetCurrentTutorialStage ( FOnGetCurrentTutorialStage : : CreateSP ( this , & STutorialRoot : : HandleGetCurrentTutorialStage ) )
. OnLaunchTutorial ( FOnLaunchTutorial : : CreateSP ( this , & STutorialRoot : : LaunchTutorial ) )
2014-09-22 09:42:52 -04:00
. OnWasWidgetDrawn ( FOnWasWidgetDrawn : : CreateSP ( this , & STutorialRoot : : WasWidgetDrawn ) )
. OnWidgetWasDrawn ( FOnWidgetWasDrawn : : CreateSP ( this , & STutorialRoot : : WidgetWasDrawn ) )
2014-08-05 09:04:35 -04:00
]
] ;
FoundWidget = & TutorialWidgets . Add ( InWindow , TutorialWidget ) ;
FoundWidget - > Pin ( ) - > RebuildCurrentContent ( ) ;
}
}
TArray < TSharedRef < SWindow > > ChildWindows = InWindow - > GetChildWindows ( ) ;
for ( auto & ChildWindow : ChildWindows )
{
MaybeAddOverlay ( ChildWindow ) ;
}
}
---- Merging with SlateDev branch ----
Introduces the concept of "Active Ticking" to allow Slate to go to sleep when there is no need to update the UI.
While asleep, Slate will skip the Tick & Paint pass for that frame entirely.
- There are TWO ways to "wake" Slate and cause a Tick/Paint pass:
1. Provide some sort of input (mouse movement, clicks, and key presses). Slate will always tick when the user is active.
- Therefore, if the logic in a given widget's Tick is only relevant in response to user action, there is no need to register an active tick.
2. Register an Active Tick. Currently this is an all-or-nothing situation, so if a single active tick needs to execute, all of Slate will be ticked.
- The purpose of an Active Tick is to allow a widget to "drive" Slate and guarantee a Tick/Paint pass in the absence of any user action.
- Examples include animation, async operations that update periodically, progress updates, loading bars, etc.
- An empty active tick is registered for viewports when they are real-time, so game project widgets are unaffected by this change and should continue to work as before.
- An Active Tick is registered by creating an FWidgetActiveTickDelegate and passing it to SWidget::RegisterActiveTick()
- There are THREE ways to unregister an active tick:
1. Return EActiveTickReturnType::StopTicking from the active tick function
2. Pass the FActiveTickHandle returned by RegisterActiveTick() to SWidget::UnregisterActiveTick()
3. Destroy the widget responsible for the active tick
- Sleeping is currently disabled, can be enabled with Slate.AllowSlateToSleep cvar
- There is currently a little buffer time during which Slate continues to tick following any input. Long-term, this is planned to be removed.
- The duration of the buffer can be adjusted using Slate.SleepBufferPostInput cvar (defaults to 1.0f)
- The FCurveSequence API has been updated to work with the active tick system
- Playing a curve sequence now requires that you pass the widget being animated by the sequence
- The active tick will automatically be registered on behalf of the widget and unregister when the sequence is complete
- GetLerpLooping() has been removed. Instead, pass true as the second param to Play() to indicate that the animation will loop. This causes the active tick to be registered indefinitely until paused or jumped to the start/end.
[CL 2391669 by Dan Hertzka in Main branch]
2014-12-17 16:07:57 -05:00
void STutorialRoot : : Tick ( const FGeometry & AllottedGeometry , const double InCurrentTime , const float InDeltaTime )
2014-08-05 09:04:35 -04:00
{
TArray < TSharedRef < SWindow > > Windows = FSlateApplication : : Get ( ) . GetInteractiveTopLevelWindows ( ) ;
for ( auto & Window : Windows )
{
MaybeAddOverlay ( Window ) ;
}
2014-09-22 09:42:52 -04:00
// empty array but leave us the slack (we dont want to reallocate all the time, and this array should never grow too large)
PreviouslyDrawnWidgets . Empty ( PreviouslyDrawnWidgets . Max ( ) ) ;
PreviouslyDrawnWidgets . Append ( MoveTemp ( DrawnWidgets ) ) ;
DrawnWidgets . Empty ( DrawnWidgets . Max ( ) ) ;
2014-08-05 09:04:35 -04:00
}
2015-04-02 16:56:18 -04:00
void STutorialRoot : : LaunchTutorial ( UEditorTutorial * InTutorial , IIntroTutorials : : ETutorialStartType InStartType , TWeakPtr < SWindow > InNavigationWindow , FSimpleDelegate InOnTutorialClosed , FSimpleDelegate InOnTutorialExited )
2014-08-05 09:04:35 -04:00
{
if ( InTutorial ! = nullptr )
{
CurrentTutorial = InTutorial ;
2014-10-01 05:57:50 -04:00
// we force a restart if this tutorial was completed
2015-04-02 16:56:18 -04:00
if ( GetDefault < UTutorialStateSettings > ( ) - > HaveCompletedTutorial ( CurrentTutorial ) & & ( InStartType = = IIntroTutorials : : ETutorialStartType : : TST_CONTINUE ) )
2014-10-01 05:57:50 -04:00
{
2015-04-02 16:56:18 -04:00
InStartType = IIntroTutorials : : ETutorialStartType : : TST_RESTART ;
2014-10-01 05:57:50 -04:00
}
2014-08-05 09:04:35 -04:00
bool bHaveSeenTutorial = false ;
2015-04-02 16:56:18 -04:00
switch ( InStartType )
{
case IIntroTutorials : : ETutorialStartType : : TST_RESTART :
CurrentTutorialStage = 0 ;
break ;
case IIntroTutorials : : ETutorialStartType : : TST_LASTSTAGE :
CurrentTutorialStage = FMath : : Max ( 0 , ( CurrentTutorial - > Stages . Num ( ) - 1 ) ) ;
break ;
default :
case IIntroTutorials : : ETutorialStartType : : TST_CONTINUE :
CurrentTutorialStage = GetDefault < UTutorialStateSettings > ( ) - > GetProgress ( CurrentTutorial , bHaveSeenTutorial ) ;
break ;
}
2014-08-05 09:04:35 -04:00
2014-09-17 05:44:56 -04:00
// check if we should be launching this tutorial for an asset editor
if ( InTutorial - > AssetToUse . IsValid ( ) )
{
TArray < FString > AssetPaths ;
2015-07-23 10:49:29 -04:00
AssetPaths . Add ( InTutorial - > AssetToUse . ToString ( ) ) ;
2014-09-17 05:44:56 -04:00
FAssetEditorManager : : Get ( ) . OpenEditorsForAssets ( AssetPaths ) ;
UObject * Asset = InTutorial - > AssetToUse . ResolveObject ( ) ;
if ( Asset ! = nullptr )
{
TSharedPtr < IToolkit > Toolkit = FToolkitManager : : Get ( ) . FindEditorForAsset ( Asset ) ;
if ( Toolkit . IsValid ( ) )
{
InNavigationWindow = FSlateApplication : : Get ( ) . FindWidgetWindow ( Toolkit - > GetToolkitHost ( ) - > GetParentWidget ( ) ) ;
2014-09-22 09:41:50 -04:00
// make sure we have a valid tutorial overlay
if ( InNavigationWindow . IsValid ( ) )
{
MaybeAddOverlay ( InNavigationWindow . Pin ( ) . ToSharedRef ( ) ) ;
}
2014-09-17 05:44:56 -04:00
}
}
}
2014-09-18 08:10:29 -04:00
CurrentTutorialStartTime = FPlatformTime : : Seconds ( ) ;
2014-08-05 09:04:35 -04:00
// launch tutorial for all windows we wrap - any tutorial can display over any window
for ( auto & TutorialWidget : TutorialWidgets )
{
if ( TutorialWidget . Value . IsValid ( ) )
{
2014-08-20 10:27:41 -04:00
bool bIsNavigationWindow = false ;
if ( ! InNavigationWindow . IsValid ( ) )
{
bIsNavigationWindow = TutorialWidget . Value . Pin ( ) - > IsNavigationVisible ( ) ;
}
else
{
bIsNavigationWindow = ( TutorialWidget . Value . Pin ( ) - > GetParentWindow ( ) = = InNavigationWindow . Pin ( ) ) ;
}
2014-08-28 06:22:40 -04:00
TutorialWidget . Value . Pin ( ) - > LaunchTutorial ( bIsNavigationWindow , InOnTutorialClosed , InOnTutorialExited ) ;
2014-08-05 09:04:35 -04:00
}
}
2014-10-15 09:37:16 -04:00
if ( CurrentTutorial ! = nullptr )
{
CurrentTutorial - > HandleTutorialLaunched ( ) ;
}
if ( CurrentTutorial ! = nullptr & & CurrentTutorialStage < CurrentTutorial - > Stages . Num ( ) )
{
CurrentTutorial - > HandleTutorialStageStarted ( CurrentTutorial - > Stages [ CurrentTutorialStage ] . Name ) ;
}
2014-08-05 09:04:35 -04:00
}
}
2014-08-28 06:22:40 -04:00
void STutorialRoot : : CloseAllTutorialContent ( )
{
for ( auto & TutorialWidget : TutorialWidgets )
{
if ( TutorialWidget . Value . IsValid ( ) )
{
TutorialWidget . Value . Pin ( ) - > HideContent ( ) ;
}
}
}
2014-08-05 09:04:35 -04:00
void STutorialRoot : : HandleNextClicked ( TWeakPtr < SWindow > InNavigationWindow )
{
GoToNextStage ( InNavigationWindow ) ;
}
void STutorialRoot : : HandleBackClicked ( )
{
2014-09-18 08:10:29 -04:00
if ( FEngineAnalytics : : IsAvailable ( ) & & CurrentTutorial ! = nullptr )
{
TArray < FAnalyticsEventAttribute > EventAttributes ;
2014-12-05 05:33:09 -05:00
EventAttributes . Add ( FAnalyticsEventAttribute ( TEXT ( " Context.Tutorial " ) , FIntroTutorials : : AnalyticsEventNameFromTutorial ( CurrentTutorial ) ) ) ;
2014-09-18 08:10:29 -04:00
EventAttributes . Add ( FAnalyticsEventAttribute ( TEXT ( " Context.StageIndex " ) , CurrentTutorialStage ) ) ;
FEngineAnalytics : : GetProvider ( ) . RecordEvent ( TEXT ( " Rocket.Tutorials.ClickedBackButton " ) , EventAttributes ) ;
}
2014-08-05 09:04:35 -04:00
GoToPreviousStage ( ) ;
for ( auto & TutorialWidget : TutorialWidgets )
{
if ( TutorialWidget . Value . IsValid ( ) )
{
TSharedPtr < SEditorTutorials > PinnedTutorialWidget = TutorialWidget . Value . Pin ( ) ;
PinnedTutorialWidget - > RebuildCurrentContent ( ) ;
}
}
}
void STutorialRoot : : HandleHomeClicked ( )
{
if ( CurrentTutorial ! = nullptr )
{
2014-10-15 09:37:16 -04:00
CurrentTutorial - > HandleTutorialClosed ( ) ;
2014-08-28 06:22:40 -04:00
GetMutableDefault < UTutorialStateSettings > ( ) - > RecordProgress ( CurrentTutorial , CurrentTutorialStage ) ;
GetMutableDefault < UTutorialStateSettings > ( ) - > SaveProgress ( ) ;
2014-08-05 09:04:35 -04:00
}
2015-03-04 06:27:23 -05:00
// submit analytics data
if ( FEngineAnalytics : : IsAvailable ( ) & & CurrentTutorial ! = nullptr & & CurrentTutorialStage < CurrentTutorial - > Stages . Num ( ) )
{
FString const CurrentExcerptTitle = CurrentTutorial - > Stages [ CurrentTutorialStage ] . Name . ToString ( ) ;
int32 const CurrentExcerptIndex = CurrentTutorialStage ;
float const CurrentPageElapsedTime = ( float ) ( FPlatformTime : : Seconds ( ) - CurrentTutorialStartTime ) ;
TArray < FAnalyticsEventAttribute > EventAttributes ;
EventAttributes . Add ( FAnalyticsEventAttribute ( TEXT ( " LastStageIndex " ) , CurrentExcerptIndex ) ) ;
EventAttributes . Add ( FAnalyticsEventAttribute ( TEXT ( " LastStageTitle " ) , CurrentExcerptTitle ) ) ;
EventAttributes . Add ( FAnalyticsEventAttribute ( TEXT ( " TimeSpentInTutorial " ) , CurrentPageElapsedTime ) ) ;
EventAttributes . Add ( FAnalyticsEventAttribute ( TEXT ( " TutorialAsset " ) , FIntroTutorials : : AnalyticsEventNameFromTutorial ( CurrentTutorial ) ) ) ;
FEngineAnalytics : : GetProvider ( ) . RecordEvent ( TEXT ( " Rocket.Tutorials.Home " ) , EventAttributes ) ;
}
2014-08-05 09:04:35 -04:00
CurrentTutorial = nullptr ;
CurrentTutorialStage = 0 ;
for ( auto & TutorialWidget : TutorialWidgets )
{
if ( TutorialWidget . Value . IsValid ( ) )
{
TSharedPtr < SEditorTutorials > PinnedTutorialWidget = TutorialWidget . Value . Pin ( ) ;
PinnedTutorialWidget - > RebuildCurrentContent ( ) ;
}
}
}
UEditorTutorial * STutorialRoot : : HandleGetCurrentTutorial ( )
{
return CurrentTutorial ;
}
int32 STutorialRoot : : HandleGetCurrentTutorialStage ( )
{
return CurrentTutorialStage ;
}
void STutorialRoot : : AddReferencedObjects ( FReferenceCollector & Collector )
{
if ( CurrentTutorial ! = nullptr )
{
Collector . AddReferencedObject ( CurrentTutorial ) ;
}
}
void STutorialRoot : : GoToPreviousStage ( )
{
2015-04-02 16:56:18 -04:00
if ( CurrentTutorial ! = nullptr )
2014-08-05 09:04:35 -04:00
{
2015-04-02 16:56:18 -04:00
UEditorTutorial * OldTutorial = CurrentTutorial ;
int32 OldTutorialStage = CurrentTutorialStage ;
if ( CurrentTutorialStage < CurrentTutorial - > Stages . Num ( ) )
2014-08-20 10:27:41 -04:00
{
CurrentTutorial - > HandleTutorialStageEnded ( CurrentTutorial - > Stages [ CurrentTutorialStage ] . Name ) ;
}
2015-06-29 14:06:00 -04:00
FString PlatformName = UGameplayStatics : : GetPlatformName ( ) ;
for ( - - CurrentTutorialStage ; CurrentTutorialStage > = 0 ; - - CurrentTutorialStage )
2015-04-02 16:56:18 -04:00
{
2015-06-29 14:06:00 -04:00
bool bPlatformFoundInList = false ;
for ( FString PlatformToTest : CurrentTutorial - > Stages [ CurrentTutorialStage ] . PlatformsToTest )
2015-04-02 16:56:18 -04:00
{
2015-06-29 14:06:00 -04:00
if ( ! PlatformName . Compare ( PlatformToTest , ESearchCase : : IgnoreCase ) )
{
bPlatformFoundInList = true ;
break ;
}
2015-04-02 16:56:18 -04:00
}
2015-06-29 14:06:00 -04:00
if ( bPlatformFoundInList ! = CurrentTutorial - > Stages [ CurrentTutorialStage ] . bInvertPlatformTest )
2015-04-02 16:56:18 -04:00
{
2015-06-29 14:06:00 -04:00
// Skip this stage
continue ;
2015-04-02 16:56:18 -04:00
}
2015-06-29 14:06:00 -04:00
// We hit a page that we don't want to skip. Record progress and stop looking.
2015-04-02 16:56:18 -04:00
GetMutableDefault < UTutorialStateSettings > ( ) - > RecordProgress ( CurrentTutorial , CurrentTutorialStage ) ;
2015-06-29 14:06:00 -04:00
break ;
}
if ( CurrentTutorialStage < 0 )
{
// We went out of bounds for this tutorial, so see if we want to go to another one.
CurrentTutorialStage = 0 ;
2015-07-23 10:49:29 -04:00
if ( FName ( * CurrentTutorial - > PreviousTutorial . ToString ( ) ) ! = NAME_None )
2015-06-29 14:06:00 -04:00
{
2015-07-23 10:49:29 -04:00
TSubclassOf < UEditorTutorial > PreviousTutorialClass = LoadClass < UEditorTutorial > ( NULL , * CurrentTutorial - > PreviousTutorial . ToString ( ) , NULL , LOAD_None , NULL ) ;
2015-06-29 14:06:00 -04:00
if ( PreviousTutorialClass ! = nullptr )
{
LaunchTutorial ( PreviousTutorialClass - > GetDefaultObject < UEditorTutorial > ( ) , IIntroTutorials : : ETutorialStartType : : TST_LASTSTAGE , nullptr , FSimpleDelegate ( ) , FSimpleDelegate ( ) ) ;
}
else
{
2015-07-23 10:49:29 -04:00
FSlateNotificationManager : : Get ( ) . AddNotification ( FNotificationInfo ( FText : : Format ( LOCTEXT ( " TutorialNotFound " , " Could not start previous tutorial {0} " ) , FText : : FromString ( CurrentTutorial - > PreviousTutorial . ToString ( ) ) ) ) ) ;
2015-06-29 14:06:00 -04:00
}
}
2015-04-02 16:56:18 -04:00
}
2014-08-20 10:27:41 -04:00
2015-04-02 16:56:18 -04:00
if ( CurrentTutorial ! = nullptr & & CurrentTutorialStage < CurrentTutorial - > Stages . Num ( ) & & ( CurrentTutorial ! = OldTutorial | | CurrentTutorialStage ! = OldTutorialStage ) )
2014-08-20 10:27:41 -04:00
{
CurrentTutorial - > HandleTutorialStageStarted ( CurrentTutorial - > Stages [ CurrentTutorialStage ] . Name ) ;
}
2014-08-05 09:04:35 -04:00
}
2015-04-02 16:56:18 -04:00
for ( auto & TutorialWidget : TutorialWidgets )
{
if ( TutorialWidget . Value . IsValid ( ) )
{
TSharedPtr < SEditorTutorials > PinnedTutorialWidget = TutorialWidget . Value . Pin ( ) ;
PinnedTutorialWidget - > RebuildCurrentContent ( ) ;
}
}
2014-08-05 09:04:35 -04:00
}
void STutorialRoot : : GoToNextStage ( TWeakPtr < SWindow > InNavigationWindow )
{
if ( CurrentTutorial ! = nullptr )
{
2015-04-02 16:56:18 -04:00
UEditorTutorial * OldTutorial = CurrentTutorial ;
int32 OldTutorialStage = CurrentTutorialStage ;
2014-09-11 03:56:58 -04:00
if ( CurrentTutorialStage < CurrentTutorial - > Stages . Num ( ) )
{
CurrentTutorial - > HandleTutorialStageEnded ( CurrentTutorial - > Stages [ CurrentTutorialStage ] . Name ) ;
}
2014-08-20 10:27:41 -04:00
2015-06-29 14:06:00 -04:00
FString PlatformName = UGameplayStatics : : GetPlatformName ( ) ;
for ( + + CurrentTutorialStage ; CurrentTutorialStage < CurrentTutorial - > Stages . Num ( ) ; + + CurrentTutorialStage )
2014-08-05 09:04:35 -04:00
{
2015-06-29 14:06:00 -04:00
bool bPlatformFoundInList = false ;
for ( FString PlatformToTest : CurrentTutorial - > Stages [ CurrentTutorialStage ] . PlatformsToTest )
2014-08-05 09:04:35 -04:00
{
2015-06-29 14:06:00 -04:00
if ( ! PlatformName . Compare ( PlatformToTest , ESearchCase : : IgnoreCase ) )
{
bPlatformFoundInList = true ;
break ;
}
2014-08-05 09:04:35 -04:00
}
2015-06-29 14:06:00 -04:00
if ( bPlatformFoundInList ! = CurrentTutorial - > Stages [ CurrentTutorialStage ] . bInvertPlatformTest )
2014-08-05 09:04:35 -04:00
{
2015-06-29 14:06:00 -04:00
// Skip this stage
continue ;
2014-08-05 09:04:35 -04:00
}
2015-06-29 14:06:00 -04:00
// We hit a page that we don't want to skip. Record progress and stop looking.
2014-08-28 06:22:40 -04:00
GetMutableDefault < UTutorialStateSettings > ( ) - > RecordProgress ( CurrentTutorial , CurrentTutorialStage ) ;
2015-06-29 14:06:00 -04:00
break ;
}
if ( CurrentTutorialStage + 1 > = CurrentTutorial - > Stages . Num ( ) )
{
// We went out of bounds for this tutorial, so see if we want to go to another one.
CurrentTutorialStage = CurrentTutorial - > Stages . Num ( ) - 1 ;
2015-07-23 10:49:29 -04:00
if ( FName ( * CurrentTutorial - > PreviousTutorial . ToString ( ) ) ! = NAME_None )
2015-06-29 14:06:00 -04:00
{
2015-07-23 10:49:29 -04:00
TSubclassOf < UEditorTutorial > NextTutorialClass = LoadClass < UEditorTutorial > ( NULL , * CurrentTutorial - > NextTutorial . ToString ( ) , NULL , LOAD_None , NULL ) ;
2015-06-29 14:06:00 -04:00
if ( NextTutorialClass ! = nullptr )
{
LaunchTutorial ( NextTutorialClass - > GetDefaultObject < UEditorTutorial > ( ) , IIntroTutorials : : ETutorialStartType : : TST_RESTART , InNavigationWindow , FSimpleDelegate ( ) , FSimpleDelegate ( ) ) ;
}
else
{
2015-07-23 10:49:29 -04:00
FSlateNotificationManager : : Get ( ) . AddNotification ( FNotificationInfo ( FText : : Format ( LOCTEXT ( " TutorialNotFound " , " Could not start next tutorial {0} " ) , FText : : FromString ( CurrentTutorial - > NextTutorial . ToString ( ) ) ) ) ) ;
2015-06-29 14:06:00 -04:00
}
}
2014-08-05 09:04:35 -04:00
}
2014-08-20 10:27:41 -04:00
2015-04-02 16:56:18 -04:00
if ( CurrentTutorial ! = nullptr & & CurrentTutorialStage < CurrentTutorial - > Stages . Num ( ) & & ( CurrentTutorial ! = OldTutorial | | CurrentTutorialStage ! = OldTutorialStage ) )
2014-08-20 10:27:41 -04:00
{
CurrentTutorial - > HandleTutorialStageStarted ( CurrentTutorial - > Stages [ CurrentTutorialStage ] . Name ) ;
}
2014-08-05 09:04:35 -04:00
}
2014-10-15 09:37:16 -04:00
for ( auto & TutorialWidget : TutorialWidgets )
{
if ( TutorialWidget . Value . IsValid ( ) )
{
TSharedPtr < SEditorTutorials > PinnedTutorialWidget = TutorialWidget . Value . Pin ( ) ;
PinnedTutorialWidget - > RebuildCurrentContent ( ) ;
}
}
2014-08-05 09:04:35 -04:00
}
2014-09-18 08:10:29 -04:00
void STutorialRoot : : HandleCloseClicked ( )
{
2014-10-15 09:37:16 -04:00
if ( CurrentTutorial ! = nullptr )
{
CurrentTutorial - > HandleTutorialClosed ( ) ;
2014-11-10 09:44:22 -05:00
// Update the current stage when we close
bool bHaveSeenTutorial = false ;
CurrentTutorialStage = GetDefault < UTutorialStateSettings > ( ) - > GetProgress ( CurrentTutorial , bHaveSeenTutorial ) ;
GetMutableDefault < UTutorialStateSettings > ( ) - > RecordProgress ( CurrentTutorial , CurrentTutorialStage ) ;
GetMutableDefault < UTutorialStateSettings > ( ) - > SaveProgress ( ) ;
2014-10-15 09:37:16 -04:00
}
2014-09-18 08:10:29 -04:00
// submit analytics data
if ( FEngineAnalytics : : IsAvailable ( ) & & CurrentTutorial ! = nullptr & & CurrentTutorialStage < CurrentTutorial - > Stages . Num ( ) )
{
UEditorTutorial * AttractTutorial = nullptr ;
UEditorTutorial * LaunchTutorial = nullptr ;
FString BrowserFilter ;
GetDefault < UEditorTutorialSettings > ( ) - > FindTutorialInfoForContext ( TEXT ( " LevelEditor " ) , AttractTutorial , LaunchTutorial , BrowserFilter ) ;
// prepare and send analytics data
bool const bClosedInitialAttract = ( CurrentTutorial = = AttractTutorial ) ;
FString const CurrentExcerptTitle = bClosedInitialAttract ? TEXT ( " InitialAttract " ) : CurrentTutorial - > Stages [ CurrentTutorialStage ] . Name . ToString ( ) ;
int32 const CurrentExcerptIndex = bClosedInitialAttract ? - 1 : CurrentTutorialStage ;
float const CurrentPageElapsedTime = bClosedInitialAttract ? 0.f : ( float ) ( FPlatformTime : : Seconds ( ) - CurrentTutorialStartTime ) ;
TArray < FAnalyticsEventAttribute > EventAttributes ;
EventAttributes . Add ( FAnalyticsEventAttribute ( TEXT ( " LastStageIndex " ) , CurrentExcerptIndex ) ) ;
EventAttributes . Add ( FAnalyticsEventAttribute ( TEXT ( " LastStageTitle " ) , CurrentExcerptTitle ) ) ;
EventAttributes . Add ( FAnalyticsEventAttribute ( TEXT ( " TimeSpentInTutorial " ) , CurrentPageElapsedTime ) ) ;
2014-12-05 05:33:09 -05:00
EventAttributes . Add ( FAnalyticsEventAttribute ( TEXT ( " TutorialAsset " ) , FIntroTutorials : : AnalyticsEventNameFromTutorial ( CurrentTutorial ) ) ) ;
2014-09-18 08:10:29 -04:00
2014-12-05 05:33:09 -05:00
FEngineAnalytics : : GetProvider ( ) . RecordEvent ( TEXT ( " Rocket.Tutorials.Closed " ) , EventAttributes ) ;
2014-09-18 08:10:29 -04:00
}
2015-01-30 11:04:45 -05:00
//Tutorial is no longer current
CurrentTutorial = nullptr ;
2014-09-18 08:10:29 -04:00
}
2014-09-22 09:42:52 -04:00
bool STutorialRoot : : WasWidgetDrawn ( const FName & InName ) const
{
for ( const auto & WidgetName : PreviouslyDrawnWidgets )
{
if ( InName = = WidgetName )
{
return true ;
}
}
return false ;
}
void STutorialRoot : : WidgetWasDrawn ( const FName & InName )
{
DrawnWidgets . Add ( InName ) ;
}
2014-08-05 09:04:35 -04:00
# undef LOCTEXT_NAMESPACE