2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
# pragma once
struct FTemplateItem ;
2014-08-18 06:48:04 -04:00
struct FTemplateCategory ;
2014-03-14 14:13:41 -04:00
/**
* A wizard to create a new game project
*/
class SNewProjectWizard : public SCompoundWidget
{
public :
SLATE_BEGIN_ARGS ( SNewProjectWizard ) { }
SLATE_EVENT ( FOnClicked , OnBackRequested )
SLATE_END_ARGS ( )
/** Constructs this widget with InArgs */
void Construct ( const FArguments & InArgs ) ;
2014-06-13 06:14:46 -04:00
virtual void Tick ( const FGeometry & AllottedGeometry , const double InCurrentTime , const float InDeltaTime ) override ;
2014-03-14 14:13:41 -04:00
private :
2014-08-18 06:48:04 -04:00
/** Build the set of template category tabs */
TSharedRef < SWidget > BuildCategoryTabs ( ) ;
2014-03-14 14:13:41 -04:00
/** Accessor for the currently selected template item */
TSharedPtr < FTemplateItem > GetSelectedTemplateItem ( ) const ;
2014-08-18 06:48:04 -04:00
/** Helper function to allow direct lookup of the selected item's properties on a delegate */
2014-08-19 06:13:33 -04:00
/** TRet should be defaulted but VS2012 doesn't allow default template arguments on non-class templates */
template < typename T >
T GetSelectedTemplateProperty ( T FTemplateItem : : * Prop ) const
2014-08-18 06:48:04 -04:00
{
TSharedPtr < FTemplateItem > SelectedItem = GetSelectedTemplateItem ( ) ;
if ( SelectedItem . IsValid ( ) )
{
return ( * SelectedItem ) . * Prop ;
}
2014-08-19 06:13:33 -04:00
return T ( ) ;
2014-08-18 06:48:04 -04:00
}
2014-03-14 14:13:41 -04:00
/** Accessor for the project name text */
FText GetCurrentProjectFileName ( ) const ;
/** Accessor for the project filename string with the extension */
FString GetCurrentProjectFileNameStringWithExtension ( ) const ;
/** Handler for when the project name string was changed */
void OnCurrentProjectFileNameChanged ( const FText & InValue ) ;
/** Accessor for the project path text */
FText GetCurrentProjectFilePath ( ) const ;
/** Accessor for the project ParentFolder string */
FString GetCurrentProjectFileParentFolder ( ) const ;
/** Handler for when the project path string was changed */
void OnCurrentProjectFilePathChanged ( const FText & InValue ) ;
/** Accessor for the label to preview the current filename with path */
FString GetProjectFilenameWithPathLabelText ( ) const ;
/** Accessor for the label to show the currently selected template */
FText GetSelectedTemplateName ( ) const ;
2014-08-18 06:48:04 -04:00
/** Get the images for the selected template preview and category */
const FSlateBrush * GetSelectedTemplatePreviewImage ( ) const ;
const FSlateBrush * GetSelectedTemplateTypeImage ( ) const ;
2014-09-09 12:16:36 -04:00
/** Get the visibility for the selected template preview image */
EVisibility GetSelectedTemplatePreviewVisibility ( ) const ;
2014-10-30 10:27:56 -04:00
/** Get a string that details the class types referenced in the selected template */
2015-01-07 09:52:40 -05:00
FText GetSelectedTemplateClassTypes ( ) const ;
2014-10-30 10:27:56 -04:00
/** Get a visiblity of the class types display. If the string is empty this return Collapsed otherwise it will return Visible */
2014-10-30 10:23:07 -04:00
EVisibility GetSelectedTemplateClassVisibility ( ) const ;
2014-10-30 10:27:56 -04:00
/** Get a string that details the class types referenced in the selected template */
2015-01-07 09:52:40 -05:00
FText GetSelectedTemplateAssetTypes ( ) const ;
2014-10-30 10:27:56 -04:00
/** Get a visiblity of the asset types display. If the string is empty this return Collapsed otherwise it will return Visible */
EVisibility GetSelectedTemplateAssetVisibility ( ) const ;
2014-10-30 10:23:07 -04:00
2014-03-14 14:13:41 -04:00
/** Gets the assembled project filename with path */
FString GetProjectFilenameWithPath ( ) const ;
/** Opens a web browser to the specified IDE url */
void OnDownloadIDEClicked ( FString URL ) ;
/** Returns true if the user is allowed to specify a project with the supplied name and path */
bool IsCreateProjectEnabled ( ) const ;
// Handles checking whether the specified page can be shown.
bool HandlePageCanShow ( FName PageName ) const ;
/** Fired when the page changes in the wizard */
void OnPageVisited ( FName NewPageName ) ;
/** Gets the visibility of the error label */
EVisibility GetGlobalErrorLabelVisibility ( ) const ;
/** Gets the visibility of the error label close button. Only visible when displaying a persistent error */
EVisibility GetGlobalErrorLabelCloseButtonVisibility ( ) const ;
/** Gets the visibility of the IDE link in the error label */
EVisibility GetGlobalErrorLabelIDELinkVisibility ( ) const ;
/** Gets the text to display in the error label */
FText GetGlobalErrorLabelText ( ) const ;
/** Handler for when the close button on the error label is clicked */
FReply OnCloseGlobalErrorLabelClicked ( ) ;
/** Gets the visibility of the error label */
EVisibility GetNameAndLocationErrorLabelVisibility ( ) const ;
/** Gets the text to display in the error label */
FText GetNameAndLocationErrorLabelText ( ) const ;
/** Handler for when the "copy starter content" checkbox changes state */
2014-10-01 06:07:53 -04:00
void OnSetCopyStarterContent ( int32 InCopyStarterContent ) ;
/** Get whether we are copying starter content or not */
int32 GetCopyStarterContentIndex ( ) const { return bCopyStarterContent ? 1 : 0 ; } ;
2014-03-14 14:13:41 -04:00
2014-09-25 22:44:16 -04:00
/** Returns the visibility of the starter content warning */
EVisibility GetStarterContentWarningVisibility ( ) const ;
/** Returns the tooltip text (actual warning) of the starter content warning */
FText GetStarterContentWarningTooltip ( ) const ;
2014-09-09 12:16:36 -04:00
private :
2014-03-14 14:13:41 -04:00
2014-09-09 12:16:36 -04:00
EHardwareClass : : Type SelectedHardwareClassTarget ;
void SetHardwareClassTarget ( EHardwareClass : : Type InHardwareClass ) ;
EHardwareClass : : Type GetHardwareClassTarget ( ) const { return SelectedHardwareClassTarget ; }
EGraphicsPreset : : Type SelectedGraphicsPreset ;
void SetGraphicsPreset ( EGraphicsPreset : : Type InGraphicsPreset ) ;
EGraphicsPreset : : Type GetGraphicsPreset ( ) const { return SelectedGraphicsPreset ; }
2014-03-14 14:13:41 -04:00
private :
/** Populates TemplateItemsSource with templates found on disk */
void FindTemplateProjects ( ) ;
/** Sets the default project name and path */
void SetDefaultProjectLocation ( ) ;
/** Checks the current project path an name for validity and updates cached values accordingly */
void UpdateProjectFileValidity ( ) ;
/** Returns true if we have a code template selected */
bool IsCompilerRequired ( ) const ;
/** Begins the creation process for the configured project */
void CreateAndOpenProject ( ) ;
/** Opens the specified project file */
2014-12-11 16:39:39 -05:00
bool OpenProject ( const FString & ProjectFile ) ;
2014-03-14 14:13:41 -04:00
/** Opens the solution for the specified project */
2014-12-11 16:39:39 -05:00
bool OpenCodeIDE ( const FString & ProjectFile ) ;
2014-03-14 14:13:41 -04:00
/** Creates a project with the supplied project filename */
bool CreateProject ( const FString & ProjectFile ) ;
/** Closes the containing window, but only if summoned via the editor so the non-game version doesn't just close to desktop. */
void CloseWindowIfAppropriate ( bool ForceClose = false ) ;
/** Displays an error to the user */
void DisplayError ( const FText & ErrorText ) ;
private :
/** Handler for when the Browse button is clicked */
FReply HandleBrowseButtonClicked ( ) ;
/** Checks whether the 'Create Project' wizard can finish. */
bool HandleCreateProjectWizardCanFinish ( ) const ;
/** Handler for when the Create button is clicked */
void HandleCreateProjectWizardFinished ( ) ;
/** Called when a user double-clicks a template item in the template project list. */
void HandleTemplateListViewDoubleClick ( TSharedPtr < FTemplateItem > TemplateItem ) ;
/** Handler for when the selection changes in the template list */
void HandleTemplateListViewSelectionChanged ( TSharedPtr < FTemplateItem > TemplateItem , ESelectInfo : : Type SelectInfo ) ;
2014-08-18 06:48:04 -04:00
/** Handle choosing a different category tab */
2014-12-10 14:24:09 -05:00
void HandleCategoryChanged ( ECheckBoxState Checked , FName Category ) ;
2014-03-14 14:13:41 -04:00
2014-08-18 06:48:04 -04:00
/** Get the check state for the specified categories tab */
2014-12-10 14:24:09 -05:00
ECheckBoxState GetCategoryTabCheckState ( FName Category ) const ;
2014-03-14 14:13:41 -04:00
private :
/** The wizard widget */
2014-08-27 21:25:34 -04:00
TSharedPtr < class SWizard > MainWizard ;
2014-03-14 14:13:41 -04:00
FString LastBrowsePath ;
FString CurrentProjectFileName ;
FString CurrentProjectFilePath ;
FText PersistentGlobalErrorLabelText ;
/** The last time that the selected project file path was checked for validity. This is used to throttle I/O requests to a reasonable frequency */
double LastValidityCheckTime ;
/** The frequency in seconds for validity checks while the dialog is idle. Changes to the path immediately update the validity. */
double ValidityCheckFrequency ;
/** Periodic checks for validity will not occur while this flag is true. Used to prevent a frame of "this project already exists" while exiting after a successful creation. */
bool bPreventPeriodicValidityChecksUntilNextChange ;
/** The global error text from the last validity check */
FText LastGlobalValidityErrorText ;
/** The global error text from the last validity check */
FText LastNameAndLocationValidityErrorText ;
/** True if the last global validity check returned that the project path is valid for creation */
bool bLastGlobalValidityCheckSuccessful ;
/** True if the last NameAndLocation validity check returned that the project path is valid for creation */
bool bLastNameAndLocationValidityCheckSuccessful ;
/** The name of the page that is currently in view */
FName CurrentPageName ;
/** True if user has selected to copy starter content. */
bool bCopyStarterContent ;
2014-08-18 06:48:04 -04:00
/** Name of the currently selected category */
FName ActiveCategory ;
2014-03-14 14:13:41 -04:00
2014-08-18 06:48:04 -04:00
/** A map of category name to array of templates available for that category */
TMap < FName , TArray < TSharedPtr < FTemplateItem > > > Templates ;
/** The filtered array of templates we are currently showing */
TArray < TSharedPtr < FTemplateItem > > FilteredTemplateList ;
/** The slate widget representing the list of templates */
TSharedPtr < STileView < TSharedPtr < FTemplateItem > > > TemplateListView ;
2014-03-14 14:13:41 -04:00
/** Names for pages */
static FName TemplatePageName ;
static FName NameAndLocationPageName ;
} ;