Files
UnrealEngineUWP/Engine/Source/Editor/Documentation/Private/Documentation.cpp

277 lines
7.8 KiB
C++
Raw Normal View History

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "Documentation.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "Misc/Paths.h"
#include "Styling/CoreStyle.h"
#include "Widgets/SToolTip.h"
#include "Misc/MessageDialog.h"
#include "HAL/FileManager.h"
#include "Misc/CommandLine.h"
#include "Dialogs/Dialogs.h"
#include "SDocumentationAnchor.h"
#include "UDNParser.h"
#include "DocumentationPage.h"
#include "DocumentationLink.h"
#include "SDocumentationToolTip.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "Interfaces/IAnalyticsProvider.h"
#include "EngineAnalytics.h"
#define LOCTEXT_NAMESPACE "DocumentationActor"
TSharedRef< IDocumentation > FDocumentation::Create()
{
return MakeShareable( new FDocumentation() );
}
FDocumentation::FDocumentation()
{
}
FDocumentation::~FDocumentation()
{
}
bool FDocumentation::OpenHome(FDocumentationSourceInfo Source) const
{
return Open( TEXT("%ROOT%"), Source );
}
bool FDocumentation::OpenHome(const FCultureRef& Culture, FDocumentationSourceInfo Source) const
{
return Open(TEXT("%ROOT%"), Culture, Source);
}
bool FDocumentation::OpenAPIHome() const
{
FString APIPath = FPaths::Combine(*FPaths::EngineDir(), TEXT("Documentation/CHM/API.chm"));
if( IFileManager::Get().FileSize( *APIPath ) != INDEX_NONE )
{
FString AbsoluteAPIPath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*APIPath);
FPlatformProcess::LaunchFileInDefaultExternalApplication(*AbsoluteAPIPath);
return true;
}
else
{
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("Documentation", "CannotFindAPIReference", "Cannot open API reference; help file not found."));
return false;
}
}
bool FDocumentation::CanOpenAPIHome() const
{
return FPaths::FileExists(FPaths::Combine(*FPaths::EngineDir(), TEXT("Documentation/CHM/API.chm")));
}
bool FDocumentation::Open(const FString& Link, FDocumentationSourceInfo Source) const
{
FString DocumentationUrl;
// Warn the user if they are opening a URL
if (Link.StartsWith(TEXT("http")) || Link.StartsWith(TEXT("https")))
{
FText Message = LOCTEXT("OpeningURLMessage", "You are about to open an external URL. This will open your web browser. Do you want to proceed?");
FText URLDialog = LOCTEXT("OpeningURLTitle", "Open external link");
Copying //UE4/Dev-Framework to Dev-Main (//UE4/Dev-Main) @ 2855699 #lockdown Nick.Penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 2839897 on 2016/01/22 by Ori.Cohen Allow static mesh editor to specify a default collision profile. #rb Lina.Halper #UE-2836 Change 2840489 on 2016/01/22 by Ori.Cohen Fix collision customization so that it respects const editing property #rb Marc.Audy Change 2840528 on 2016/01/22 by Ori.Cohen Fix compile error and actually get value from attribute Change 2840672 on 2016/01/22 by Zak.Middleton #ue4 - Include data from USkinnedMeshComponent in USkeletalMeshComponent::GetResourceSize(). #rb Michael.Noland Change 2841314 on 2016/01/24 by Marc.Audy Fix depressingly frequent misspellings of 'suppress' Change 2841323 on 2016/01/24 by Marc.Audy Reserve worst case memory for TSet Intersect, Union, and Difference to avoid memory allocations during iteration Ensure that TSet Intersect considers the least number of elements possible Early out from TSet Contains if Other is larger than this Clarify comment on TSet Difference #rb Steve.Robb Change 2841380 on 2016/01/24 by Aaron.McLeran UE-25586 Audio assets not correctly reporting resource memory usage Tested on PC/PS4 and with Editor builds. Memory reporting is working for all cases now. Change 2841385 on 2016/01/24 by Aaron.McLeran UE-21210 Adding subtitle priority to USoundWave Change 2841386 on 2016/01/24 by Marc.Audy Return null for GameNetDriver if World is null instead of crashing Change 2841409 on 2016/01/24 by Aaron.McLeran UE-25514 Removing load for default objects for every sound wave Change 2841858 on 2016/01/25 by Ori.Cohen Make sure that PIE face index results are consistent with runtime #rb Benn.Gallagher Change 2841977 on 2016/01/25 by Ori.Cohen Fix object type customization so that it's only enabled when custom is selected. (Accidently broke this in recent change) Change 2841982 on 2016/01/25 by Marc.Audy Minor optimization by avoiding recreating FNames repeatedly in constructor Change 2842169 on 2016/01/25 by Benn.Gallagher Fixes to animBP compiler and instance to store and double buffer internal machine state weights on the instance. So they can be queried cross-machine without issue. #rb Lina.Halper Change 2842390 on 2016/01/25 by Ori.Cohen Fix in world editing of BodyInstance not working. No longer serializing Scale3D as this is allways initialized in InitBody. No longer overwriting MassInKg and renamed to to MassInKgOverride which better reflects what this variable does. #JIRA UE-25518 #rb Lina.Halper Change 2843579 on 2016/01/26 by Marc.Audy Only update replication when it actually changes Don't check calling SetIsReplicated if the class cannot replicate, instead output an error message Fix spelling in comment #rb Ori.Cohen Change 2843627 on 2016/01/26 by Marc.Audy Add \\ as a default console key for Italian keyboard layouts #jira UE-25198 #rb James.Golding Change 2843628 on 2016/01/26 by Marc.Audy Don't reconstruct FName on each call to GetHitResultAtScreenPosition #rb James.Golding Change 2843671 on 2016/01/26 by Martin.Wilson Fix incorrect bone transforms being pushed to the renderer during SetSkeletalMesh. This presented as motion blur artifacts in editor #rb Thomas.Sarkanen Change 2843768 on 2016/01/26 by Marc.Audy Inline Get Component functions in TriggerBase Change 2844003 on 2016/01/26 by Zak.Middleton #ue4 - Fix FMath::Fmod(X, Y) sometimes returning small negative values for positive X and Y due to float imprecision. Added tests to math tests at startup to check this, and also to better handle results close to Y. Wrap the ensure on Y=0 within a conditional so a breakpoint can be used during debugging (to distinguish between zero and very small input). #codereview Laurent.Delayen Change 2844005 on 2016/01/26 by Zak.Middleton #ue4 - Convert uses of fmod() and fmodf() to use FMath::Fmod() instead. Also see CL 2844003 [CL 2855709 by Marc Audy in Main branch]
2016-02-04 10:55:30 -05:00
FSuppressableWarningDialog::FSetupInfo Info(Message, URLDialog, "SuppressOpenURLWarning");
Info.ConfirmText = LOCTEXT("OpenURL_yes", "Yes");
Info.CancelText = LOCTEXT("OpenURL_no", "No");
FSuppressableWarningDialog OpenURLWarning(Info);
if (OpenURLWarning.ShowModal() == FSuppressableWarningDialog::Cancel)
{
return false;
}
else
{
FPlatformProcess::LaunchURL(*Link, nullptr, nullptr);
return true;
}
}
if (!FParse::Param(FCommandLine::Get(), TEXT("testdocs")))
{
FString OnDiskPath = FDocumentationLink::ToFilePath(Link);
if (IFileManager::Get().FileSize(*OnDiskPath) != INDEX_NONE)
{
DocumentationUrl = FDocumentationLink::ToFileUrl(Link, Source);
}
}
if (DocumentationUrl.IsEmpty())
{
// When opening a doc website we always request the most ideal culture for our documentation.
// The DNS will redirect us if necessary.
DocumentationUrl = FDocumentationLink::ToUrl(Link, Source);
}
if (!DocumentationUrl.IsEmpty())
{
FPlatformProcess::LaunchURL(*DocumentationUrl, NULL, NULL);
}
if (!DocumentationUrl.IsEmpty() && FEngineAnalytics::IsAvailable())
{
FEngineAnalytics::GetProvider().RecordEvent(TEXT("Editor.Usage.Documentation"), TEXT("OpenedPage"), Link);
}
return !DocumentationUrl.IsEmpty();
}
bool FDocumentation::Open(const FString& Link, const FCultureRef& Culture, FDocumentationSourceInfo Source) const
{
FString DocumentationUrl;
if (!FParse::Param(FCommandLine::Get(), TEXT("testdocs")))
{
FString OnDiskPath = FDocumentationLink::ToFilePath(Link, Culture);
if (IFileManager::Get().FileSize(*OnDiskPath) != INDEX_NONE)
{
DocumentationUrl = FDocumentationLink::ToFileUrl(Link, Culture, Source);
}
}
if (DocumentationUrl.IsEmpty())
{
DocumentationUrl = FDocumentationLink::ToUrl(Link, Culture, Source);
}
if (!DocumentationUrl.IsEmpty())
{
FPlatformProcess::LaunchURL(*DocumentationUrl, NULL, NULL);
}
if (!DocumentationUrl.IsEmpty() && FEngineAnalytics::IsAvailable())
{
FEngineAnalytics::GetProvider().RecordEvent(TEXT("Editor.Usage.Documentation"), TEXT("OpenedPage"), Link);
}
return !DocumentationUrl.IsEmpty();
}
TSharedRef< SWidget > FDocumentation::CreateAnchor( const TAttribute<FString>& Link, const FString& PreviewLink, const FString& PreviewExcerptName ) const
{
return SNew( SDocumentationAnchor )
.Link(Link)
.PreviewLink(PreviewLink)
.PreviewExcerptName(PreviewExcerptName);
}
TSharedRef< IDocumentationPage > FDocumentation::GetPage( const FString& Link, const TSharedPtr< FParserConfiguration >& Config, const FDocumentationStyle& Style )
{
TSharedPtr< IDocumentationPage > Page;
const TWeakPtr< IDocumentationPage >* ExistingPagePtr = LoadedPages.Find( Link );
if ( ExistingPagePtr != NULL )
{
const TSharedPtr< IDocumentationPage > ExistingPage = ExistingPagePtr->Pin();
if ( ExistingPage.IsValid() )
{
Page = ExistingPage;
}
}
if ( !Page.IsValid() )
{
Page = FDocumentationPage::Create( Link, FUDNParser::Create( Config, Style ) );
LoadedPages.Add( Link, TWeakPtr< IDocumentationPage >( Page ) );
}
return Page.ToSharedRef();
}
bool FDocumentation::PageExists(const FString& Link) const
{
const TWeakPtr< IDocumentationPage >* ExistingPagePtr = LoadedPages.Find(Link);
if (ExistingPagePtr != NULL)
{
return true;
}
const FString SourcePath = FDocumentationLink::ToSourcePath(Link);
return FPaths::FileExists(SourcePath);
}
bool FDocumentation::PageExists(const FString& Link, const FCultureRef& Culture) const
{
const TWeakPtr< IDocumentationPage >* ExistingPagePtr = LoadedPages.Find(Link);
if (ExistingPagePtr != NULL)
{
return true;
}
const FString SourcePath = FDocumentationLink::ToSourcePath(Link, Culture);
return FPaths::FileExists(SourcePath);
}
TSharedRef< class SToolTip > FDocumentation::CreateToolTip(const TAttribute<FText>& Text, const TSharedPtr<SWidget>& OverrideContent, const FString& Link, const FString& ExcerptName) const
{
TSharedPtr< SDocumentationToolTip > DocToolTip;
if ( !Text.IsBound() && Text.Get().IsEmpty() )
{
return SNew( SToolTip );
}
if ( OverrideContent.IsValid() )
{
SAssignNew( DocToolTip, SDocumentationToolTip )
.DocumentationLink( Link )
.ExcerptName( ExcerptName )
[
OverrideContent.ToSharedRef()
];
}
else
{
SAssignNew( DocToolTip, SDocumentationToolTip )
.Text( Text )
.DocumentationLink( Link )
.ExcerptName( ExcerptName );
}
return SNew( SToolTip )
.IsInteractive( DocToolTip.ToSharedRef(), &SDocumentationToolTip::IsInteractive )
// Emulate text-only tool-tip styling that SToolTip uses when no custom content is supplied. We want documentation tool-tips to
// be styled just like text-only tool-tips
.BorderImage( FCoreStyle::Get().GetBrush("ToolTip.BrightBackground") )
.TextMargin(FMargin(11.0f))
[
DocToolTip.ToSharedRef()
];
}
TSharedRef< class SToolTip > FDocumentation::CreateToolTip(const TAttribute<FText>& Text, const TSharedRef<SWidget>& OverrideContent, const TSharedPtr<SVerticalBox>& DocVerticalBox, const FString& Link, const FString& ExcerptName) const
{
TSharedRef<SDocumentationToolTip> DocToolTip =
SNew(SDocumentationToolTip)
.Text(Text)
.DocumentationLink(Link)
.ExcerptName(ExcerptName)
.AddDocumentation(false)
.DocumentationMargin(7)
[
OverrideContent
];
if (DocVerticalBox.IsValid())
{
DocToolTip->AddDocumentation(DocVerticalBox);
}
return SNew(SToolTip)
.IsInteractive(DocToolTip, &SDocumentationToolTip::IsInteractive)
// Emulate text-only tool-tip styling that SToolTip uses when no custom content is supplied. We want documentation tool-tips to
// be styled just like text-only tool-tips
.BorderImage( FCoreStyle::Get().GetBrush("ToolTip.BrightBackground") )
.TextMargin(FMargin(11.0f))
[
DocToolTip
];
}
#undef LOCTEXT_NAMESPACE