2019-12-26 15:33:43 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
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 "HistoryManager.h"
|
|
|
|
|
#include "Textures/SlateIcon.h"
|
|
|
|
|
#include "Framework/Commands/UIAction.h"
|
|
|
|
|
#include "Framework/MultiBox/MultiBoxBuilder.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "ContentBrowser"
|
|
|
|
|
|
|
|
|
|
FHistoryManager::FHistoryManager()
|
|
|
|
|
{
|
|
|
|
|
CurrentHistoryIndex = 0;
|
|
|
|
|
MaxHistoryEntries = 300;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FHistoryManager::SetOnApplyHistoryData(const FOnApplyHistoryData& InOnApplyHistoryData)
|
|
|
|
|
{
|
|
|
|
|
OnApplyHistoryData = InOnApplyHistoryData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FHistoryManager::SetOnUpdateHistoryData(const FOnUpdateHistoryData& InOnUpdateHistoryData)
|
|
|
|
|
{
|
|
|
|
|
OnUpdateHistoryData = InOnUpdateHistoryData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FHistoryManager::GoBack()
|
|
|
|
|
{
|
|
|
|
|
if ( CanGoBack() )
|
|
|
|
|
{
|
|
|
|
|
// Update the current history data
|
|
|
|
|
UpdateCurrentHistoryData();
|
|
|
|
|
|
|
|
|
|
// if its possible to go back, decrement the index we are at
|
|
|
|
|
--CurrentHistoryIndex;
|
|
|
|
|
|
|
|
|
|
// Update the owner
|
|
|
|
|
ApplyCurrentHistoryData();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FHistoryManager::GoForward()
|
|
|
|
|
{
|
|
|
|
|
if ( CanGoForward() )
|
|
|
|
|
{
|
|
|
|
|
// Update the current history data
|
|
|
|
|
UpdateCurrentHistoryData();
|
|
|
|
|
|
|
|
|
|
// if its possible to go forward, increment the index we are at
|
|
|
|
|
++CurrentHistoryIndex;
|
|
|
|
|
|
|
|
|
|
// Update the owner
|
|
|
|
|
ApplyCurrentHistoryData();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FHistoryManager::AddHistoryData()
|
|
|
|
|
{
|
|
|
|
|
if (HistoryData.Num() == 0)
|
|
|
|
|
{
|
|
|
|
|
// History added to the beginning
|
|
|
|
|
HistoryData.Add(FHistoryData());
|
|
|
|
|
CurrentHistoryIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (CurrentHistoryIndex == HistoryData.Num() - 1)
|
|
|
|
|
{
|
|
|
|
|
// History added to the end
|
|
|
|
|
if (HistoryData.Num() == MaxHistoryEntries)
|
|
|
|
|
{
|
|
|
|
|
// If max history entries has been reached
|
|
|
|
|
// remove the oldest history
|
|
|
|
|
HistoryData.RemoveAt(0);
|
|
|
|
|
}
|
|
|
|
|
HistoryData.Add(FHistoryData());
|
|
|
|
|
// Current history index is the last index in the list
|
|
|
|
|
CurrentHistoryIndex = HistoryData.Num() - 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// History added to the middle
|
|
|
|
|
// clear out all history after the current history index.
|
|
|
|
|
HistoryData.RemoveAt(CurrentHistoryIndex + 1, HistoryData.Num() - (CurrentHistoryIndex + 1));
|
|
|
|
|
HistoryData.Add(FHistoryData());
|
|
|
|
|
// Current history index is the last index in the list
|
|
|
|
|
CurrentHistoryIndex = HistoryData.Num() - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the current history data
|
|
|
|
|
UpdateCurrentHistoryData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FHistoryManager::UpdateHistoryData()
|
|
|
|
|
{
|
|
|
|
|
// Update the current history data
|
|
|
|
|
UpdateCurrentHistoryData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FHistoryManager::CanGoForward() const
|
|
|
|
|
{
|
|
|
|
|
// User can go forward if there are items in the history data list,
|
|
|
|
|
// and the current history index isn't the last index in the list
|
|
|
|
|
return HistoryData.Num() > 0 && CurrentHistoryIndex < HistoryData.Num() - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FHistoryManager::CanGoBack() const
|
|
|
|
|
{
|
|
|
|
|
// User can go back if there are items in the history data list,
|
|
|
|
|
// and the current history index isn't the first index in the list
|
|
|
|
|
return HistoryData.Num() > 0 && CurrentHistoryIndex > 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-08 11:35:01 -05:00
|
|
|
FText FHistoryManager::GetBackDesc() const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
if ( CanGoBack() )
|
|
|
|
|
{
|
|
|
|
|
return HistoryData[CurrentHistoryIndex - 1].HistoryDesc;
|
|
|
|
|
}
|
2015-01-08 11:35:01 -05:00
|
|
|
return FText::GetEmpty();
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2015-01-08 11:35:01 -05:00
|
|
|
FText FHistoryManager::GetForwardDesc() const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
if ( CanGoForward() )
|
|
|
|
|
{
|
|
|
|
|
return HistoryData[CurrentHistoryIndex + 1].HistoryDesc;
|
|
|
|
|
}
|
2015-01-08 11:35:01 -05:00
|
|
|
return FText::GetEmpty();
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FHistoryManager::GetAvailableHistoryMenuItems(bool bGetPrior, FMenuBuilder& MenuBuilder)
|
|
|
|
|
{
|
|
|
|
|
const FText HistoryHeadingString = (bGetPrior)? LOCTEXT("BackHistory", "Back History") : LOCTEXT("NextHistory", "Next History");
|
|
|
|
|
MenuBuilder.BeginSection("HistoryBackNext", HistoryHeadingString);
|
|
|
|
|
{
|
|
|
|
|
if (HistoryData.Num() > 1)
|
|
|
|
|
{
|
|
|
|
|
// if there is at least 2 history items...
|
|
|
|
|
|
|
|
|
|
// Start index is the first snapshot we should make a menu item out of
|
|
|
|
|
int32 StartIndex = 0;
|
|
|
|
|
// EndIndex is the last snapshot we should make a menu item out of
|
|
|
|
|
int32 EndIndex = CurrentHistoryIndex;
|
|
|
|
|
|
|
|
|
|
if (!bGetPrior)
|
|
|
|
|
{
|
|
|
|
|
// Need to return only items on or after the current history index
|
|
|
|
|
StartIndex = CurrentHistoryIndex;
|
|
|
|
|
EndIndex = HistoryData.Num() - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check to make sure the start and end indices are within the bounds of the history list
|
|
|
|
|
if (StartIndex < HistoryData.Num() && EndIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
// Get all menu items between and including the start index and end index
|
|
|
|
|
for (int32 HistoryIdx = StartIndex; HistoryIdx <= EndIndex; ++HistoryIdx)
|
|
|
|
|
{
|
|
|
|
|
MenuBuilder.AddMenuEntry(
|
2015-01-08 11:35:01 -05:00
|
|
|
HistoryData[HistoryIdx].HistoryDesc,
|
2014-03-14 14:13:41 -04:00
|
|
|
FText(),
|
|
|
|
|
FSlateIcon(),
|
|
|
|
|
FUIAction(
|
|
|
|
|
FExecuteAction::CreateRaw( this, &FHistoryManager::ExecuteJumpToHistory, HistoryIdx )
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MenuBuilder.EndSection();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FHistoryManager::ApplyCurrentHistoryData()
|
|
|
|
|
{
|
|
|
|
|
if ( CurrentHistoryIndex >= 0 && CurrentHistoryIndex < HistoryData.Num())
|
|
|
|
|
{
|
|
|
|
|
OnApplyHistoryData.ExecuteIfBound( HistoryData[CurrentHistoryIndex] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FHistoryManager::UpdateCurrentHistoryData()
|
|
|
|
|
{
|
|
|
|
|
if ( CurrentHistoryIndex >= 0 && CurrentHistoryIndex < HistoryData.Num())
|
|
|
|
|
{
|
|
|
|
|
OnUpdateHistoryData.ExecuteIfBound( HistoryData[CurrentHistoryIndex] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FHistoryManager::ExecuteJumpToHistory(int32 HistoryIndex)
|
|
|
|
|
{
|
|
|
|
|
if (HistoryIndex >= 0 && HistoryIndex < HistoryData.Num())
|
|
|
|
|
{
|
|
|
|
|
// if the history index is valid, set the current history index to the history index requested by the user
|
|
|
|
|
CurrentHistoryIndex = HistoryIndex;
|
|
|
|
|
|
|
|
|
|
// Update the owner
|
|
|
|
|
ApplyCurrentHistoryData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|