You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
========================== MAJOR FEATURES + CHANGES ========================== Change 2946506 on 2016/04/18 by Steven.Hutton Update to Crash Reporter buggs table to add new search fields and inclusion of packages needed for e-mail reports. Change 3017807 on 2016/06/17 by Chris.Wood Improved Crash Report Process folder delete code as it could sometimes fail. [UE-30349] - Crash Report Process is leaving crashes in the landing zone that build up and block the queue Also added logging to Slack when stop request received instead of just when stop is complete. Change 3019367 on 2016/06/20 by Chris.Wood Improve Crash Report Process logging to track bad reads from S3. Also, better logging when CleanReport fails to delete folders. Change 3019376 on 2016/06/20 by Steve.Robb Clarification of assert message and comments which talk about 'null' TFunctions. Tidy-up of dead code. Change 3019409 on 2016/06/20 by Steve.Robb New Find and FindByPredicate algorithms for finding stuff in arbitrary containers. Change 3022658 on 2016/06/22 by Chris.Wood Discarding duplicated crash reports earlier in read from Data Router process to avoid clashes in the landing zone (CRP v1.1.11) [UE-30349] - Crash Report Process is leaving crashes in the landing zone that build up and block the queue Also improved logging to Slack with better layout, fixed event ordering and counting duplicates. Change 3022840 on 2016/06/22 by Steve.Robb Skipped UHT attributes removed. Change 3022907 on 2016/06/22 by Robert.Manuszewski Fixing crash when adding a new C++ class to project #jira UE-32333 Change 3023169 on 2016/06/22 by Steve.Robb Checks for UTHINGs in skipped preprocessor blocks. Fixes for skipped UTHINGs and some other parsing accidents. #jira UE-31627 Change 3023239 on 2016/06/22 by Steve.Robb Fix for JSON date parsing reported here: https://udn.unrealengine.com/questions/299342/fdatetime-json-serialization-bug.html Change 3026812 on 2016/06/24 by Mieszko.Zielinski Marked FEnvQueryInstance::AddItemData UEnvQueryItemType_Point specialization as AIMODULE_API #UE4 Change3028235on 2016/06/27 by Robert.Manuszewski PR #2535: BUGFIX: FPS pop-up updates when loading new stat file (Contributed by projectgheist) Change 3028282 on 2016/06/27 by Steve.Robb Fix for missing UFUNCTION check in skipped preprocessor blocks. #jira UE-31627 Change 3028284 on 2016/06/27 by Steve.Robb Debuggability improvements and coding standards changes. Change 3028343 on 2016/06/27 by Steve.Robb Fix for UHT error in WEX. #jira UE-32464 Change 3028393 on 2016/06/27 by Steve.Robb Fix for hot reload of enums finding the old enum. Fix to stop SPropertyEditorNumeric caching the enum flags. #jira UE-31658 Change 3030362 on 2016/06/28 by Robert.Manuszewski Fixing hang when cooking. Change 3030462 on 2016/06/28 by Steve.Robb Assert added to PackageTools::GetFilteredPackageList() to help with catching a bug reported in the wild. #jira UE-32001 Change 3034341 on 2016/06/30 by Robert.Manuszewski Modified crash handling code (on Windows) to handle two threads crashing at the same time properly. Previously the second crash would force the process to exit before generating the crash report. Added 'debug twothreadsgpf' command to test the functionality. Change 3034342 on 2016/06/30 by John.Mahoney Fix for crash when loading an empty cached asset registry. #jira UE-32232 Change 3035599 on 2016/07/01 by Chris.Wood Added support for CrashType string to Crash Report Process. CRP v1.1.12 [UE-30592] - Crash Reporter should determine crash type on client and pass string to server Also fixes problem with reports falling back on the legacy WER metadata when a crash context exists. They now only read the error message from metadata if available and keep crash context data when possible. Added in missing crash context parameters that have been added to clients but not known by the server. Change 3035787 on 2016/07/01 by John.Mahoney Fix for crash when DuplicateRedirects does not contain the DependentObject when saving dependencies. It will still fall through to the assertion below, but it will now fail with a useful error message instead of a generic 'Pair != nullptr' from Map.h. #jira UE-30189 Change 3036933 on 2016/07/04 by Steve.Robb Proper forwarding constructor for FAsyncTask. Change 3036938 on 2016/07/04 by Steve.Robb Fix for CDO hot reload corrupting memory when replacing references inside structs. #jira UE-29335 Change 3036960 on 2016/07/04 by Steve.Robb Fix for FAnsiAllocator::ResizeAllocation when resizing to zero. Change 3037423 on 2016/07/05 by Steve.Robb FModuleManager::UnloadOrAbandonModuleWithCallback split into two instead of switching behavior with a bool. Change 3037464 on 2016/07/05 by Steve.Robb HotReload.cpp cleanup: Deep nesting flattened. Linear array searches replaced with maps. FHotReloadModule::GetGameModules made into a non-member function and split into two. Comment and coding standard fixes. Change 3037741 on 2016/07/05 by John.Mahoney Fix for COTF not checking the correct timestamps on startup. #jira UE-31023 Change3037846on 2016/07/05 by Steve.Robb Fix for compile button disappearing on a bad compile. #jira UE-31575 Change 3037994 on 2016/07/05 by Steve.Robb Static analysis fixes: warning C6308: 'realloc' might return null pointer: assigning null pointer to 'Data', which is passed as an argument to 'realloc', will cause the original memory block to be leaked. Change 3039186 on 2016/07/06 by Robert.Manuszewski Enabling crash callstack logging by default. Change 3039220 on 2016/07/06 by Steve.Robb Static analysis fixes: warning C28159: Consider using 'InitiateSystemShutdownEx' instead of 'ExitWindowsEx'. Reason: Legacy API. Rearchitect to avoid Reboot warning C6001: Using uninitialized memory 'UserNameLength' warning C6001: Using uninitialized memory 'DomainNameLength' Change 3039230 on 2016/07/06 by Steve.Robb Fix for VC internal compiler errors. Change 3039237 on 2016/07/06 by Steve.Robb Static analysis fix: warning C6385: Reading invalid data from 'Path': the readable size is '400' bytes, but 'PathCurrentDepth' bytes may be read. Change 3039287 on 2016/07/06 by Steve.Robb Static analysis fixes: warning C6509: Invalid annotation: 'return' cannot be referenced in some contexts warning C6101: Returning uninitialized memory '*lpdwExitCode'. A successful path through the function does not set the named _Out_ parameter. warning C6387: '_Param_(1)' could be '0': this does not adhere to the specification for the function 'IMoniker::BindToStorage'. warning C6387: '_Param_(1)' could be '0': this does not adhere to the specification for the function 'IMoniker::BindToObject'. warning C6031: Return value ignored: 'CoCreateInstance'. Change 3039359 on 2016/07/06 by Graeme.Thornton Compile error fix for FAsyncTask, courtesy of SteveR Change 3039534 on 2016/07/06 by Steve.Robb Static analysis fix: warning C6319: Use of the comma-operator in a tested expression causes the left argument to be ignored when it has no side-effects. Change 3039545 on 2016/07/06 by Steve.Robb Static analysis fix: warning C6297: Arithmetic overflow: 32-bit value is shifted, then cast to 64-bit value. Results might not be an expected value. Change 3039578 on 2016/07/06 by Steve.Robb Static analysis fix: warning C6263: Using _alloca in a loop: this can quickly overflow stack. Change 3039623 on 2016/07/06 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'X' warning C6308:'realloc' might return null pointer: assigning null pointer to 'X', which is passed as an argument to 'realloc', will cause the original memory block to be leaked. warning C6385: Reading invalid data from 'X': the readable size is 'Y' bytes, but 'Z' bytes may be read. warning C6386: Buffer overrun while writing to 'X': the writable size is 'Y' bytes, but 'Z' bytes might be written. warning C28182: Dereferencing NULL pointer. 'X' contains the same NULL value as 'Y' did. Change 3039630 on 2016/07/06 by John.Mahoney Fix for crash when spawning an actor using a template object that has instance components. UActorComponent::PostInitProperties was adding itself to the owner's InstanceComponents array, resulting in a realloc of that array and invalidating the reference that the owner's ObjectInitializer was trying to replace while instantiating that property. The new instance component will be added to the array as part of the owner's initialization anyway, so it is not necessary to do it here. #jira UE-29123 Change 3039664 on 2016/07/06 by Steve.Robb Static analysis fixes: warning C6386: Buffer overrun while writing to 'NewKeys': the writable size is 'NewIndexSize*4' bytes, but '8' bytes might be written. warning C6386: Buffer overrun while writing to 'NewHeapIndexes': the writable size is 'NewIndexSize*4' bytes, but '8' bytes might be written. Change 3039673 on 2016/07/06 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'v'. Change 3039690 on 2016/07/06 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'X'. warning C6246: Local declaration of 'X' hides declaration of the same name in outer scope. warning C6262: Function uses '121180' bytes of stack: exceeds /analyze:stacksize '81940'. Consider moving some data to heap. warning C6263: Using _alloca in a loop: this can quickly overflow stack. Change 3040868 on 2016/07/07 by Graeme.Thornton Config based class stripping for server builds Change 3040872 on 2016/07/07 by Graeme.Thornton Remove "return false" NeedsLoadForServer functions from engine code Change3040997on 2016/07/07 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'Landscape'. warning C6011: Dereferencing NULL pointer 'rhs.Allocation.LayerInfo'. warning C6011: Dereferencing NULL pointer 'lhs.Allocation.LayerInfo'. Change 3041004 on 2016/07/07 by Steve.Robb Static analysis fix: warning C6336: Arithmetic operator has precedence over question operator, use parentheses to clarify intent. Change 3041014 on 2016/07/07 by Steve.Robb Static analysis fix: warning C6287: Redundant code: the left and right sub-expressions are identical. Change 3041111 on 2016/07/07 by Steve.Robb Removal of an obsolete error message about INI file case sensitivity. Change 3041150 on 2016/07/07 by Steve.Robb Static analysis fix: warning C6289: Incorrect operator: mutual exclusion over || is always a non-zero constant. Did you intend to use && instead? Change 3041274 on 2016/07/07 by Steve.Robb Static analysis fixes: warning C6001: Using uninitialized memory 'X'. Change 3041294 on 2016/07/07 by Chris.Wood Fixed protocol buffer and decompression errors in Crash Report Process (v.1.1.14) [UE-32151] - High number of crashes read from S3 by Crash Report Process are failing to unpack Size of buffer received from S3 is incorrect for some records. Fixed read problems by using size header value instead of stream length. Increased buffer size for decompression as this was sometimes too small. Modified S3 reading code to look for multiple records in each downloaded file. Change 3041472 on 2016/07/07 by Steve.Robb Static analysis fixes: warning C6294: Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed. warning C6201: Index '1' is out of valid index range '0' to '0' for possibly stack allocated buffer 'NewHistory.Nodes'. Change 3043074 on 2016/07/08 by John.Mahoney Fix for COTF incorrectly reconstructing the original asset path based on the sandbox path when the game name differs from the game folder name. Fix for COTF GetFiles not handling absolute GameDir paths properly. #jira UE-31023 Change 3044461 on 2016/07/11 by Steve.Robb Static analysis fix: warning C6386: Buffer overrun while writing to 'Attributes': the writable size is '16384' bytes, but '-8' bytes might be written. Change 3044470 on 2016/07/11 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Node.Sequence'. Change 3044476 on 2016/07/11 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Property'. Change 3044551 on 2016/07/11 by Steve.Robb Static analysis fix: warning C28182: Dereferencing NULL pointer. 'Node' contains the same NULL value as 'KeyAreaNode' did. Change 3044664 on 2016/07/11 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'ToLandscape->SplineComponent'. warning C28182: Dereferencing NULL pointer. 'SplinesComponent' contains the same NULL value as 'Landscape->SplineComponent' did. warning C6011: Dereferencing NULL pointer 'Landscape->SplineComponent'. warning C6385: Reading invalid data from 'out': the readable size is 'sizeof(kiss_fft_cpx)*Dims[0]*Dims[1]' bytes, but '16' bytes may be read. Change 3044716 on 2016/07/11 by Steve.Robb Static analysis fix: warning C6385: Reading invalid data from 'this->ScreenSize': the readable size is '32' bytes, but '-4' bytes may be read. Change 3044717 on 2016/07/11 by Steve.Robb Static analysis fix: warning C28182: Dereferencing NULL pointer. 'Window' contains the same NULL value as 'ElementType * Window=AllWindows.FindByPredicate((*FStaticMeshEditorTest::RunTest::<lambda_46fd0093f3912289e870263afe1fcb2e>(ExpectedTitle)))' did. This appears to be a false positive. Change 3044787 on 2016/07/11 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'FbxObject'. warning C28182: Dereferencing NULL pointer. 'Node' contains the same NULL value as 'RigidMeshNode' did. warning C28182: Dereferencing NULL pointer. 'Node' contains the same NULL value as 'Result' did. Change 3045933 on 2016/07/12 by Steve.Robb Overloading support for TSharedPtr, TSharedRef and TWeakPtr. Change 3045960 on 2016/07/12 by Robert.Manuszewski Fixing a crash in Portal (and any other program that uses UObjects and GCs, with the exception of UHT) caused by classes not having their token stream assembled. Change 3045963 on 2016/07/12 by Steve.Robb PLATFORM_COMPILER_HAS_EXPLICIT_OPERATORS, FORCEINLINE_EXPLICIT_OPERATOR_BOOL and SAFE_BOOL_OPERATORS macros removed. THasOperatorEquals and THasOperatorNotEquals traits moved to their own header. Change3045967on 2016/07/12 by Steve.Robb Initializer list support for TArray and TSet. Change 3045968 on 2016/07/12 by Robert.Manuszewski Fixing an ensure after typing 'stat dumphitches' in console. Change 3045992 on 2016/07/12 by Robert.Manuszewski Making sure CoreUObject headers are included for programs that don't include the engine (fixing MinidumpDiagnostics CIS failure) Change 3047870 on 2016/07/13 by Steven.Hutton Updated CRW to entity framework with repository models. #rb none Change 3047871 on 2016/07/13 by Steven.Hutton Add repository models #rb none Change 3049468 on 2016/07/14 by Steven.Hutton Fix broken project files. #rb none #lockdown Nick.Penwarden [CL 3050320 by Robert Manuszewski in Main branch]
1080 lines
32 KiB
C++
1080 lines
32 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "IntroTutorialsPrivatePCH.h"
|
|
#include "STutorialsBrowser.h"
|
|
#include "EditorTutorial.h"
|
|
#include "STutorialContent.h"
|
|
#include "TutorialSettings.h"
|
|
#include "EditorTutorialSettings.h"
|
|
#include "TutorialStateSettings.h"
|
|
#include "AssetRegistryModule.h"
|
|
#include "EngineAnalytics.h"
|
|
#include "Runtime/Analytics/Analytics/Public/Interfaces/IAnalyticsProvider.h"
|
|
#include "SSearchBox.h"
|
|
#include "SBreadcrumbTrail.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "TutorialsBrowser"
|
|
|
|
class FTutorialListEntry_Tutorial;
|
|
|
|
DECLARE_DELEGATE_OneParam(FOnCategorySelected, const FString& /* InCategory */);
|
|
|
|
namespace TutorialBrowserConstants
|
|
{
|
|
const float RefreshTimerInterval = 1.0f;
|
|
|
|
const float ProgressUpdateInterval = 0.5f;
|
|
}
|
|
|
|
class FTutorialListEntry_Category : public ITutorialListEntry, public TSharedFromThis<FTutorialListEntry_Category>
|
|
{
|
|
public:
|
|
FTutorialListEntry_Category(FOnCategorySelected InOnCategorySelected)
|
|
: OnCategorySelected(InOnCategorySelected)
|
|
, SlateBrush(nullptr)
|
|
{}
|
|
|
|
FTutorialListEntry_Category(const FTutorialCategory& InCategory, FOnCategorySelected InOnCategorySelected, const TAttribute<FText>& InHighlightText)
|
|
: Category(InCategory)
|
|
, OnCategorySelected(InOnCategorySelected)
|
|
, HighlightText(InHighlightText)
|
|
, SlateBrush(nullptr)
|
|
{
|
|
if(!Category.Identifier.IsEmpty())
|
|
{
|
|
int32 Index = INDEX_NONE;
|
|
if(Category.Identifier.FindLastChar(TEXT('.'), Index))
|
|
{
|
|
CategoryName = Category.Identifier.RightChop(Index + 1);
|
|
}
|
|
else
|
|
{
|
|
CategoryName = Category.Identifier;
|
|
}
|
|
}
|
|
|
|
if(Category.Texture.IsValid())
|
|
{
|
|
UTexture2D* Texture = LoadObject<UTexture2D>(nullptr, *Category.Texture.ToString());
|
|
if(Texture != nullptr)
|
|
{
|
|
FIntPoint TextureSize = Texture->GetImportedSize();
|
|
DynamicBrush = MakeShareable(new FSlateDynamicImageBrush(Texture, FVector2D((float)TextureSize.X, (float)TextureSize.Y), NAME_None));
|
|
SlateBrush = DynamicBrush.Get();
|
|
}
|
|
}
|
|
|
|
if(SlateBrush == nullptr)
|
|
{
|
|
if(Category.Icon.Len() > 0)
|
|
{
|
|
SlateBrush = FEditorStyle::Get().GetBrush(FName(*Category.Icon));
|
|
}
|
|
}
|
|
|
|
if(SlateBrush == nullptr)
|
|
{
|
|
SlateBrush = FEditorStyle::Get().GetBrush("Tutorials.Browser.DefaultTutorialIcon");
|
|
}
|
|
}
|
|
|
|
virtual ~FTutorialListEntry_Category()
|
|
{
|
|
if( DynamicBrush.IsValid() )
|
|
{
|
|
DynamicBrush->ReleaseResource();
|
|
}
|
|
}
|
|
|
|
virtual TSharedRef<ITableRow> OnGenerateTutorialRow(const TSharedRef<STableViewBase>& OwnerTable) const override
|
|
{
|
|
return SNew(STableRow<TSharedPtr<ITutorialListEntry>>, OwnerTable)
|
|
[
|
|
SNew(SBox)
|
|
.Padding(FMargin(0.0f, 2.0f))
|
|
[
|
|
SNew(SButton)
|
|
.OnClicked(this, &FTutorialListEntry_Category::OnClicked)
|
|
.ButtonStyle(&FEditorStyle::Get().GetWidgetStyle<FButtonStyle>("Tutorials.Browser.Button"))
|
|
.ForegroundColor(FSlateColor::UseForeground())
|
|
.Content()
|
|
[
|
|
SNew(SHorizontalBox)
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
.VAlign(VAlign_Center)
|
|
.HAlign(HAlign_Center)
|
|
.Padding(8.0f)
|
|
[
|
|
SNew(SOverlay)
|
|
+ SOverlay::Slot()
|
|
[
|
|
SNew(SBox)
|
|
.WidthOverride(64.0f)
|
|
.HeightOverride(64.0f)
|
|
.VAlign(VAlign_Center)
|
|
.HAlign(HAlign_Center)
|
|
[
|
|
SNew(SImage)
|
|
.Image(SlateBrush)
|
|
]
|
|
]
|
|
+ SOverlay::Slot()
|
|
.VAlign(VAlign_Bottom)
|
|
.HAlign(HAlign_Right)
|
|
[
|
|
SNew(SImage)
|
|
.ToolTipText(LOCTEXT("CompletedCategoryCheckToolTip", "This category has been completed"))
|
|
.Visibility(this, &FTutorialListEntry_Category::GetCompletedVisibility)
|
|
.Image(FEditorStyle::Get().GetBrush("Tutorials.Browser.Completed"))
|
|
]
|
|
]
|
|
+ SHorizontalBox::Slot()
|
|
.FillWidth(1.0f)
|
|
.VAlign(VAlign_Center)
|
|
[
|
|
SNew(SVerticalBox)
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
[
|
|
SNew(STextBlock)
|
|
.Text(!Category.Title.IsEmpty() ? Category.Title : FText::FromString(CategoryName))
|
|
.TextStyle(&FEditorStyle::Get().GetWidgetStyle<FTextBlockStyle>("Tutorials.Browser.SummaryHeader"))
|
|
.HighlightText(HighlightText)
|
|
.HighlightColor(FEditorStyle::Get().GetColor("Tutorials.Browser.HighlightTextColor"))
|
|
.HighlightShape(FEditorStyle::Get().GetBrush("TextBlock.HighlightShape"))
|
|
]
|
|
+SVerticalBox::Slot()
|
|
.FillHeight(1.0f)
|
|
[
|
|
SNew(STextBlock)
|
|
.AutoWrapText(true)
|
|
.Text(Category.Description)
|
|
.TextStyle(&FEditorStyle::Get().GetWidgetStyle<FTextBlockStyle>("Tutorials.Browser.SummaryText"))
|
|
.HighlightText(HighlightText)
|
|
.HighlightColor(FEditorStyle::Get().GetColor("Tutorials.Browser.HighlightTextColor"))
|
|
.HighlightShape(FEditorStyle::Get().GetBrush("TextBlock.HighlightShape"))
|
|
]
|
|
]
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
.HAlign(HAlign_Right)
|
|
.VAlign(VAlign_Center)
|
|
[
|
|
SNew(SImage)
|
|
.Visibility(this, &FTutorialListEntry_Category::OnGetArrowVisibility)
|
|
.Image(FEditorStyle::Get().GetBrush("Tutorials.Browser.CategoryArrow"))
|
|
]
|
|
]
|
|
]
|
|
];
|
|
}
|
|
|
|
bool PassesFilter(const FString& InCategoryFilter, const FString& InFilter) const override
|
|
{
|
|
const FString Title = !Category.Title.IsEmpty() ? Category.Title.ToString() : CategoryName;
|
|
const bool bPassesFilter = InFilter.IsEmpty() || (Title.Contains(InFilter) || Category.Description.ToString().Contains(InFilter));
|
|
const bool bPassesCategory = InCategoryFilter.IsEmpty() || Category.Identifier.StartsWith(InCategoryFilter);
|
|
return bPassesFilter && bPassesCategory;
|
|
}
|
|
|
|
FString GetTitleString() const override
|
|
{
|
|
const FString Title = !Category.Title.IsEmpty() ? Category.Title.ToString() : CategoryName;
|
|
return Title;
|
|
}
|
|
|
|
int32 GetSortOrder() const override
|
|
{
|
|
return Category.SortOrder;
|
|
}
|
|
|
|
FText GetTitleText() const override
|
|
{
|
|
return !Category.Title.IsEmpty() ? Category.Title : FText::FromString(CategoryName);
|
|
}
|
|
|
|
bool SortAgainst(TSharedRef<ITutorialListEntry> OtherEntry) const override
|
|
{
|
|
return (GetSortOrder() == OtherEntry->GetSortOrder()) ? (GetTitleString() > OtherEntry->GetTitleString()) : (GetSortOrder() < OtherEntry->GetSortOrder());
|
|
}
|
|
|
|
void AddSubCategory(TSharedPtr<FTutorialListEntry_Category> InSubCategory)
|
|
{
|
|
SubCategories.Add(InSubCategory);
|
|
}
|
|
|
|
void AddTutorial(TSharedPtr<FTutorialListEntry_Tutorial> InTutorial);
|
|
|
|
FReply OnClicked() const
|
|
{
|
|
if(SubCategories.Num() > 0 || Tutorials.Num() > 0)
|
|
{
|
|
OnCategorySelected.ExecuteIfBound(Category.Identifier);
|
|
}
|
|
return FReply::Handled();
|
|
}
|
|
|
|
EVisibility OnGetArrowVisibility() const
|
|
{
|
|
return (SubCategories.Num() > 0 || Tutorials.Num() > 0) ? EVisibility::Visible : EVisibility::Collapsed;
|
|
}
|
|
|
|
EVisibility GetCompletedVisibility() const override
|
|
{
|
|
for (int32 i = 0; i < Tutorials.Num(); ++i)
|
|
{
|
|
if (Tutorials[i].IsValid() && (Tutorials[i]->GetCompletedVisibility() != EVisibility::Visible))
|
|
{
|
|
return EVisibility::Hidden;
|
|
}
|
|
}
|
|
for (int32 i = 0; i < SubCategories.Num(); ++i)
|
|
{
|
|
if (SubCategories[i].IsValid() && (SubCategories[i]->GetCompletedVisibility() != EVisibility::Visible))
|
|
{
|
|
return EVisibility::Hidden;
|
|
}
|
|
}
|
|
return EVisibility::Visible;
|
|
}
|
|
|
|
public:
|
|
/** Copy of the category info */
|
|
FTutorialCategory Category;
|
|
|
|
/** Parent category */
|
|
TWeakPtr<ITutorialListEntry> ParentCategory;
|
|
|
|
/** Sub-categories */
|
|
TArray<TSharedPtr<ITutorialListEntry>> SubCategories;
|
|
|
|
/** Tutorials in this category */
|
|
TArray<TSharedPtr<ITutorialListEntry>> Tutorials;
|
|
|
|
/** Selection delegate */
|
|
FOnCategorySelected OnCategorySelected;
|
|
|
|
/** Name of the category, empty if this category is at the root */
|
|
FString CategoryName;
|
|
|
|
/** Text to highlight */
|
|
TAttribute<FText> HighlightText;
|
|
|
|
/** Static brush from the editor style */
|
|
const FSlateBrush* SlateBrush;
|
|
|
|
/** Dynamic brush from the texture specified by the user */
|
|
TSharedPtr<FSlateDynamicImageBrush> DynamicBrush;
|
|
};
|
|
|
|
DECLARE_DELEGATE_TwoParams(FOnTutorialSelected, UEditorTutorial* /* InTutorial */, bool /* bRestart */ );
|
|
|
|
class FTutorialListEntry_Tutorial : public ITutorialListEntry, public TSharedFromThis<FTutorialListEntry_Tutorial>
|
|
{
|
|
public:
|
|
FTutorialListEntry_Tutorial(UEditorTutorial* InTutorial, FOnTutorialSelected InOnTutorialSelected, const TAttribute<FText>& InHighlightText)
|
|
: Tutorial(InTutorial)
|
|
, OnTutorialSelected(InOnTutorialSelected)
|
|
, HighlightText(InHighlightText)
|
|
, SlateBrush(nullptr)
|
|
, LastUpdateTime(0.0f)
|
|
{
|
|
if(Tutorial->Texture != nullptr)
|
|
{
|
|
FIntPoint TextureSize = Tutorial->Texture->GetImportedSize();
|
|
DynamicBrush = MakeShareable(new FSlateDynamicImageBrush(Tutorial->Texture, FVector2D((float)TextureSize.X, (float)TextureSize.Y), NAME_None));
|
|
SlateBrush = DynamicBrush.Get();
|
|
}
|
|
else if(Tutorial->Icon.Len() > 0)
|
|
{
|
|
SlateBrush = FEditorStyle::Get().GetBrush(FName(*Tutorial->Icon));
|
|
}
|
|
|
|
if(SlateBrush == nullptr)
|
|
{
|
|
SlateBrush = FEditorStyle::Get().GetBrush("Tutorials.Browser.DefaultTutorialIcon");
|
|
}
|
|
}
|
|
|
|
virtual ~FTutorialListEntry_Tutorial()
|
|
{
|
|
if( DynamicBrush.IsValid() )
|
|
{
|
|
DynamicBrush->ReleaseResource();
|
|
}
|
|
}
|
|
|
|
virtual TSharedRef<ITableRow> OnGenerateTutorialRow(const TSharedRef<STableViewBase>& OwnerTable) const override
|
|
{
|
|
CacheProgress();
|
|
|
|
return SNew(STableRow<TSharedPtr<ITutorialListEntry>>, OwnerTable)
|
|
[
|
|
SNew(SBox)
|
|
.Padding(FMargin(0.0f, 2.0f))
|
|
[
|
|
SAssignNew(LaunchButton, SButton)
|
|
.OnClicked(this, &FTutorialListEntry_Tutorial::OnClicked, false)
|
|
.ButtonStyle(&FEditorStyle::Get().GetWidgetStyle<FButtonStyle>("Tutorials.Browser.Button"))
|
|
.ForegroundColor(FSlateColor::UseForeground())
|
|
.Content()
|
|
[
|
|
SNew(SVerticalBox)
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
[
|
|
SNew(SHorizontalBox)
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
.VAlign(VAlign_Center)
|
|
.HAlign(HAlign_Center)
|
|
.Padding(8.0f)
|
|
[
|
|
SNew(SOverlay)
|
|
+SOverlay::Slot()
|
|
[
|
|
SNew(SBox)
|
|
.WidthOverride(64.0f)
|
|
.HeightOverride(64.0f)
|
|
.VAlign(VAlign_Center)
|
|
.HAlign(HAlign_Center)
|
|
[
|
|
SNew(SImage)
|
|
.Image(SlateBrush)
|
|
]
|
|
]
|
|
+SOverlay::Slot()
|
|
.VAlign(VAlign_Bottom)
|
|
.HAlign(HAlign_Right)
|
|
[
|
|
SNew(SImage)
|
|
.ToolTipText(LOCTEXT("CompletedTutorialCheckToolTip", "This tutorial has been completed"))
|
|
.Visibility(this, &FTutorialListEntry_Tutorial::GetCompletedVisibility)
|
|
.Image(FEditorStyle::Get().GetBrush("Tutorials.Browser.Completed"))
|
|
]
|
|
]
|
|
+SHorizontalBox::Slot()
|
|
.FillWidth(1.0f)
|
|
.HAlign(HAlign_Fill)
|
|
.VAlign(VAlign_Center)
|
|
[
|
|
SNew(SVerticalBox)
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
[
|
|
SNew(SHorizontalBox)
|
|
+SHorizontalBox::Slot()
|
|
.FillWidth(1.0f)
|
|
[
|
|
SNew(STextBlock)
|
|
.Text(Tutorial->Title)
|
|
.TextStyle(&FEditorStyle::Get().GetWidgetStyle<FTextBlockStyle>("Tutorials.Browser.SummaryHeader"))
|
|
.HighlightText(HighlightText)
|
|
.HighlightColor(FEditorStyle::Get().GetColor("Tutorials.Browser.HighlightTextColor"))
|
|
.HighlightShape(FEditorStyle::Get().GetBrush("TextBlock.HighlightShape"))
|
|
]
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
.VAlign(VAlign_Center)
|
|
[
|
|
SNew(SButton)
|
|
.ToolTipText(LOCTEXT("RestartButtonToolTip", "Start this tutorial from the beginning"))
|
|
.Visibility(this, &FTutorialListEntry_Tutorial::GetRestartVisibility)
|
|
.OnClicked(this, &FTutorialListEntry_Tutorial::OnClicked, true)
|
|
.ButtonStyle(&FEditorStyle::Get().GetWidgetStyle<FButtonStyle>("Tutorials.Browser.Button"))
|
|
.Content()
|
|
[
|
|
SNew(SImage)
|
|
.Image(FEditorStyle::GetBrush("Tutorials.Browser.RestartButton"))
|
|
]
|
|
]
|
|
]
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
[
|
|
SNew(SBox)
|
|
.Visibility(this, &FTutorialListEntry_Tutorial::GetProgressVisibility)
|
|
.HeightOverride(3.0f)
|
|
[
|
|
SNew(SProgressBar)
|
|
.Percent(this, &FTutorialListEntry_Tutorial::GetProgress)
|
|
]
|
|
]
|
|
+SVerticalBox::Slot()
|
|
.FillHeight(1.0f)
|
|
[
|
|
STutorialContent::GenerateContentWidget(Tutorial->SummaryContent, DocumentationPage, HighlightText)
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
];
|
|
}
|
|
|
|
bool PassesFilter(const FString& InCategoryFilter, const FString& InFilter) const override
|
|
{
|
|
const bool bPassesFilter = InFilter.IsEmpty() || (Tutorial->Title.ToString().Contains(InFilter) || Tutorial->SummaryContent.Text.ToString().Contains(InFilter));
|
|
const bool bPassesCategory = InCategoryFilter.IsEmpty() || Tutorial->Category.StartsWith(InCategoryFilter);
|
|
|
|
return bPassesFilter && bPassesCategory;
|
|
}
|
|
|
|
FText GetTitleText() const override
|
|
{
|
|
return Tutorial->Title;
|
|
}
|
|
|
|
FString GetTitleString() const override
|
|
{
|
|
return Tutorial->Title.ToString();
|
|
}
|
|
|
|
int32 GetSortOrder() const override
|
|
{
|
|
return Tutorial->SortOrder;
|
|
}
|
|
|
|
bool SortAgainst(TSharedRef<ITutorialListEntry> OtherEntry) const override
|
|
{
|
|
return (GetSortOrder() == OtherEntry->GetSortOrder()) ? (GetTitleString() > OtherEntry->GetTitleString()) : (GetSortOrder() < OtherEntry->GetSortOrder());
|
|
}
|
|
|
|
FReply OnClicked(bool bRestart) const
|
|
{
|
|
OnTutorialSelected.ExecuteIfBound(Tutorial, bRestart);
|
|
|
|
return FReply::Handled();
|
|
}
|
|
|
|
TOptional<float> GetProgress() const
|
|
{
|
|
CacheProgress();
|
|
return Progress;
|
|
}
|
|
|
|
EVisibility GetProgressVisibility() const
|
|
{
|
|
if(LaunchButton->IsHovered())
|
|
{
|
|
CacheProgress();
|
|
return LaunchButton->IsHovered() && bHaveSeenTutorial ? EVisibility::Visible : EVisibility::Hidden;
|
|
}
|
|
|
|
return EVisibility::Hidden;
|
|
}
|
|
|
|
EVisibility GetRestartVisibility() const
|
|
{
|
|
if(LaunchButton->IsHovered())
|
|
{
|
|
CacheProgress();
|
|
return LaunchButton->IsHovered() && bHaveSeenTutorial ? EVisibility::Visible : EVisibility::Collapsed;
|
|
}
|
|
|
|
return EVisibility::Collapsed;
|
|
}
|
|
|
|
EVisibility GetCompletedVisibility() const override
|
|
{
|
|
CacheProgress();
|
|
return bHaveCompletedTutorial ? EVisibility::Visible : EVisibility::Hidden;
|
|
}
|
|
|
|
void CacheProgress() const
|
|
{
|
|
if(FPlatformTime::Seconds() - LastUpdateTime > TutorialBrowserConstants::ProgressUpdateInterval)
|
|
{
|
|
bHaveCompletedTutorial = GetDefault<UTutorialStateSettings>()->HaveCompletedTutorial(Tutorial);
|
|
bHaveSeenTutorial = false;
|
|
const int32 CurrentStage = GetDefault<UTutorialStateSettings>()->GetProgress(Tutorial, bHaveSeenTutorial);
|
|
Progress = (Tutorial->Stages.Num() > 0) ? (float)(CurrentStage + 1) / (float)Tutorial->Stages.Num() : 0.0f;
|
|
|
|
LastUpdateTime = FPlatformTime::Seconds();
|
|
}
|
|
}
|
|
|
|
public:
|
|
/** Parent category */
|
|
TWeakPtr<ITutorialListEntry> ParentCategory;
|
|
|
|
/** Tutorial that we will launch */
|
|
UEditorTutorial* Tutorial;
|
|
|
|
/** Selection delegate */
|
|
FOnTutorialSelected OnTutorialSelected;
|
|
|
|
/** Text to highlight */
|
|
TAttribute<FText> HighlightText;
|
|
|
|
/** Button clicked to launch tutorial */
|
|
mutable TSharedPtr<SWidget> LaunchButton;
|
|
|
|
/** Documentation page reference to use if we are displaying a UDN doc */
|
|
mutable TSharedPtr<IDocumentationPage> DocumentationPage;
|
|
|
|
/** Static brush from the editor style */
|
|
const FSlateBrush* SlateBrush;
|
|
|
|
/** Dynamic brush from the texture specified by the user */
|
|
TSharedPtr<FSlateDynamicImageBrush> DynamicBrush;
|
|
|
|
/** Cached tutorial completion state */
|
|
mutable bool bHaveCompletedTutorial;
|
|
|
|
/** Cached tutorial seen state */
|
|
mutable bool bHaveSeenTutorial;
|
|
|
|
/** Cached tutorial progress */
|
|
mutable float Progress;
|
|
|
|
/** Last update time */
|
|
mutable float LastUpdateTime;
|
|
};
|
|
|
|
void STutorialsBrowser::Construct(const FArguments& InArgs)
|
|
{
|
|
bNeedsRefresh = false;
|
|
RefreshTimer = TutorialBrowserConstants::RefreshTimerInterval;
|
|
|
|
OnClosed = InArgs._OnClosed;
|
|
OnLaunchTutorial = InArgs._OnLaunchTutorial;
|
|
ParentWindow = InArgs._ParentWindow;
|
|
|
|
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
|
|
AssetRegistryModule.Get().OnAssetAdded().AddSP(this, &STutorialsBrowser::HandleAssetAdded);
|
|
|
|
RegisterActiveTimer( TutorialBrowserConstants::RefreshTimerInterval, FWidgetActiveTimerDelegate::CreateSP( this, &STutorialsBrowser::TriggerReloadTutorials ) );
|
|
|
|
ChildSlot
|
|
[
|
|
SNew(SVerticalBox)
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
[
|
|
SNew(SBorder)
|
|
.BorderImage(FEditorStyle::Get().GetBrush("ToolPanel.GroupBorder"))
|
|
.Padding(5.0f)
|
|
[
|
|
SNew(SHorizontalBox)
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
.VAlign(VAlign_Center)
|
|
[
|
|
SNew(SButton)
|
|
.OnClicked(this, &STutorialsBrowser::OnBackButtonClicked)
|
|
.IsEnabled(this, &STutorialsBrowser::IsBackButtonEnabled)
|
|
.ButtonStyle(&FEditorStyle::Get().GetWidgetStyle<FButtonStyle>("Tutorials.Browser.BackButton"))
|
|
.ForegroundColor(FSlateColor::UseForeground())
|
|
.Content()
|
|
[
|
|
SNew(SImage)
|
|
.Image(FEditorStyle::GetBrush("Tutorials.Browser.BackButton.Image"))
|
|
]
|
|
]
|
|
+SHorizontalBox::Slot()
|
|
.FillWidth(1.0f)
|
|
.VAlign(VAlign_Center)
|
|
.Padding(2.0f, 0.0f, 0.0f, 0.0f)
|
|
[
|
|
SNew(SVerticalBox)
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(0.0f, 1.0f)
|
|
[
|
|
SAssignNew(BreadcrumbTrail, SBreadcrumbTrail<TSharedPtr<ITutorialListEntry>>)
|
|
.ButtonContentPadding(FMargin(1.0f, 1.0f))
|
|
.DelimiterImage(FEditorStyle::GetBrush("Tutorials.Browser.Breadcrumb"))
|
|
.TextStyle(FEditorStyle::Get(), "Tutorials.Browser.PathText")
|
|
.ShowLeadingDelimiter( true )
|
|
.InvertTextColorOnHover( false )
|
|
.OnCrumbClicked(this, &STutorialsBrowser::OnBreadcrumbClicked)
|
|
]
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(0.0f, 1.0f)
|
|
[
|
|
SNew(SSearchBox)
|
|
.OnTextChanged(this, &STutorialsBrowser::OnSearchTextChanged)
|
|
]
|
|
]
|
|
]
|
|
]
|
|
+SVerticalBox::Slot()
|
|
.FillHeight(1.0f)
|
|
.Padding(0.0f, 3.0f, 0.0f, 0.0f)
|
|
[
|
|
SNew(SVerticalBox)
|
|
+SVerticalBox::Slot()
|
|
.FillHeight(1.0f)
|
|
[
|
|
SAssignNew(TutorialList, SListView<TSharedPtr<ITutorialListEntry>>)
|
|
.ItemHeight(128.0f)
|
|
.ListItemsSource(&FilteredEntries)
|
|
.OnGenerateRow(this, &STutorialsBrowser::OnGenerateTutorialRow)
|
|
.SelectionMode(ESelectionMode::None)
|
|
]
|
|
]
|
|
];
|
|
|
|
ReloadTutorials();
|
|
|
|
RebuildCrumbs();
|
|
}
|
|
|
|
inline void FTutorialListEntry_Category::AddTutorial(TSharedPtr<FTutorialListEntry_Tutorial> InTutorial)
|
|
{
|
|
Tutorials.Add(InTutorial);
|
|
}
|
|
|
|
EActiveTimerReturnType STutorialsBrowser::TriggerReloadTutorials( double InCurrentTime, float InDeltaTime )
|
|
{
|
|
if (bNeedsRefresh)
|
|
{
|
|
bNeedsRefresh = false;
|
|
ReloadTutorials();
|
|
}
|
|
|
|
return EActiveTimerReturnType::Continue;
|
|
}
|
|
|
|
void STutorialsBrowser::SetFilter(const FString& InFilter)
|
|
{
|
|
CategoryFilter = InFilter;
|
|
ReloadTutorials();
|
|
}
|
|
|
|
TSharedRef<ITableRow> STutorialsBrowser::OnGenerateTutorialRow(TSharedPtr<ITutorialListEntry> InItem, const TSharedRef<STableViewBase>& OwnerTable) const
|
|
{
|
|
return InItem->OnGenerateTutorialRow(OwnerTable);
|
|
}
|
|
|
|
TSharedPtr<FTutorialListEntry_Category> STutorialsBrowser::RebuildCategories()
|
|
{
|
|
TArray<TSharedPtr<FTutorialListEntry_Category>> Categories;
|
|
|
|
// add root category
|
|
TSharedPtr<FTutorialListEntry_Category> RootCategory = MakeShareable(new FTutorialListEntry_Category(FOnCategorySelected::CreateSP(this, &STutorialsBrowser::OnCategorySelected)));
|
|
Categories.Add(RootCategory);
|
|
|
|
// rebuild categories
|
|
for(const auto& TutorialCategory : GetDefault<UTutorialSettings>()->Categories)
|
|
{
|
|
Categories.Add(MakeShareable(new FTutorialListEntry_Category(TutorialCategory, FOnCategorySelected::CreateSP(this, &STutorialsBrowser::OnCategorySelected), TAttribute<FText>::Create(TAttribute<FText>::FGetter::CreateSP(this, &STutorialsBrowser::GetSearchText)))));
|
|
}
|
|
|
|
for(const auto& TutorialCategory : GetDefault<UEditorTutorialSettings>()->Categories)
|
|
{
|
|
Categories.Add(MakeShareable(new FTutorialListEntry_Category(TutorialCategory, FOnCategorySelected::CreateSP(this, &STutorialsBrowser::OnCategorySelected), TAttribute<FText>::Create(TAttribute<FText>::FGetter::CreateSP(this, &STutorialsBrowser::GetSearchText)))));
|
|
}
|
|
|
|
for(auto& Category : Categories)
|
|
{
|
|
// Figure out which base category this category belongs in
|
|
TSharedPtr<FTutorialListEntry_Category> ParentCategory = RootCategory;
|
|
const FString& CategoryPath = Category->Category.Identifier;
|
|
|
|
// We're expecting the category string to be in the "A.B.C" format. We'll split up the string here and form
|
|
// a proper hierarchy in the UI
|
|
TArray< FString > SplitCategories;
|
|
CategoryPath.ParseIntoArray( SplitCategories, TEXT( "." ), true /* bCullEmpty */ );
|
|
|
|
FString CurrentCategoryPath;
|
|
|
|
// Make sure all of the categories exist
|
|
for(const auto& SplitCategory : SplitCategories)
|
|
{
|
|
// Locate this category at the level we're at in the hierarchy
|
|
TSharedPtr<FTutorialListEntry_Category> FoundCategory = NULL;
|
|
TArray< TSharedPtr<ITutorialListEntry> >& TestCategoryList = ParentCategory.IsValid() ? ParentCategory->SubCategories : RootCategory->SubCategories;
|
|
for(auto& TestCategory : TestCategoryList)
|
|
{
|
|
if( StaticCastSharedPtr<FTutorialListEntry_Category>(TestCategory)->CategoryName == SplitCategory )
|
|
{
|
|
// Found it!
|
|
FoundCategory = StaticCastSharedPtr<FTutorialListEntry_Category>(TestCategory);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(!CurrentCategoryPath.IsEmpty())
|
|
{
|
|
CurrentCategoryPath += TEXT(".");
|
|
}
|
|
|
|
CurrentCategoryPath += SplitCategory;
|
|
|
|
if( !FoundCategory.IsValid() )
|
|
{
|
|
// OK, this is a new category name for us, so add it now!
|
|
if(CategoryPath == CurrentCategoryPath)
|
|
{
|
|
FoundCategory = Category;
|
|
}
|
|
else
|
|
{
|
|
FTutorialCategory InterveningCategory;
|
|
InterveningCategory.Identifier = CurrentCategoryPath;
|
|
FoundCategory = MakeShareable(new FTutorialListEntry_Category(InterveningCategory, FOnCategorySelected::CreateSP(this, &STutorialsBrowser::OnCategorySelected), TAttribute<FText>::Create(TAttribute<FText>::FGetter::CreateSP(this, &STutorialsBrowser::GetSearchText))));
|
|
}
|
|
|
|
FoundCategory->ParentCategory = ParentCategory;
|
|
TestCategoryList.Add( FoundCategory );
|
|
}
|
|
|
|
// Descend the hierarchy for the next category
|
|
ParentCategory = FoundCategory;
|
|
}
|
|
}
|
|
|
|
return RootCategory;
|
|
}
|
|
|
|
void STutorialsBrowser::RebuildTutorials(TSharedPtr<FTutorialListEntry_Category> InRootCategory)
|
|
{
|
|
TArray<TSharedPtr<FTutorialListEntry_Tutorial>> Tutorials;
|
|
|
|
//Ensure that tutorials are loaded into the asset registry before making a list of them.
|
|
FAssetRegistryModule& AssetRegistry = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
|
|
|
|
// rebuild tutorials
|
|
FARFilter Filter;
|
|
Filter.ClassNames.Add(UBlueprint::StaticClass()->GetFName());
|
|
Filter.bRecursiveClasses = true;
|
|
Filter.TagsAndValues.Add(TEXT("NativeParentClass"), FString::Printf(TEXT("%s'%s'"), *UClass::StaticClass()->GetName(), *UEditorTutorial::StaticClass()->GetPathName()));
|
|
Filter.TagsAndValues.Add(TEXT("ParentClass"), FString::Printf(TEXT("%s'%s'"), *UClass::StaticClass()->GetName(), *UEditorTutorial::StaticClass()->GetPathName()));
|
|
|
|
TArray<FAssetData> AssetData;
|
|
AssetRegistry.Get().GetAssets(Filter, AssetData);
|
|
|
|
for (const auto& TutorialAsset : AssetData)
|
|
{
|
|
UBlueprint* Blueprint = LoadObject<UBlueprint>(nullptr, *TutorialAsset.ObjectPath.ToString());
|
|
if (Blueprint && Blueprint->GeneratedClass && Blueprint->BlueprintType == BPTYPE_Normal)
|
|
{
|
|
UEditorTutorial* Tutorial = Blueprint->GeneratedClass->GetDefaultObject<UEditorTutorial>();
|
|
if(!Tutorial->bHideInBrowser)
|
|
{
|
|
Tutorials.Add(MakeShareable(new FTutorialListEntry_Tutorial(Tutorial, FOnTutorialSelected::CreateSP(this, &STutorialsBrowser::OnTutorialSelected), TAttribute<FText>::Create(TAttribute<FText>::FGetter::CreateSP(this, &STutorialsBrowser::GetSearchText)))));
|
|
}
|
|
}
|
|
}
|
|
|
|
// add tutorials to categories
|
|
for(const auto& Tutorial : Tutorials)
|
|
{
|
|
// Figure out which base category this tutorial belongs in
|
|
TSharedPtr<FTutorialListEntry_Category> CategoryForTutorial = InRootCategory;
|
|
const FString& CategoryPath = Tutorial->Tutorial->Category;
|
|
|
|
// We're expecting the category string to be in the "A.B.C" format. We'll split up the string here and form
|
|
// a proper hierarchy in the UI
|
|
TArray< FString > SplitCategories;
|
|
CategoryPath.ParseIntoArray( SplitCategories, TEXT( "." ), true /* bCullEmpty */ );
|
|
|
|
FString CurrentCategoryPath;
|
|
|
|
// Make sure all of the categories exist
|
|
for(const auto& SplitCategory : SplitCategories)
|
|
{
|
|
// Locate this category at the level we're at in the hierarchy
|
|
TSharedPtr<FTutorialListEntry_Category> FoundCategory = NULL;
|
|
TArray< TSharedPtr<ITutorialListEntry> >& TestCategoryList = CategoryForTutorial.IsValid() ? CategoryForTutorial->SubCategories : InRootCategory->SubCategories;
|
|
for(auto& TestCategory : TestCategoryList)
|
|
{
|
|
if( StaticCastSharedPtr<FTutorialListEntry_Category>(TestCategory)->CategoryName == SplitCategory )
|
|
{
|
|
// Found it!
|
|
FoundCategory = StaticCastSharedPtr<FTutorialListEntry_Category>(TestCategory);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(!CurrentCategoryPath.IsEmpty())
|
|
{
|
|
CurrentCategoryPath += TEXT(".");
|
|
}
|
|
|
|
CurrentCategoryPath += SplitCategory;
|
|
|
|
if( !FoundCategory.IsValid() )
|
|
{
|
|
// OK, this is a new category name for us, so add it now!
|
|
FTutorialCategory InterveningCategory;
|
|
InterveningCategory.Identifier = CurrentCategoryPath;
|
|
|
|
FoundCategory = MakeShareable(new FTutorialListEntry_Category(InterveningCategory, FOnCategorySelected::CreateSP(this, &STutorialsBrowser::OnCategorySelected), TAttribute<FText>::Create(TAttribute<FText>::FGetter::CreateSP(this, &STutorialsBrowser::GetSearchText))));
|
|
FoundCategory->ParentCategory = CategoryForTutorial;
|
|
TestCategoryList.Add( FoundCategory );
|
|
}
|
|
|
|
// Descend the hierarchy for the next category
|
|
CategoryForTutorial = FoundCategory;
|
|
}
|
|
|
|
Tutorial->ParentCategory = CategoryForTutorial;
|
|
CategoryForTutorial->AddTutorial( Tutorial );
|
|
}
|
|
}
|
|
|
|
void STutorialsBrowser::ReloadTutorials()
|
|
{
|
|
TSharedPtr<FTutorialListEntry_Category> RootCategory = RebuildCategories();
|
|
RebuildTutorials(RootCategory);
|
|
RootEntry = RootCategory;
|
|
|
|
// now filter & arrange available tutorials
|
|
FilterTutorials();
|
|
}
|
|
|
|
FReply STutorialsBrowser::OnCloseButtonClicked()
|
|
{
|
|
OnClosed.ExecuteIfBound();
|
|
return FReply::Handled();
|
|
}
|
|
|
|
FReply STutorialsBrowser::OnBackButtonClicked()
|
|
{
|
|
TSharedPtr<FTutorialListEntry_Category> CurrentCategory = FindCategory_Recursive(RootEntry);
|
|
if(CurrentCategory.IsValid() && CurrentCategory->ParentCategory.IsValid())
|
|
{
|
|
TSharedPtr<FTutorialListEntry_Category> PinnedParentCategory = StaticCastSharedPtr<FTutorialListEntry_Category>(CurrentCategory->ParentCategory.Pin());
|
|
if(PinnedParentCategory.IsValid())
|
|
{
|
|
NavigationFilter = PinnedParentCategory->Category.Identifier;
|
|
FilterTutorials();
|
|
}
|
|
}
|
|
|
|
RebuildCrumbs();
|
|
|
|
return FReply::Handled();
|
|
}
|
|
|
|
bool STutorialsBrowser::IsBackButtonEnabled() const
|
|
{
|
|
if(CurrentCategoryPtr.IsValid())
|
|
{
|
|
return CurrentCategoryPtr.Pin()->ParentCategory.IsValid();
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void STutorialsBrowser::OnTutorialSelected(UEditorTutorial* InTutorial, bool bRestart)
|
|
{
|
|
if (InTutorial != nullptr)
|
|
{
|
|
if (FEngineAnalytics::IsAvailable())
|
|
{
|
|
TArray<FAnalyticsEventAttribute> EventAttributes;
|
|
EventAttributes.Add(FAnalyticsEventAttribute(TEXT("Restarted"), bRestart));
|
|
EventAttributes.Add(FAnalyticsEventAttribute(TEXT("TutorialAsset"), FIntroTutorials::AnalyticsEventNameFromTutorial(InTutorial)));
|
|
|
|
FEngineAnalytics::GetProvider().RecordEvent(TEXT("Rocket.Tutorials.LaunchedFromBrowser"), EventAttributes);
|
|
}
|
|
//Close the tutorial browser so it doesn't get in the way of the actual tutorial.
|
|
if (OnLaunchTutorial.IsBound())
|
|
{
|
|
FIntroTutorials& IntroTutorials = FModuleManager::GetModuleChecked<FIntroTutorials>(TEXT("IntroTutorials"));
|
|
IntroTutorials.DismissTutorialBrowser();
|
|
}
|
|
}
|
|
OnLaunchTutorial.ExecuteIfBound(InTutorial, bRestart ? IIntroTutorials::ETutorialStartType::TST_RESTART : IIntroTutorials::ETutorialStartType::TST_CONTINUE, ParentWindow, FSimpleDelegate(), FSimpleDelegate());
|
|
}
|
|
|
|
void STutorialsBrowser::OnCategorySelected(const FString& InCategory)
|
|
{
|
|
NavigationFilter = InCategory;
|
|
FilterTutorials();
|
|
|
|
RebuildCrumbs();
|
|
}
|
|
|
|
void STutorialsBrowser::FilterTutorials()
|
|
{
|
|
FilteredEntries.Empty();
|
|
|
|
if(SearchFilter.IsEmpty())
|
|
{
|
|
TSharedPtr<FTutorialListEntry_Category> CurrentCategory = FindCategory_Recursive(RootEntry);
|
|
|
|
if(CurrentCategory.IsValid())
|
|
{
|
|
for(const auto& SubCategory : CurrentCategory->SubCategories)
|
|
{
|
|
if(SubCategory->PassesFilter(CategoryFilter, SearchFilter.ToString()))
|
|
{
|
|
FilteredEntries.Add(SubCategory);
|
|
}
|
|
}
|
|
|
|
for(const auto& Tutorial : CurrentCategory->Tutorials)
|
|
{
|
|
if(Tutorial->PassesFilter(CategoryFilter, SearchFilter.ToString()))
|
|
{
|
|
FilteredEntries.Add(Tutorial);
|
|
}
|
|
}
|
|
|
|
CurrentCategoryPtr = CurrentCategory;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
struct Local
|
|
{
|
|
static void AddSubCategory_Recursive(const FString& InCategoryFilter, const FString& InSearchFilter, TSharedPtr<FTutorialListEntry_Category> InCategory, TArray<TSharedPtr<ITutorialListEntry>>& InOutFilteredEntries)
|
|
{
|
|
if(InCategory.IsValid())
|
|
{
|
|
for(const auto& SubCategory : InCategory->SubCategories)
|
|
{
|
|
if(SubCategory->PassesFilter(InCategoryFilter, InSearchFilter))
|
|
{
|
|
InOutFilteredEntries.Add(SubCategory);
|
|
}
|
|
|
|
AddSubCategory_Recursive(InCategoryFilter, InSearchFilter, StaticCastSharedPtr<FTutorialListEntry_Category>(SubCategory), InOutFilteredEntries);
|
|
}
|
|
|
|
for(const auto& Tutorial : InCategory->Tutorials)
|
|
{
|
|
if(Tutorial->PassesFilter(InCategoryFilter, InSearchFilter))
|
|
{
|
|
InOutFilteredEntries.Add(Tutorial);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
TSharedPtr<FTutorialListEntry_Category> CurrentCategory = FindCategory_Recursive(RootEntry);
|
|
if(CurrentCategory.IsValid())
|
|
{
|
|
Local::AddSubCategory_Recursive(CategoryFilter, SearchFilter.ToString(), CurrentCategory, FilteredEntries);
|
|
CurrentCategoryPtr = CurrentCategory;
|
|
}
|
|
}
|
|
|
|
FilteredEntries.Sort(
|
|
[](TSharedPtr<ITutorialListEntry> EntryA, TSharedPtr<ITutorialListEntry> EntryB)->bool
|
|
{
|
|
if(EntryA.IsValid() && EntryB.IsValid())
|
|
{
|
|
return EntryA->SortAgainst(EntryB.ToSharedRef());
|
|
}
|
|
return false;
|
|
}
|
|
);
|
|
|
|
TutorialList->RequestListRefresh();
|
|
}
|
|
|
|
TSharedPtr<FTutorialListEntry_Category> STutorialsBrowser::FindCategory_Recursive(TSharedPtr<FTutorialListEntry_Category> InCategory) const
|
|
{
|
|
if(InCategory.IsValid())
|
|
{
|
|
if(InCategory->Category.Identifier == NavigationFilter)
|
|
{
|
|
return InCategory;
|
|
}
|
|
|
|
for(const auto& Category : InCategory->SubCategories)
|
|
{
|
|
TSharedPtr<FTutorialListEntry_Category> TestCategory = FindCategory_Recursive(StaticCastSharedPtr<FTutorialListEntry_Category>(Category));
|
|
if(TestCategory.IsValid())
|
|
{
|
|
return TestCategory;
|
|
}
|
|
}
|
|
}
|
|
|
|
return TSharedPtr<FTutorialListEntry_Category>();
|
|
}
|
|
|
|
void STutorialsBrowser::OnSearchTextChanged(const FText& InText)
|
|
{
|
|
SearchFilter = InText;
|
|
FilterTutorials();
|
|
}
|
|
|
|
FText STutorialsBrowser::GetSearchText() const
|
|
{
|
|
return SearchFilter;
|
|
}
|
|
|
|
void STutorialsBrowser::OnBreadcrumbClicked(const TSharedPtr<ITutorialListEntry>& InEntry)
|
|
{
|
|
TSharedPtr<ITutorialListEntry> ClickedEntry = InEntry;
|
|
|
|
if(ClickedEntry.IsValid())
|
|
{
|
|
NavigationFilter = StaticCastSharedPtr<FTutorialListEntry_Category>(ClickedEntry)->Category.Identifier;
|
|
}
|
|
else
|
|
{
|
|
NavigationFilter.Empty();
|
|
}
|
|
|
|
RebuildCrumbs();
|
|
|
|
FilterTutorials();
|
|
}
|
|
|
|
void STutorialsBrowser::RebuildCrumbs()
|
|
{
|
|
BreadcrumbTrail->ClearCrumbs();
|
|
|
|
// rebuild crumbs to this point
|
|
TArray<TSharedPtr<FTutorialListEntry_Category>> Entries;
|
|
TSharedPtr<FTutorialListEntry_Category> CurrentCategory = FindCategory_Recursive(RootEntry);
|
|
if(CurrentCategory.IsValid())
|
|
{
|
|
TSharedPtr<FTutorialListEntry_Category> Category = StaticCastSharedPtr<FTutorialListEntry_Category>(CurrentCategory);
|
|
while(Category.IsValid())
|
|
{
|
|
Entries.Add(Category);
|
|
if(Category->ParentCategory.IsValid())
|
|
{
|
|
Category = StaticCastSharedPtr<FTutorialListEntry_Category>(Category->ParentCategory.Pin());
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
for(int32 Index = Entries.Num() - 1; Index >= 0; Index--)
|
|
{
|
|
TSharedPtr<FTutorialListEntry_Category> Entry = Entries[Index];
|
|
if(RootEntry == Entry)
|
|
{
|
|
BreadcrumbTrail->PushCrumb(LOCTEXT("PathRoot", "Tutorials"), TSharedPtr<ITutorialListEntry>());
|
|
}
|
|
else
|
|
{
|
|
BreadcrumbTrail->PushCrumb(Entry->GetTitleText(), Entry);
|
|
}
|
|
}
|
|
}
|
|
|
|
void STutorialsBrowser::HandleAssetAdded(const FAssetData& InAssetData)
|
|
{
|
|
if(InAssetData.AssetClass == UBlueprint::StaticClass()->GetFName())
|
|
{
|
|
const FString ParentClassPath = InAssetData.GetTagValueRef<FString>("ParentClass");
|
|
if(!ParentClassPath.IsEmpty())
|
|
{
|
|
UClass* ParentClass = FindObject<UClass>(NULL, *ParentClassPath);
|
|
if(ParentClass == UEditorTutorial::StaticClass())
|
|
{
|
|
bNeedsRefresh = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE |