Files
UnrealEngineUWP/Engine/Source/Editor/GameProjectGeneration/Private/SProjectBrowser.h
ryan durand 627baf970a Updating copyright for Engine Editor.
#rnx
#rb none


#ROBOMERGE-SOURCE: CL 10869241 via CL 10869527 via CL 10869904
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870586 by ryan durand in Main branch]
2019-12-26 15:33:43 -05:00

207 lines
6.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "SlateFwd.h"
#include "Layout/Visibility.h"
#include "Input/Reply.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/SCompoundWidget.h"
#include "Misc/TextFilter.h"
class ITableRow;
class STableViewBase;
class SToolTip;
class SVerticalBox;
struct FProjectCategory;
struct FProjectItem;
struct FSlateBrush;
enum class ECheckBoxState : uint8;
DECLARE_DELEGATE_OneParam(FProjectSelectionChanged, FString);
/**
* A list of known projects with the option to add a new one
*/
class SProjectBrowser
: public SCompoundWidget
{
public:
DECLARE_DELEGATE(FNewProjectScreenRequested)
SLATE_BEGIN_ARGS(SProjectBrowser) :
_HideOpenButton(false)
{}
SLATE_ARGUMENT(FProjectSelectionChanged, OnSelectionChanged);
SLATE_ARGUMENT(bool, HideOpenButton)
SLATE_END_ARGS()
public:
/** Constructor */
SProjectBrowser();
/**
* Constructs this widget with InArgs.
*
* @param InArgs - The construction arguments.
*/
void Construct( const FArguments& InArgs );
bool HasProjects() const;
void ClearSelection();
FString GetSelectedProjectFile() const;
/** Begins the opening process for the selected project */
void OpenSelectedProject();
protected:
void ConstructCategory( const TSharedRef<SVerticalBox>& CategoriesBox, const TSharedRef<FProjectCategory>& Category );
/** Creates a row in the template list */
TSharedRef<ITableRow> MakeProjectViewWidget( TSharedPtr<FProjectItem> ProjectItem, const TSharedRef<STableViewBase>& OwnerTable );
/** Create a tooltip for the given project item */
TSharedRef<SToolTip> MakeProjectToolTip( TSharedPtr<FProjectItem> ProjectItem ) const;
/** Add information to the tooltip for this project item */
void AddToToolTipInfoBox(const TSharedRef<SVerticalBox>& InfoBox, const FText& Key, const FText& Value) const;
/** Get the context menu to use for the selected project item */
TSharedPtr<SWidget> OnGetContextMenuContent() const;
/** Handler for when find in explorer is selected */
void ExecuteFindInExplorer() const;
/** Handler to check to see if a find in explorer command is allowed */
bool CanExecuteFindInExplorer() const;
/** Gets the image to display for the specified template */
const FSlateBrush* GetProjectItemImage( TWeakPtr<FProjectItem> ProjectItem ) const;
/** Gets the currently selected template item */
TSharedPtr<FProjectItem> GetSelectedProjectItem( ) const;
/** Gets the label to show the currently selected template */
FText GetSelectedProjectName( ) const;
/** Populates ProjectItemsSource with projects found on disk */
FReply FindProjects( );
/** Adds the specified project to the specified category. Creates a new category if necessary. */
void AddProjectToCategory( const TSharedRef<FProjectItem>& ProjectItem, const FText& ProjectCategory );
/** Opens the specified project file */
bool OpenProject( const FString& ProjectFile );
/** Populate the list of filtered project categories */
void PopulateFilteredProjectCategories();
/**
* Called after a key is pressed when this widget has focus (this event bubbles if not handled)
*
* @param MyGeometry The Geometry of the widget receiving the event
* @param InKeyEvent Key event
*
* @return Returns whether the event was handled, along with other possible actions
*/
virtual FReply OnKeyDown( const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent ) override;
protected:
/** Holds the collection of project categories. */
TArray<TSharedRef<FProjectCategory> > ProjectCategories;
bool bHasProjectFiles;
TSharedPtr<SVerticalBox> CategoriesBox;
FProjectSelectionChanged ProjectSelectionChangedDelegate;
private:
FReply OnBrowseToProjectClicked();
/** Handler for when the Open button is clicked */
FReply HandleOpenProjectButtonClicked( );
/** Returns true if the user is allowed to open a project with the supplied name and path */
bool HandleOpenProjectButtonIsEnabled( ) const;
/** Called when a user double-clicks a project item in the project view */
void HandleProjectItemDoubleClick( TSharedPtr<FProjectItem> ProjectItem );
/** Handler for when the selection changes in the project view */
void HandleProjectViewSelectionChanged( TSharedPtr<FProjectItem> ProjectItem, ESelectInfo::Type SelectInfo, FText CategoryName );
/** Callback for clicking the 'Marketplace' button. */
FReply HandleMarketplaceTabButtonClicked( );
/** Called when the text in the filter box is changed */
void OnFilterTextChanged(const FText& InText);
/** Whether to autoload the last project. */
void OnAutoloadLastProjectChanged(ECheckBoxState NewState);
/** Get the visibility of the specified category */
EVisibility GetProjectCategoryVisibility(const TSharedRef<FProjectCategory> InCategory) const;
EVisibility GetNoProjectsErrorVisibility() const;
/** Get the visibility of the "no projects" error */
EVisibility GetNoProjectsAfterFilterErrorVisibility() const;
/** Get the visibility of the active search overlay */
EVisibility GetFilterActiveOverlayVisibility() const;
/** Get the filter text to highlight on items in the list */
FText GetItemHighlightText() const;
private:
/** Search box used to set the filter text */
TSharedPtr<class SSearchBox> SearchBoxPtr;
/** Filter that is used to test for the visibility of projects */
typedef TTextFilter<const TSharedPtr<FProjectItem>> ProjectItemTextFilter;
ProjectItemTextFilter ProjectItemFilter;
int32 NumFilteredProjects;
int32 ThumbnailBorderPadding;
int32 ThumbnailSize;
bool bPreventSelectionChangeEvent;
TSharedPtr<FProjectItem> CurrentlySelectedItem;
FText CurrentSelectedProjectPath;
bool IsOnlineContentFinished;
// Holds a delegate that is executed when the new project screen is being requested.
FNewProjectScreenRequested NewProjectScreenRequestedDelegate;
};
/** Class to only display a finite number of most-recent projects. */
class SRecentProjectBrowser : public SProjectBrowser
{
SLATE_BEGIN_ARGS(SRecentProjectBrowser)
{
_NumProjects = 10;
}
SLATE_ARGUMENT(int32, NumProjects);
SLATE_EVENT(FProjectSelectionChanged, OnSelectionChanged);
SLATE_END_ARGS()
SRecentProjectBrowser();
void Construct(const FArguments& InArgs);
};