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
# include "MainFramePrivatePCH.h"
2014-09-16 15:41:40 -04:00
# include "MessageLog.h"
2014-10-14 22:50:06 -04:00
# include "SDockTab.h"
# include "SNotificationList.h"
# include "NotificationManager.h"
# include "GenericCommands.h"
2014-12-10 09:03:15 -05:00
# include "EngineBuildSettings.h"
2015-02-06 06:43:45 -05:00
# include "SourceCodeNavigation.h"
2015-04-09 11:11:48 -04:00
# include "SOutputLogDialog.h"
2014-09-16 15:41:40 -04:00
2015-04-20 10:12:55 -04:00
# include "Settings/EditorSettings.h"
2014-03-14 14:13:41 -04:00
# define LOCTEXT_NAMESPACE "MainFrameActions"
DEFINE_LOG_CATEGORY_STATIC ( MainFrameActions , Log , All ) ;
2014-09-16 15:41:40 -04:00
2014-03-14 14:13:41 -04:00
TSharedRef < FUICommandList > FMainFrameCommands : : ActionList ( new FUICommandList ( ) ) ;
TWeakPtr < SNotificationItem > FMainFrameActionCallbacks : : ChoosePackagesToCheckInNotification ;
FMainFrameCommands : : FMainFrameCommands ( )
: TCommands < FMainFrameCommands > (
TEXT ( " MainFrame " ) , // Context name for fast lookup
LOCTEXT ( " MainFrame " , " Main Frame " ) , // Localized context name for displaying
NAME_None , // No parent context
FEditorStyle : : GetStyleSetName ( ) ) , // Icon Style Set
ToggleFullscreenConsoleCommand (
TEXT ( " MainFrame.ToggleFullscreen " ) ,
TEXT ( " Toggles the editor between \" full screen \" mode and \" normal \" mode. In full screen mode, the task bar and window title area are hidden. " ) ,
FConsoleCommandDelegate : : CreateStatic ( & FMainFrameActionCallbacks : : ToggleFullscreen_Execute ) )
2014-09-16 15:41:40 -04:00
{ }
2014-03-14 14:13:41 -04:00
void FMainFrameCommands : : RegisterCommands ( )
{
2014-08-04 18:20:28 -04:00
if ( ! IsRunningCommandlet ( ) )
{
// The global action list was created at static initialization time. Create a handler for otherwise unhandled keyboard input to route key commands through this list.
2014-10-30 12:29:36 -04:00
FSlateApplication : : Get ( ) . SetUnhandledKeyDownEventHandler ( FOnKeyEvent : : CreateStatic ( & FMainFrameActionCallbacks : : OnUnhandledKeyDownEvent ) ) ;
2014-08-04 18:20:28 -04:00
}
2014-03-14 14:13:41 -04:00
// Make a default can execute action that disables input when in debug mode
FCanExecuteAction DefaultExecuteAction = FCanExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : DefaultCanExecuteAction ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( SaveAll , " Save All " , " Saves all unsaved levels and assets to disk " , EUserInterfaceActionType : : Button , FInputChord ( EModifierKey : : Control , EKeys : : S ) ) ;
2014-10-14 13:02:53 -04:00
ActionList - > MapAction ( SaveAll , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : SaveAll ) , FCanExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : CanSaveWorld ) ) ;
2014-03-14 14:13:41 -04:00
2015-03-17 11:36:28 -04:00
UI_COMMAND ( ChooseFilesToSave , " Choose Files to Save... " , " Opens a dialog with save options for content and levels " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-10-14 13:02:53 -04:00
ActionList - > MapAction ( ChooseFilesToSave , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : ChoosePackagesToSave ) , FCanExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : CanSaveWorld ) ) ;
2014-03-14 14:13:41 -04:00
2015-03-17 11:36:28 -04:00
UI_COMMAND ( ChooseFilesToCheckIn , " Submit to Source Control... " , " Opens a dialog with check in options for content and levels " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( ChooseFilesToCheckIn , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : ChoosePackagesToCheckIn ) , FCanExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : CanChoosePackagesToCheckIn ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( ConnectToSourceControl , " Connect To Source Control... " , " Connect to source control to allow source control operations to be performed on content and levels. " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( ConnectToSourceControl , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : ConnectToSourceControl ) , DefaultExecuteAction ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( NewProject , " New Project... " , " Opens a dialog to create a new game project " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( NewProject , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : NewProject , false , true ) , DefaultExecuteAction ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( OpenProject , " Open Project... " , " Opens a dialog to choose a game project to open " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( OpenProject , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : NewProject , true , false ) , DefaultExecuteAction ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( AddCodeToProject , " New C++ Class... " , " Adds C++ code to the project. The code can only be compiled if you have an appropriate C++ compiler installed. " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2015-01-26 20:00:14 -05:00
ActionList - > MapAction ( AddCodeToProject , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : AddCodeToProject ) ) ;
2014-03-14 14:13:41 -04:00
2015-03-17 11:36:28 -04:00
UI_COMMAND ( RefreshCodeProject , " Refresh code project " , " Refreshes your C++ code project. " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( RefreshCodeProject , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : RefreshCodeProject ) , DefaultExecuteAction ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( OpenIDE , " Open IDE " , " Opens your C++ code in an integrated development environment. " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( OpenIDE , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : OpenIDE ) , DefaultExecuteAction ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( PackagingSettings , " Packaging Settings... " , " Opens the settings for project packaging " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( PackagingSettings , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : PackagingSettings ) , DefaultExecuteAction ) ;
2015-03-17 11:36:28 -04:00
//UI_COMMAND( LocalizeProject, "Localize Project...", "Opens the dashboard for managing project localization data.", EUserInterfaceActionType::Button, FInputChord() );
2015-01-27 16:31:40 -05:00
//ActionList->MapAction( LocalizeProject, FExecuteAction::CreateStatic( &FMainFrameActionCallbacks::LocalizeProject ), DefaultExecuteAction );
2014-03-14 14:13:41 -04:00
const int32 MaxProjects = 20 ;
for ( int32 CurProjectIndex = 0 ; CurProjectIndex < MaxProjects ; + + CurProjectIndex )
{
// NOTE: The actual label and tool-tip will be overridden at runtime when the command is bound to a menu item, however
// we still need to set one here so that the key bindings UI can function properly
FFormatNamedArguments Arguments ;
Arguments . Add ( TEXT ( " CurrentProjectIndex " ) , CurProjectIndex ) ;
const FText Message = FText : : Format ( LOCTEXT ( " SwitchProject " , " Switch Project {CurrentProjectIndex} " ) , Arguments ) ;
TSharedRef < FUICommandInfo > SwitchProject =
FUICommandInfoDecl (
this - > AsShared ( ) ,
FName ( * FString : : Printf ( TEXT ( " SwitchProject%i " ) , CurProjectIndex ) ) ,
Message ,
LOCTEXT ( " SwitchProjectToolTip " , " Restarts the editor and switches to selected project " ) )
. UserInterfaceType ( EUserInterfaceActionType : : Button )
2015-03-17 11:36:28 -04:00
. DefaultChord ( FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
SwitchProjectCommands . Add ( SwitchProject ) ;
ActionList - > MapAction ( SwitchProjectCommands [ CurProjectIndex ] , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : SwitchProjectByIndex , CurProjectIndex ) ,
FCanExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : CanSwitchToProject , CurProjectIndex ) ,
FIsActionChecked : : CreateStatic ( & FMainFrameActionCallbacks : : IsSwitchProjectChecked , CurProjectIndex ) ) ;
}
2015-03-17 11:36:28 -04:00
UI_COMMAND ( Exit , " Exit " , " Exits the application " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( Exit , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : Exit ) , DefaultExecuteAction ) ;
ActionList - > MapAction ( FGenericCommands : : Get ( ) . Undo , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : ExecuteExecCommand , FString ( TEXT ( " TRANSACTION UNDO " ) ) ) , FCanExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : Undo_CanExecute ) ) ;
ActionList - > MapAction ( FGenericCommands : : Get ( ) . Redo , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : ExecuteExecCommand , FString ( TEXT ( " TRANSACTION REDO " ) ) ) , FCanExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : Redo_CanExecute ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( OpenDeviceManagerApp , " Device Manager " , " Opens up the device manager app " , EUserInterfaceActionType : : Check , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( OpenDeviceManagerApp ,
FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : OpenSlateApp , FName ( TEXT ( " DeviceManager " ) ) ) ,
FCanExecuteAction ( ) ,
FIsActionChecked : : CreateStatic ( & FMainFrameActionCallbacks : : OpenSlateApp_IsChecked , FName ( TEXT ( " DeviceManager " ) ) ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( OpenSessionManagerApp , " Session Manager " , " Opens up the session manager app " , EUserInterfaceActionType : : Check , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( OpenSessionManagerApp ,
FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : OpenSlateApp , FName ( " SessionFrontend " ) ) ,
FCanExecuteAction ( ) ,
FIsActionChecked : : CreateStatic ( & FMainFrameActionCallbacks : : OpenSlateApp_IsChecked , FName ( " SessionFrontend " ) ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( VisitWiki , " Wiki... " , " Go to the Unreal Engine Wiki page " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( VisitWiki , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : VisitWiki ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( VisitForums , " Forums... " , " Go to the Unreal Engine forums " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( VisitForums , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : VisitForums ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( VisitAskAQuestionPage , " Ask a Question... " , " Have a question? Go here to ask about anything and everything related to Unreal. " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( VisitAskAQuestionPage , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : VisitAskAQuestionPage ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( VisitSearchForAnswersPage , " Answer Hub... " , " Searches for useful answers on UDN provided by other users and experts. " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( VisitSearchForAnswersPage , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : VisitSearchForAnswersPage ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( VisitSupportWebSite , " Unreal Engine Support Web Site... " , " Navigates to the Unreal Engine Support web site's main page. " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( VisitSupportWebSite , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : VisitSupportWebSite ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( VisitEpicGamesDotCom , " Visit UnrealEngine.com... " , " Navigates to UnrealEngine.com where you can learn more about Unreal Technology. " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( VisitEpicGamesDotCom , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : VisitEpicGamesDotCom ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( AboutUnrealEd , " About Editor... " , " Displays application credits and copyright information " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( AboutUnrealEd , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : AboutUnrealEd_Execute ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( CreditsUnrealEd , " Credits " , " Displays application credits " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-06-26 10:47:24 -04:00
ActionList - > MapAction ( CreditsUnrealEd , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : CreditsUnrealEd_Execute ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( ResetLayout , " Reset Layout... " , " Make a backup of your user settings and reset the layout customizations " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-04-02 18:09:23 -04:00
ActionList - > MapAction ( ResetLayout , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : ResetLayout ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( SaveLayout , " Save Layout " , " Save the layout customizations " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( SaveLayout , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : SaveLayout ) ) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( ToggleFullscreen , " Enable Fullscreen " , " Enables fullscreen mode for the application, expanding across the entire monitor " , EUserInterfaceActionType : : ToggleButton , FInputChord ( EModifierKey : : Shift , EKeys : : F11 ) ) ;
2014-03-14 14:13:41 -04:00
ActionList - > MapAction ( ToggleFullscreen ,
FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : ToggleFullscreen_Execute ) ,
FCanExecuteAction ( ) ,
FIsActionChecked : : CreateStatic ( & FMainFrameActionCallbacks : : FullScreen_IsChecked )
) ;
2015-03-17 11:36:28 -04:00
UI_COMMAND ( OpenWidgetReflector , " Open Widget Reflector " , " Opens the Widget Reflector " , EUserInterfaceActionType : : Button , FInputChord ( EModifierKey : : Shift | EModifierKey : : Control , EKeys : : W ) ) ;
2014-04-02 18:09:23 -04:00
ActionList - > MapAction ( OpenWidgetReflector , FExecuteAction : : CreateStatic ( & FMainFrameActionCallbacks : : OpenWidgetReflector_Execute ) ) ;
2014-03-14 14:13:41 -04:00
FGlobalEditorCommonCommands : : MapActions ( ActionList ) ;
}
2014-10-30 12:29:36 -04:00
FReply FMainFrameActionCallbacks : : OnUnhandledKeyDownEvent ( const FKeyEvent & InKeyEvent )
2014-03-14 14:13:41 -04:00
{
2014-10-30 12:29:36 -04:00
if ( FMainFrameCommands : : ActionList - > ProcessCommandBindings ( InKeyEvent ) )
2014-03-14 14:13:41 -04:00
{
return FReply : : Handled ( ) ;
}
return FReply : : Unhandled ( ) ;
}
bool FMainFrameActionCallbacks : : DefaultCanExecuteAction ( )
{
return FSlateApplication : : Get ( ) . IsNormalExecution ( ) ;
}
void FMainFrameActionCallbacks : : ChoosePackagesToSave ( )
{
const bool bPromptUserToSave = true ;
const bool bSaveMapPackages = true ;
const bool bSaveContentPackages = true ;
const bool bFastSave = false ;
const bool bClosingEditor = false ;
const bool bNotifyNoPackagesSaved = true ;
2015-02-27 04:17:41 -05:00
const bool bCanBeDeclined = false ;
FEditorFileUtils : : SaveDirtyPackages ( bPromptUserToSave , bSaveMapPackages , bSaveContentPackages , bFastSave , bNotifyNoPackagesSaved , bCanBeDeclined ) ;
2014-03-14 14:13:41 -04:00
}
void FMainFrameActionCallbacks : : ChoosePackagesToCheckIn ( )
{
2015-01-14 06:59:46 -05:00
FSourceControlWindows : : ChoosePackagesToCheckIn ( ) ;
2014-03-14 14:13:41 -04:00
}
bool FMainFrameActionCallbacks : : CanChoosePackagesToCheckIn ( )
{
2015-01-14 06:59:46 -05:00
return FSourceControlWindows : : CanChoosePackagesToCheckIn ( ) ;
2014-03-14 14:13:41 -04:00
}
void FMainFrameActionCallbacks : : ConnectToSourceControl ( )
{
2014-10-09 11:26:06 -04:00
ELoginWindowMode : : Type Mode = ! FSlateApplication : : Get ( ) . GetActiveModalWindow ( ) . IsValid ( ) ? ELoginWindowMode : : Modeless : ELoginWindowMode : : Modal ;
ISourceControlModule : : Get ( ) . ShowLoginDialog ( FSourceControlLoginClosed ( ) , Mode ) ;
2014-03-14 14:13:41 -04:00
}
2014-10-14 13:02:53 -04:00
bool FMainFrameActionCallbacks : : CanSaveWorld ( )
{
return FSlateApplication : : Get ( ) . IsNormalExecution ( ) & & ( ! GUnrealEd | | ! GUnrealEd - > GetPackageAutoSaver ( ) . IsAutoSaving ( ) ) ;
}
2014-03-14 14:13:41 -04:00
void FMainFrameActionCallbacks : : SaveAll ( )
{
const bool bPromptUserToSave = false ;
const bool bSaveMapPackages = true ;
const bool bSaveContentPackages = true ;
const bool bFastSave = false ;
2015-02-27 04:17:41 -05:00
const bool bNotifyNoPackagesSaved = false ;
const bool bCanBeDeclined = false ;
FEditorFileUtils : : SaveDirtyPackages ( bPromptUserToSave , bSaveMapPackages , bSaveContentPackages , bFastSave , bNotifyNoPackagesSaved , bCanBeDeclined ) ;
2014-03-14 14:13:41 -04:00
}
TArray < FString > FMainFrameActionCallbacks : : ProjectNames ;
void FMainFrameActionCallbacks : : CacheProjectNames ( )
{
ProjectNames . Empty ( ) ;
// The switch project menu is filled with recently opened project files
2015-04-20 10:12:55 -04:00
ProjectNames = GetDefault < UEditorSettings > ( ) - > RecentlyOpenedProjectFiles ;
2014-03-14 14:13:41 -04:00
}
void FMainFrameActionCallbacks : : NewProject ( bool bAllowProjectOpening , bool bAllowProjectCreate )
{
if ( GUnrealEd - > WarnIfLightingBuildIsCurrentlyRunning ( ) )
{
return ;
}
2014-09-09 12:16:36 -04:00
FText Title ;
if ( bAllowProjectOpening & & bAllowProjectCreate )
{
Title = LOCTEXT ( " SelectProjectWindowHeader " , " Select Project " ) ;
}
else if ( bAllowProjectOpening )
{
Title = LOCTEXT ( " OpenProjectWindowHeader " , " Open Project " ) ;
}
else
{
Title = LOCTEXT ( " NewProjectWindowHeader " , " New Project " ) ;
}
2014-03-14 14:13:41 -04:00
TSharedRef < SWindow > NewProjectWindow =
SNew ( SWindow )
2014-09-09 12:16:36 -04:00
. Title ( Title )
2014-08-18 06:48:04 -04:00
. ClientSize ( FMainFrameModule : : GetProjectBrowserWindowSize ( ) )
. SizingRule ( ESizingRule : : UserSized )
2014-03-14 14:13:41 -04:00
. SupportsMinimize ( false ) . SupportsMaximize ( false ) ;
NewProjectWindow - > SetContent ( FGameProjectGenerationModule : : Get ( ) . CreateGameProjectDialog ( bAllowProjectOpening , bAllowProjectCreate ) ) ;
IMainFrameModule & MainFrameModule = FModuleManager : : GetModuleChecked < IMainFrameModule > ( TEXT ( " MainFrame " ) ) ;
if ( MainFrameModule . GetParentWindow ( ) . IsValid ( ) )
{
FSlateApplication : : Get ( ) . AddWindowAsNativeChild ( NewProjectWindow , MainFrameModule . GetParentWindow ( ) . ToSharedRef ( ) ) ;
}
else
{
FSlateApplication : : Get ( ) . AddWindow ( NewProjectWindow ) ;
}
}
void FMainFrameActionCallbacks : : AddCodeToProject ( )
{
FGameProjectGenerationModule : : Get ( ) . OpenAddCodeToProjectDialog ( ) ;
}
2015-02-04 04:24:32 -05:00
/**
* Gets compilation flags for UAT for this system .
*/
const TCHAR * GetUATCompilationFlags ( )
{
return FRocketSupport : : IsRocket ( ) | | ! FSourceCodeNavigation : : IsCompilerAvailable ( )
? TEXT ( " -nocompile " )
: TEXT ( " -nocompileeditor " ) ;
}
void FMainFrameActionCallbacks : : CookContent ( const FName InPlatformInfoName )
2014-03-14 14:13:41 -04:00
{
2014-06-05 12:13:44 -04:00
const PlatformInfo : : FPlatformInfo * const PlatformInfo = PlatformInfo : : FindPlatformInfo ( InPlatformInfoName ) ;
check ( PlatformInfo ) ;
2014-03-14 14:13:41 -04:00
FString OptionalParams ;
2014-06-05 12:13:44 -04:00
if ( ! FModuleManager : : LoadModuleChecked < IProjectTargetPlatformEditorModule > ( " ProjectTargetPlatformEditor " ) . ShowUnsupportedTargetWarning ( PlatformInfo - > VanillaPlatformName ) )
2014-05-29 17:38:00 -04:00
{
return ;
}
2014-07-31 13:31:22 -04:00
if ( PlatformInfo - > SDKStatus = = PlatformInfo : : EPlatformSDKStatus : : NotInstalled )
{
IMainFrameModule & MainFrameModule = FModuleManager : : GetModuleChecked < IMainFrameModule > ( TEXT ( " MainFrame " ) ) ;
MainFrameModule . BroadcastMainFrameSDKNotInstalled ( PlatformInfo - > TargetPlatformName . ToString ( ) , PlatformInfo - > SDKTutorial ) ;
return ;
}
2014-06-05 12:13:44 -04:00
// Append any extra UAT flags specified for this platform flavor
if ( ! PlatformInfo - > UATCommandLine . IsEmpty ( ) )
{
OptionalParams + = TEXT ( " " ) ;
OptionalParams + = PlatformInfo - > UATCommandLine ;
}
2015-02-13 15:31:12 -05:00
else
{
OptionalParams + = TEXT ( " -targetplatform= " ) ;
OptionalParams + = * PlatformInfo - > TargetPlatformName . ToString ( ) ;
}
2014-03-14 14:13:41 -04:00
const bool bRunningDebug = FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " debug " ) ) ;
if ( bRunningDebug )
{
OptionalParams + = TEXT ( " -UseDebugParamForEditorExe " ) ;
}
FString ProjectPath = FPaths : : IsProjectFilePathSet ( ) ? FPaths : : ConvertRelativePathToFull ( FPaths : : GetProjectFilePath ( ) ) : FPaths : : RootDir ( ) / FApp : : GetGameName ( ) / FApp : : GetGameName ( ) + TEXT ( " .uproject " ) ;
2015-03-10 09:50:47 -04:00
FString CommandLine = FString : : Printf ( TEXT ( " BuildCookRun %s%s%s -nop4 -project= \" %s \" -cook -ue4exe=%s %s " ) ,
2015-02-04 04:24:32 -05:00
FRocketSupport : : IsRocket ( ) ? TEXT ( " -rocket " ) : TEXT ( " " ) ,
GetUATCompilationFlags ( ) ,
2014-03-14 14:13:41 -04:00
FApp : : IsEngineInstalled ( ) ? TEXT ( " -installed " ) : TEXT ( " " ) ,
* ProjectPath ,
2014-07-15 15:21:09 -04:00
* FUnrealEdMisc : : Get ( ) . GetExecutableForCommandlets ( ) ,
2014-03-14 14:13:41 -04:00
* OptionalParams
) ;
2014-06-05 12:13:44 -04:00
CreateUatTask ( CommandLine , PlatformInfo - > DisplayName , LOCTEXT ( " CookingContentTaskName " , " Cooking content " ) , LOCTEXT ( " CookingTaskName " , " Cooking " ) , FEditorStyle : : GetBrush ( TEXT ( " MainFrame.CookContent " ) ) ) ;
2014-03-14 14:13:41 -04:00
}
2014-06-05 12:13:44 -04:00
bool FMainFrameActionCallbacks : : CookContentCanExecute ( const FName PlatformInfoName )
2014-03-14 14:13:41 -04:00
{
return true ;
}
void FMainFrameActionCallbacks : : PackageBuildConfiguration ( EProjectPackagingBuildConfigurations BuildConfiguration )
{
UProjectPackagingSettings * PackagingSettings = Cast < UProjectPackagingSettings > ( UProjectPackagingSettings : : StaticClass ( ) - > GetDefaultObject ( ) ) ;
PackagingSettings - > BuildConfiguration = BuildConfiguration ;
}
2014-08-06 17:53:07 -04:00
bool FMainFrameActionCallbacks : : CanPackageBuildConfiguration ( EProjectPackagingBuildConfigurations BuildConfiguration )
{
UProjectPackagingSettings * PackagingSettings = Cast < UProjectPackagingSettings > ( UProjectPackagingSettings : : StaticClass ( ) - > GetDefaultObject ( ) ) ;
if ( PackagingSettings - > ForDistribution & & BuildConfiguration ! = PPBC_Shipping )
{
return false ;
}
return true ;
}
2014-03-14 14:13:41 -04:00
bool FMainFrameActionCallbacks : : PackageBuildConfigurationIsChecked ( EProjectPackagingBuildConfigurations BuildConfiguration )
{
return ( GetDefault < UProjectPackagingSettings > ( ) - > BuildConfiguration = = BuildConfiguration ) ;
}
2014-06-05 12:13:44 -04:00
void FMainFrameActionCallbacks : : PackageProject ( const FName InPlatformInfoName )
2014-03-14 14:13:41 -04:00
{
// does the project have any code?
FGameProjectGenerationModule & GameProjectModule = FModuleManager : : LoadModuleChecked < FGameProjectGenerationModule > ( TEXT ( " GameProjectGeneration " ) ) ;
2014-10-13 11:47:21 -04:00
bool bProjectHasCode = GameProjectModule . Get ( ) . ProjectHasCodeFiles ( ) ;
2014-03-14 14:13:41 -04:00
2014-06-05 12:13:44 -04:00
const PlatformInfo : : FPlatformInfo * const PlatformInfo = PlatformInfo : : FindPlatformInfo ( InPlatformInfoName ) ;
check ( PlatformInfo ) ;
2015-02-06 06:43:45 -05:00
if ( PlatformInfo - > SDKStatus = = PlatformInfo : : EPlatformSDKStatus : : NotInstalled | | ( bProjectHasCode & & PlatformInfo - > bUsesHostCompiler & & ! FSourceCodeNavigation : : IsCompilerAvailable ( ) ) )
2014-07-31 13:31:22 -04:00
{
IMainFrameModule & MainFrameModule = FModuleManager : : GetModuleChecked < IMainFrameModule > ( TEXT ( " MainFrame " ) ) ;
MainFrameModule . BroadcastMainFrameSDKNotInstalled ( PlatformInfo - > TargetPlatformName . ToString ( ) , PlatformInfo - > SDKTutorial ) ;
2014-08-01 20:30:13 -04:00
TArray < FAnalyticsEventAttribute > ParamArray ;
ParamArray . Add ( FAnalyticsEventAttribute ( TEXT ( " Time " ) , 0.0 ) ) ;
FEditorAnalytics : : ReportEvent ( TEXT ( " Editor.Package.Failed " ) , PlatformInfo - > TargetPlatformName . ToString ( ) , bProjectHasCode , EAnalyticsErrorCodes : : SDKNotFound , ParamArray ) ;
2014-07-31 13:31:22 -04:00
return ;
}
2014-03-14 14:13:41 -04:00
{
2014-06-05 12:13:44 -04:00
const ITargetPlatform * const Platform = GetTargetPlatformManager ( ) - > FindTargetPlatform ( PlatformInfo - > TargetPlatformName . ToString ( ) ) ;
if ( Platform )
2014-03-14 14:13:41 -04:00
{
2014-09-18 08:10:29 -04:00
FString NotInstalledTutorialLink ;
2014-07-22 17:53:31 -04:00
FString ProjectPath = FPaths : : IsProjectFilePathSet ( ) ? FPaths : : ConvertRelativePathToFull ( FPaths : : GetProjectFilePath ( ) ) : FPaths : : RootDir ( ) / FApp : : GetGameName ( ) / FApp : : GetGameName ( ) + TEXT ( " .uproject " ) ;
2014-10-10 20:54:09 -04:00
int32 Result = Platform - > CheckRequirements ( ProjectPath , bProjectHasCode , NotInstalledTutorialLink ) ;
2014-09-16 15:41:40 -04:00
// report to analytics
2014-08-01 20:30:13 -04:00
FEditorAnalytics : : ReportBuildRequirementsFailure ( TEXT ( " Editor.Package.Failed " ) , PlatformInfo - > TargetPlatformName . ToString ( ) , bProjectHasCode , Result ) ;
2014-09-16 15:41:40 -04:00
// report to message log
2014-10-10 20:49:06 -04:00
if ( ( Result & ETargetPlatformReadyStatus : : SDKNotFound ) ! = 0 )
2014-09-16 15:41:40 -04:00
{
2014-10-10 20:49:06 -04:00
AddMessageLog (
LOCTEXT ( " SdkNotFoundMessage " , " Software Development Kit (SDK) not found. " ) ,
FText : : Format ( LOCTEXT ( " SdkNotFoundMessageDetail " , " Please install the SDK for the {0} target platform! " ) , Platform - > DisplayName ( ) ) ,
NotInstalledTutorialLink
) ;
2014-09-16 15:41:40 -04:00
}
2014-10-10 20:49:06 -04:00
if ( ( Result & ETargetPlatformReadyStatus : : ProvisionNotFound ) ! = 0 )
2014-09-16 15:41:40 -04:00
{
2014-10-10 20:49:06 -04:00
AddMessageLog (
LOCTEXT ( " ProvisionNotFoundMessage " , " Provision not found. " ) ,
LOCTEXT ( " ProvisionNotFoundMessageDetail " , " A provision is required for deploying your app to the device. " ) ,
NotInstalledTutorialLink
) ;
}
2014-09-16 15:41:40 -04:00
2014-10-10 20:49:06 -04:00
if ( ( Result & ETargetPlatformReadyStatus : : SigningKeyNotFound ) ! = 0 )
{
AddMessageLog (
LOCTEXT ( " SigningKeyNotFoundMessage " , " Signing key not found. " ) ,
LOCTEXT ( " SigningKeyNotFoundMessageDetail " , " The app could not be digitally signed, because the signing key is not configured. " ) ,
NotInstalledTutorialLink
) ;
2014-09-16 15:41:40 -04:00
}
2015-03-02 15:57:43 -05:00
if ( ( Result & ETargetPlatformReadyStatus : : ManifestNotFound ) ! = 0 )
{
AddMessageLog (
LOCTEXT ( " ManifestNotFound " , " Manifest not found. " ) ,
LOCTEXT ( " ManifestNotFoundMessageDetail " , " The generated application manifest could not be found. " ) ,
NotInstalledTutorialLink
) ;
}
2014-09-16 15:41:40 -04:00
// report to main frame
2014-10-10 20:49:06 -04:00
bool UnrecoverableError = false ;
2014-07-22 17:53:31 -04:00
2014-10-10 20:49:06 -04:00
# if PLATFORM_WINDOWS
if ( ( Result & ETargetPlatformReadyStatus : : CodeUnsupported ) ! = 0 )
{
FMessageDialog : : Open ( EAppMsgType : : Ok , LOCTEXT ( " IOSNotSupported " , " Sorry, launching on a device is currently not supported for code-based iOS projects. This feature will be available in a future release. " ) ) ;
UnrecoverableError = true ;
}
2014-11-24 17:43:28 -05:00
else if ( ( Result & ETargetPlatformReadyStatus : : PluginsUnsupported ) ! = 0 )
2014-10-10 20:49:06 -04:00
{
2014-07-22 17:53:31 -04:00
FMessageDialog : : Open ( EAppMsgType : : Ok , LOCTEXT ( " IOSNotSupported " , " Sorry, launching on a device is currently not supported for content based projects with third-party plugins. This feature will be available in a future release. " ) ) ;
2014-10-10 20:49:06 -04:00
UnrecoverableError = true ;
}
2014-07-22 17:53:31 -04:00
# endif
2014-10-10 20:49:06 -04:00
if ( UnrecoverableError )
{
return ;
2014-06-05 12:13:44 -04:00
}
2014-03-14 14:13:41 -04:00
}
}
2014-06-05 12:13:44 -04:00
if ( ! FModuleManager : : LoadModuleChecked < IProjectTargetPlatformEditorModule > ( " ProjectTargetPlatformEditor " ) . ShowUnsupportedTargetWarning ( PlatformInfo - > VanillaPlatformName ) )
2014-05-29 17:38:00 -04:00
{
return ;
}
2014-03-14 14:13:41 -04:00
UProjectPackagingSettings * PackagingSettings = Cast < UProjectPackagingSettings > ( UProjectPackagingSettings : : StaticClass ( ) - > GetDefaultObject ( ) ) ;
// let the user pick a target directory
if ( PackagingSettings - > StagingDirectory . Path . IsEmpty ( ) )
{
PackagingSettings - > StagingDirectory . Path = FPaths : : GameDir ( ) ;
}
FString OutFolderName ;
void * ParentWindowWindowHandle = nullptr ;
IMainFrameModule & MainFrameModule = FModuleManager : : LoadModuleChecked < IMainFrameModule > ( TEXT ( " MainFrame " ) ) ;
const TSharedPtr < SWindow > & MainFrameParentWindow = MainFrameModule . GetParentWindow ( ) ;
if ( MainFrameParentWindow . IsValid ( ) & & MainFrameParentWindow - > GetNativeWindow ( ) . IsValid ( ) )
{
ParentWindowWindowHandle = MainFrameParentWindow - > GetNativeWindow ( ) - > GetOSWindowHandle ( ) ;
}
if ( ! FDesktopPlatformModule : : Get ( ) - > OpenDirectoryDialog ( ParentWindowWindowHandle , LOCTEXT ( " PackageDirectoryDialogTitle " , " Package project... " ) . ToString ( ) , PackagingSettings - > StagingDirectory . Path , OutFolderName ) )
{
return ;
}
PackagingSettings - > StagingDirectory . Path = OutFolderName ;
PackagingSettings - > SaveConfig ( ) ;
// create the packager process
FString OptionalParams ;
if ( PackagingSettings - > FullRebuild )
{
OptionalParams + = TEXT ( " -clean " ) ;
}
2015-02-13 15:35:16 -05:00
if ( PackagingSettings - > bCompressed )
{
OptionalParams + = TEXT ( " -compressed " ) ;
}
2015-02-03 16:06:53 -05:00
if ( PackagingSettings - > bCookAll )
{
OptionalParams + = TEXT ( " -CookAll " ) ;
// maps only flag only affects cook all
if ( PackagingSettings - > bCookMapsOnly )
{
OptionalParams + = TEXT ( " -CookMapsOnly " ) ;
}
}
2015-02-03 17:32:30 -05:00
else if ( PackagingSettings - > MapsToCook . Num ( ) )
2015-02-03 16:06:53 -05:00
{
OptionalParams + = TEXT ( " -mapstocook= " ) ;
for ( const auto & Map : PackagingSettings - > MapsToCook )
{
OptionalParams + = FString : : Printf ( TEXT ( " %s+ " ) , * Map . FilePath ) ;
}
OptionalParams . RemoveFromEnd ( " + " ) ;
}
2014-03-14 14:13:41 -04:00
if ( PackagingSettings - > UsePakFile )
{
2014-08-04 08:08:56 -04:00
if ( PlatformInfo - > TargetPlatformName ! = FName ( " HTML5 " ) )
{
2014-03-14 14:13:41 -04:00
OptionalParams + = TEXT ( " -pak " ) ;
2014-08-04 08:08:56 -04:00
}
2014-03-14 14:13:41 -04:00
}
2014-09-23 13:55:06 -04:00
if ( PackagingSettings - > IncludePrerequisites )
{
OptionalParams + = TEXT ( " -prereqs " ) ;
}
2014-03-14 14:13:41 -04:00
if ( PackagingSettings - > ForDistribution )
{
2015-02-18 09:21:55 -05:00
OptionalParams + = TEXT ( " -distribution " ) ;
}
if ( ! PackagingSettings - > IncludeDebugFiles )
{
OptionalParams + = TEXT ( " -nodebuginfo " ) ;
2014-03-14 14:13:41 -04:00
}
2015-02-13 15:31:12 -05:00
if ( PlatformInfo - > TargetPlatformName = = FName ( " WindowsNoEditor " ) & & PlatformInfo - > PlatformFlavor = = TEXT ( " Win32 " ) )
2014-12-06 10:29:12 -05:00
{
FString MinumumSupportedWindowsOS ;
GConfig - > GetString ( TEXT ( " /Script/WindowsTargetPlatform.WindowsTargetSettings " ) , TEXT ( " MinimumOSVersion " ) , MinumumSupportedWindowsOS , GEngineIni ) ;
if ( MinumumSupportedWindowsOS = = TEXT ( " MSOS_XP " ) )
{
OptionalParams + = TEXT ( " -OverrideMinimumOS=WinXP " ) ;
}
}
2014-03-14 14:13:41 -04:00
2014-06-05 12:13:44 -04:00
// Append any extra UAT flags specified for this platform flavor
if ( ! PlatformInfo - > UATCommandLine . IsEmpty ( ) )
{
OptionalParams + = TEXT ( " " ) ;
OptionalParams + = PlatformInfo - > UATCommandLine ;
}
2015-02-13 15:31:12 -05:00
else
{
OptionalParams + = TEXT ( " -targetplatform= " ) ;
OptionalParams + = * PlatformInfo - > TargetPlatformName . ToString ( ) ;
}
2014-06-05 12:13:44 -04:00
2014-03-14 14:13:41 -04:00
// only build if the project has code that might need to be built
2015-02-01 12:33:30 -05:00
if ( bProjectHasCode & & FSourceCodeNavigation : : IsCompilerAvailable ( ) )
2014-03-14 14:13:41 -04:00
{
OptionalParams + = TEXT ( " -build " ) ;
}
2014-12-10 09:03:15 -05:00
// we can include the crash reporter for any non-code projects or internal builds (we don't have the symbols to interpret external builds of code-based projects)
if ( PackagingSettings - > IncludeCrashReporter & & ( ! bProjectHasCode | | FEngineBuildSettings : : IsInternalBuild ( ) ) )
{
OptionalParams + = TEXT ( " -CrashReporter " ) ;
}
2015-04-09 05:52:05 -04:00
if ( PackagingSettings - > bBuildHttpChunkInstallData )
{
OptionalParams + = FString : : Printf ( TEXT ( " -manifests -createchunkinstall -chunkinstalldirectory= \" %s \" -chunkinstallversion=%s " ) , * ( PackagingSettings - > HttpChunkInstallDataDirectory . Path ) , * ( PackagingSettings - > HttpChunkInstallDataVersion ) ) ;
}
2014-03-14 14:13:41 -04:00
FString ExecutableName = FPlatformProcess : : ExecutableName ( false ) ;
# if PLATFORM_WINDOWS
// turn UE4editor into UE4editor.cmd
if ( ExecutableName . EndsWith ( " .exe " , ESearchCase : : IgnoreCase ) & & ! FPaths : : GetBaseFilename ( ExecutableName ) . EndsWith ( " -cmd " , ESearchCase : : IgnoreCase ) )
{
FString NewExeName = ExecutableName . Left ( ExecutableName . Len ( ) - 4 ) + " -Cmd.exe " ;
if ( FPaths : : FileExists ( NewExeName ) )
{
ExecutableName = NewExeName ;
}
}
# endif
const bool bRunningDebug = FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " debug " ) ) ;
if ( bRunningDebug )
{
OptionalParams + = TEXT ( " -UseDebugParamForEditorExe " ) ;
}
2014-04-23 18:35:32 -04:00
FString Configuration = FindObject < UEnum > ( ANY_PACKAGE , TEXT ( " EProjectPackagingBuildConfigurations " ) ) - > GetEnumName ( PackagingSettings - > BuildConfiguration ) ;
Configuration = Configuration . Replace ( TEXT ( " PPBC_ " ) , TEXT ( " " ) ) ;
2014-03-14 14:13:41 -04:00
FString ProjectPath = FPaths : : IsProjectFilePathSet ( ) ? FPaths : : ConvertRelativePathToFull ( FPaths : : GetProjectFilePath ( ) ) : FPaths : : RootDir ( ) / FApp : : GetGameName ( ) / FApp : : GetGameName ( ) + TEXT ( " .uproject " ) ;
2015-03-10 09:50:47 -04:00
FString CommandLine = FString : : Printf ( TEXT ( " BuildCookRun %s%s%s -nop4 -project= \" %s \" -cook -stage -archive -archivedirectory= \" %s \" -package -clientconfig=%s -ue4exe=%s %s -utf8output " ) ,
2015-02-04 04:24:32 -05:00
FRocketSupport : : IsRocket ( ) ? TEXT ( " -rocket " ) : TEXT ( " " ) ,
GetUATCompilationFlags ( ) ,
2014-03-14 14:13:41 -04:00
FApp : : IsEngineInstalled ( ) ? TEXT ( " -installed " ) : TEXT ( " " ) ,
* ProjectPath ,
* PackagingSettings - > StagingDirectory . Path ,
2014-04-23 18:35:32 -04:00
* Configuration ,
2014-03-14 14:13:41 -04:00
* ExecutableName ,
* OptionalParams
) ;
2014-06-05 12:13:44 -04:00
CreateUatTask ( CommandLine , PlatformInfo - > DisplayName , LOCTEXT ( " PackagingProjectTaskName " , " Packaging project " ) , LOCTEXT ( " PackagingTaskName " , " Packaging " ) , FEditorStyle : : GetBrush ( TEXT ( " MainFrame.PackageProject " ) ) ) ;
2014-03-14 14:13:41 -04:00
}
2014-07-31 13:31:22 -04:00
bool FMainFrameActionCallbacks : : PackageProjectCanExecute ( const FName PlatformInfoName )
2014-03-14 14:13:41 -04:00
{
2014-07-03 11:20:25 -04:00
// For a binary Rocket build, Development is ALWAYS Win64, and Shipping is ALWAYS Win32.
2014-07-31 13:31:22 -04:00
if ( FRocketSupport : : IsRocket ( ) )
2014-07-03 11:20:25 -04:00
{
const EProjectPackagingBuildConfigurations BuildConfiguration = GetDefault < UProjectPackagingSettings > ( ) - > BuildConfiguration ;
switch ( BuildConfiguration )
{
case PPBC_DebugGame : // DebugGame uses the same libs as Development, so fall through and apply the same validation logic
case PPBC_Development :
return PlatformInfoName ! = " WindowsNoEditor_Win32 " ;
case PPBC_Shipping :
return PlatformInfoName ! = " WindowsNoEditor_Win64 " ;
default :
break ;
}
}
2014-07-31 13:31:22 -04:00
return true ;
2014-03-14 14:13:41 -04:00
}
void FMainFrameActionCallbacks : : RefreshCodeProject ( )
{
if ( ! FSourceCodeNavigation : : IsCompilerAvailable ( ) )
{
// Attempt to trigger the tutorial if the user doesn't have a compiler installed for the project.
FSourceCodeNavigation : : AccessOnCompilerNotFound ( ) . Broadcast ( ) ;
}
2015-04-09 11:11:48 -04:00
FText FailReason , FailLog ;
if ( ! FGameProjectGenerationModule : : Get ( ) . UpdateCodeProject ( FailReason , FailLog ) )
2014-03-14 14:13:41 -04:00
{
2015-04-09 11:11:48 -04:00
SOutputLogDialog : : Open ( LOCTEXT ( " RefreshProject " , " Refresh Project " ) , FailReason , FailLog , FText : : GetEmpty ( ) ) ;
2014-03-14 14:13:41 -04:00
}
}
void FMainFrameActionCallbacks : : OpenIDE ( )
{
if ( ! FSourceCodeNavigation : : IsCompilerAvailable ( ) )
{
// Attempt to trigger the tutorial if the user doesn't have a compiler installed for the project.
FSourceCodeNavigation : : AccessOnCompilerNotFound ( ) . Broadcast ( ) ;
}
else
{
if ( ! FSourceCodeNavigation : : OpenModuleSolution ( ) )
{
2014-08-29 15:31:27 -04:00
FString SolutionPath ;
if ( FDesktopPlatformModule : : Get ( ) - > GetSolutionPath ( SolutionPath ) )
{
const FString FullPath = IFileManager : : Get ( ) . ConvertToAbsolutePathForExternalAppForRead ( * SolutionPath ) ;
const FText Message = FText : : Format ( LOCTEXT ( " OpenIDEFailed_MissingFile " , " Could not open {0} for project {1} " ) , FSourceCodeNavigation : : GetSuggestedSourceCodeIDE ( ) , FText : : FromString ( FullPath ) ) ;
FMessageDialog : : Open ( EAppMsgType : : Ok , Message ) ;
}
else
{
FMessageDialog : : Open ( EAppMsgType : : Ok , LOCTEXT ( " OpenIDEFailed_MissingSolution " , " Couldn't find solution " ) ) ;
}
2014-03-14 14:13:41 -04:00
}
}
}
void FMainFrameActionCallbacks : : PackagingSettings ( )
{
2014-08-22 07:18:30 -04:00
FModuleManager : : LoadModuleChecked < ISettingsModule > ( " Settings " ) . ShowViewer ( " Project " , " Project " , " Packaging " ) ;
2014-03-14 14:13:41 -04:00
}
2015-01-27 16:31:40 -05:00
//void FMainFrameActionCallbacks::LocalizeProject()
//{
// FModuleManager::LoadModuleChecked<ILocalizationDashboardModule>("LocalizationDashboard").Show();
//}
2014-03-14 14:13:41 -04:00
void FMainFrameActionCallbacks : : SwitchProjectByIndex ( int32 ProjectIndex )
{
FUnrealEdMisc : : Get ( ) . SwitchProject ( ProjectNames [ ProjectIndex ] ) ;
}
void FMainFrameActionCallbacks : : SwitchProject ( const FString & GameOrProjectFileName )
{
FUnrealEdMisc : : Get ( ) . SwitchProject ( GameOrProjectFileName ) ;
}
2014-04-02 18:09:23 -04:00
void FMainFrameActionCallbacks : : OpenBackupDirectory ( FString BackupFile )
{
FPlatformProcess : : LaunchFileInDefaultExternalApplication ( * FPaths : : GetPath ( FPaths : : ConvertRelativePathToFull ( BackupFile ) ) ) ;
}
void FMainFrameActionCallbacks : : ResetLayout ( )
{
if ( EAppReturnType : : Ok ! = OpenMsgDlgInt ( EAppMsgType : : OkCancel , LOCTEXT ( " ActionRestartMsg " , " This action requires the editor to restart; you will be prompted to save any changes. Continue? " ) , LOCTEXT ( " ResetUILayout_Title " , " Reset UI Layout " ) ) )
{
return ;
}
// make a backup
2015-04-20 10:12:55 -04:00
GetMutableDefault < UEditorPerProjectUserSettings > ( ) - > SaveConfig ( ) ;
2014-04-02 18:09:23 -04:00
2014-05-15 17:34:02 -04:00
FString BackupEditorLayoutIni = FString : : Printf ( TEXT ( " %s_Backup.ini " ) , * FPaths : : GetBaseFilename ( GEditorLayoutIni , false ) ) ;
2014-04-02 18:09:23 -04:00
2014-05-15 17:34:02 -04:00
if ( COPY_Fail = = IFileManager : : Get ( ) . Copy ( * BackupEditorLayoutIni , * GEditorLayoutIni ) )
2014-04-02 18:09:23 -04:00
{
FMessageLog EditorErrors ( " EditorErrors " ) ;
2014-05-15 17:34:02 -04:00
if ( ! FPaths : : FileExists ( GEditorLayoutIni ) )
2014-04-02 18:09:23 -04:00
{
FFormatNamedArguments Arguments ;
2014-05-15 17:34:02 -04:00
Arguments . Add ( TEXT ( " FileName " ) , FText : : FromString ( GEditorLayoutIni ) ) ;
2014-04-02 18:09:23 -04:00
EditorErrors . Warning ( FText : : Format ( LOCTEXT ( " UnsuccessfulBackup_NoExist_Notification " , " Unsuccessful backup! {FileName} does not exist! " ) , Arguments ) ) ;
}
2014-05-15 17:34:02 -04:00
else if ( IFileManager : : Get ( ) . IsReadOnly ( * BackupEditorLayoutIni ) )
2014-04-02 18:09:23 -04:00
{
FFormatNamedArguments Arguments ;
2014-05-15 17:34:02 -04:00
Arguments . Add ( TEXT ( " FileName " ) , FText : : FromString ( FPaths : : ConvertRelativePathToFull ( BackupEditorLayoutIni ) ) ) ;
2014-04-02 18:09:23 -04:00
EditorErrors . Warning ( FText : : Format ( LOCTEXT ( " UnsuccessfulBackup_ReadOnly_Notification " , " Unsuccessful backup! {FileName} is read-only! " ) , Arguments ) ) ;
}
else
{
// We don't specifically know why it failed, this is a fallback.
FFormatNamedArguments Arguments ;
2014-05-15 17:34:02 -04:00
Arguments . Add ( TEXT ( " SourceFileName " ) , FText : : FromString ( GEditorLayoutIni ) ) ;
Arguments . Add ( TEXT ( " BackupFileName " ) , FText : : FromString ( FPaths : : ConvertRelativePathToFull ( BackupEditorLayoutIni ) ) ) ;
2014-04-02 18:09:23 -04:00
EditorErrors . Warning ( FText : : Format ( LOCTEXT ( " UnsuccessfulBackup_Fallback_Notification " , " Unsuccessful backup of {SourceFileName} to {BackupFileName} " ) , Arguments ) ) ;
}
EditorErrors . Notify ( LOCTEXT ( " BackupUnsuccessful_Title " , " Backup Unsuccessful! " ) ) ;
}
else
{
FNotificationInfo ErrorNotification ( FText : : GetEmpty ( ) ) ;
ErrorNotification . bFireAndForget = true ;
ErrorNotification . ExpireDuration = 3.0f ;
ErrorNotification . bUseThrobber = true ;
2014-05-15 17:34:02 -04:00
ErrorNotification . Hyperlink = FSimpleDelegate : : CreateStatic ( & FMainFrameActionCallbacks : : OpenBackupDirectory , BackupEditorLayoutIni ) ;
2014-04-02 18:09:23 -04:00
ErrorNotification . HyperlinkText = LOCTEXT ( " SuccessfulBackup_Notification_Hyperlink " , " Open Directory " ) ;
ErrorNotification . Text = LOCTEXT ( " SuccessfulBackup_Notification " , " Backup Successful! " ) ;
ErrorNotification . Image = FEditorStyle : : GetBrush ( TEXT ( " NotificationList.SuccessImage " ) ) ;
FSlateNotificationManager : : Get ( ) . AddNotification ( ErrorNotification ) ;
}
// reset layout & restart Editor
FUnrealEdMisc : : Get ( ) . AllowSavingLayoutOnClose ( false ) ;
FUnrealEdMisc : : Get ( ) . RestartEditor ( false ) ;
}
2014-03-14 14:13:41 -04:00
void FMainFrameActionCallbacks : : SaveLayout ( )
{
FGlobalTabmanager : : Get ( ) - > SaveAllVisualState ( ) ;
// Write the saved state's config to disk
2014-05-15 17:34:02 -04:00
GConfig - > Flush ( false , GEditorLayoutIni ) ;
2014-03-14 14:13:41 -04:00
}
void FMainFrameActionCallbacks : : ToggleFullscreen_Execute ( )
{
if ( GIsEditor & & FApp : : HasGameName ( ) )
{
static TWeakPtr < SDockTab > LevelEditorTabPtr = FGlobalTabmanager : : Get ( ) - > InvokeTab ( FTabId ( " LevelEditor " ) ) ;
const TSharedPtr < SWindow > LevelEditorWindow = FSlateApplication : : Get ( ) . FindWidgetWindow ( LevelEditorTabPtr . Pin ( ) . ToSharedRef ( ) ) ;
if ( LevelEditorWindow - > GetWindowMode ( ) = = EWindowMode : : Windowed )
{
LevelEditorWindow - > SetWindowMode ( EWindowMode : : WindowedFullscreen ) ;
}
else
{
LevelEditorWindow - > SetWindowMode ( EWindowMode : : Windowed ) ;
}
}
}
bool FMainFrameActionCallbacks : : FullScreen_IsChecked ( )
{
2014-10-08 10:39:04 -04:00
const TSharedPtr < SDockTab > LevelEditorTabPtr = FModuleManager : : Get ( ) . GetModuleChecked < FLevelEditorModule > ( " LevelEditor " ) . GetLevelEditorTab ( ) ;
2014-03-14 14:13:41 -04:00
const TSharedPtr < SWindow > LevelEditorWindow = LevelEditorTabPtr . IsValid ( )
2014-10-08 10:39:04 -04:00
? LevelEditorTabPtr - > GetParentWindow ( )
2014-03-14 14:13:41 -04:00
: TSharedPtr < SWindow > ( ) ;
return ( LevelEditorWindow . IsValid ( ) )
? ( LevelEditorWindow - > GetWindowMode ( ) ! = EWindowMode : : Windowed )
: false ;
}
bool FMainFrameActionCallbacks : : CanSwitchToProject ( int32 InProjectIndex )
{
2014-10-14 10:31:43 -04:00
if ( FApp : : HasGameName ( ) & & ProjectNames [ InProjectIndex ] . StartsWith ( FApp : : GetGameName ( ) ) )
2014-03-14 14:13:41 -04:00
{
return false ;
}
if ( FPaths : : IsProjectFilePathSet ( ) & & ProjectNames [ InProjectIndex ] = = FPaths : : GetProjectFilePath ( ) )
{
return false ;
}
return true ;
}
bool FMainFrameActionCallbacks : : IsSwitchProjectChecked ( int32 InProjectIndex )
{
return CanSwitchToProject ( InProjectIndex ) = = false ;
}
void FMainFrameActionCallbacks : : Exit ( )
{
FSlateApplication : : Get ( ) . LeaveDebuggingMode ( ) ;
// Shut down the editor
// NOTE: We can't close the editor from within this stack frame as it will cause various DLLs
// (such as MainFrame) to become unloaded out from underneath the code pointer. We'll shut down
// as soon as it's safe to do so.
GEngine - > DeferredCommands . Add ( TEXT ( " CLOSE_SLATE_MAINFRAME " ) ) ;
}
bool FMainFrameActionCallbacks : : Undo_CanExecute ( )
{
return GUnrealEd - > Trans - > CanUndo ( ) & & FSlateApplication : : Get ( ) . IsNormalExecution ( ) ;
}
bool FMainFrameActionCallbacks : : Redo_CanExecute ( )
{
return GUnrealEd - > Trans - > CanRedo ( ) & & FSlateApplication : : Get ( ) . IsNormalExecution ( ) ;
}
void FMainFrameActionCallbacks : : ExecuteExecCommand ( FString Command )
{
GUnrealEd - > Exec ( GEditor - > GetEditorWorldContext ( true ) . World ( ) , * Command ) ;
}
void FMainFrameActionCallbacks : : OpenSlateApp_ViaModule ( FName AppName , FName ModuleName )
{
FModuleManager : : Get ( ) . LoadModule ( ModuleName ) ;
OpenSlateApp ( AppName ) ;
}
void FMainFrameActionCallbacks : : OpenSlateApp ( FName AppName )
{
FGlobalTabmanager : : Get ( ) - > InvokeTab ( FTabId ( AppName ) ) ;
}
bool FMainFrameActionCallbacks : : OpenSlateApp_IsChecked ( FName AppName )
{
return false ;
}
void FMainFrameActionCallbacks : : VisitAskAQuestionPage ( )
{
FString AskAQuestionURL ;
if ( FUnrealEdMisc : : Get ( ) . GetURL ( TEXT ( " AskAQuestionURL " ) , AskAQuestionURL , true ) )
{
FPlatformProcess : : LaunchURL ( * AskAQuestionURL , NULL , NULL ) ;
}
}
void FMainFrameActionCallbacks : : VisitSearchForAnswersPage ( )
{
FString SearchForAnswersURL ;
if ( FUnrealEdMisc : : Get ( ) . GetURL ( TEXT ( " SearchForAnswersURL " ) , SearchForAnswersURL , true ) )
{
FPlatformProcess : : LaunchURL ( * SearchForAnswersURL , NULL , NULL ) ;
}
}
void FMainFrameActionCallbacks : : VisitSupportWebSite ( )
{
FString SupportWebsiteURL ;
if ( FUnrealEdMisc : : Get ( ) . GetURL ( TEXT ( " SupportWebsiteURL " ) , SupportWebsiteURL , true ) )
{
FPlatformProcess : : LaunchURL ( * SupportWebsiteURL , NULL , NULL ) ;
}
}
void FMainFrameActionCallbacks : : VisitEpicGamesDotCom ( )
{
FString EpicGamesURL ;
if ( FUnrealEdMisc : : Get ( ) . GetURL ( TEXT ( " EpicGamesURL " ) , EpicGamesURL ) )
{
FPlatformProcess : : LaunchURL ( * EpicGamesURL , NULL , NULL ) ;
}
}
void FMainFrameActionCallbacks : : VisitWiki ( )
{
FString URL ;
if ( FUnrealEdMisc : : Get ( ) . GetURL ( TEXT ( " WikiURL " ) , URL ) )
{
FPlatformProcess : : LaunchURL ( * URL , NULL , NULL ) ;
}
}
void FMainFrameActionCallbacks : : VisitForums ( )
{
FString URL ;
if ( FUnrealEdMisc : : Get ( ) . GetURL ( TEXT ( " ForumsURL " ) , URL ) )
{
FPlatformProcess : : LaunchURL ( * URL , NULL , NULL ) ;
}
}
void FMainFrameActionCallbacks : : AboutUnrealEd_Execute ( )
{
const FText AboutWindowTitle = LOCTEXT ( " AboutUnrealEditor " , " About Unreal Editor " ) ;
TSharedPtr < SWindow > AboutWindow =
SNew ( SWindow )
. Title ( AboutWindowTitle )
. ClientSize ( FVector2D ( 600.f , 200.f ) )
. SupportsMaximize ( false ) . SupportsMinimize ( false )
. SizingRule ( ESizingRule : : FixedSize )
[
SNew ( SAboutScreen )
] ;
IMainFrameModule & MainFrame = FModuleManager : : LoadModuleChecked < IMainFrameModule > ( " MainFrame " ) ;
TSharedPtr < SWindow > ParentWindow = MainFrame . GetParentWindow ( ) ;
if ( ParentWindow . IsValid ( ) )
{
FSlateApplication : : Get ( ) . AddModalWindow ( AboutWindow . ToSharedRef ( ) , ParentWindow . ToSharedRef ( ) ) ;
}
else
{
FSlateApplication : : Get ( ) . AddWindow ( AboutWindow . ToSharedRef ( ) ) ;
}
}
2014-06-26 10:47:24 -04:00
void FMainFrameActionCallbacks : : CreditsUnrealEd_Execute ( )
{
const FText CreditsWindowTitle = LOCTEXT ( " CreditsUnrealEditor " , " Credits " ) ;
TSharedPtr < SWindow > CreditsWindow =
SNew ( SWindow )
. Title ( CreditsWindowTitle )
. ClientSize ( FVector2D ( 600.f , 700.f ) )
. SupportsMaximize ( false )
. SupportsMinimize ( false )
. SizingRule ( ESizingRule : : FixedSize )
[
SNew ( SCreditsScreen )
] ;
IMainFrameModule & MainFrame = FModuleManager : : LoadModuleChecked < IMainFrameModule > ( " MainFrame " ) ;
TSharedPtr < SWindow > ParentWindow = MainFrame . GetParentWindow ( ) ;
if ( ParentWindow . IsValid ( ) )
{
FSlateApplication : : Get ( ) . AddModalWindow ( CreditsWindow . ToSharedRef ( ) , ParentWindow . ToSharedRef ( ) ) ;
}
else
{
FSlateApplication : : Get ( ) . AddWindow ( CreditsWindow . ToSharedRef ( ) ) ;
}
}
2014-04-02 18:09:23 -04:00
void FMainFrameActionCallbacks : : OpenWidgetReflector_Execute ( )
{
FGlobalTabmanager : : Get ( ) - > InvokeTab ( FTabId ( " WidgetReflector " ) ) ;
}
2014-03-14 14:13:41 -04:00
/* FMainFrameActionCallbacks implementation
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2014-10-10 20:49:06 -04:00
void FMainFrameActionCallbacks : : AddMessageLog ( const FText & Text , const FText & Detail , const FString & TutorialLink )
{
TSharedRef < FTokenizedMessage > Message = FTokenizedMessage : : Create ( EMessageSeverity : : Error ) ;
Message - > AddToken ( FTextToken : : Create ( Text ) ) ;
Message - > AddToken ( FTextToken : : Create ( Detail ) ) ;
Message - > AddToken ( FTutorialToken : : Create ( TutorialLink ) ) ;
Message - > AddToken ( FDocumentationToken : : Create ( TEXT ( " Platforms/iOS/QuickStart/6 " ) ) ) ;
FMessageLog MessageLog ( " PackagingResults " ) ;
MessageLog . AddMessage ( Message ) ;
MessageLog . Open ( ) ;
}
2014-03-14 14:13:41 -04:00
void FMainFrameActionCallbacks : : CreateUatTask ( const FString & CommandLine , const FText & PlatformDisplayName , const FText & TaskName , const FText & TaskShortName , const FSlateBrush * TaskIcon )
{
// make sure that the UAT batch file is in place
# if PLATFORM_WINDOWS
FString RunUATScriptName = TEXT ( " RunUAT.bat " ) ;
FString CmdExe = TEXT ( " cmd.exe " ) ;
2014-07-08 00:06:17 -04:00
# elif PLATFORM_LINUX
FString RunUATScriptName = TEXT ( " RunUAT.sh " ) ;
2014-10-09 11:50:05 -04:00
FString CmdExe = TEXT ( " /bin/bash " ) ;
2014-03-14 14:13:41 -04:00
# else
FString RunUATScriptName = TEXT ( " RunUAT.command " ) ;
FString CmdExe = TEXT ( " /bin/sh " ) ;
# endif
FString UatPath = FPaths : : ConvertRelativePathToFull ( FPaths : : EngineDir ( ) / TEXT ( " Build/BatchFiles " ) / RunUATScriptName ) ;
2014-08-01 20:30:13 -04:00
FGameProjectGenerationModule & GameProjectModule = FModuleManager : : LoadModuleChecked < FGameProjectGenerationModule > ( TEXT ( " GameProjectGeneration " ) ) ;
2014-10-13 11:47:21 -04:00
bool bHasCode = GameProjectModule . Get ( ) . ProjectHasCodeFiles ( ) ;
2014-03-14 14:13:41 -04:00
if ( ! FPaths : : FileExists ( UatPath ) )
{
FFormatNamedArguments Arguments ;
Arguments . Add ( TEXT ( " File " ) , FText : : FromString ( UatPath ) ) ;
FMessageDialog : : Open ( EAppMsgType : : Ok , FText : : Format ( LOCTEXT ( " RequiredFileNotFoundMessage " , " A required file could not be found: \n {File} " ) , Arguments ) ) ;
2014-08-01 20:30:13 -04:00
TArray < FAnalyticsEventAttribute > ParamArray ;
ParamArray . Add ( FAnalyticsEventAttribute ( TEXT ( " Time " ) , 0.0 ) ) ;
FString EventName = ( CommandLine . Contains ( TEXT ( " -package " ) ) ? TEXT ( " Editor.Package " ) : TEXT ( " Editor.Cook " ) ) ;
FEditorAnalytics : : ReportEvent ( EventName + TEXT ( " .Failed " ) , PlatformDisplayName . ToString ( ) , bHasCode , EAnalyticsErrorCodes : : UATNotFound , ParamArray ) ;
2014-03-14 14:13:41 -04:00
return ;
}
# if PLATFORM_WINDOWS
FString FullCommandLine = FString : : Printf ( TEXT ( " /c \" \" %s \" %s \" " ) , * UatPath , * CommandLine ) ;
# else
FString FullCommandLine = FString : : Printf ( TEXT ( " \" %s \" %s " ) , * UatPath , * CommandLine ) ;
# endif
TSharedPtr < FMonitoredProcess > UatProcess = MakeShareable ( new FMonitoredProcess ( CmdExe , FullCommandLine , true ) ) ;
// create notification item
FFormatNamedArguments Arguments ;
Arguments . Add ( TEXT ( " Platform " ) , PlatformDisplayName ) ;
Arguments . Add ( TEXT ( " TaskName " ) , TaskName ) ;
FNotificationInfo Info ( FText : : Format ( LOCTEXT ( " UatTaskInProgressNotification " , " {TaskName} for {Platform}... " ) , Arguments ) ) ;
Info . Image = TaskIcon ;
Info . bFireAndForget = false ;
Info . ExpireDuration = 3.0f ;
Info . Hyperlink = FSimpleDelegate : : CreateStatic ( & FMainFrameActionCallbacks : : HandleUatHyperlinkNavigate ) ;
2014-06-17 12:05:50 -04:00
Info . HyperlinkText = LOCTEXT ( " ShowOutputLogHyperlink " , " Show Output Log " ) ;
2014-03-14 14:13:41 -04:00
Info . ButtonDetails . Add (
FNotificationButtonInfo (
LOCTEXT ( " UatTaskCancel " , " Cancel " ) ,
LOCTEXT ( " UatTaskCancelToolTip " , " Cancels execution of this task. " ) ,
FSimpleDelegate : : CreateStatic ( & FMainFrameActionCallbacks : : HandleUatCancelButtonClicked , UatProcess )
)
) ;
TSharedPtr < SNotificationItem > NotificationItem = FSlateNotificationManager : : Get ( ) . AddNotification ( Info ) ;
if ( ! NotificationItem . IsValid ( ) )
{
return ;
}
2014-06-23 18:10:01 -04:00
FString EventName = ( CommandLine . Contains ( TEXT ( " -package " ) ) ? TEXT ( " Editor.Package " ) : TEXT ( " Editor.Cook " ) ) ;
2014-08-01 20:30:13 -04:00
FEditorAnalytics : : ReportEvent ( EventName + TEXT ( " .Start " ) , PlatformDisplayName . ToString ( ) , bHasCode ) ;
2014-06-23 18:10:01 -04:00
2014-03-14 14:13:41 -04:00
NotificationItem - > SetCompletionState ( SNotificationItem : : CS_Pending ) ;
// launch the packager
TWeakPtr < SNotificationItem > NotificationItemPtr ( NotificationItem ) ;
2014-06-23 18:10:01 -04:00
EventData Data ;
Data . StartTime = FPlatformTime : : Seconds ( ) ;
Data . EventName = EventName ;
2014-08-01 20:30:13 -04:00
Data . bProjectHasCode = bHasCode ;
2014-06-23 18:10:01 -04:00
UatProcess - > OnCanceled ( ) . BindStatic ( & FMainFrameActionCallbacks : : HandleUatProcessCanceled , NotificationItemPtr , PlatformDisplayName , TaskShortName , Data ) ;
UatProcess - > OnCompleted ( ) . BindStatic ( & FMainFrameActionCallbacks : : HandleUatProcessCompleted , NotificationItemPtr , PlatformDisplayName , TaskShortName , Data ) ;
2014-03-14 14:13:41 -04:00
UatProcess - > OnOutput ( ) . BindStatic ( & FMainFrameActionCallbacks : : HandleUatProcessOutput , NotificationItemPtr , PlatformDisplayName , TaskShortName ) ;
if ( UatProcess - > Launch ( ) )
{
GEditor - > PlayEditorSound ( TEXT ( " /Engine/EditorSounds/Notifications/CompileStart_Cue.CompileStart_Cue " ) ) ;
}
else
{
GEditor - > PlayEditorSound ( TEXT ( " /Engine/EditorSounds/Notifications/CompileFailed_Cue.CompileFailed_Cue " ) ) ;
NotificationItem - > SetText ( LOCTEXT ( " UatLaunchFailedNotification " , " Failed to launch Unreal Automation Tool (UAT)! " ) ) ;
NotificationItem - > SetCompletionState ( SNotificationItem : : CS_Fail ) ;
NotificationItem - > ExpireAndFadeout ( ) ;
2014-08-01 20:30:13 -04:00
TArray < FAnalyticsEventAttribute > ParamArray ;
ParamArray . Add ( FAnalyticsEventAttribute ( TEXT ( " Time " ) , 0.0 ) ) ;
FEditorAnalytics : : ReportEvent ( EventName + TEXT ( " .Failed " ) , PlatformDisplayName . ToString ( ) , bHasCode , EAnalyticsErrorCodes : : UATLaunchFailure , ParamArray ) ;
2014-03-14 14:13:41 -04:00
}
}
/* FMainFrameActionCallbacks callbacks
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
class FMainFrameActionsNotificationTask
{
public :
FMainFrameActionsNotificationTask ( TWeakPtr < SNotificationItem > InNotificationItemPtr , SNotificationItem : : ECompletionState InCompletionState , const FText & InText )
: CompletionState ( InCompletionState )
, NotificationItemPtr ( InNotificationItemPtr )
, Text ( InText )
{ }
void DoTask ( ENamedThreads : : Type CurrentThread , const FGraphEventRef & MyCompletionGraphEvent )
{
if ( NotificationItemPtr . IsValid ( ) )
{
if ( CompletionState = = SNotificationItem : : CS_Fail )
{
GEditor - > PlayEditorSound ( TEXT ( " /Engine/EditorSounds/Notifications/CompileFailed_Cue.CompileFailed_Cue " ) ) ;
}
else
{
GEditor - > PlayEditorSound ( TEXT ( " /Engine/EditorSounds/Notifications/CompileSuccess_Cue.CompileSuccess_Cue " ) ) ;
}
TSharedPtr < SNotificationItem > NotificationItem = NotificationItemPtr . Pin ( ) ;
NotificationItem - > SetText ( Text ) ;
NotificationItem - > SetCompletionState ( CompletionState ) ;
NotificationItem - > ExpireAndFadeout ( ) ;
}
}
static ESubsequentsMode : : Type GetSubsequentsMode ( ) { return ESubsequentsMode : : TrackSubsequents ; }
ENamedThreads : : Type GetDesiredThread ( ) { return ENamedThreads : : GameThread ; }
2014-04-23 19:22:09 -04:00
FORCEINLINE TStatId GetStatId ( ) const
2014-03-14 14:13:41 -04:00
{
RETURN_QUICK_DECLARE_CYCLE_STAT ( FMainFrameActionsNotificationTask , STATGROUP_TaskGraphTasks ) ;
}
private :
SNotificationItem : : ECompletionState CompletionState ;
TWeakPtr < SNotificationItem > NotificationItemPtr ;
FText Text ;
} ;
void FMainFrameActionCallbacks : : HandleUatHyperlinkNavigate ( )
{
FGlobalTabmanager : : Get ( ) - > InvokeTab ( FName ( " OutputLog " ) ) ;
}
void FMainFrameActionCallbacks : : HandleUatCancelButtonClicked ( TSharedPtr < FMonitoredProcess > PackagerProcess )
{
if ( PackagerProcess . IsValid ( ) )
{
PackagerProcess - > Cancel ( true ) ;
}
}
2014-06-23 18:10:01 -04:00
void FMainFrameActionCallbacks : : HandleUatProcessCanceled ( TWeakPtr < SNotificationItem > NotificationItemPtr , FText PlatformDisplayName , FText TaskName , EventData Event )
2014-03-14 14:13:41 -04:00
{
FFormatNamedArguments Arguments ;
Arguments . Add ( TEXT ( " Platform " ) , PlatformDisplayName ) ;
Arguments . Add ( TEXT ( " TaskName " ) , TaskName ) ;
TGraphTask < FMainFrameActionsNotificationTask > : : CreateTask ( ) . ConstructAndDispatchWhenReady (
NotificationItemPtr ,
SNotificationItem : : CS_Fail ,
FText : : Format ( LOCTEXT ( " UatProcessFailedNotification " , " {TaskName} canceled! " ) , Arguments )
) ;
2014-08-01 20:30:13 -04:00
TArray < FAnalyticsEventAttribute > ParamArray ;
ParamArray . Add ( FAnalyticsEventAttribute ( TEXT ( " Time " ) , FPlatformTime : : Seconds ( ) - Event . StartTime ) ) ;
FEditorAnalytics : : ReportEvent ( Event . EventName + TEXT ( " .Canceled " ) , PlatformDisplayName . ToString ( ) , Event . bProjectHasCode , ParamArray ) ;
2014-03-14 14:13:41 -04:00
// FMessageLog("PackagingResults").Warning(FText::Format(LOCTEXT("UatProcessCanceledMessageLog", "{TaskName} for {Platform} canceled by user"), Arguments));
}
2015-02-01 12:33:30 -05:00
DECLARE_CYCLE_STAT ( TEXT ( " Requesting FMainFrameActionCallbacks::HandleUatProcessCompleted message dialog to present the error message " ) , STAT_FMainFrameActionCallbacks_HandleUatProcessCompleted_DialogMessage , STATGROUP_TaskGraphTasks ) ;
2014-06-23 18:10:01 -04:00
void FMainFrameActionCallbacks : : HandleUatProcessCompleted ( int32 ReturnCode , TWeakPtr < SNotificationItem > NotificationItemPtr , FText PlatformDisplayName , FText TaskName , EventData Event )
2014-03-14 14:13:41 -04:00
{
FFormatNamedArguments Arguments ;
Arguments . Add ( TEXT ( " Platform " ) , PlatformDisplayName ) ;
Arguments . Add ( TEXT ( " TaskName " ) , TaskName ) ;
if ( ReturnCode = = 0 )
{
TGraphTask < FMainFrameActionsNotificationTask > : : CreateTask ( ) . ConstructAndDispatchWhenReady (
NotificationItemPtr ,
SNotificationItem : : CS_Success ,
FText : : Format ( LOCTEXT ( " UatProcessSucceededNotification " , " {TaskName} complete! " ) , Arguments )
) ;
2014-08-01 20:30:13 -04:00
TArray < FAnalyticsEventAttribute > ParamArray ;
ParamArray . Add ( FAnalyticsEventAttribute ( TEXT ( " Time " ) , FPlatformTime : : Seconds ( ) - Event . StartTime ) ) ;
FEditorAnalytics : : ReportEvent ( Event . EventName + TEXT ( " .Completed " ) , PlatformDisplayName . ToString ( ) , Event . bProjectHasCode , ParamArray ) ;
2014-06-23 18:10:01 -04:00
2014-03-14 14:13:41 -04:00
// FMessageLog("PackagingResults").Info(FText::Format(LOCTEXT("UatProcessSuccessMessageLog", "{TaskName} for {Platform} completed successfully"), Arguments));
}
else
{
TGraphTask < FMainFrameActionsNotificationTask > : : CreateTask ( ) . ConstructAndDispatchWhenReady (
NotificationItemPtr ,
SNotificationItem : : CS_Fail ,
FText : : Format ( LOCTEXT ( " PackagerFailedNotification " , " {TaskName} failed! " ) , Arguments )
) ;
2014-08-01 20:30:13 -04:00
TArray < FAnalyticsEventAttribute > ParamArray ;
ParamArray . Add ( FAnalyticsEventAttribute ( TEXT ( " Time " ) , FPlatformTime : : Seconds ( ) - Event . StartTime ) ) ;
FEditorAnalytics : : ReportEvent ( Event . EventName + TEXT ( " .Failed " ) , PlatformDisplayName . ToString ( ) , Event . bProjectHasCode , ReturnCode , ParamArray ) ;
2014-06-23 18:10:01 -04:00
2015-02-01 12:33:30 -05:00
// Present a message dialog if we want the error message to be prominent.
if ( FEditorAnalytics : : ShouldElevateMessageThroughDialog ( ReturnCode ) )
{
FSimpleDelegateGraphTask : : CreateAndDispatchWhenReady (
FSimpleDelegateGraphTask : : FDelegate : : CreateLambda ( [ = ] ( ) {
FMessageDialog : : Open ( EAppMsgType : : Ok , FText : : FromString ( FEditorAnalytics : : TranslateErrorCode ( ReturnCode ) ) ) ;
} ) ,
GET_STATID ( STAT_FMainFrameActionCallbacks_HandleUatProcessCompleted_DialogMessage ) ,
nullptr ,
ENamedThreads : : GameThread
) ;
}
2014-03-14 14:13:41 -04:00
// FMessageLog("PackagingResults").Info(FText::Format(LOCTEXT("UatProcessFailedMessageLog", "{TaskName} for {Platform} failed"), Arguments));
}
}
void FMainFrameActionCallbacks : : HandleUatProcessOutput ( FString Output , TWeakPtr < SNotificationItem > NotificationItemPtr , FText PlatformDisplayName , FText TaskName )
{
2014-07-23 16:31:31 -04:00
if ( ! Output . IsEmpty ( ) & & ! Output . Equals ( " \r " ) )
2014-03-14 14:13:41 -04:00
{
UE_LOG ( MainFrameActions , Log , TEXT ( " %s (%s): %s " ) , * TaskName . ToString ( ) , * PlatformDisplayName . ToString ( ) , * Output ) ;
}
}
# undef LOCTEXT_NAMESPACE