/**** @param Title The title of the dialog * @param FileTypes Filter for which file types are accepted and should be shown * @param InOutLastPath Keep track of the last location from which the user attempted an import * @param DialogMode Multiple items vs single item. * @param OutOpenFilenames The list of filenames that the user attempted to open * * @return true if the dialog opened successfully and the user accepted; false otherwise. */ bool OpenFiles( const FString& Title, const FString& FileTypes, FString& InOutLastPath, EFileDialogFlags::Type DialogMode, TArray<FString>& OutOpenFilenames ) { IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); bool bOpened = false; if ( DesktopPlatform ) { bOpened = DesktopPlatform->OpenFileDialog( ChooseParentWindowHandle(), Title, InOutLastPath, TEXT(""), FileTypes, DialogMode, OutOpenFilenames ); } bOpened = (OutOpenFilenames.Num() > 0); if ( bOpened ) { // User successfully chose a file; remember the path for the next time the dialog opens. InOutLastPath = OutOpenFilenames[0]; } return bOpened; }
FReply SLocalizationDashboardTargetRow::ExportAll() { ULocalizationTarget* const LocalizationTarget = GetTarget(); IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); if (LocalizationTarget && DesktopPlatform) { void* ParentWindowWindowHandle = NULL; const TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(AsShared()); if (ParentWindow.IsValid() && ParentWindow->GetNativeWindow().IsValid()) { ParentWindowWindowHandle = ParentWindow->GetNativeWindow()->GetOSWindowHandle(); } const FString DefaultPath = FPaths::ConvertRelativePathToFull(LocalizationConfigurationScript::GetDataDirectory(LocalizationTarget->Settings)); FText DialogTitle; { FFormatNamedArguments FormatArguments; FormatArguments.Add(TEXT("TargetName"), FText::FromString(LocalizationTarget->Settings.Name)); DialogTitle = FText::Format(LOCTEXT("ExportAllTranslationsForTargetDialogTitleFormat", "Export All Translations for {TargetName} to Directory"), FormatArguments); } // Prompt the user for the directory FString OutputDirectory; if (DesktopPlatform->OpenDirectoryDialog(ParentWindowWindowHandle, DialogTitle.ToString(), DefaultPath, OutputDirectory)) { LocalizationCommandletTasks::ExportTarget(ParentWindow.ToSharedRef(), LocalizationTarget->Settings, TOptional<FString>(OutputDirectory)); } } return FReply::Handled(); }
FReply SSessionLauncherDeployRepositorySettings::HandleBrowseButtonClicked( ) { IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); if ( DesktopPlatform ) { void* ParentWindowWindowHandle = NULL; FString FolderName; const FString Title = LOCTEXT("RepositoryBrowseTitle", "Choose a repository location").ToString(); const bool bFolderSelected = DesktopPlatform->OpenDirectoryDialog( 0, Title, RepositoryPathTextBox->GetText().ToString(), FolderName ); if ( bFolderSelected ) { if ( !FolderName.EndsWith(TEXT("/")) ) { FolderName += TEXT("/"); } RepositoryPathTextBox->SetText(FText::FromString(FolderName)); ILauncherProfilePtr SelectedProfile = Model->GetSelectedProfile(); if(SelectedProfile.IsValid()) { SelectedProfile->SetPackageDirectory(FolderName); } } } return FReply::Handled(); }
void FAssetTypeActions_DataTable::ExecuteExportAsJSON(TArray< TWeakObjectPtr<UObject> > Objects) { IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); const void* ParentWindowWindowHandle = FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr); for (auto ObjIt = Objects.CreateConstIterator(); ObjIt; ++ObjIt) { auto DataTable = Cast<UDataTable>((*ObjIt).Get()); if (DataTable) { const FText Title = FText::Format(LOCTEXT("DataTable_ExportJSONDialogTitle", "Export '{0}' as JSON..."), FText::FromString(*DataTable->GetName())); const FString CurrentFilename = DataTable->AssetImportData->GetFirstFilename(); const FString FileTypes = TEXT("Data Table JSON (*.json)|*.json"); TArray<FString> OutFilenames; DesktopPlatform->SaveFileDialog( ParentWindowWindowHandle, Title.ToString(), (CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetPath(CurrentFilename), (CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetBaseFilename(CurrentFilename) + TEXT(".json"), FileTypes, EFileDialogFlags::None, OutFilenames ); if (OutFilenames.Num() > 0) { FFileHelper::SaveStringToFile(DataTable->GetTableAsJSON(EDataTableExportFlags::UsePrettyPropertyNames | EDataTableExportFlags::UsePrettyEnumNames | EDataTableExportFlags::UseJsonObjectsForStructs), *OutFilenames[0]); } } } }
void UJanusExporterTool::SearchForExport() { // If not prompting individual files, prompt the user to select a target directory. IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); void* ParentWindowWindowHandle = NULL; IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame")); const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow(); if (MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid()) { ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle(); } FString FolderName; const FString Title = NSLOCTEXT("UnrealEd", "ChooseADirectory", "Choose A Directory").ToString(); const bool bFolderSelected = DesktopPlatform->OpenDirectoryDialog( ParentWindowWindowHandle, Title, ExportPath, FolderName ); if (bFolderSelected) { ExportPath = FolderName.Append("//"); } }
/**** @param Title The title of the dialog * @param FileTypes Filter for which file types are accepted and should be shown * @param InOutLastPath Keep track of the last location from which the user attempted an import * @param DefaultFile Default file name to use for saving. * @param OutOpenFilenames The list of filenames that the user attempted to open * * @return true if the dialog opened successfully and the user accepted; false otherwise. */ bool SaveFile( const FString& Title, const FString& FileTypes, FString& InOutLastPath, const FString& DefaultFile, FString& OutFilename ) { OutFilename = FString(); IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); bool bFileChosen = false; TArray<FString> OutFilenames; if (DesktopPlatform) { bFileChosen = DesktopPlatform->SaveFileDialog( ChooseParentWindowHandle(), Title, InOutLastPath, DefaultFile, FileTypes, EFileDialogFlags::None, OutFilenames ); } bFileChosen = (OutFilenames.Num() > 0); if (bFileChosen) { // User successfully chose a file; remember the path for the next time the dialog opens. InOutLastPath = OutFilenames[0]; OutFilename = OutFilenames[0]; } return bFileChosen; }
void SVisualLogger::HandleSaveCommandExecute() { TArray<TSharedPtr<class STimeline> > OutTimelines; MainView->GetTimelines(OutTimelines, true); if (OutTimelines.Num() == 0) { MainView->GetTimelines(OutTimelines); } if (OutTimelines.Num()) { // Prompt the user for the filenames TArray<FString> SaveFilenames; IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); bool bSaved = false; if (DesktopPlatform) { void* ParentWindowWindowHandle = NULL; IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame")); const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow(); if (MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid()) { ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle(); } const FString DefaultBrowsePath = FString::Printf(TEXT("%slogs/"), *FPaths::GameSavedDir()); bSaved = DesktopPlatform->SaveFileDialog( ParentWindowWindowHandle, LOCTEXT("NewProjectBrowseTitle", "Choose a project location").ToString(), DefaultBrowsePath, TEXT(""), LogVisualizer::SaveFileTypes, EFileDialogFlags::None, SaveFilenames ); } if (bSaved) { if (SaveFilenames.Num() > 0) { TArray<FVisualLogDevice::FVisualLogEntryItem> FrameCache; for (auto CurrentItem : OutTimelines) { FrameCache.Append(CurrentItem->GetEntries()); } if (FrameCache.Num()) { FArchive* FileArchive = IFileManager::Get().CreateFileWriter(*SaveFilenames[0]); FVisualLoggerHelpers::Serialize(*FileArchive, FrameCache); FileArchive->Close(); delete FileArchive; FileArchive = NULL; } } } } }
bool FRealSenseInspectorCustomization::PickFile(FString& OutPath, const void* ParentWindow, const FString& Title, const FString& Filter, bool SaveFlag) { IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); if (DesktopPlatform) { TArray<FString> OutFiles; if (SaveFlag) { auto DefaultPath = FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_SAVE); if (DesktopPlatform->SaveFileDialog(ParentWindow, Title, DefaultPath, TEXT(""), Filter, EFileDialogFlags::None, OutFiles)) { OutPath = OutFiles[0]; return true; } } else { auto DefaultPath = FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_OPEN); if (DesktopPlatform->OpenFileDialog(ParentWindow, Title, DefaultPath, TEXT(""), Filter, EFileDialogFlags::None, OutFiles)) { OutPath = OutFiles[0]; return true; } } } return false; }
FReply SProjectLauncherDeployRepositorySettings::HandleBrowseButtonClicked( ) { IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); if ( DesktopPlatform ) { TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(AsShared()); void* ParentWindowHandle = (ParentWindow.IsValid() && ParentWindow->GetNativeWindow().IsValid()) ? ParentWindow->GetNativeWindow()->GetOSWindowHandle() : nullptr; FString FolderName; const bool bFolderSelected = DesktopPlatform->OpenDirectoryDialog( ParentWindowHandle, LOCTEXT("RepositoryBrowseTitle", "Choose a repository location").ToString(), RepositoryPathTextBox->GetText().ToString(), FolderName ); if ( bFolderSelected ) { if ( !FolderName.EndsWith(TEXT("/")) ) { FolderName += TEXT("/"); } RepositoryPathTextBox->SetText(FText::FromString(FolderName)); ILauncherProfilePtr SelectedProfile = Model->GetSelectedProfile(); if(SelectedProfile.IsValid()) { SelectedProfile->SetPackageDirectory(FolderName); } } } return FReply::Handled(); }
void SAuthorizingPlugin::ShowStorePageForPlugin() { IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); if ( DesktopPlatform != nullptr ) { FOpenLauncherOptions StorePageOpen(FString(TEXT("/ue/marketplace/content/")) + PluginOfferId); DesktopPlatform->OpenLauncher(StorePageOpen); } }
void SVisualLogger::HandleLoadCommandExecute() { FArchive Ar; TArray<FVisualLogDevice::FVisualLogEntryItem> RecordedLogs; TArray<FString> OpenFilenames; IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); bool bOpened = false; if (DesktopPlatform) { void* ParentWindowWindowHandle = NULL; IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame")); const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow(); if (MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid()) { ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle(); } const FString DefaultBrowsePath = FString::Printf(TEXT("%slogs/"), *FPaths::GameSavedDir()); bOpened = DesktopPlatform->OpenFileDialog( ParentWindowWindowHandle, LOCTEXT("OpenProjectBrowseTitle", "Open Project").ToString(), DefaultBrowsePath, TEXT(""), LogVisualizer::LoadFileTypes, EFileDialogFlags::None, OpenFilenames ); } if (bOpened && OpenFilenames.Num() > 0) { OnNewWorld(nullptr); for (int FilenameIndex = 0; FilenameIndex < OpenFilenames.Num(); ++FilenameIndex) { FString CurrentFileName = OpenFilenames[FilenameIndex]; const bool bIsBinaryFile = CurrentFileName.Find(TEXT(".bvlog")) != INDEX_NONE; if (bIsBinaryFile) { FArchive* FileAr = IFileManager::Get().CreateFileReader(*CurrentFileName); FVisualLoggerHelpers::Serialize(*FileAr, RecordedLogs); FileAr->Close(); delete FileAr; FileAr = NULL; for (FVisualLogDevice::FVisualLogEntryItem& CurrentItem : RecordedLogs) { OnNewLogEntry(CurrentItem); } } } } }
FReply FCrashReportClient::SubmitAndRestart() { Submit(); // Check for processes that were started from the Launcher using -EpicPortal on the command line bool bRunFromLauncher = FParse::Param(*FPrimaryCrashProperties::Get()->RestartCommandLine, TEXT("EPICPORTAL")); const FString CrashedAppPath = ErrorReport.FindCrashedAppPath(); bool bLauncherRestarted = false; if (bRunFromLauncher) { // We'll restart Launcher-run processes by having the installed Launcher handle it IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); if (DesktopPlatform != nullptr) { // Split the path so we can format it as a URI TArray<FString> PathArray; CrashedAppPath.Replace(TEXT("//"), TEXT("/")).ParseIntoArray(PathArray, TEXT("/"), false); // WER saves this out on Windows with double slashes as the separator for some reason. FString CrashedAppPathUri; // Exclude the last item (the filename). The Launcher currently expects an installed application folder. for (int32 ItemIndex = 0; ItemIndex < PathArray.Num() - 1; ItemIndex++) { FString& PathItem = PathArray[ItemIndex]; CrashedAppPathUri += FPlatformHttp::UrlEncode(PathItem); CrashedAppPathUri += TEXT("/"); } CrashedAppPathUri.RemoveAt(CrashedAppPathUri.Len() - 1); // Re-run the application via the Launcher FOpenLauncherOptions OpenOptions(FString::Printf(TEXT("apps/%s"), *CrashedAppPathUri)); OpenOptions.bSilent = true; if (DesktopPlatform->OpenLauncher(OpenOptions)) { bLauncherRestarted = true; } } } if (!bLauncherRestarted) { // Launcher didn't restart the process so start it ourselves const FString CommandLineArguments = FPrimaryCrashProperties::Get()->RestartCommandLine; FPlatformProcess::CreateProc(*CrashedAppPath, *CommandLineArguments, true, false, false, NULL, 0, NULL, NULL); } return FReply::Handled(); }
void AFilePickerCharacter::OpenFileDialog(const FString& DialogTitle, const FString& DefaultPath, const FString& FileTypes, TArray<FString>& OutFileNames) { if (GEngine) { if (GEngine->GameViewport) { void* ParentWindowHandle = GEngine->GameViewport->GetWindow()->GetNativeWindow()->GetOSWindowHandle(); IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); if (DesktopPlatform) { //Opening the file picker! uint32 SelectionFlag = 0; //A value of 0 represents single file selection while a value of 1 represents multiple file selection DesktopPlatform->OpenFileDialog(ParentWindowHandle, DialogTitle, DefaultPath, FString(""), FileTypes, SelectionFlag, OutFileNames); } } } }
bool GenerateProjectFiles(const FString& ProjectFileName) { IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); // Check it's a code project FString SourceDir = FPaths::GetPath(ProjectFileName) / TEXT("Source"); if(!IPlatformFile::GetPlatformPhysical().DirectoryExists(*SourceDir)) { FPlatformMisc::MessageBoxExt(EAppMsgType::Ok, TEXT("This project does not have any source code. You need to add C++ source files to the project from the Editor before you can generate project files."), TEXT("Error")); return false; } // Get the engine root directory FString RootDir; if (!GetValidatedEngineRootDir(ProjectFileName, RootDir)) { return false; } // Build the argument list FString Arguments = TEXT("-game"); if (FDesktopPlatformModule::Get()->IsSourceDistribution(RootDir)) { Arguments += TEXT(" -engine"); } // Start capturing the log output FStringOutputDevice LogCapture; LogCapture.SetAutoEmitLineTerminator(true); GLog->AddOutputDevice(&LogCapture); // Generate project files FFeedbackContext* Warn = DesktopPlatform->GetNativeFeedbackContext(); bool bResult = DesktopPlatform->GenerateProjectFiles(RootDir, ProjectFileName, Warn); GLog->RemoveOutputDevice(&LogCapture); // Display an error dialog if we failed if(!bResult) { FPlatformInstallation::ErrorDialog(TEXT("Failed to generate project files."), LogCapture); return false; } return true; }
void FAssetTypeActions_CurveTable::ExecuteExportAsCSV(TArray< TWeakObjectPtr<UObject> > Objects) { IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); 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(); } for (auto ObjIt = Objects.CreateConstIterator(); ObjIt; ++ObjIt) { auto CurTable = Cast<UCurveTable>((*ObjIt).Get()); if (CurTable) { const FText Title = FText::Format(LOCTEXT("CurveTable_ExportCSVDialogTitle", "Export '{0}' as CSV..."), FText::FromString(*CurTable->GetName())); const FString CurrentFilename = (CurTable->ImportPath.IsEmpty()) ? TEXT("") : FReimportManager::ResolveImportFilename(CurTable->ImportPath, CurTable); const FString FileTypes = TEXT("Curve Table CSV (*.csv)|*.csv"); TArray<FString> OutFilenames; DesktopPlatform->SaveFileDialog( ParentWindowWindowHandle, Title.ToString(), (CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetPath(CurrentFilename), (CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetBaseFilename(CurrentFilename) + TEXT(".csv"), FileTypes, EFileDialogFlags::None, OutFilenames ); if (OutFilenames.Num() > 0) { FFileHelper::SaveStringToFile(CurTable->GetTableAsCSV(), *OutFilenames[0]); } } } }
void FProfilerActionManager::ProfilerManager_Load_Execute() { // @see FStatConstants::StatsFileExtension TArray<FString> OutFiles; const FString ProfilingDirectory = *FPaths::ConvertRelativePathToFull( *FPaths::ProfilingDir() ); IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); bool bOpened = false; if( DesktopPlatform != NULL ) { bOpened = DesktopPlatform->OpenFileDialog ( NULL, LOCTEXT("ProfilerManager_Load_Desc", "Open profiler capture file...").ToString(), ProfilingDirectory, TEXT(""), LOCTEXT("ProfilerManager_Load_FileFilter", "Stats files (*.ue4stats)|*.ue4stats|Raw Stats files (*.ue4statsraw)|*.ue4statsraw").ToString(), //FProfilerManager::GetSettings().bSingleInstanceMode ? EFileDialogFlags::None : EFileDialogFlags::Multiple, EFileDialogFlags::None, OutFiles ); } if( bOpened == true ) { if( OutFiles.Num() == 1 ) { const FString DraggedFileExtension = FPaths::GetExtension( OutFiles[0], true ); if( DraggedFileExtension == FStatConstants::StatsFileExtension ) { This->LoadProfilerCapture( OutFiles[0] ); } else if( DraggedFileExtension == FStatConstants::StatsFileRawExtension ) { This->LoadRawStatsFile( OutFiles[0] ); } } } }
virtual bool RunLauncher(ELauncherAction Action) const override { IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); if (DesktopPlatform != nullptr) { // Construct a url to tell the launcher of this app and what we want to do with it FOpenLauncherOptions LauncherOptions; LauncherOptions.LauncherRelativeUrl = TEXT("apps"); LauncherOptions.LauncherRelativeUrl /= GetEncodedExePath(); switch (Action) { case ELauncherAction::AppLaunch: LauncherOptions.LauncherRelativeUrl += TEXT("?action=launch"); break; case ELauncherAction::AppUpdateCheck: LauncherOptions.LauncherRelativeUrl += TEXT("?action=updatecheck"); break; }; return DesktopPlatform->OpenLauncher(LauncherOptions); } return false; }
FReply FLandscapeEditorDetailCustomization_CopyPaste::OnGizmoHeightmapFilenameButtonClicked(TSharedRef<IPropertyHandle> HeightmapPropertyHandle) { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode != NULL) { // Prompt the user for the Filenames IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); if (DesktopPlatform != NULL) { void* ParentWindowWindowHandle = NULL; IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame")); const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow(); if (MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid()) { ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle(); } TArray<FString> OpenFilenames; bool bOpened = DesktopPlatform->OpenFileDialog( ParentWindowWindowHandle, NSLOCTEXT("UnrealEd", "Import", "Import").ToString(), LandscapeEdMode->UISettings->LastImportPath, TEXT(""), TEXT("Raw Heightmap files (*.raw,*.r16)|*.raw;*.r16|All files (*.*)|*.*"), EFileDialogFlags::None, OpenFilenames); if (bOpened) { //SetGizmoHeightmapFilenameString(FText::FromString(OpenFilenames[0]), ETextCommit::OnEnter); HeightmapPropertyHandle->SetValue(OpenFilenames[0]); LandscapeEdMode->UISettings->LastImportPath = FPaths::GetPath(OpenFilenames[0]); } } } return FReply::Handled(); }
void FProfilerActionManager::ProfilerManager_LoadMultiple_Execute() { // @see FStatConstants::StatsFileExtension FString OutFolder; const FString ProfilingDirectory = *FPaths::ConvertRelativePathToFull(*FPaths::ProfilingDir()); IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); bool bOpened = false; if (DesktopPlatform != NULL) { bOpened = DesktopPlatform->OpenDirectoryDialog(NULL, LOCTEXT("ProfilerManager_Load_Desc", "Open capture folder...").ToString(), ProfilingDirectory, OutFolder); } if (bOpened == true) { This->ProfilerWindow.Pin()->MultiDumpBrowser->Clear(); if (!OutFolder.IsEmpty()) { TArray<FString> FoundFiles; FFileManagerGeneric::Get().FindFiles(FoundFiles, *OutFolder, TEXT(".ue4stats")); for (FString &FilePath : FoundFiles) { const TCHAR* PathDelimiter = FPlatformMisc::GetDefaultPathSeparator(); SMultiDumpBrowser::FFileDescriptor *Desc = new SMultiDumpBrowser::FFileDescriptor(); Desc->FullPath = OutFolder + PathDelimiter + FilePath; Desc->DisplayName = FilePath; This->ProfilerWindow.Pin()->MultiDumpBrowser->AddFile(Desc); } This->ProfilerWindow.Pin()->MultiDumpBrowser->Update(); } } }
void FRenderDocPluginLoader::Initialize() { if (GUsingNullRHI) { // THIS WILL NEVER TRIGGER because of a sort of chicken-and-egg problem: RenderDoc Loader is a PostConfigInit // plugin, and GUsingNullRHI is only initialized properly between PostConfigInit and PreLoadingScreen phases. // (nevertheless, keep this comment around for future iterations of UE4) UE_LOG(RenderDocPlugin, Warning, TEXT("this plugin will not be loaded because a null RHI (Cook Server, perhaps) is being used.")); return; } // Look for a renderdoc.dll somewhere in the system: UE_LOG(RenderDocPlugin, Log, TEXT("locating RenderDoc library (renderdoc.dll)...")); RenderDocDLL = RenderDocAPI = NULL; // 1) Check the Game configuration files: if (GConfig) { FString RenderdocPath; GConfig->GetString(TEXT("RenderDoc"), TEXT("BinaryPath"), RenderdocPath, GGameIni); RenderDocDLL = LoadAndCheckRenderDocLibrary(RenderDocAPI, RenderdocPath); } // 2) Check for a RenderDoc system installation in the registry: if (!RenderDocDLL) { FString RenderdocPath; FWindowsPlatformMisc::QueryRegKey(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Classes\\RenderDoc.RDCCapture.1\\DefaultIcon\\"), TEXT(""), RenderdocPath); RenderDocDLL = LoadAndCheckRenderDocLibrary(RenderDocAPI, RenderdocPath); if (RenderDocDLL) UpdateConfigFiles(RenderdocPath); } // 3) Check for a RenderDoc custom installation by prompting the user: if (!RenderDocDLL) { //Renderdoc does not seem to be installed, but it might be built from source or downloaded by archive, //so prompt the user to navigate to the main exe file UE_LOG(RenderDocPlugin, Log, TEXT("RenderDoc library not found; provide a custom installation location...")); FString RenderdocPath; // TODO: rework the logic here by improving error checking and reporting IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); if (DesktopPlatform) { FString Filter = TEXT("Renderdoc executable|renderdocui.exe"); TArray<FString> OutFiles; if (DesktopPlatform->OpenFileDialog(NULL, TEXT("Locate main Renderdoc executable..."), TEXT(""), TEXT(""), Filter, EFileDialogFlags::None, OutFiles)) RenderdocPath = OutFiles[0]; } RenderdocPath = FPaths::GetPath(RenderdocPath); RenderDocDLL = LoadAndCheckRenderDocLibrary(RenderDocAPI, RenderdocPath); if (RenderDocDLL) UpdateConfigFiles(RenderdocPath); } // 4) All bets are off; aborting... if (!RenderDocDLL) { UE_LOG(RenderDocPlugin, Error, TEXT("unable to initialize the plugin because no RenderDoc libray has been located.")); return; } UE_LOG(RenderDocPlugin, Log, TEXT("plugin has been loaded successfully.")); }
void FRenderDocLoaderPluginModule::StartupModule() { FString BinaryPath; if (GConfig) { GConfig->GetString(TEXT("RenderDoc"), TEXT("BinaryPath"), BinaryPath, GGameIni); } if (BinaryPath.IsEmpty()) { //Try to localize the installation path and update the BinaryPath if (!(FWindowsPlatformMisc::QueryRegKey(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Classes\\RenderDoc.RDCCapture.1\\DefaultIcon\\"), TEXT(""), BinaryPath) && (BinaryPath.Len() > 0))) { //Renderdoc does not seem to be installed, but it might be built from source or downloaded by archive, //so prompt the user to navigate to the main exe file UE_LOG(RenderDocLoaderPlugin, Log, TEXT("RenderDoc is not installed! Please provide custom exe path...")); IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); if (DesktopPlatform) { FString Filter = TEXT("Renderdoc executable|renderdocui.exe"); TArray<FString> OutFiles; if (DesktopPlatform->OpenFileDialog(NULL, TEXT("Locate main Renderdoc executable..."), TEXT(""), TEXT(""), Filter, EFileDialogFlags::None, OutFiles)) { BinaryPath = OutFiles[0]; } } } if (!BinaryPath.IsEmpty()) { BinaryPath = FPaths::GetPath(BinaryPath); if (GConfig) { GConfig->SetString(TEXT("RenderDoc"), TEXT("BinaryPath"), *BinaryPath, GGameIni); GConfig->Flush(false, GGameIni); } } } if (BinaryPath.IsEmpty()) { UE_LOG(RenderDocLoaderPlugin, Error, TEXT("Could not locate Renderdoc! Aborting module load...")); return; } RenderDocDLL = NULL; FString PathToRenderDocDLL = FPaths::Combine(*BinaryPath, *FString("renderdoc.dll")); RenderDocDLL = LoadLibrary(*PathToRenderDocDLL); if (!RenderDocDLL) { FMessageDialog::Open(EAppMsgType::Ok, FText::Format(LOCTEXT("CouldNotLoadDLLDialog", "Could not load renderdoc DLL, if you have moved your renderdoc installation, please amend the path declaration in your Game.ini file. The path that was searched for the module was {0}"), FText::FromString(PathToRenderDocDLL))); UE_LOG(RenderDocLoaderPlugin, Error, TEXT("Could not load renderdoc DLL! Aborting module load...")); return; } UE_LOG(RenderDocLoaderPlugin, Log, TEXT("RenderDoc Loader Plugin loaded!")); }
EActiveTimerReturnType SAuthorizingPlugin::RefreshStatus(double InCurrentTime, float InDeltaTime) { // Engine tick isn't running when the modal window is open, so we need to tick any core tickers // to as that's what the RPC system uses to update the current state of RPC calls. FTaskGraphInterface::Get().ProcessThreadUntilIdle(ENamedThreads::GameThread); FTicker::GetCoreTicker().Tick(InDeltaTime); switch ( CurrentState ) { case EPluginAuthorizationState::Initializing: { WaitingTime = 0; if ( PortalWindowService->IsAvailable() && PortalUserService->IsAvailable() ) { CurrentState = EPluginAuthorizationState::AuthorizePlugin; } else { CurrentState = EPluginAuthorizationState::StartLauncher; } break; } case EPluginAuthorizationState::StartLauncher: { WaitingTime = 0; IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); if ( DesktopPlatform != nullptr ) { if ( !FPlatformProcess::IsApplicationRunning(TEXT("EpicGamesLauncher")) && !FPlatformProcess::IsApplicationRunning(TEXT("EpicGamesLauncher-Mac-Shipping")) ) { FOpenLauncherOptions SilentOpen; if ( DesktopPlatform->OpenLauncher(SilentOpen) ) { CurrentState = EPluginAuthorizationState::StartLauncher_Waiting; } else { CurrentState = EPluginAuthorizationState::LauncherStartFailed; } } else { // If the process is found to be running already, move into the next state. CurrentState = EPluginAuthorizationState::StartLauncher_Waiting; } } else { CurrentState = EPluginAuthorizationState::LauncherStartFailed; } break; } case EPluginAuthorizationState::StartLauncher_Waiting: { if ( PortalWindowService->IsAvailable() && PortalUserService->IsAvailable() ) { CurrentState = EPluginAuthorizationState::AuthorizePlugin; } else { WaitingTime += InDeltaTime; } break; } case EPluginAuthorizationState::AuthorizePlugin: { WaitingTime = 0; EntitlementResult = PortalUserService->IsEntitledToItem(PluginItemId, EEntitlementCacheLevelRequest::Memory); CurrentState = EPluginAuthorizationState::AuthorizePlugin_Waiting; break; } case EPluginAuthorizationState::AuthorizePlugin_Waiting: { WaitingTime += InDeltaTime; check(EntitlementResult.GetFuture().IsValid()); if ( EntitlementResult.GetFuture().IsReady() ) { FPortalUserIsEntitledToItemResult Entitlement = EntitlementResult.GetFuture().Get(); if ( Entitlement.IsEntitled ) { CurrentState = EPluginAuthorizationState::Authorized; } else { CurrentState = EPluginAuthorizationState::IsUserSignedIn; } } break; } case EPluginAuthorizationState::IsUserSignedIn: { WaitingTime = 0; UserDetailsResult = PortalUserService->GetUserDetails(); CurrentState = EPluginAuthorizationState::IsUserSignedIn_Waiting; break; } case EPluginAuthorizationState::IsUserSignedIn_Waiting: { WaitingTime += InDeltaTime; check(UserDetailsResult.GetFuture().IsValid()); if ( UserDetailsResult.GetFuture().IsReady() ) { FPortalUserDetails UserDetails = UserDetailsResult.GetFuture().Get(); if ( UserDetails.IsSignedIn ) { // if the user is signed in, and we're at this stage, we know they are unauthorized. CurrentState = EPluginAuthorizationState::Unauthorized; } else { // If they're not signed in, but they were unauthorized, they may have purchased it // they may just need to sign-in. if ( PortalUserLoginService->IsAvailable() ) { CurrentState = EPluginAuthorizationState::SigninRequired; } } } break; } case EPluginAuthorizationState::SigninRequired: { WaitingTime = 0; UserSigninResult = PortalUserLoginService->PromptUserForSignIn(); CurrentState = EPluginAuthorizationState::SigninRequired_Waiting; break; } case EPluginAuthorizationState::SigninRequired_Waiting: { // We don't advance the wait time in the sign-required state, as this may take a long time. check(UserSigninResult.GetFuture().IsValid()); if ( UserSigninResult.GetFuture().IsReady() ) { bool IsUserSignedIn = UserSigninResult.GetFuture().Get(); if ( IsUserSignedIn ) { UserDetailsResult = PortalUserService->GetUserDetails(); CurrentState = EPluginAuthorizationState::Signin_Waiting; } else { CurrentState = EPluginAuthorizationState::Unauthorized; } } break; } // We stay in the Signin_Waiting state until the user is signed in or until they cancel the // authorizing plug-in UI. It would be nice to be able to know if the user closes the sign-in // dialog and cancel out of this dialog automatically. case EPluginAuthorizationState::Signin_Waiting: { WaitingTime = 0; check(UserDetailsResult.GetFuture().IsValid()); if ( UserDetailsResult.GetFuture().IsReady() ) { FPortalUserDetails UserDetails = UserDetailsResult.GetFuture().Get(); if ( UserDetails.IsSignedIn ) { // if the user is signed in, and we're at this stage, we know they are unauthorized. CurrentState = EPluginAuthorizationState::AuthorizePlugin; } else { UserDetailsResult = PortalUserService->GetUserDetails(); } } break; } case EPluginAuthorizationState::Authorized: case EPluginAuthorizationState::Unauthorized: case EPluginAuthorizationState::Timeout: case EPluginAuthorizationState::LauncherStartFailed: { bUserInterrupted = false; ParentWindow.Pin()->RequestDestroyWindow(); break; } case EPluginAuthorizationState::Canceled: { bUserInterrupted = true; ParentWindow.Pin()->RequestDestroyWindow(); break; } default: { // Should never be in a non-explicit state. check(false); break; } } // If we're in a waiting state, check to see if we're over the timeout period. switch ( CurrentState ) { case EPluginAuthorizationState::StartLauncher_Waiting: case EPluginAuthorizationState::AuthorizePlugin_Waiting: case EPluginAuthorizationState::IsUserSignedIn_Waiting: case EPluginAuthorizationState::SigninRequired_Waiting: // We Ignore EPluginAuthorizationState::Signin_Waiting, that state could take forever, the user needs to sign-in or close the dialog. { const float TimeoutSeconds = 15; if ( WaitingTime > TimeoutSeconds ) { bUserInterrupted = false; CurrentState = EPluginAuthorizationState::Timeout; } break; } } return EActiveTimerReturnType::Continue; }
void FStreamingLevelCollectionModel::AddExistingLevel(bool bRemoveInvalidSelectedLevelsAfter) { if (UEditorEngine::IsUsingWorldAssets()) { if (!bAssetDialogOpen) { bAssetDialogOpen = true; FEditorFileUtils::FOnLevelsChosen LevelsChosenDelegate = FEditorFileUtils::FOnLevelsChosen::CreateSP(this, &FStreamingLevelCollectionModel::HandleAddExistingLevelSelected, bRemoveInvalidSelectedLevelsAfter); FEditorFileUtils::FOnLevelPickingCancelled LevelPickingCancelledDelegate = FEditorFileUtils::FOnLevelPickingCancelled::CreateSP(this, &FStreamingLevelCollectionModel::HandleAddExistingLevelCancelled); const bool bAllowMultipleSelection = true; FEditorFileUtils::OpenLevelPickingDialog(LevelsChosenDelegate, LevelPickingCancelledDelegate, bAllowMultipleSelection); } } else { TArray<FString> OpenFilenames; IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); bool bOpened = false; if ( DesktopPlatform ) { void* ParentWindowWindowHandle = NULL; IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame")); const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow(); if ( MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid() ) { ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle(); } bOpened = DesktopPlatform->OpenFileDialog( ParentWindowWindowHandle, NSLOCTEXT("UnrealEd", "Open", "Open").ToString(), *FEditorDirectories::Get().GetLastDirectory(ELastDirectory::UNR), TEXT(""), *FEditorFileUtils::GetFilterString(FI_Load), EFileDialogFlags::Multiple, OpenFilenames ); } if( bOpened ) { // Save the path as default for next time FEditorDirectories::Get().SetLastDirectory( ELastDirectory::UNR, FPaths::GetPath( OpenFilenames[ 0 ] ) ); TArray<FString> Filenames; for( int32 FileIndex = 0 ; FileIndex < OpenFilenames.Num() ; ++FileIndex ) { // Strip paths from to get the level package names. const FString FilePath( OpenFilenames[FileIndex] ); // make sure the level is in our package cache, because the async loading code will use this to find it if (!FPaths::FileExists(FilePath)) { FMessageDialog::Open( EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "Error_LevelImportFromExternal", "Importing external sublevels is not allowed. Move the level files into the standard content directory and try again.\nAfter moving the level(s), restart the editor.") ); return; } FText ErrorMessage; bool bFilenameIsValid = FEditorFileUtils::IsValidMapFilename(OpenFilenames[FileIndex], ErrorMessage); if ( !bFilenameIsValid ) { // Start the loop over, prompting for save again const FText DisplayFilename = FText::FromString( IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*OpenFilenames[FileIndex]) ); FFormatNamedArguments Arguments; Arguments.Add(TEXT("Filename"), DisplayFilename); Arguments.Add(TEXT("LineTerminators"), FText::FromString(LINE_TERMINATOR LINE_TERMINATOR)); Arguments.Add(TEXT("ErrorMessage"), ErrorMessage); const FText DisplayMessage = FText::Format( NSLOCTEXT("UnrealEd", "Error_InvalidLevelToAdd", "Unable to add streaming level {Filename}{LineTerminators}{ErrorMessage}"), Arguments ); FMessageDialog::Open( EAppMsgType::Ok, DisplayMessage ); return; } Filenames.Add( FilePath ); } TArray<FString> PackageNames; for (const auto& Filename : Filenames) { const FString& PackageName = FPackageName::FilenameToLongPackageName(Filename); PackageNames.Add(PackageName); } // Save or selected list, adding a new level will clean it up FLevelModelList SavedInvalidSelectedLevels = InvalidSelectedLevels; EditorLevelUtils::AddLevelsToWorld(CurrentWorld.Get(), PackageNames, AddedLevelStreamingClass); // Force a cached level list rebuild PopulateLevelsList(); if (bRemoveInvalidSelectedLevelsAfter) { InvalidSelectedLevels = SavedInvalidSelectedLevels; RemoveInvalidSelectedLevels_Executed(); } } } }
FReply FDirectoryPathStructCustomization::OnPickDirectory(TSharedRef<IPropertyHandle> PropertyHandle, const bool bRelativeToGameContentDir, const bool bUseRelativePath, const bool bLongPackageName) const { FString Directory; IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); if (DesktopPlatform) { TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(BrowseButton.ToSharedRef()); void* ParentWindowHandle = (ParentWindow.IsValid() && ParentWindow->GetNativeWindow().IsValid()) ? ParentWindow->GetNativeWindow()->GetOSWindowHandle() : nullptr; FString StartDirectory = FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_IMPORT); if (bRelativeToGameContentDir && !IsValidPath(StartDirectory, bRelativeToGameContentDir)) { StartDirectory = AbsoluteGameContentDir; } // Loop until; a) the user cancels (OpenDirectoryDialog returns false), or, b) the chosen path is valid (IsValidPath returns true) for (;;) { if (DesktopPlatform->OpenDirectoryDialog(ParentWindowHandle, LOCTEXT("FolderDialogTitle", "Choose a directory").ToString(), StartDirectory, Directory)) { FText FailureReason; if (IsValidPath(Directory, bRelativeToGameContentDir, &FailureReason)) { FEditorDirectories::Get().SetLastDirectory(ELastDirectory::GENERIC_IMPORT, Directory); if (bLongPackageName) { FString LongPackageName; FString StringFailureReason; if (FPackageName::TryConvertFilenameToLongPackageName(Directory, LongPackageName, &StringFailureReason) == false) { StartDirectory = Directory; FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(StringFailureReason)); continue; } Directory = LongPackageName; } if (bRelativeToGameContentDir) { Directory = Directory.RightChop(AbsoluteGameContentDir.Len()); } if (bUseRelativePath) { Directory = IFileManager::Get().ConvertToRelativePath(*Directory); } PropertyHandle->SetValue(Directory); } else { StartDirectory = Directory; FMessageDialog::Open(EAppMsgType::Ok, FailureReason); continue; } } break; } } return FReply::Handled(); }
FReply FLandscapeEditorDetailCustomization_CopyPaste::OnGizmoExportButtonClicked() { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode != NULL) { ALandscapeGizmoActiveActor* Gizmo = LandscapeEdMode->CurrentGizmoActor.Get(); if (Gizmo && Gizmo->TargetLandscapeInfo && Gizmo->SelectedData.Num()) { int32 TargetIndex = -1; ULandscapeInfo* LandscapeInfo = Gizmo->TargetLandscapeInfo; TArray<FString> Filenames; // Local set for export TSet<ULandscapeLayerInfoObject*> LayerInfoSet; for (int i = 0; i < Gizmo->LayerInfos.Num(); i++) { if (LandscapeEdMode->CurrentToolTarget.TargetType == ELandscapeToolTargetType::Weightmap && LandscapeEdMode->CurrentToolTarget.LayerInfo == Gizmo->LayerInfos[i]) { TargetIndex = i; } LayerInfoSet.Add(Gizmo->LayerInfos[i]); } for (int32 i = -1; i < Gizmo->LayerInfos.Num(); i++) { if (!LandscapeEdMode->UISettings->bApplyToAllTargets && i != TargetIndex) { continue; } FString SaveDialogTitle; FString DefaultFilename; FString FileTypes; if (i < 0) { if (!(Gizmo->DataType & LGT_Height)) { continue; } SaveDialogTitle = NSLOCTEXT("UnrealEd", "LandscapeExport_HeightmapFilename", "Choose filename for Heightmap Export").ToString(); DefaultFilename = TEXT("Heightmap.raw"); FileTypes = TEXT("Heightmap .raw files|*.raw|Heightmap .r16 files|*.r16|All files|*.*"); } else { if (!(Gizmo->DataType & LGT_Weight)) { continue; } FName LayerName = Gizmo->LayerInfos[i]->LayerName; SaveDialogTitle = FText::Format(NSLOCTEXT("UnrealEd", "LandscapeExport_LayerFilename", "Choose filename for Layer {0} Export"), FText::FromString(LayerName.ToString())).ToString(); DefaultFilename = FString::Printf(TEXT("%s.raw"), *LayerName.ToString()); FileTypes = TEXT("Layer .raw files|*.raw|Layer .r8 files|*.r8|All files|*.*"); } TArray<FString> SaveFilenames; IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); bool bSave = false; if (DesktopPlatform) { void* ParentWindowWindowHandle = NULL; IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame")); const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow(); if (MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid()) { ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle(); } bSave = DesktopPlatform->SaveFileDialog( ParentWindowWindowHandle, SaveDialogTitle, LandscapeEdMode->UISettings->LastImportPath, DefaultFilename, FileTypes, EFileDialogFlags::None, SaveFilenames ); } if (!bSave) { return FReply::Handled(); } Filenames.Add(SaveFilenames[0]); LandscapeEdMode->UISettings->LastImportPath = FPaths::GetPath(SaveFilenames[0]); } Gizmo->Export(TargetIndex, Filenames); } } return FReply::Handled(); }
void ImportMeshLODDialog( class UObject* SelectedMesh, int32 LODLevel ) { if(!SelectedMesh) { return; } USkeletalMesh* SkeletonMesh = Cast<USkeletalMesh>(SelectedMesh); UStaticMesh* StaticMesh = Cast<UStaticMesh>(SelectedMesh); if( !SkeletonMesh && !StaticMesh ) { return; } FString ExtensionStr; ExtensionStr += TEXT("All model files|*.fbx;*.obj|"); ExtensionStr += TEXT("FBX files|*.fbx|"); ExtensionStr += TEXT("Object files|*.obj|"); ExtensionStr += TEXT("All files|*.*"); // First, display the file open dialog for selecting the file. TArray<FString> OpenFilenames; IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); bool bOpen = false; if ( DesktopPlatform ) { void* ParentWindowWindowHandle = NULL; IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame")); const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow(); if ( MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid() ) { ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle(); } bOpen = DesktopPlatform->OpenFileDialog( ParentWindowWindowHandle, FText::Format( NSLOCTEXT("UnrealEd", "ImportMeshLOD", "Failed to import mesh for LOD {0}!"), FText::AsNumber( LODLevel ) ).ToString(), *FEditorDirectories::Get().GetLastDirectory(ELastDirectory::FBX), TEXT(""), *ExtensionStr, EFileDialogFlags::None, OpenFilenames ); } // Only continue if we pressed OK and have only one file selected. if( bOpen ) { if( OpenFilenames.Num() == 0) { UnFbx::FFbxImporter* FFbxImporter = UnFbx::FFbxImporter::GetInstance(); FFbxImporter->AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Error, LOCTEXT("NoFileSelectedForLOD", "No file was selected for the LOD.")), FFbxErrors::Generic_Mesh_LOD_NoFileSelected); } else if(OpenFilenames.Num() > 1) { UnFbx::FFbxImporter* FFbxImporter = UnFbx::FFbxImporter::GetInstance(); FFbxImporter->AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Error, LOCTEXT("MultipleFilesSelectedForLOD", "You may only select one file for the LOD.")), FFbxErrors::Generic_Mesh_LOD_MultipleFilesSelected); } else { FString Filename = OpenFilenames[0]; FEditorDirectories::Get().SetLastDirectory(ELastDirectory::FBX, FPaths::GetPath(Filename)); // Save path as default for next time. if( SkeletonMesh ) { ImportSkeletalMeshLOD(SkeletonMesh, Filename, LODLevel); } else if( StaticMesh ) { ImportStaticMeshLOD(StaticMesh, Filename, LODLevel); } } } }
void FDestructibleMeshEditorViewportClient::ImportFBXChunks() { // Get the FBX that we want to import TArray<FString> OpenFilenames; IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); bool bOpened = false; if (DesktopPlatform != NULL) { bOpened = DesktopPlatform->OpenFileDialog( NULL, NSLOCTEXT("UnrealEd", "ImportMatineeSequence", "Import UnrealMatinee Sequence").ToString(), *(FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_IMPORT)), TEXT(""), TEXT("FBX document|*.fbx"), EFileDialogFlags::None, OpenFilenames); } if (bOpened) { // Get the filename from dialog FString ImportFilename = OpenFilenames[0]; FString FileName = OpenFilenames[0]; FEditorDirectories::Get().SetLastDirectory(ELastDirectory::GENERIC_IMPORT, FPaths::GetPath(FileName)); // Save path as default for next time. const FString FileExtension = FPaths::GetExtension(FileName); const bool bIsFBX = FCString::Stricmp(*FileExtension, TEXT("FBX")) == 0; if (bIsFBX) { FlushRenderingCommands(); UnFbx::FFbxImporter* FFbxImporter = UnFbx::FFbxImporter::GetInstance(); if (FFbxImporter->ImportFromFile( *ImportFilename, FPaths::GetExtension( ImportFilename ) ) ) { TArray<FbxNode*> FbxMeshArray; FFbxImporter->FillFbxMeshArray(FFbxImporter->Scene->GetRootNode(), FbxMeshArray, FFbxImporter); UFbxStaticMeshImportData* ImportData = NewObject<UFbxStaticMeshImportData>(GetTransientPackage(), NAME_None, RF_NoFlags, NULL); TArray<UStaticMesh*> ChunkMeshes; for (int32 i=0; i < FbxMeshArray.Num(); ++i) { UStaticMesh* TempStaticMesh = NULL; TempStaticMesh = (UStaticMesh*)FFbxImporter->ImportStaticMesh(GetTransientPackage(), FbxMeshArray[i], NAME_None, RF_NoFlags, ImportData, 0); ChunkMeshes.Add(TempStaticMesh); } UDestructibleMesh* DestructibleMesh = DestructibleMeshEditorPtr.Pin()->GetDestructibleMesh(); if (DestructibleMesh) { DestructibleMesh->SetupChunksFromStaticMeshes(ChunkMeshes); } } FFbxImporter->ReleaseScene(); // Update the viewport DestructibleMeshEditorPtr.Pin()->RefreshTool(); DestructibleMeshEditorPtr.Pin()->SetCurrentPreviewDepth(0xFFFFFFFF); // This will get clamped to the max depth } else { // Invalid filename } } #if WITH_APEX #endif // WITH_APEX }