You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Tutorial contexts for IOS/Android/Whatever are now hooked up (console setup ones are still missing). Analytics added for tutorial usage in various places. Added ability to reset tutorial state with -ResetTutorials command-line flag. Cleaned up some unused code (still a lot more to come here!). [CL 2302314 by Thomas Sarkanen in Main branch]
128 lines
3.2 KiB
C++
128 lines
3.2 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "IntroTutorialsPrivatePCH.h"
|
|
#include "TutorialStateSettings.h"
|
|
|
|
UTutorialStateSettings::UTutorialStateSettings(const class FPostConstructInitializeProperties& PCIP)
|
|
: Super(PCIP)
|
|
{
|
|
|
|
}
|
|
|
|
void UTutorialStateSettings::PostInitProperties()
|
|
{
|
|
Super::PostInitProperties();
|
|
|
|
for(const auto& Progress : TutorialsProgress)
|
|
{
|
|
TSubclassOf<UEditorTutorial> TutorialClass = LoadClass<UEditorTutorial>(NULL, *Progress.Tutorial.AssetLongPathname, NULL, LOAD_None, NULL);
|
|
if(TutorialClass != nullptr)
|
|
{
|
|
UEditorTutorial* Tutorial = TutorialClass->GetDefaultObject<UEditorTutorial>();
|
|
ProgressMap.Add(Tutorial, Progress);
|
|
}
|
|
}
|
|
}
|
|
|
|
int32 UTutorialStateSettings::GetProgress(UEditorTutorial* InTutorial, bool& bOutHaveSeenTutorial) const
|
|
{
|
|
const FTutorialProgress* FoundProgress = ProgressMap.Find(InTutorial);
|
|
if(FoundProgress != nullptr)
|
|
{
|
|
bOutHaveSeenTutorial = true;
|
|
return FoundProgress->CurrentStage;
|
|
}
|
|
|
|
bOutHaveSeenTutorial = false;
|
|
return 0;
|
|
}
|
|
|
|
bool UTutorialStateSettings::HaveSeenTutorial(UEditorTutorial* InTutorial) const
|
|
{
|
|
return ProgressMap.Find(InTutorial) != nullptr;
|
|
}
|
|
|
|
bool UTutorialStateSettings::HaveCompletedTutorial(UEditorTutorial* InTutorial) const
|
|
{
|
|
const FTutorialProgress* FoundProgress = ProgressMap.Find(InTutorial);
|
|
if (FoundProgress != nullptr)
|
|
{
|
|
return FoundProgress->CurrentStage >= InTutorial->Stages.Num() - 1;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void UTutorialStateSettings::RecordProgress(UEditorTutorial* InTutorial, int32 CurrentStage)
|
|
{
|
|
if(InTutorial != nullptr)
|
|
{
|
|
FTutorialProgress* FoundProgress = ProgressMap.Find(InTutorial);
|
|
if(FoundProgress != nullptr)
|
|
{
|
|
FoundProgress->CurrentStage = FMath::Max(FoundProgress->CurrentStage, CurrentStage);
|
|
}
|
|
else
|
|
{
|
|
FTutorialProgress Progress;
|
|
Progress.Tutorial = FStringClassReference(InTutorial->GetClass());
|
|
Progress.CurrentStage = CurrentStage;
|
|
Progress.bUserDismissed = false;
|
|
Progress.bUserDismissedThisSession = false;
|
|
|
|
ProgressMap.Add(InTutorial, Progress);
|
|
}
|
|
}
|
|
}
|
|
|
|
void UTutorialStateSettings::DismissTutorial(UEditorTutorial* InTutorial, bool bDismissAcrossSessions)
|
|
{
|
|
if (InTutorial != nullptr)
|
|
{
|
|
FTutorialProgress* FoundProgress = ProgressMap.Find(InTutorial);
|
|
if (FoundProgress != nullptr)
|
|
{
|
|
FoundProgress->bUserDismissed = bDismissAcrossSessions;
|
|
FoundProgress->bUserDismissedThisSession = true;
|
|
}
|
|
else
|
|
{
|
|
FTutorialProgress Progress;
|
|
Progress.Tutorial = FStringClassReference(InTutorial->GetClass());
|
|
Progress.CurrentStage = 0;
|
|
Progress.bUserDismissed = bDismissAcrossSessions;
|
|
Progress.bUserDismissedThisSession = true;
|
|
|
|
ProgressMap.Add(InTutorial, Progress);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool UTutorialStateSettings::IsTutorialDismissed(UEditorTutorial* InTutorial) const
|
|
{
|
|
const FTutorialProgress* FoundProgress = ProgressMap.Find(InTutorial);
|
|
if (FoundProgress != nullptr)
|
|
{
|
|
return FoundProgress->bUserDismissed || FoundProgress->bUserDismissedThisSession;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void UTutorialStateSettings::SaveProgress()
|
|
{
|
|
TutorialsProgress.Empty();
|
|
|
|
for(const auto& ProgressMapEntry : ProgressMap)
|
|
{
|
|
TutorialsProgress.Add(ProgressMapEntry.Value);
|
|
}
|
|
|
|
SaveConfig();
|
|
}
|
|
|
|
void UTutorialStateSettings::ClearProgress()
|
|
{
|
|
ProgressMap.Empty();
|
|
TutorialsProgress.Empty();
|
|
|
|
SaveConfig();
|
|
} |